Descriptions and Metadata
Docs Home | Previous: OpenAPI and Swagger | Next: Spec-Only Mode
A valid OpenAPI spec is useful, but a well-documented spec is what makes your API easy to consume. bun-openapi provides several decorators to enrich the generated documentation without duplicating information.
Endpoint Summaries and Descriptions
Use @Summary for a short one-liner and @Description for a longer explanation. Both appear in Swagger UI and the raw OpenAPI spec.
In Swagger UI, the summary shows as the endpoint title, and the description appears when you expand the endpoint.
TIP: Keep summaries under 10 words. Use the description for details, edge cases, and examples.
Operation IDs
@OperationId assigns a stable identifier to each operation. This is valuable for SDK generators that use operation IDs as function names.
Without @OperationId, the generated spec omits the field and SDK generators fall back to their own naming heuristics.
Tags
Tags group endpoints in Swagger UI. Apply @Tags at the controller level to tag all methods, or at the method level for overrides.
Deprecating Endpoints
Mark endpoints that should no longer be used with @Deprecated. Swagger UI renders them with a strikethrough style.
Hiding Endpoints from the Spec
Use @Hidden to exclude an endpoint from the OpenAPI document entirely. The route still works at runtime — it just won't appear in docs or generated SDKs.
Response Documentation
@Returns documents the response schema and description for a specific status code. This is how consumers know what to expect.
Multiple @Returns decorators on one method document different status codes. Error responses that don't have a body schema can pass undefined.
Content Type
Use @Produces when a response uses a non-default content type.
Putting It All Together
A well-documented endpoint combines several metadata decorators:
This produces a rich Swagger UI entry with clear descriptions, typed response schemas, and documented error cases.
See Also
- Decorator Reference — full list of all decorators.
- OpenAPI and Swagger — configuring the spec and Swagger UI.
- examples/03_multi-controller — example using metadata decorators.