Complete the code to import swagger-jsdoc in an Express app.
const swaggerJSDoc = require('[1]');
The swagger-jsdoc package is imported to generate Swagger specification from JSDoc comments.
Complete the code to define the swagger-jsdoc options object.
const options = {
definition: {
openapi: '[1]',
info: {
title: 'API Docs',
version: '1.0.0'
}
},
apis: ['./routes/*.js']
};The OpenAPI version 3.0.0 is the current standard for swagger-jsdoc definitions.
Fix the error in creating the swaggerSpec variable.
const swaggerSpec = swaggerJSDoc([1]);The swaggerJSDoc function expects the options object, not a function call.
Fill both blanks to set up swagger-ui-express middleware in Express.
const swaggerUi = require('[1]'); app.use('/api-docs', swaggerUi.[2](swaggerSpec));
swagger-ui-express is used to serve the Swagger UI, and setup is the middleware to initialize it with the spec.
Fill all three blanks to complete the swagger-jsdoc setup and serve docs at '/docs'.
const swaggerUi = require('[1]'); const swaggerSpec = swaggerJSDoc([2]); app.use('[3]', swaggerUi.serve, swaggerUi.setup(swaggerSpec));
Import swagger-ui-express, pass the options object to swaggerJSDoc, and serve the docs at /docs.