This repository demonstrates how to host an OpenAPI specification and automate
validation, documentation and client generation using GitHub Actions. The
spec/openapi.yaml file contains an example API definition that can be
replaced with your own.
spec/openapi.yaml– example OpenAPI 3.1 specification.github/workflows/– GitHub Actions for validating the spec and generating artifacts
Fork or use this repository as a template when starting a new API project. After replacing the sample spec with your own, the provided workflows will validate and publish your API documentation and optional client libraries.
The project includes several workflows that run on different branches or after successful validation. They are intended to show a full pipeline from authoring a spec to publishing docs.
- Trigger: Pushes to the
stagingbranch or manual invocation. - Purpose: Validates the YAML syntax and automatically adds missing
titlefields to schemas. The workflow checks out thestagingbranch, scans the spec for schemas without titles (including inline schemas) and writes the titles back. If changes are made they are committed directly to the same branch. This keeps the specification tidy before merging it intomain.
- Trigger: Pushes to the
mainbranch or manual invocation. - Purpose: Runs the OpenAPI Generator CLI in validation mode to ensure the
specification is syntactically correct. This job acts as the gate for other
workflows. When it completes successfully it triggers documentation and client
generation jobs via the
workflow_runevent.
- Trigger: After a successful
validate-openapi.ymlrun or manual invocation. - Purpose: Uses
openapitools/openapi-generatorto generate API clients for several languages (Java, JavaScript, Python, Ruby, R, Rust, Go, C# and C). The resulting client code for each language is pushed to a dedicated branch namedgenerated-<language>-client. You can adjust the language matrix to suit your needs.
- Trigger: Pushes to
main, after validation succeeds, or manual invocation. - Purpose: Generates ReDoc HTML and deploys it to GitHub Pages, similar to
build-docs.yml, but includes additional setup for the Pages environment and concurrency controls. The generated documentation is also kept on thegenerated-docsbranch. Use this workflow if you want an all-in-one build and deploy job on themainbranch.
- Work on your OpenAPI specification in a feature branch or the
stagingbranch. When pushing tostaging, the auto‑fix workflow may commit missing titles back for you. - Create a pull request targeting
main. Once merged, thevalidate-openapi.ymlworkflow verifies the spec. - After successful validation the documentation and client generation workflows run automatically and publish their results.