Simplify OpenAPI generation

This commit is contained in:
gabdevele
2026-06-03 02:04:56 +02:00 Unverified
parent 21883a4a8f
commit 25c280f38b
25 changed files with 2695 additions and 1944 deletions
+7 -6
View File
@@ -77,16 +77,17 @@ discoverable by CMake. The default build uses CPM.cmake and downloads Drogon
## OpenAPI
The OpenAPI spec is generated with `scripts/swagger-drogon/`. The generator
discovers Drogon controller route macros, reads adjacent `openapi:` metadata,
infers simple query/body/response shapes from C++ code, then merges the Visione
schema registry in `docs/openapi/visione.yaml`. Generation fails if an endpoint
still has generic request or response schemas.
The OpenAPI spec is generated from Drogon controller route macros plus the
manual standard OpenAPI document in `docs/openapi/visione.openapi.yaml`.
The script extracts paths and methods from C++ and lets the manual file own
summaries, request bodies, responses, schemas and examples.
The manual file uses JSON-compatible YAML so the CMake build does not require
extra Python packages.
```bash
cmake --build build --target openapi
python3 -m json.tool build/openapi/visione.openapi.json >/dev/null
python3 -m unittest discover scripts/swagger-drogon/tests
python3 -m unittest scripts/test_generate_openapi.py
```
The app serves the generated JSON at `/api/v1/openapi.json` and Swagger UI at