-
-
Notifications
You must be signed in to change notification settings - Fork 240
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
Spectral and OAS 3.x requirement mismatches #834
Comments
Spectral is not trying to only tell you if it's valid OpenAPI. It's helping you make a useful document. We welcome everyone to turn off rules they don't like in our default OpenAPI ruleset, or create their own rulesets which do match their expectations. Enjoy Spectral! :D |
Making description required (which deviates from the spec) could do the inverse of making a useful doc. I.e. an operation like I don't know for sure, but from your response and closing this, I'm guessing that this issue will not be addressed? |
I think I may see now what the intent is. If you use the form editor of stoplight studio, they don't even expose summary as a property at all. I think Spectral/Stoplight is intending for description to replace summary entirely. Summary is sort of the elephant in the room for the spec anyway since description is used just about everywhere and summary is only used in a few places. |
Summary is in use. It's the header on every endpoint in the form editor. There was a good bit of back and form at API Specification Conference 2019 about this (@philsturgeon and I were on "opposing" sides 😉). The core of the argument is as you described it: requiring can result in worse docs, not requiring it can also result in worse docs. 😜 It is a tough call to make, and thankfully Spectral is configurable and the description check is only a warning anyway (and not an error). So there's that. 😺 In the end, if your API can't be understood from |
People have been saying that REST API, HTTP APIs, and more recently GraphQL APIs are "self documenting" for a while, but hey look, here we are working on documentation tooling and it's selling like hot cakes. If you are producing an API which is so incredibly simple that every single operation can be explained entirely by the URL alone, then you can disable operation-descriptions in your ruleset and you don't need to worry about it. Nobody likes 100% of the default eslint rules either. They tell you to do all sorts of things which JavaScript does not require, or they disallow it and JavaScript allows it, and everyone has opinions about it. Look, here is our tslint file for Spectral: https://github.com/stoplightio/tslint-config-stoplight/blob/master/tslint.json
Everyone tweaks default rulesets. So the only question is: should this be on by default. We think so. We are not replacing summary with description (you can edit both in the GUI, we use summary as the title). The description is optional and for more information, and yes for GET /users/id it is rather clear you're getting the Users by their ID, but over time you will start to add more information like "Users can be fetch by their UUID or their username, but UUID has been deprecated in favor of username." Even then, GETs are pretty common and POST and PATCH require a lot more information as they grow, especially when state becomes involved. So turn it off for now, and if your API grows to a point where you find a description would be useful, add it back, and everyone is happy. |
Describe the bug
Spectral requires
servers
anddescription
, but OpenAPI 3.x does not.To Reproduce
spectral lint file.yaml
Expected behavior
1.1
is incorrect asservers
is not required (see the OpenAPI Object fields):2:6
is incorrect asdescription
is optional (and not even a SHOULD...per the Info object fields info):10:9
is incorrect asdescription
on a Path Item Object is also not required:12:13
is incorrect as$ref
is not required--but this probably relates to Invalid schema causes "should have required property '$ref'" error #403.Additionally,
description
is required for the Response Object and should be appearing in this list, but doesn't...though that may be due to Invalid schema causes "should have required property '$ref'" error #403 also...So...there seem to be some mismatches here and there. 😕 Hopefully they're easy tweaks!
The text was updated successfully, but these errors were encountered: