Skip to content

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
mainfrom
pcollins/practical-chebyshev-46a9aa
Draft

feat: optional API docs in staging/prod; rename api/manage.py to api/cli.py#520
somethingnew2-0 wants to merge 1 commit into
mainfrom
pcollins/practical-chebyshev-46a9aa

Conversation

@somethingnew2-0

Copy link
Copy Markdown
Collaborator

What & why

Two small, independent changes.

Optional OpenAPI docs outside development

Adds an ENABLE_API_DOCS setting (default false) 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 when DEBUG (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_docs property (DEBUG or ENABLE_API_DOCS) that create_app consults for both docs_url and openapi_url. Key safety point: both routes stay behind the app-wide require_authenticated gate, 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.pyapi/cli.py

The 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 in pyproject.toml (entry point + ty override), the Dockerfile comment, and doc strings.

Notes for reviewers

  • Rebased on latest 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 in pyproject.toml (where the entry point and per-module type-checker override now live) rather than the removed setup.py/.mypy.ini.
  • Verified locally with uv run ty check ., uv run ruff check/format --check, and the full uv run pytest suite (587 passing, including new coverage for the docs toggle and the expose_api_docs policy).

…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant