@mindbaz/sweego-openapi-spec-generator

0.0.5 • Public • Published

Swego-openapi-spec-generator

This module aims to replace an old yaml file generation for sweego learn doc.
As we want to automatically generate sdks for sweego apis it was needed to export/upgrade this part

What for?

This project generates openapi spec file from combined apis.
Openapi spec file can be generated in json or yaml.

Requirements

You need to have an environement file in order to specify 2 things :

  • your primary api url
  • your secondary api url
Env File
{
    "API_SI_URL": "<PRIMARY_API>/openapi.json",
    "API_CLIENT_URL": "<SECONDARY_API>/openapi.json"
}

Using the entrypoints

In a node project

npm i @mindbaz/sweego-openapi-spec-generator --save-dev
package.json
  "scripts": {
    ...,
    "spec-generate": "sweego-openapi-spec-generator"
    ...
  }
# Exported as yaml file
npm run spec-generate -- yaml <ENV_FILE_PATH> <PATH_TO_EXPORT_DIR>

# Exported as json file
npm run spec-generate -- json <ENV_FILE_PATH> <PATH_TO_EXPORT_DIR>

As a cli

npm i -g @mindbaz/sweego-openapi-spec-generator
sweego-openapi-spec-generator <EXPORT_TYPE> <ENV_FILE_PATH> <PATH_TO_EXPORT_DIR>

Using the lib

npm i @mindbaz/sweego-openapi-spec-generator --save-dev
const swgSpecGenerator = require ('sweego-openapi-spec-generator');

// Returned as json object
const res = swgSpecGenerator.genOpenapiSpec ('json', '/path/to/env/file',);

// Exported as yaml file
swgSpecGenerator.genOpenapiSpec ('yaml', '/path/to/env/file', '/path/to/export/dir/');

Readme

Keywords

Package Sidebar

Install

npm i @mindbaz/sweego-openapi-spec-generator

Weekly Downloads

2

Version

0.0.5

License

MIT

Unpacked Size

5.01 kB

Total Files

5

Last publish

Collaborators

  • schwarzion
  • vhenon