Prompt
How do I get interactive API reference docs with auth and examples?
Latest observation
Oct 4, 2026
OpenAI APIWeb search: off
You usually get that by combining OpenAPI/Swagger with your API docs site.
The common setup
-
Define your API in OpenAPI
- Include:
- endpoints, parameters, request/response schemas
- auth schemes (
bearerAuth, API keys, OAuth2, etc.) - example requests/responses
- Include:
-
Serve interactive docs
- Use one of these:
- Swagger UI
- ReDoc
- Redocly
- Stoplight Elements
- These render the OpenAPI spec and let users:
- try endpoints
- paste auth tokens
- see examples inline
- Use one of these:
To support auth in the docs
In your OpenAPI spec, define security schemes, for example:
components:
securitySchemes:
bearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
Then apply it globally or per endpoint:
security:
- bearerAuth: []
Swagger UI will then show an Authorize button.
To show examples
Add examples in your schema or request bodies:
paths:
/users:
get:
responses:
'200':
description: OK
content:
application/json:
example:
id: 1
name: Ada
Or with multiple examples:
content:
application/json:
examples:
simple:
value:
id: 1
name: Ada
full:
value:
id: 1
name: Ada
role: admin
If you want a quick tool recommendation
- Swagger UI: best for “try it now” interactivity
- Redoc: prettier reference docs, less interactive by default
- Stoplight: good for design + docs + mocking
Typical architecture
- Build API spec from code or write it manually
- Host
/openapi.jsonor/openapi.yaml - Mount docs at
/docs - Configure auth in the spec
- Add examples to schemas and responses
Example with FastAPI
FastAPI gives you this out of the box:
/docs→ Swagger UI/redoc→ ReDoc- auth support via dependencies and OpenAPI integration
- examples via Pydantic schemas
If you want, I can show you:
- a minimal OpenAPI example with auth + examples, or
- how to do this in FastAPI / Express / Django / Flask / NestJS.