Enhance schema resolution logic for composite parameters in conversion with types #868
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.
This pull request enhances how composite schemas (such as
oneOf,anyOf, andallOf) are resolved for OpenAPI parameters and headers, ensuring only the first option is extracted for types generation, while merging constraints forallOf. It also introduces a comprehensive unit test to verify this behavior and removes unnecessary ESLint disables for theone-varrule throughout the codebase.Composite schema resolution improvements:
libV2/schemaUtils.jsto extract only the first option from composite schemas (oneOf,anyOf,allOf) for query parameters, path parameters, request headers, and response headers, and to merge constraints forallOfduring types generation. This prevents loss of schema information and improves type extraction accuracy. [1] [2] [3] [4] [5]Testing enhancements:
test/unit/convertV2WithTypes.test.jsthat verifies the extraction logic for composite schemas, ensuring only the first option is considered and constraints are merged as intended.Code quality and linting:
eslint-disable one-varcomments from multiple files, includinglibV2/index.js,libV2/schemaUtils.js, andtest/unit/convertV2WithTypes.test.js, and updated the.eslintrcconfiguration to no longer enforce theone-varrule. [1] [2] [3] [4] [5] [6]These changes together improve the maintainability of the codebase and ensure more accurate OpenAPI type extraction for downstream consumers.