fix(openapi): declare authentication via securitySchemes instead of ignored header parameters - #716
Open
yingzhehu-TT wants to merge 1 commit into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Contributor
Author
|
@googlebot I signed it! |
…gnored header parameters
yingzhehu-TT
force-pushed
the
fix/openapi-security-schemes
branch
from
August 12, 2026 08:20
b03de9c to
3dd8837
Compare
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.
Closes #668
Summary
components.securitySchemeswithoauth2_bearer(HTTP bearer) andapi_key(X-API-Key), and a document-levelsecurityrequirement.authorization,x_api_key,content_typeandacceptheaderparameter definitions and all 53
$refs to them.Motivation
#668 reports that
Authorizationis declared as a header parameter, whichOpenAPI 3.1 requires implementations to ignore. The same clause covers two more
parameters in the same file that the issue does not mention:
Current state of
source/services/shopping/rest.openapi.json:name$refsauthorizationAuthorizationcontent_typeContent-TypeacceptAcceptx_api_keyX-API-KeyThat is 39 parameter references the specification requires tooling to discard,
and
components.securitySchemesis absent from the document entirely. Anythinggenerated from this file — clients, validators, docs — silently drops the
authentication contract.
Content-TypeandAcceptneed no replacement: the information is alreadycarried correctly and non-ignorably by the
requestBody.contentandresponses.*.contentmedia-type maps, which every operation already declares.X-API-Keyis not in the ignore list, but #668 asks for "securitySchemes thatspecify all supported types (i.e. JWT/OAuth, API key, basic auth, etc.)", so
leaving it as a parameter would be half a fix.
Design decisions
type: http, scheme: bearerrather thantype: oauth2with flows. Thereplaced description named
client_credentialsandauthorization_code, whichargues for
type: oauth2. But an OAuth Flow Object requires concretetokenUrl/authorizationUrlvalues, and UCP has none to give: peridentity-linking.md, platforms discover the business's authorization server atruntime via RFC 8414 metadata (OIDC fallback), and the issuer may sit on a
different origin than the business.
http/bearerstates exactly what is trueon the wire —
Authorization: Bearer <access_token>— without fabricating fixedendpoints. The description points readers at Identity Linking for discovery.
Happy to switch to
oauth2if the council would rather assert templated URLs.securityincludes the empty requirement{}. Every parameter this PRreplaces was
required: false, andsignatures.mdstates that platformsSHOULD sign requests and MAY use alternative mechanisms (API keys, OAuth,
mTLS) instead. So no single scheme is universally mandatory, and omitting
{}would tighten the contract beyond what the spec says.
RFC 9421 signature headers stay as parameters.
Signature,Signature-InputandContent-Digestare not in the OpenAPI ignore list, andOpenAPI 3.1 has no security-scheme type that expresses HTTP Message Signatures.
Modelling them is a separate question and is deliberately out of scope here.
Scope
One file:
source/services/shopping/rest.openapi.json(+22 / −129).permalink.openapi.jsonandhandlers/tokenization/openapi.jsondeclare noauthentication headers at all, so they are untouched.
Note that
x_api_keywas also referenced by theorderEventwebhook; thedocument-level
securityrequirement applies to webhook operations too, so thewebhook's authentication contract is preserved rather than dropped.
Validation
ucp-schema lint source/— 100 files checked, all passed.scripts/validate_examples.py --schema-base source/schemas/— 292 passed,0 failed, 0 errors, 48 skipped.
mkdocs build --strict— completes, no warnings escalated.openapi-spec-validatoragainst the built artifact shape (withinfo.versioninjected as
hooks.py::_set_schema_versiondoes at build time):VALID OpenAPI 3.1 both before and after, so document validity is preserved.
assertion against an independently constructed target document, so nothing
outside the four parameters could be reordered or dropped.
main.py::method_fieldsexplicitlyskips
in: headerparameters ("Filter out headers (transport-specific)"), soremoving them changes no generated table. The prose references to
X-API-Keyin
cart-rest.mdandcheckout-rest.mdremain accurate — these headers arestill sent on the wire; only their OpenAPI declaration moves.