0
0
Expressframework~5 mins

swagger-jsdoc setup in Express - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is swagger-jsdoc used for in an Express app?
swagger-jsdoc generates API documentation from JSDoc comments in your code. It helps create a Swagger (OpenAPI) specification automatically.
Click to reveal answer
beginner
Which package do you use alongside swagger-jsdoc to serve the API docs in Express?
You use swagger-ui-express to serve the generated Swagger UI documentation in your Express app.
Click to reveal answer
intermediate
What is the purpose of the swaggerDefinition object in swagger-jsdoc setup?
It defines the basic info about your API like title, version, description, and server URLs. This info appears in the generated docs.
Click to reveal answer
intermediate
How do you tell swagger-jsdoc where to find your API route files for documentation?
You specify the file paths or glob patterns in the apis array option when configuring swagger-jsdoc.
Click to reveal answer
intermediate
What is the typical Express middleware setup to serve Swagger UI using swagger-jsdoc?
You create the swaggerSpec with swagger-jsdoc, then use app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerSpec)) to serve docs at /api-docs.
Click to reveal answer
What does swagger-jsdoc generate from your code comments?
AOpenAPI specification JSON
BHTML pages for your website
CDatabase schemas
DCSS stylesheets
Which Express middleware package is commonly used to display swagger-jsdoc output as a web page?
Aexpress-session
Bbody-parser
Ccors
Dswagger-ui-express
Where do you specify the API info like title and version in swagger-jsdoc?
AIn the .env environment file
BIn the Express app.listen() method
CIn the swaggerDefinition object
DIn the package.json file
How do you tell swagger-jsdoc which files to scan for API documentation comments?
ABy importing them in app.js
BBy listing file paths in the apis array option
CBy naming files swagger.js
DBy placing files in a docs folder
What URL path is commonly used to serve Swagger UI docs in an Express app?
A/api-docs
B/docs
C/swagger
D/documentation
Explain the steps to set up swagger-jsdoc and swagger-ui-express in an Express app.
Think about installation, configuration, generating spec, and serving docs.
You got /5 concepts.
    Describe how swagger-jsdoc uses JSDoc comments to create API documentation.
    Focus on the role of comments and how swagger-jsdoc processes them.
    You got /4 concepts.