Prompt
How do I generate SDKs and docs from the same spec?
Latest observation
Oct 4, 2026
OpenAI APIWeb search: off
A common way is to keep one source-of-truth API spec and run multiple generators from it.
Typical setup
Use a spec format like:
- OpenAPI for REST APIs
- GraphQL schema for GraphQL APIs
- AsyncAPI for event-driven APIs
Then generate:
- SDKs with a code generator
- Docs with a documentation generator
Example with OpenAPI
If you have an openapi.yaml, you can generate both:
SDKs
Use tools like:
- OpenAPI Generator
- Swagger Codegen
Example:
openapi-generator-cli generate -i openapi.yaml -g typescript-axios -o ./sdk
Docs
Use tools like:
- Redoc
- Swagger UI
- Stoplight Elements
Example with Redoc:
redocly build-docs openapi.yaml
Recommended workflow
- Write and maintain the spec in version control.
- Validate the spec in CI.
- Generate SDKs for each target language.
- Generate docs from the same spec.
- Publish both on release.
Good practice
- Keep the spec authoritative; don’t hand-edit generated SDKs.
- Use templates/config to customize generated output.
- Version the spec so SDKs and docs stay in sync.
Minimal pipeline example
# Generate docs
redocly build-docs openapi.yaml -o docs.html
# Generate SDK
openapi-generator-cli generate -i openapi.yaml -g python -o ./python-sdk
If you want, I can give you:
- a full CI pipeline example
- a GitHub Actions workflow
- or a setup for OpenAPI + TypeScript/Python SDKs + docs