Skip to content

fix(openapi): preserve Swagger response examples - #118

Open
xujiantop-crypto wants to merge 1 commit into
universal-tool-calling-protocol:devfrom
xujiantop-crypto:fix/swagger-response-examples
Open

xujiantop-crypto wants to merge 1 commit into
universal-tool-calling-protocol:devfrom
xujiantop-crypto:fix/swagger-response-examples

Conversation

@xujiantop-crypto

Copy link
Copy Markdown

Swagger 2 response examples are stored in responses.<status>.examples as a MIME-type-to-value map. The converter currently copies the response schema but drops those examples, so generated tools lose the sample response values supplied by the API.

Normalize the map values into an examples list before merging them with schema-level examples. Keep literal objects intact, including payload fields named value, $ref, or externalValue, and reuse the existing stable, type-aware deduplication.

This addresses only item 3 of #98. The request-body and parameter-content gaps remain outside this change. Refs #98.

Validation on Windows with Python 3.13.12:

  • Original source with the new regressions: 13 failed, 3 passed.
  • Fixed converter regressions and existing offline OpenAPI tests: 21 passed; all three new executable lines covered.
  • Full CI test selection and doctests: 624 passed, 9 Unix-specific CLI tests skipped, and one existing GraphQL integration test hit a connection timeout to countries.trevorblades.com. That test passed on its first rerun with the same code and environment.
  • git diff --check passed.

The new tests use in-memory Swagger documents and no external services. They cover raw values (including false, zero, empty values and null), serialization, schema references, multiple MIME types, response-status selection, and deduplication without collapsing distinct JSON types. Linux, macOS and the other Python versions in CI have not been run locally.

@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 2 files

View guided diff | Re-trigger cubic

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