swagger-by-jsdoc-serverless
v1.0.4
Published
Read serverless and jsdoc to make a swagger json
Readme
swagger-by-jsdoc-serverless
Read serverless and jsdoc to make a swagger json
Install
npm i swagger-by-jsdoc-serverlessPost install
Run script
node -r swagger-by-jsdoc-serverless/scripts/init.jsOr manually edit pachage.json":
"scripts": {
"swagger-spec": "node -r swagger-by-jsdoc-serverless/scripts/spec.js > NUL",
"swagger-html": "node -r swagger-by-jsdoc-serverless/scripts/html.js > NUL"
}And edit .gitignore:
swagger/*/*
!swagger/components/schemas/
tmp/*.jsonThe next folders will be created
./swagger
./tmpSpec first
Create folders and default shcemas files
npm run swagger-specUpdate schema files in \swagger\components\schemas and now run again
npm run swagger-specMake html
Run script
npm run swagger-htmland you can find tmp\index.html
Schemas
The schemas mentioned in this project refer to the JSON objects used in both the request body and the response body. These schemas define the structure and validation of the data sent or received in the API operations.
If you need help creating a schema, you can refer to the json-to-schema-swagger package, where you will find a detailed guide on how to generate schemas compatible with Swagger.
For example:
- Request Body Schema: Defines the data that the client must send to the server.
- Response Body Schema: Defines the data that the server returns to the client.
Make sure to properly document these schemas in your Swagger definitions to ensure a well-structured and easy-to-understand API.
