Complete the code to import the Swagger UI middleware in an Express app.
const swaggerUi = require('[1]');
The correct package to serve Swagger UI in Express is swagger-ui-express.
Complete the code to serve the Swagger UI at the '/api-docs' route.
app.use('/api-docs', swaggerUi.serve, swaggerUi.[1](swaggerDocument));
The method to setup Swagger UI middleware is setup.
Fix the error in the Swagger document import statement.
const swaggerDocument = require('./[1].json');
The Swagger JSON file is commonly named swagger.json.
Fill both blanks to create a basic Swagger document with title and version.
const swaggerDocument = {
openapi: '3.0.0',
info: {
title: '[1]',
version: '[2]'
},
paths: {}
};The title is usually a friendly name like 'My API', and version follows semantic versioning like '1.0.0'.
Fill all three blanks to define a GET endpoint '/users' with a summary and 200 response description.
paths: {
'/users': {
get: {
summary: '[1]',
responses: {
'200': {
description: '[2]',
content: {
'application/json': {
schema: [3]
}
}
}
}
}
}
}The summary describes the endpoint action, the description explains the response, and the schema defines the data structure returned.