docs(openapi): document apikey auth in openapi.json#7534
Open
JohnMcLear wants to merge 1 commit intodevelopfrom
Open
docs(openapi): document apikey auth in openapi.json#7534JohnMcLear wants to merge 1 commit intodevelopfrom
JohnMcLear wants to merge 1 commit intodevelopfrom
Conversation
The API accepts the key via ?apikey=, ?api_key=, or the apikey header, but
only ?apikey= was advertised in /api-docs.json. /api/{version}/openapi.json
was worse: it hardcoded an OAuth2 scheme even when Etherpad was started in
apikey auth mode.
Switch both generators on settings.authenticationMethod and publish apiKey
schemes for the query (apikey, api_key) and header (apikey) variants. The
openapi.ts definition is now regenerated per request so runtime settings
are reflected.
The raw authorization: <key> header still works in code but is deliberately
not documented — pinning it in the spec would ossify a quirk.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Review Summary by QodoDocument API key authentication methods in OpenAPI specifications
WalkthroughsDescription• Document all three API key authentication methods in OpenAPI specs - Query parameter apikey (primary) - Query parameter api_key (alias) - Header apikey • Switch security scheme generation based on authenticationMethod setting • Regenerate OpenAPI definitions per request to reflect runtime settings • Add comprehensive test coverage for apikey authentication documentation Diagramflowchart LR
A["authenticationMethod setting"] -->|apikey mode| B["Generate apiKey schemes"]
A -->|sso mode| C["Generate OAuth2 scheme"]
B --> D["Query: apikey"]
B --> E["Query: api_key"]
B --> F["Header: apikey"]
C --> G["OpenID Connect"]
D --> H["/api-docs.json"]
E --> H
F --> H
D --> I["/api/openapi.json"]
E --> I
F --> I
G --> H
G --> I
J["Per-request regeneration"] --> H
J --> I
File Changes1. src/node/handler/RestAPI.ts
|
|
Well done |
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.

Fixes #7532.
Summary
?apikey=,?api_key=, and theapikeyheader, but only?apikey=was advertised in/api-docs.json./api/{version}/openapi.jsonwas worse: it hardcoded an OAuth2 (openid) scheme even when Etherpad was started in apikey auth mode, so the doc contradicted how the server actually authenticated.securitySchemes/securityoffsettings.authenticationMethod. When it'sapikey, they publish three schemes:apikeyin query,api_keyin query (alias), andapikeyin header.openapi.tsregenerates the definition per request so runtime settings are reflected (it used to cache at startup).The raw
authorization: <key>header still works in code but is deliberately not documented — pinning it in the spec would ossify a quirk.Test plan
src/tests/backend/specs/api/api.tsverify/api-docs.jsonexposes all three schemes and/api/openapi.jsonexposes anapiKeyscheme whenauthenticationMethod === 'apikey'.pnpm ts-checkclean.api.tsspecs still pass.🤖 Generated with Claude Code