Fix OpenAPI import: preserve description and decorators for anyOf/oneOf with null#8514
Merged
Fix OpenAPI import: preserve description and decorators for anyOf/oneOf with null#8514
Conversation
Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] [Bug]: import tool anyOf type null + definition leads to loss of information
Fix OpenAPI import: preserve description and decorators for anyOf/oneOf with null
Sep 22, 2025
Contributor
|
All changed packages have been documented.
Show changes
|
Signed-off-by: Vincent Biret <vibiret@microsoft.com>
Signed-off-by: Vincent Biret <vibiret@microsoft.com>
packages/openapi3/src/cli/actions/convert/transforms/transform-component-schemas.ts
Outdated
Show resolved
Hide resolved
packages/openapi3/src/cli/actions/convert/transforms/transform-component-schemas.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Timothee Guerin <tiguerin@microsoft.com>
Co-authored-by: Timothee Guerin <tiguerin@microsoft.com>
Signed-off-by: Vincent Biret <vibiret@microsoft.com>
256a0e7 to
8e2f452
Compare
packages/openapi3/src/cli/actions/convert/transforms/transform-component-schemas.ts
Show resolved
Hide resolved
timotheeguerin
approved these changes
Sep 24, 2025
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.
The OpenAPI 3.1 import tool was losing description and decorator information when converting schemas with
anyOf/oneOfcontaining a definition +nulltype. This is a common pattern in OpenAPI 3.1 as an equivalent tonullable: truefrom OpenAPI 3.0.Before this fix:
Generated incomplete TypeSpec:
After this fix:
Changes Made
Enhanced union metadata extraction: Added logic to identify and extract descriptions and decorators from meaningful (non-null) members in
anyOf/oneOfscenarios.Support for type arrays: Fixed handling of OpenAPI 3.1 type arrays like
["string", "null"]to properly preserve constraints and descriptions.Improved type identification: Updated
getTypeSpecKindto correctly identify type arrays containing "null" as unions rather than scalars.Test Coverage
Added comprehensive test suite covering:
anyOfwith definition + nulloneOfwith constraints + null["integer", "null"]All existing tests continue to pass (1609 tests).
Fixes #8513.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
telemetry.astro.buildnode /home/REDACTED/work/typespec/typespec/website/node_modules/.bin/../astro/astro.js build(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.