-
Notifications
You must be signed in to change notification settings - Fork 224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
swagger doc is not creating. #47
Comments
Hi @sitamailing, Can you please provide some more information, as well as check other open bugs to see if you're using something that is part of a known issue? Thanks! |
My app.js exist in another folder, not in the root directory. If I put my app.js in the root folder, it works. Do I need to change the path of swagger.json or something else? |
It may have something to do with the way your calling your routes to be processed by swagger-jsdoc. Relative routes should work, but what I tend to do in the base of my applications is get the PWD of the base file or if you have libraries outside of that folder that need referencing generate the PROJECT_ROOT (below are app.rootDir) to base all my globs from. This should allow the routes to generate properly. The reference below can be seen here in a koa generator I built with built-in swagger-jsdoc support. let swaggerOptions =
{ swaggerDefinition:
{ swagger: '2.0'
, info:
{ title: 'API Explorer' // Title (required)
, version: '1.0.0' // Version (required)
, contact:
{ name: ''
, url: ''
}
}
, host: `${config.app.domain || config.app.host}:${config.app.port}`
, basePath: config.app.namespace
}
, apis:
[ app.rootDir + '/routes/**/*.js'
, app.rootDir + '/lib/**/*.js'
, app.rootDir + '/models/**/*.js'
]
};
// Initialize swagger-jsdoc -> returns validated swagger spec in json format
let swaggerSpec = swaggerJSDoc(swaggerOptions); |
Thank you. It works for me. |
So, my server configuration looks something like this -
But after running the project, nothing is getting generated in swagger.json and the page looks like this - |
@aayushis12 please open a new issue with your code samples. If you have tried the suggestions in this issue and they do not work for you, you might want to include details what you've tried and what you've received as feedback. Otherwise, if suggestions here are not relevant to your issue: create a new issue in order to keep the topic separate. |
Swagger doc is not creating. Just following is displaying.
{"info":{"title":"Node Swagger API","version":"1.0.0","description":"Demonstrating how to desribe a RESTful API with Swagger"},"host":"localhost:3000","basePath":"/","swagger":"2.0","paths":{},"definitions":{},"responses":{},"parameters":{},"securityDefinitions":{},"tags":[]}
The text was updated successfully, but these errors were encountered: