Skip to content

Conversation

@Spence1115
Copy link
Contributor

@Spence1115 Spence1115 commented Dec 11, 2025

Summary

When a schema produces multiple oneOf statements for a key, we are nesting them when we should be combining them

Example

        {
          "form": [
            {
              "value": "John Doe",
            },
            {
              "value": [],
            },
            {
              "value": null,
            },
          ]
        },
        {
          "form": null
        },
        {
          "form": [
            {
              "value": false,
            },
            {
              "value": ["First", "Second"],
            },
            {
              "value": 3,
            },
          ]
        }

Before

                              value:
                                oneOf:
                                - oneOf:
                                  - type: string
                                  - type: array
                                    items: {}
                                - oneOf:
                                  - type: boolean
                                  - type: array
                                    items:
                                      type: string
                                  - type: integer

Now

                              value:
                                oneOf:
                                - type: string
                                - type: array
                                  items: {}
                                - type: boolean
                                - type: array
                                  items:
                                    type: string
                                - type: integer

Fixes #290

merged_schema[:properties][key] = { oneOf: unique_props }
else
merged_schema[:properties][key] = property_variations.first.dup
case unique_types.first

Check notice

Code scanning / Rubocop

Avoid excessive block nesting. Note

Metrics/BlockNesting: Avoid more than 3 levels of block nesting.
@codecov
Copy link

codecov bot commented Dec 11, 2025

Codecov Report

❌ Patch coverage is 74.19355% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.44%. Comparing base (70ff4b2) to head (8e0a545).

Files with missing lines Patch % Lines
lib/rspec/openapi/schema_builder.rb 74.19% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #291      +/-   ##
==========================================
- Coverage   98.48%   97.44%   -1.04%     
==========================================
  Files          20       20              
  Lines         724      744      +20     
  Branches      184      192       +8     
==========================================
+ Hits          713      725      +12     
- Misses         11       19       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Spence1115 Spence1115 marked this pull request as draft December 11, 2025 09:36
all_options = []
prop_variations.each do |prop|
clean_prop = prop.reject { |k, _| k == :nullable }
if clean_prop.key?(:oneOf)

Check notice

Code scanning / Rubocop

Avoid excessive block nesting. Note

Metrics/BlockNesting: Avoid more than 3 levels of block nesting.
@Spence1115 Spence1115 marked this pull request as ready for review December 11, 2025 11:35
@Spence1115
Copy link
Contributor Author

Doesn't seem to be pulling the latest results from codecov

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.

bug: multiple oneOf cases for a key are not handled properly

1 participant