-
Notifications
You must be signed in to change notification settings - Fork 476
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
base: master
Are you sure you want to change the base?
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! |
72a9e69
to
c943989
Compare
c943989
to
ea10462
Compare
Hm. I'm not sure why this PR is now causing segfaults with Ruby 3.5-dev 🤔 |
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: