-
Notifications
You must be signed in to change notification settings - Fork 87
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
feat: warn for missing response examples #265
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good but there's one more detail that you will need to handle. In OpenAPI 3.0 they introduced examples
on parameters, request bodies, and response bodies. examples
is a slightly more elaborate way to provide an example -- you can include not just the example value but also a description and summary. You can also have multiple named examples.
So in addition to checking for example
you should also check for examples
and only issue the message if neither is present.
I believe the current rule does allow for |
cf84e65
to
d248b0e
Compare
Purpose: - Establish working pattern for writing custom functions such that, when users extend the `ibm:oas` ruleset, our custom functions are still findable by Spectral. - Tooling to generate documenation relies on response examples provided either in the schema or "next to" the schema at response level. Warn about responses that do not provide examples in these locations. Changes: - Create a custom Spectral rule to warn about missing response examples - Create a custom Spectral function to check if a response example provided in the locations supported by the code that generates documentation. Tests: - Add tests to ensure no warning given when a response example is provided. - Add a test to ensure a warning is given when no response example provided. Docs: - Document the response-example-provided rule in `docs/spectral-rules.md`
d248b0e
to
6fc2100
Compare
Thanks Barrett, I missed that. Looks like you have it covered. Nice work! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! 👍
# [0.38.0](v0.37.1...v0.38.0) (2021-03-19) ### Features * warn for missing response examples ([#265](#265)) ([0f10376](0f10376))
🎉 This PR is included in version 0.38.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Purpose:
ibm:oas
ruleset, our custom functions are still findable by Spectral.Changes:
Tests:
Docs:
docs/spectral-rules.md
Possible changes:
application/json
responses. To do this, we would change thegiven
field of the rule from$.paths[*][*].responses[*].content.application/json
to$.paths[*][*].responses[*].content[*]
.