fix(openapi): type-aware, order-insensitive example de-duplication
Problem (P3, correctness + cross-impl divergence)
_merge_examples de-duplicated with if ex not in merged, which relies on Python ==. So distinct JSON examples collapse:
True == 1,False == 0,1 == 1.0
Mixing e.g. a media-type example value: true and a schema example 1 for the same field silently dropped one. It also diverged from the TypeScript implementation (which used JSON.stringify and 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:
- order-insensitive for objects (
{a:1,b:2}=={b:2,a:1}) - type-aware for scalars (
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 and true/1 stay distinct. Full converter suite: 7 passed.
Bumps utcp-http 1.1.10 → 1.1.11.
Found during a cross-repo audit of the examples implementation. Same fix in typescript-utcp (paired PR).
🤖 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
- De-duplicate using canonical JSON serialization (sorted keys) as identity.
- Keeps JSON types distinct (true ≠ 1, 1 ≠ 1.0); collapses re-ordered object keys.
- Aligns behavior with the TypeScript implementation for consistent output.
-
Dependencies
- Bump
utcp-httpto1.1.11.
- Bump