Skip to content

[18.0][ADD] openapi_doc_base: OpenAPI docs building blocks - #181

Draft
simahawk wants to merge 1 commit into
OCA:18.0from
camptocamp:18-add-openapi_doc_base
Draft

simahawk wants to merge 1 commit into
OCA:18.0from
camptocamp:18-add-openapi_doc_base

Conversation

@simahawk

Copy link
Copy Markdown
Contributor

Motivation

There is no shared way to document an HTTP endpoint with OpenAPI or to browse the docs: the existing one is tied to base_rest. This module provides the building blocks to document any HTTP endpoint with OpenAPI, and to browse the docs with Swagger UI, so that every module exposing an API can document it the same way. It offers no page of its own: each module defines its routes, auth and access policy.

Key features

  • SpecBuilder: builds an OpenAPI document from any list of routes (routing map, generator, records)
  • documentation sources grouped by category and app, registered via ir.http._openapi_doc_sources; controllers w/ an api_doc routing key are collected automatically
  • sources protected by groups (a viewer group by default); no source is visible without them
  • openapi.doc.mixin: docs fields and helpers for records that are routes
  • OpenApiDocsControllerMixin: helpers for controllers to serve Swagger UI (category and app selectors) and the JSON docs
  • server selector ("Current domain" by default) for the "Try it out" and curl snippets

@simahawk
simahawk force-pushed the 18-add-openapi_doc_base branch from f063071 to 5b62244 Compare October 16, 2026 14:22
simahawk added a commit to camptocamp/web-api that referenced this pull request Oct 16, 2026
Pending OCA#181 (openapi_doc_base).
To be removed once merged.
simahawk added a commit to camptocamp/web-api that referenced this pull request Oct 16, 2026
Pending OCA#183 (openapi_doc_viewer) and OCA#181 (openapi_doc_base).
To be removed once merged.
Base module to document HTTP endpoints w/ OpenAPI and Swagger UI,
w/o depending on any API framework and w/o exposing any URL.

* `SpecBuilder`: build OpenAPI 3 documents from any list of
  `(url, endpoint)`, reading the routing (`api_doc` key, plain JSON
  schemas or params exposing `to_json_schema`)
* documentation sources grouped by category and app, always protected
  by groups (per source and per category),
  registered via `ir.http._openapi_doc_sources`
* `openapi.doc.mixin`: docs fields and helpers for records that are routes
* `OpenApiDocsControllerMixin`: helpers for controllers to serve Swagger UI
  w/ category/app selectors and JSON documents
* server selector for "Try it out" and curl snippets: the current domain
  by default (`web.base.url` might be internal), `web.base.url` and
  configured URLs as alternatives
@simahawk
simahawk force-pushed the 18-add-openapi_doc_base branch from 5b62244 to 3620e3c Compare October 21, 2026 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants