docs(decorator): document last-writer-wins for register_openapi_metadata - #402
Merged
Conversation
A method+path pair is a single OpenAPI operation by definition, so re-registering it replaces the prior entry rather than being a bug. This last-writer-wins semantic intentionally powers the scan-then-enrich pattern: scan_endpoint_metadata seeds a minimal bridge/validation entry and a subsequent register_openapi_metadata call overrides it with richer, human-authored metadata (see examples/partner_import_bridge). Document the contract in the docstring, add a debug-level log so the replace stays traceable, and lock the behavior in with a regression test. Closes #397
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.
Summary
method+pathpair is a single OpenAPI operation, so re-registering it is an intentional last-writer-wins replace — not a collision between two distinct operations.examples/partner_import_bridge):scan_endpoint_metadataseeds a minimal bridge/validation entry, then an explicitregister_openapi_metadatacall overrides it with richer, human-authored metadata. Treating the second call as an error/warning would break this first-class workflow.method::pathkey andprogrammatic.*_function_id), so there is no non-fragile way to distinguish "legitimate override" from "accidental overwrite" — and per the OpenAPI data model there is nothing to distinguish, since one operation can exist per method+path.Changes
register_openapi_metadatadocstring.DUPLICATE_OPERATIONwarning).Why not the originally-proposed fix
The issue proposed recording collisions via
add_duplicate_operation. That is incompatible with #393 (which recomputesduplicate_operationspurely from registry state each generation — the overwritten entry leaves no trace to re-derive) and would break the bridge-then-enrich example. See issue thread.Validation
make check-allgreen (tests + lint + typecheck + security).Closes #397