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

new rules: error for anyOf & oneOf in OpenAPI v2 #393

Closed
rossmcdonald opened this issue Jul 18, 2019 · 5 comments · Fixed by #406

Comments

@rossmcdonald
Copy link
Collaborator

commented Jul 18, 2019

User story.

As an average user who is not completely familiar with the intricacies of JSON Schema <≠> OpenAPI and the differences between OpenAPI v2 and v3, I often mix up JSON Schema, OAS2 and OAS3 keywords like anyOf and oneOf, so please let me know when I put the wrong keyword in the wrong place.

Is your feature request related to a problem?

API description documents should conform to the description format in question, as putting invalid keywords in those documents can lead to inconsistent behavior across various tools that might mistakenly support those keywords. Other tooling which is actually compliant will then look like its failing.

Describe the solution you'd like

The rule should error if an anyOf, oneOf or not appears in OpenAPI v2, but anyOf is in fact allowed.

@marbemac

This comment has been minimized.

Copy link
Member

commented Jul 18, 2019

In fact we should just report usage of oneOf or anyOf as errors in openapi, since it's not valid openapi - no need for separate "strict" concept.

@tbarn

This comment has been minimized.

Copy link
Contributor

commented Jul 18, 2019

Except in v3 though, right?

@philsturgeon

This comment has been minimized.

Copy link
Contributor

commented Jul 19, 2019

V2 has allOf
V3 has allOf, oneOf, anyOf, not

@tbarn

This comment has been minimized.

Copy link
Contributor

commented Jul 19, 2019

We also let people in Next create OAS v2 specs with oneOf and anyOf, so we might need to explain that too.

@philsturgeon

This comment has been minimized.

Copy link
Contributor

commented Jul 19, 2019

Is it x-oneOf and x-anyOf or are we putting invalid keywords into their API description documents?

This is all the more reason to create errors for oneOf and anyOf in Spectral. Folks can turn the rule off if they really want to keep on writing invalid documents.

@philsturgeon philsturgeon changed the title Add "strict" rules for OpenAPIv2 that restrict usage of 'anyOf' and 'oneOf' combination types new rules: error for anyOf & oneOf in OpenAPI v2 Jul 19, 2019

@philsturgeon philsturgeon referenced this issue Jul 26, 2019
2 of 4 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.