Complete the code to add a description to the API endpoint using Swagger comments.
app.get('/users', /** [1] */ (req, res) => { res.send('User list'); });
The @desc tag is used to add a description to the API endpoint in Swagger comments.
Complete the code to specify the HTTP method in Swagger documentation.
/** * [1] GET /users * Returns list of users */ app.get('/users', (req, res) => { res.send('User list'); });
The @route tag specifies the HTTP method and path in Swagger documentation.
Fix the error in the Swagger comment to correctly document a query parameter.
/** * @route GET /search * @desc Search users * @param [1] query.string.required - search term */ app.get('/search', (req, res) => { res.send('Search results'); });
The query parameter name should match the actual query key used in the URL, commonly 'q' for search queries.
Fill both blanks to document a POST endpoint with a JSON body parameter.
/** * @route POST /users * @desc Create a new user * @param [1] body.object.required - user data * @param [2] body.object.required.name - user's name */ app.post('/users', (req, res) => { res.send('User created'); });
The body parameter is named 'userData' to represent the user object, and the nested property is 'name' for the user's name.
Fill all three blanks to document a response with status code and description.
/** * @route DELETE /users/[1] * @desc Delete a user by ID * [2] id path.string.required - user ID * [3] 204 - No content */ app.delete('/users/:id', (req, res) => { res.status(204).send(); });
The path parameter is named 'id', the tag for path parameters is '@param', and the tag for responses is '@returns'.