Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial support of complex schema with manually-added oneOf #174

Merged
merged 7 commits into from
Feb 17, 2024
Merged

Initial support of complex schema with manually-added oneOf #174

merged 7 commits into from
Feb 17, 2024

Conversation

hss-mateus
Copy link
Contributor

As reported in #173, manually added oneOf attributes are ignored and the generated schema is placed alongside.

This PR implements an algorithm that compare the generated schema with every oneOf option, merges with the most similar one, or adds a new option if none are sufficiently similar.

I placed an abitrary value of 0.5 that represents the minimum similarity score required.

I have to update the $ref handling code too, since it was discarding paths inside arrays.

Copy link

codecov bot commented Feb 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (ae4d22e) 96.78% compared to head (4a1d88a) 97.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #174      +/-   ##
==========================================
+ Coverage   96.78%   97.00%   +0.21%     
==========================================
  Files          14       14              
  Lines         467      500      +33     
  Branches      102      115      +13     
==========================================
+ Hits          452      485      +33     
  Misses         15       15              

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

@simba909
Copy link

I've tested this with my setup from #173 and it works beautifully, well done @hss-mateus! 👏🏻

@exoego Have you had a chance to look at this yet?

@exoego
Copy link
Owner

exoego commented Feb 14, 2024

This PR implements an algorithm that compare the generated schema with every oneOf option, merges with the most similar one, or adds a new option if none are sufficiently similar.

I placed an abitrary value of 0.5 that represents the minimum similarity score required.

That algorithm sounds smart.
Please add a test case for this behavior in requests/rails_smart_merge_spec.rb.
A new option of oneOf, which is not found in rails/doc/smart/openapi.yaml, should be added to rails/doc/smart/expected.yaml.

@hss-mateus
Copy link
Contributor Author

Please add a test case for this behavior in requests/rails_smart_merge_spec.rb. A new option of oneOf, which is not found in rails/doc/smart/openapi.yaml, should be added to rails/doc/smart/expected.yaml.

If I understand it correctly, this part of the generated schema is already not found in openapi.yml, but is being added to expected.yml

@exoego
Copy link
Owner

exoego commented Feb 17, 2024

Ah, I overlooked that.
Thanks.

@exoego exoego merged commit 3932a49 into exoego:master Feb 17, 2024
15 checks passed
@exoego exoego changed the title Merge manually added oneOf schemas Initial support of complex schema with manually-added oneOf Feb 17, 2024
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