Repository navigation
Serve Swagger UI and an OpenAPI description for the local API - #11
Merged
Merged
Conversation
added 2 commits
December 2, 2026 10:26
Programs and people using the local API had only a prose page and a curl example to go by. The API now serves an OpenAPI 3.1 description at /openapi.json (with the models usable right now as examples for `model`), so it can be imported into Postman or Insomnia or used to generate clients, and a Swagger UI page at /docs to browse it and send requests with the key from the Authorize button. Both answer without the key because they hold no secrets; every other route still requires it. Swagger UI loads from jsDelivr at a pinned version with SRI hashes, so the app ships no copy of it. The API tab links both while the API runs.
The OpenAPI description is served without the key, but it listed the models of the logged-in subscriptions, which told any caller which subscriptions this computer has and ran the CLIs to find out. Without the key it now has static example models; with the key (Swagger UI sends it after Authorize) it lists the live ones. Every request must now be addressed to 127.0.0.1, localhost or [::1] on the API's port. Otherwise a web page could point its own domain at 127.0.0.1 (DNS rebinding) and read the keyless pages as same-origin.
redacid
pushed a commit
that referenced
this pull request
Dec 2, 2026
Bump the version and add the changelog entry for Swagger UI and the OpenAPI description of the local API (#11).
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
The local subscription API (#10) now documents itself:
GET /openapi.json: OpenAPI 3.1 description of/v1/modelsand/v1/chat/completions, covering request and response schemas, SSE streaming, error codes and bearer auth. It imports into Postman, Insomnia or Bruno, or into client generators.GET /docs: a Swagger UI page. Authorize takes the key, and Try it out sends real requests.Security
/docsand/openapi.jsonanswer without the key, since they hold no secrets. Every other route still requires it.Hostof127.0.0.1,localhostor[::1]on the API's port; anything else gets421. This blocks DNS rebinding: a web page pointing its own domain at 127.0.0.1 can no longer read the keyless pages as same-origin.swagger-ui-dist@5.17.14from jsDelivr, pinned and checked with SRI hashes, so the app ships no copy. That page needs internet access;openapi.jsondoes not.Testing
make check: 179 tests. New tests cover:Hostcheck, including a request with a foreignHost.mkdocs build --strictpasses./chat/completionsreturned the answer and the matching curl command. No real CLI was used from this page.Docs
docs/api.md: new "Swagger UI and OpenAPI" section, the endpoints table, and the Host rule under Security.docs/interface.md: the Docs row.openapi.tsmodule and the keyless and Host behaviour.