0
0
Expressframework~20 mins

API documentation best practices in Express - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
API Documentation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:00remaining
What is the primary purpose of API documentation?

Why do developers create API documentation for Express applications?

ATo automatically generate database schemas
BTo increase the server response speed
CTo reduce the size of the application code
DTo explain how to use the API endpoints clearly to other developers
Attempts:
2 left
💡 Hint

Think about what helps developers understand how to interact with the API.

component_behavior
intermediate
1:30remaining
What output does this Express route documentation produce?

Given this API documentation snippet, what is the expected HTTP response when a GET request is made to /users?

Express
app.get('/users', (req, res) => {
  /**
   * @api {get} /users Get all users
   * @apiSuccess {Object[]} users List of user objects
   */
  res.json([{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }]);
});
A404 Not Found
B{"users":[]}
C[{"id":1,"name":"Alice"},{"id":2,"name":"Bob"}]
D500 Internal Server Error
Attempts:
2 left
💡 Hint

Look at the res.json call inside the route handler.

📝 Syntax
advanced
2:00remaining
Which option correctly documents a POST endpoint with request body in Express?

Choose the correct JSDoc-style comment to document a POST /login endpoint that expects a JSON body with username and password fields.

A
/**
 * @api {post} /login User login
 * @apiParam {String} username User's username
 * @apiParam {String} password User's password
 * @apiSuccess {String} token Authentication token
 */
B
/**
 * @api {post} /login User login
 * @apiBody {String} username User's username
 * @apiBody {String} password User's password
 * @apiSuccess {String} token Authentication token
 */
C
/**
 * @api {post} /login User login
 * @apiRequest {String} username User's username
 * @apiRequest {String} password User's password
 * @apiSuccess {String} token Authentication token
 */
D
/**
 * @api {post} /login User login
 * @apiInput {String} username User's username
 * @apiInput {String} password User's password
 * @apiSuccess {String} token Authentication token
 */
Attempts:
2 left
💡 Hint

Look for the standard tag used to describe parameters in the request body.

🔧 Debug
advanced
2:00remaining
Why does this API documentation fail to show request body parameters?

Consider this Express route and its documentation. Why will the generated API docs not show the expected request body parameters?

Express
app.post('/register', (req, res) => {
  /**
   * @api {post} /register Register user
   * @apiParam {String} email User email
   * @apiParam {String} password User password
   */
  res.send('User registered');
});
AThe JSDoc comment is inside the route handler function, so the documentation tool cannot detect it.
BThe @apiParam tags are misspelled and should be @apiBodyParam.
CThe route method should be GET to document parameters correctly.
DThe response does not include JSON, so documentation tools ignore the parameters.
Attempts:
2 left
💡 Hint

Think about where documentation comments should be placed for tools to parse them.

lifecycle
expert
1:30remaining
When should API documentation be updated during Express app development?

Choose the best practice for maintaining API documentation in an Express project.

AUpdate documentation only before major releases to save time
BUpdate documentation immediately after adding or changing any API endpoint behavior
CUpdate documentation once a year during maintenance windows
DUpdate documentation only if users report issues
Attempts:
2 left
💡 Hint

Think about what keeps documentation accurate and useful for developers.