openapi2conv: preserve x-fields when converting from v2 to v3#1092
Merged
fenollp merged 2 commits intogetkin:masterfrom Aug 25, 2025
Merged
Conversation
This commit fixes an issue where schema property-level extensions such as x-order were being lost during OpenAPI v2 to v3 conversion. The problem was in the ToV3SchemaRef function where schema.Extensions was being assigned to v3Schema.Extensions instead of schema.Value.Extensions. This meant that only SchemaRef-level extensions were preserved, but not the actual schema property extensions. Changes: - Modified ToV3SchemaRef to properly copy schema.Value.Extensions - Added comprehensive tests to verify extension preservation - Ensured both schema-level and property-level extensions are maintained - Verified nested properties also preserve their extensions Fixes getkin#1091
fenollp
requested changes
Aug 21, 2025
Signed-off-by: saltbo <saltbo@foxmail.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.
Fixes #1091
When converting OpenAPI v2 specifications to v3 using openapi2conv.ToV3(), schema property-level extensions such as x-order were being lost during the conversion process.
Root Cause
The issue was in the ToV3SchemaRef function where schema.Extensions was assigned to v3Schema.Extensions instead of schema.Value.Extensions.
Changes
Impact
This fix ensures that property-level extensions are now correctly preserved when converting from OpenAPI v2 to v3, which is important for field ordering, custom validation rules, code generation hints, and other custom metadata.