alexjennings / openapi-proptypes-generator

Generate PropTypes from openAPI 3 schemas

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

openapi-proptypes-generator

Generate PropTypes from openAPI 3, Swagger 2 in JSON or YAML schemas

Usage

From your terminal, provide a source file in openAPI 3 or Swagger 2 in JSON or YAML format and a destination file where you would like your generated prop-types to be saved:

index.js ./examples/openapi.json ./examples/proptypes-openapi.js

or

index.js ./examples/openapi.yaml ./examples/proptypes-openapi.js

or for Swagger 2:

index.js ./examples/swagger.json ./examples/proptypes-swagger.js

Adding optional 3rd parameter - schemaToParse

index.js ./examples/openapi.yaml ./proptypes.js datamodels

will generate PropTypes only from given schema (if exists in source file, else it will generate all found schemas).

Alternatively you can also set an npm script in your package.json:

{
  "scripts": {
    "generate": "index.js ./examples/openapi.json ./examples/proptypes.js"
  }
}

Then you can call it from your shell:

npm run generate

Further development

  • Use the proper node version, in this repo via NVM: nvm use (Stick to LTS versions only)
  • Install the project: npm ci

Roadmap

  • Pass options through CLI
  • Add tests
  • Going UMD?
  • Move to a template(s) based system instead of a string generation?

About

Generate PropTypes from openAPI 3 schemas

License:GNU Lesser General Public License v3.0


Languages

Language:JavaScript 100.0%