npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

apidoc2ts

v0.3.4

Published

Typescript interface generator based on ApiDoc

Downloads

296

Readme

apiDoc to Interfaces

Command line tool that generates typescript interfaces from your apiDoc documentation.

Getting Started

Installing

To use this tool install it using npm:

$ npm install apidoc2ts -g

Usage

Get help on how to use the tool:

$ apidoc2ts --help

Generating interfaces from your apiDoc:

$ apidoc2ts --source ./doc/api_data.json --output generated --name interfaces.ts

Options

Required flags:

  • -s --source - path to the api_data.json file from apiDoc
  • -o --output - path to the output folder (default ./)
  • -n --name - name for the file with generated interfaces

Additional flags:

  • -g --gropuing = (single|url):
    • single - create one file with all interfaces in it (not the best idea)
    • url - create multiple folders with interfaces corresponding to URL structure
  • -v --version = (last|all) - which versions should be used
    • last - interfaces are generated only for the latest versions
    • all - interfaces are generated for all version and older version interfaces has a postfix _vx.x.x
  • -t --custom-types - list of custom types that should not be replaced with strings
  • -w --whitelist - list of endpoints names which should be processed, the rest of endpoints will be ignored
  • -e --parse-examples - if example requests/responses should be parsed if no parameters are specified

Prefixes/postfixes for top-level interfaces names:

  • --static-prefix - prefix for all interfaces names
  • --static-postfix - postfix for all interfaces names
  • --request-prefix - prefix for a request interface name
  • --request-postfix - postfix for a request interface name
  • --response-prefix - prefix for a response interface name
  • --response-postfix - postfix for a response interface name
  • --error-prefix - prefix for an error interface name
  • --error-postfix - postfix for an error interface name

Config file

The tool will look for a default config file called apidoc2ts.config.js in a current folder and combine flags from the file with a flags specified in command line. Note that command line flags override config file flags and all flags in config file should be in a camelCase.

Also you can specify a path to the config file which must contain all required flags:

-c --config - path to the config file

Example of the config file:

module.exports = {
    source: "source",
    name: "name.ts",
    output: "output",
    staticPrefix: "I",
    customTypes: ["type1", "type2"]
}

Contributing

We appreciate any contribution to this project whether it is a bug report, feature request or some improvement and have a small guide for that.

License

This project is licensed under the MIT License - see the LICENSE.md file for details