feat: optional API docs in staging/prod; rename api/manage.py to api/cli.py#520
Draft
somethingnew2-0 wants to merge 1 commit into
Draft
feat: optional API docs in staging/prod; rename api/manage.py to api/cli.py#520somethingnew2-0 wants to merge 1 commit into
somethingnew2-0 wants to merge 1 commit into
Conversation
…cli.py Add an ENABLE_API_DOCS setting (default false) so the auto-generated OpenAPI docs (/api/docs) and schema (/api/openapi.json) can be exposed outside development. They remain always-on in development and stay behind the app-wide require_authenticated gate, so enabling the flag exposes them to authenticated users only, never the public internet. The policy lives in a new settings.expose_api_docs property (DEBUG or ENABLE_API_DOCS) that create_app consults for docs_url/openapi_url. Also rename api/manage.py to api/cli.py — the module is the Click CLI, not a Flask-style management shim, so the name was misleading. Updated the console script entry point and ty override in pyproject.toml, the Dockerfile comment, and doc references. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
What & why
Two small, independent changes.
Optional OpenAPI docs outside development
Adds an
ENABLE_API_DOCSsetting (defaultfalse) that lets an operator expose the auto-generated OpenAPI docs (/api/docs) and schema (/api/openapi.json) in staging/production. Previously these were mounted only whenDEBUG(i.e.ENV=development), so there was no way to reach them in a deployed environment — useful for debugging or client-code generation against a live deployment.The exposure decision is centralized in a new
settings.expose_api_docsproperty (DEBUG or ENABLE_API_DOCS) thatcreate_appconsults for bothdocs_urlandopenapi_url. Key safety point: both routes stay behind the app-widerequire_authenticatedgate, so flipping the flag exposes the docs to authenticated users only — never the public internet. Off by default so deployments don't publish their API surface unless they opt in.Rename
api/manage.py→api/cli.pyThe module is the Click-based CLI (
access sync,access notify, …), not a Flask-style management shim, so the old name was misleading. The console-script entry point name (access) is unchanged, so cronjobs/manifests are unaffected. References updated inpyproject.toml(entry point + ty override), theDockerfilecomment, and doc strings.Notes for reviewers
main, including build: adopt uv and ty in place of pip/tox and mypy #507's uv/ty migration — the rename's config touchpoints landed inpyproject.toml(where the entry point and per-module type-checker override now live) rather than the removedsetup.py/.mypy.ini.uv run ty check .,uv run ruff check/format --check, and the fulluv run pytestsuite (587 passing, including new coverage for the docs toggle and theexpose_api_docspolicy).