Skip to content

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

Merged
exoego merged 7 commits into
exoego:masterfrom
hss-mateus:master
Feb 17, 2024
Merged

Initial support of complex schema with manually-added oneOf#174
exoego merged 7 commits into
exoego:masterfrom
hss-mateus:master

Conversation

@hss-mateus

Copy link
Copy Markdown
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.

@codecov

codecov Bot commented Feb 8, 2024

Copy link
Copy Markdown

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
Copy Markdown

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

exoego commented Feb 14, 2024

Copy link
Copy Markdown
Owner

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
Copy Markdown
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

exoego commented Feb 17, 2024

Copy link
Copy Markdown
Owner

Ah, I overlooked that.
Thanks.

@exoego
exoego merged commit 3932a49 into exoego:master Feb 17, 2024
@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