Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

apidoc2ts

Package Overview
Dependencies
Maintainers
7
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apidoc2ts

Typescript interface generator based on ApiDoc

  • 0.3.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
7
Created
Source

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

Keywords

FAQs

Package last updated on 19 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc