Skip to content

fix(openapi): type-aware, order-insensitive example de-duplication#97

Merged
h3xxit merged 1 commit into
devfrom
fix/openapi-example-dedup
Jun 24, 2026
Merged

fix(openapi): type-aware, order-insensitive example de-duplication#97
h3xxit merged 1 commit into
devfrom
fix/openapi-example-dedup

Conversation

@h3xxit

@h3xxit h3xxit commented Jun 24, 2026

Copy link
Copy Markdown
Member

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 (true1, 11.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-http to 1.1.11.

Written for commit 3e00914. Summary will update on new commits.

Review in cubic

…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>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

Re-trigger cubic

@h3xxit h3xxit merged commit 89a9832 into dev Jun 24, 2026
10 checks passed
@h3xxit h3xxit deleted the fix/openapi-example-dedup branch June 24, 2026 22:06
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