Skip to content

Conversation

saltbo
Copy link
Contributor

@saltbo saltbo commented Aug 18, 2025

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

  • Fixed ToV3SchemaRef function to properly copy schema.Value.Extensions
  • Added comprehensive tests in issue1091_test.go
  • Ensured backward compatibility with all existing tests

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.

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 fenollp changed the title Fix: Preserve extensions (like x-order) when converting OpenAPI v2 to v3 openapi2conv: preserve x-fields when converting from v2 to v3 Aug 21, 2025
@saltbo saltbo requested a review from fenollp August 23, 2025 01:10
@fenollp fenollp merged commit 2baea3d into getkin:master Aug 25, 2025
5 checks passed
@saltbo saltbo deleted the fix/preserve-extensions-in-v2-to-v3-conversion branch August 27, 2025 01:26
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.

openapi2conv.ToV3() loses schema property-level extensions like x-order
2 participants