Skip to content

Conversation

@barshan23
Copy link
Collaborator

This pull request enhances how composite schemas (such as oneOf, anyOf, and allOf) are resolved for OpenAPI parameters and headers, ensuring only the first option is extracted for types generation, while merging constraints for allOf. It also introduces a comprehensive unit test to verify this behavior and removes unnecessary ESLint disables for the one-var rule throughout the codebase.

Composite schema resolution improvements:

  • Updated libV2/schemaUtils.js to 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 for allOf during types generation. This prevents loss of schema information and improves type extraction accuracy. [1] [2] [3] [4] [5]

Testing enhancements:

  • Added a new unit test to test/unit/convertV2WithTypes.test.js that verifies the extraction logic for composite schemas, ensuring only the first option is considered and constraints are merged as intended.

Code quality and linting:

  • Removed unnecessary eslint-disable one-var comments from multiple files, including libV2/index.js, libV2/schemaUtils.js, and test/unit/convertV2WithTypes.test.js, and updated the .eslintrc configuration to no longer enforce the one-var rule. [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.

…e schema resolution logic for composite parameters in conversion tests
@github-actions
Copy link
Contributor

integration test code coverage

Lines Statements Branches Functions
Coverage: 19%
19.3% (2043/10585) 13.5% (996/7374) 19.86% (235/1183)
Coverage Breakdown • (19%)
File% Stmts% Branch% Funcs% LinesUncovered Line #s
All files19.313.519.8619.58 
report-only-changed-files is enabled. No files were changed in this commit :)

@github-actions
Copy link
Contributor

unit test code coverage

Lines Statements Branches Functions
Coverage: 89%
89.19% (5780/6480) 80.8% (3767/4662) 93.78% (860/917)
Coverage Breakdown • (89%)
File% Stmts% Branch% Funcs% LinesUncovered Line #s
All files89.1980.893.7889.31 
report-only-changed-files is enabled. No files were changed in this commit :)

Base automatically changed from feature/add-composite-schema-to-generated-type to develop September 17, 2025 11:35
@barshan23 barshan23 marked this pull request as ready for review September 18, 2025 07:37
}


const shouldResolveSchema = _.has(param, 'schema') &&
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can make it concise with
const shouldResolveSchema = _.some(['$ref', 'anyOf', 'oneOf', 'allOf'], (key) => { return _.has(param, ['schema', key]); });

Copy link
Collaborator

@AyushShri AyushShri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm 🚀

@AyushShri AyushShri merged commit 8e399c7 into develop Sep 18, 2025
8 checks passed
AyushShri added a commit that referenced this pull request Sep 19, 2025
* Enhance  type fetching to support composite schemas (anyOf, oneOf, allOf)

* Refactor type fetching logic to process original schema before modifications

* Update parameter resolution logic to handle 'PROCESSING' state in schema conversion

* Refactor schema processing to conditionally push resolved schema types for 'PROCESSING' state

* Add support for composite schemas (anyOf, oneOf, allOf) in conversion process

* schema changes for 2-way-sync

* fixed test

* Enhance composite schema tests to validate specific structures for anyOf cases

* removed examples

* Refactor ESLint rules and remove unnecessary one-var disables; enhance schema resolution logic for composite parameters in conversion tests (#868)

Refactor ESLint rules and remove unnecessary one-var disables; enhance schema resolution logic for composite parameters in conversion tests (#868)

* added deprecated example

* added test for description

* Resolved comments

* Bug Fixes

* refactored

* Prepare release v5.2.0

---------

Co-authored-by: Avishek Saha <[email protected]>
Co-authored-by: barshan23 <[email protected]>
Co-authored-by: Ayush Shrivastav <[email protected]>
Co-authored-by: GitHub Actions <[email protected]>
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.

3 participants