Simplify OpenAPI generation
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user