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
Closed

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

rossmcdonald opened this issue Jul 18, 2019 · 5 comments

Comments

@rossmcdonald
Copy link
Contributor

@rossmcdonald rossmcdonald 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
Copy link
Member

@marbemac marbemac 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.

Loading

@tbarn
Copy link
Contributor

@tbarn tbarn commented Jul 18, 2019

Except in v3 though, right?

Loading

@philsturgeon
Copy link
Contributor

@philsturgeon philsturgeon commented Jul 19, 2019

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

Loading

@tbarn
Copy link
Contributor

@tbarn tbarn 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.

Loading

@philsturgeon
Copy link
Contributor

@philsturgeon philsturgeon 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.

Loading

@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

4 participants