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

fix: oneof implementation #814

Closed
wants to merge 2 commits into from

Conversation

jacopomaroli
Copy link

@jacopomaroli jacopomaroli commented Jul 15, 2022

Description
Currently oneOf and anyOf are treated equally

this.interpretAndCombineMultipleSchemas(schema.oneOf, model, schema, interpreterOptions);
this.interpretAndCombineMultipleSchemas(schema.anyOf, model, schema, interpreterOptions);

This PR aims to handle correctly oneOf in accordance to the OpenAPI specs https://swagger.io/docs/specification/data-models/oneof-anyof-allof-not/#anyof-vs-oneof

I needed to update one of the tests because there's no reason for oneOf to generate an array type implicitly in the datamodel definition

Test Suites: 115 passed, 115 total
Tests:       699 passed, 699 total
Snapshots:   123 passed, 123 total
Time:        40.322 s
Ran all test suites.

Related issue(s)

Fixes #367

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

@sonarcloud
Copy link

sonarcloud bot commented Jul 15, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@coveralls
Copy link

Pull Request Test Coverage Report for Build 2677437607

  • 11 of 11 (100.0%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.007%) to 92.098%

Totals Coverage Status
Change from base Build 2606652547: -0.007%
Covered Lines: 2816
Relevant Lines: 2914

💛 - Coveralls

Copy link
Member

@jonaslagoni jonaslagoni left a comment

Choose a reason for hiding this comment

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

Hey @jacopomaroli, thanks for providing this!

I really dont want to change what's currently on the master branch, because this change is really difficult to do right in that environment.

Do you have the possibility to recreate it and target next?

I can guide you through the change it require 🙂

@jonaslagoni
Copy link
Member

Fixed in next here: #899

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.

Typescript: Using oneOf leads to creation and use of an anonymous schema rather than use of a union type
3 participants