1.0.2 • Published 5 years ago
joi-api-doc v1.0.2
Joi-API-Doc Generator
Status
A node module to generate Open API 3 spec, that is importable to Redoc, Swagger, Postman and other API tools.
Loaded with an example to demonstrate
Aiming to plug & play in your current express project easily
Preview
Install
# use npm
npm install joi-api-doc --save
Example
Visit example/ folder to see the full example.
API
new SwaggerAPI()
Creates a new SwaggerAPI instance.
swaggerAPI.addJoiRouter(router, options)
Add a joi-router object to the API. The object should already have all its properties as below example
{
routes: [
{
path: '/endpoint',
method: ['post'],
meta: {
swagger: {
summary: 'New API',
description: 'New API',
tags: ['User']
}
},
request: {
body: JoiSchema
},
response: {
'200': {
body: JoiSchema
}
}
},
// More routes
];
}
Options:
- prefix: Prefix to add to Swagger path (use prefix from JoiRouter if not set)
swaggerAPI.generateSpec(baseSpec, options)
Create a Swagger specification for this API. A base specification should be
provided with an info
object (containing at least the title
and version
strings) and any other global descriptions.
Options:
- defaultResponses: Custom default responses
{ 200: { description: 'Success' } }