fix(openapi): preserve array-form (JSON Schema / OAS 3.1) schema examples#95
Merged
Conversation
_extract_examples only handled 'examples' as an OpenAPI map of named Example Objects, while _schema_without_example_keys strips 'examples' from schemas before spreading. So a JSON Schema / OpenAPI 3.1 schema-level 'examples' list was extracted as nothing and then dropped - silent data loss. Handle the list form too: list entries are literal example values; the map form keeps its Example Object 'value' handling. Adds a test covering array-form schema examples on both request body and response. Bumps utcp-http 1.1.9 -> 1.1.10. 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 (P2)
Schema-level
examplesdeclared as a JSON Schema list were silently lost during conversion:Root cause
_extract_examplesonly recognizedexamplesas an OpenAPI map of named Example Objects (isinstance(obj["examples"], dict)), so it returned nothing for the list form. Meanwhile_schema_without_example_keysstripsexamplesfrom the schema before it is spread onto the property. Before that strip the list passed through raw; after it (added when normalizing examples), the list is extracted as nothing and removed — net data loss. JSON Schema (and OpenAPI 3.1 schema objects) defineexamplesas a list of values.Fix
_extract_examplesnow handles all three shapes:example(single value)examplesas a map of Example Objects (OpenAPI 3.0) —valueper entry,$refresolvedexamplesas a list of literal values (JSON Schema / OAS 3.1) — extended verbatimThe two forms can't collide: a media type object's
examplesis always a map, a schema's is always a list.Tests
New
test_openapi_converter_array_form_schema_examplescovering array-form schema examples on both request body and response. Full converter suite: 6 passed.Bumps
utcp-http1.1.9 → 1.1.10.🤖 Generated with Claude Code
Summary by cubic
Preserves array-form schema
examples(JSON Schema / OAS 3.1) in the OpenAPI converter. Prevents silent data loss so examples appear on request and response models.Bug Fixes
_extract_examplesnow supports singleexample,examplesmap (OAS 3.0,$refresolved), andexampleslist (JSON Schema/OAS 3.1).Dependencies
utcp-httpto1.1.10.Written for commit 8b32145. Summary will update on new commits.