Conversation
… export Authentication is a per-route dependency, so the schema pages (/openapi.json, /openapi-3.0.json, /swagger, /docs, /docs/oauth2-redirect, /scalar) and /metrics are readable without an API key on every deployment. There was no setting for the reference pages, and DOCLING_SERVE_OTEL_ENABLE_PROMETHEUS=false only left the Prometheus reader and the RQ/Ray collectors unregistered while the /metrics route stayed mounted, still publishing python_info and process_*. Add `enable_api_docs` (default true). When false, FastAPI gets no openapi_url, which drops the schema, its Swagger UI and ReDoc pages and the OAuth2 redirect page, and the offline Swagger UI/ReDoc, Scalar and OpenAPI 3.0 routes are not registered either; the paths answer 404 like any unregistered route. Register /metrics only while otel_enable_prometheus is true, which is what the configuration docs already promise for that flag. Behaviour change: a deployment with DOCLING_SERVE_OTEL_ENABLE_PROMETHEUS=false now gets 404 on /metrics (before: 200 with the Python process metrics only), so a scraper still pointed at it fails visibly instead of collecting an empty page. The separate `metrics_port` server is not affected and stays additive. The disabled routes answer 404 rather than the 403 used by show_version_info and enable_management_endpoints because an unregistered route reveals nothing about the deployment, and 404 is also what FastAPI's own docs_url=None yields. While there, the CLI banner's Scalar link pointed at the ReDoc URL. Signed-off-by: Markus Uhlending <privat0816@gmail.com>
Contributor
|
✅ DCO Check Passed Thanks @Ulli2060, all your commits are properly signed off. 🎉 |
Contributor
Merge Protections🟢 Merge protection satisfied — ready to merge. Show 1 satisfied protection🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
Ulli2060
marked this pull request as ready for review
September 21, 2026 10:24
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Authentication is a per-route dependency, so the schema pages (
/openapi.json,/openapi-3.0.json,/swagger,/docs,/docs/oauth2-redirect,/scalar) and/metricsare readable without an API key on every deployment. There was no setting for the reference pages, andDOCLING_SERVE_OTEL_ENABLE_PROMETHEUS=falseonly left the Prometheus reader and the RQ/Ray collectors unregistered while the/metricsroute stayed mounted, still publishingpython_infoandprocess_*.enable_api_docs(DOCLING_SERVE_ENABLE_API_DOCS, defaulttrue). Whenfalse, FastAPI gets noopenapi_url, which drops the schema, its Swagger UI and ReDoc pages and the OAuth2 redirect page, and the offline Swagger UI/ReDoc, Scalar and OpenAPI 3.0 routes are not registered either. The paths answer 404 like any unregistered route./metricsis registered only whileotel_enable_prometheusistrue, which is what the configuration docs already promise for that flag.Behaviour change: a deployment with
DOCLING_SERVE_OTEL_ENABLE_PROMETHEUS=falsenow gets 404 on/metrics(before: 200 with the Python process metrics only), so a scraper still pointed at it fails visibly instead of collecting an empty page. The separatemetrics_portserver is not affected and stays additive.Design notes, in case they come up:
show_version_infoandenable_management_endpoints: an unregistered route reveals nothing about the deployment, and it is what FastAPI's owndocs_url=Noneyields.otel_enable_prometheusalone, notmetrics_port: with the flag on, the in-app route serves the same registry as the separate port. Hiding it when a port is configured would be a second behaviour change; easy to add if wanted.Tests (
tests/test_api_docs_and_metrics_toggle.py, 27 cases): all six reference routes with and without static assets (200 / 404), the API itself unaffected (POST /v1/convert/source-> 422),/metrics200 / 404 by flag. The orchestrator dependency and the OpenTelemetry setup are stubbed as intest_batch_endpoint.py.AI disclosure
The change and its tests were prepared with an AI coding assistant (Claude Code) under my direction; I reviewed the code paths against v1.34.0 and ran the tests, ruff and mypy locally.