Skip to content

Add OpenAPI 3.0 documentation#165

Draft
tvdeyen wants to merge 9 commits intomainfrom
add-openapi-docs
Draft

Add OpenAPI 3.0 documentation#165
tvdeyen wants to merge 9 commits intomainfrom
add-openapi-docs

Conversation

@tvdeyen
Copy link
Copy Markdown
Member

@tvdeyen tvdeyen commented Mar 21, 2026

Summary

A special treat for my friend @lassediercks ❤️

  • Add a comprehensive OpenAPI 3.0 spec (docs/openapi.yml) covering all public and admin endpoints (pages, layout pages, nodes), resource schemas, all 15 ingredient types, pagination, filtering, sparse fieldsets, and caching headers
  • Add a GET /openapi.json endpoint (OpenapiController) that serves the spec as JSON for tools like Swagger UI and Redoc
  • Integrate rspec-openapi to regenerate the spec from actual request spec responses (OPENAPI=1 bundle exec rspec)
  • Add an OpenAPI drift check to CI that fails if docs/openapi.yml is out of date
  • Expand the README with OpenAPI usage docs and a proper Contributing guide

How it works

The OpenAPI spec is a hand-written YAML file with detailed component schemas. Running OPENAPI=1 bundle exec rspec uses rspec-openapi to merge actual API response shapes into the paths section while preserving hand-written schemas. CI enforces that the committed spec matches what the tests produce.

@tvdeyen tvdeyen requested a review from lassediercks March 21, 2026 21:53
@tvdeyen tvdeyen self-assigned this Mar 21, 2026
@tvdeyen tvdeyen force-pushed the add-openapi-docs branch 2 times, most recently from 3bcee0f to ab692bb Compare March 21, 2026 22:03
tvdeyen added 7 commits March 21, 2026 23:20
Covers all public and admin endpoints (pages, layout_pages, nodes),
all resource schemas (page, element, language, node), all 15 ingredient
type schemas, pagination, filtering, sparse fieldsets, and caching
headers.
Adds OpenapiController that loads the YAML spec once and serves it as
JSON. Clients and tools like Swagger UI can discover the API at
/jsonapi/openapi.json.
Add rspec-openapi to Gemfile and configure it in spec/support/openapi.rb
to regenerate docs/openapi.yml from request specs when running with
OPENAPI=1. The gem merges actual JSON:API responses into the existing
spec file, preserving hand-written component schemas.

Also includes docs/openapi.yml in the gemspec file list and documents
the workflow in the README.
Runs the test suite with OPENAPI=1 and fails if docs/openapi.yml has
uncommitted changes, ensuring the checked-in spec stays in sync with
the actual API responses.
Expand the Contributing section with step-by-step instructions including
the OpenAPI regeneration step. Add a note to the OpenAPI section about
the CI drift check.
Useful for working with Bruno App
Necessary if you want to serve from
the dummy app.
@tvdeyen tvdeyen force-pushed the add-openapi-docs branch 2 times, most recently from bde7925 to 7fd57cf Compare March 21, 2026 22:22
Serves a lightweight HTML page that loads Swagger UI from the CDN and
points it at the existing /jsonapi/openapi.json endpoint. No extra gem
dependencies required.

Signed-off-by: Thomas von Deyen <thomas@vondeyen.com>
Update generated OpenAPI spec with tags, schemas,
and component definitions.

Signed-off-by: Thomas von Deyen <thomas@vondeyen.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant