API documentation with OpenAPI/Swagger — endpoint descriptions, request/response
66
57%
Does it follow best practices?
Impact
100%
1.06xAverage score across 3 eval scenarios
Passed
No known issues
When building or updating a REST API, ensure every endpoint is documented for consumers.
Document every endpoint — method, path, one-line summary, request body shape (with required fields marked), success response shape with status code, and error responses with status codes.
Use the framework's built-in docs when available:
summary, response_description to decorators; add docstrings to handler functions; use Pydantic Field(description=...) on model fields. Docs auto-generate at /docs.swagger-jsdoc with @openapi JSDoc annotations on route handlers + swagger-ui-express mounted at /api-docs.springdoc-openapi with @Operation / @ApiResponse annotations.When no framework tooling is available, write a markdown file (API.md or in README.md) covering every endpoint with the same elements listed in rule 1.
Always follow the task's output requirements exactly — if the task asks for a setup script, a verification script, a specific output file, or a specific docs URL path, implement those precisely. Do not skip or alter requested deliverables.
WRONG — Documenting only the happy path:
POST /api/orders → 201 CreatedRIGHT — Documenting success AND error responses:
POST /api/orders
201: Order created { "data": { "id": 42, ... } }
400: Validation error { "error": "items is required" }
401: Unauthorized { "error": "Missing auth token" }WRONG — Listing fields without marking which are required:
Body: { customer_name, items, notes }RIGHT — Clearly marking required vs optional:
Body:
customer_name (string, required)
items (array, required)
notes (string, optional)WRONG — FastAPI: omitting response_description, responses, and required/optional distinction:
@app.post("/items", status_code=201)
async def create_item(body: ItemCreate):
...RIGHT — FastAPI: full decorator params, error responses declared, Pydantic model with clear required/optional:
class ItemCreate(BaseModel):
name: str = Field(..., description="Item name") # required (no default)
quantity: int = Field(..., ge=1, description="Quantity") # required
notes: Optional[str] = Field(None, description="Notes") # optional
@app.post("/items", status_code=201,
summary="Create a new item",
response_description="The newly created item",
responses={400: {"description": "Validation error"}, 404: {"description": "Not found"}})
async def create_item(body: ItemCreate):
"""Create an item in the inventory."""
...WRONG — Forgetting to document query parameters and path parameters:
GET /api/ordersRIGHT — Including all parameters:
GET /api/orders?status=active&page=1
Path params: none
Query params:
status (string, optional) — filter by order status
page (integer, optional, default: 1) — pagination