Skip to content

Stop the docs demanding a key the server does not use - #12

Merged
walhalabi-code merged 1 commit into
mainfrom
fix/swagger-security
Aug 31, 2026
Merged

walhalabi-code merged 1 commit into
mainfrom
fix/swagger-security

Conversation

@walhalabi-code

Copy link
Copy Markdown
Owner

Opening the generated docs and running any endpoint produced a request carrying X-Parse-REST-API-Key. Parse ignores that header unless restAPIKey is configured, which no project psk new generates does - so the docs put a dead header into every example and implied a gate that was not there.

The spec asserted it unconditionally. Its own comment said "applicationId and restApiKey are always required", which was true of neither. It is now opt-in: pass restApiKey: true when the server actually has one. The scheme is still declared either way, so a reader can see the header exists, but it is only required when it is real.

The same session also lost time to a wrong application id. Every request needs X-Parse-Application-Id, the docs page never said what to put there, a guess came back as a bare {"error":"unauthorized"} naming nothing, and the endpoint looked broken when the data was fine. SwaggerConfig now takes appId, rendered into the Authorize dialog as "This server: my-api". The generated project passes its own. It is not a secret - every client sends it on every request; the master key is the secret and is never rendered.

Verified both ways: default gives [{applicationId}] on each endpoint and
globally, with restApiKey: true it gives [{applicationId, restApiKey}].

334 tests pass.

Opening the generated docs and running any endpoint produced a request
carrying X-Parse-REST-API-Key. Parse ignores that header unless restAPIKey is
configured, which no project psk new generates does - so the docs put a dead
header into every example and implied a gate that was not there.

The spec asserted it unconditionally. Its own comment said "applicationId and
restApiKey are always required", which was true of neither. It is now opt-in:
pass restApiKey: true when the server actually has one. The scheme is still
declared either way, so a reader can see the header exists, but it is only
required when it is real.

The same session also lost time to a wrong application id. Every request needs
X-Parse-Application-Id, the docs page never said what to put there, a guess
came back as a bare {"error":"unauthorized"} naming nothing, and the endpoint
looked broken when the data was fine. SwaggerConfig now takes appId, rendered
into the Authorize dialog as "This server: my-api". The generated project
passes its own. It is not a secret - every client sends it on every request;
the master key is the secret and is never rendered.

Verified both ways: default gives [{applicationId}] on each endpoint and
globally, with restApiKey: true it gives [{applicationId, restApiKey}].

334 tests pass.
@walhalabi-code
walhalabi-code merged commit 0db3418 into main Aug 31, 2026
5 checks passed
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