fix(openapi): type-aware, order-insensitive example de-duplication#97
Merged
Conversation
…itive _merge_examples de-duped with `ex not in merged`, i.e. Python `==`. That collapses semantically distinct JSON examples: True == 1, False == 0, 1 == 1.0 — so mixing such values silently dropped one. Switch to a canonical JSON key (json.dumps with sorted keys) for identity: order-insensitive for objects and type-aware for scalars. Aligns the de-dup behavior with the TypeScript implementation. Bumps utcp-http 1.1.10 -> 1.1.11. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Problem (P3, correctness + cross-impl divergence)
_merge_examplesde-duplicated withif ex not in merged, which relies on Python==. So distinct JSON examples collapse:True == 1,False == 0,1 == 1.0Mixing e.g. a media-type example
value: trueand a schema example1for the same field silently dropped one. It also diverged from the TypeScript implementation (which usedJSON.stringifyand had the opposite bug — key-order false negatives).Fix
Use a canonical JSON serialization (
json.dumps(ex, sort_keys=True, default=str)) as the de-dup identity:{a:1,b:2}=={b:2,a:1})true≠1,1≠1.0)This matches the corrected TypeScript behavior so both implementations produce identical output.
Tests
New
test_openapi_converter_example_dedup_is_type_aware_and_order_insensitive: asserts key-reordered objects collapse to one andtrue/1stay distinct. Full converter suite: 7 passed.Bumps
utcp-http1.1.10 → 1.1.11.🤖 Generated with Claude Code
Summary by cubic
Fixes OpenAPI example de-duplication to be type-aware and order-insensitive so distinct values aren’t dropped and outputs match the TypeScript implementation.
Bug Fixes
Dependencies
utcp-httpto1.1.11.Written for commit 3e00914. Summary will update on new commits.