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
This project generates openapi spec file from combined apis.
Openapi spec file can be generated in json or yaml.
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"
}
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>
npm i -g @mindbaz/sweego-openapi-spec-generator
sweego-openapi-spec-generator <EXPORT_TYPE> <ENV_FILE_PATH> <PATH_TO_EXPORT_DIR>
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/');