-
Notifications
You must be signed in to change notification settings - Fork 477
Use x-example
for non-body parameters
#951
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
Use x-example
for non-body parameters
#951
Conversation
bc32c7e
to
647b5e1
Compare
I don't know why tests are failing. The failures do not look related to the code changed in this PR, and I cannot reproduce the failures locally. |
Hi @olivier-thatch, MODEL_PARSER=grape-swagger-entity bundle install
MODEL_PARSER=grape-swagger-entity bundle exec rspec spec/swagger_v2/api_swagger_v2_type-format_spec.rb:87 For now, I can confirm that these failures do not seem to be related to the code changed in this PR. I will be looking closely into the issue. If you'd like to investigate these unrelated failures as well, please let me know. |
Just a heads-up, I've identified the cause of the failing test and have opened a PR (ruby-grape/grape-swagger-entity#82) to address it. The issue with red specs absolutely is not related to the changes in this PR. |
@numbata Thanks! I will rebase once your PR is merged. |
647b5e1
to
72a9e69
Compare
@numbata Tests are passing now! |
c943989
to
ea10462
Compare
Hm. I'm not sure why this PR is now causing segfaults with Ruby 3.5-dev 🤔 |
I fixed CI on master, rebase please? |
ea10462
to
1877046
Compare
Thanks for the rebase, @olivier-thatch! Could you add a CHANGELOG entry? Once that's in, we'll squash and merge this PR into master. |
x-example
for non-body parameters
c5035e4
to
af6eea5
Compare
#951 (comment) |
af6eea5
to
5e2504a
Compare
@olivier-thatch Fantastic work on this PR! 👍 |
LGTM, @LeFnord is usual maintainer here, tagging him but will merge if we don't hear back in a bit |
@dblock … will do it on sunday, but feel free to to merge it, if you think it is urgent |
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.
Thanks @olivier-thatch …
Do we want an documentation entry, so this feture is known?
no, don't think so … will merge it
OpenAPI 2.0 does not support setting
example
for non-body parameters. Thex-example
extension is commonly used instead and is understood by most OpenAPI tooling including Swagger UI and Swagger Converter (which will convertx-example
toexample
, since that works in OpenAPI 3.0).Today one can work around this by setting
documentation: { x: { example: "foo" } }
for non-body parameters, however the inconsistency betweendocumentation: { example: "foo" }
anddocumentation: { x: { example: "foo" } }
is annoying, and it's also problematic if you want to share params between e.g. a GET endpoint (which will use query parameters by default) and a POST endpoint (which will use body parameters by default).This PR makes is so that
documentation: { example: "foo" }
can be used in all places, and grape-swagger will automatically convert the examples for non-body parameters to be rendered asx-example
in the generated schema.References: