-
Notifications
You must be signed in to change notification settings - Fork 477
Don't overwrite model description with the route description. #804
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
Conversation
* [###](https://github.com/ruby-grape/grape-swagger/pull): Don't overwrite model definition with the route description. - [@Bhacaz](https://github.com/Bhacaz) Generated by 🚫 danger |
3 similar comments
* [###](https://github.com/ruby-grape/grape-swagger/pull): Don't overwrite model definition with the route description. - [@Bhacaz](https://github.com/Bhacaz) Generated by 🚫 danger |
* [###](https://github.com/ruby-grape/grape-swagger/pull): Don't overwrite model definition with the route description. - [@Bhacaz](https://github.com/Bhacaz) Generated by 🚫 danger |
* [###](https://github.com/ruby-grape/grape-swagger/pull): Don't overwrite model definition with the route description. - [@Bhacaz](https://github.com/Bhacaz) Generated by 🚫 danger |
* [#804](https://github.com/ruby-grape/grape-swagger/pull/804): Don't overwrite model description with the route description. - [@Bhacaz](https://github.com/Bhacaz) Generated by 🚫 danger |
b200802
to
a828ce0
Compare
2 similar comments
yeap that does it 😄 … thanks @Bhacaz please can you add an entry in UPGRADING.md with title: |
Sure! |
c6cef6a
to
fc7b5b1
Compare
fc7b5b1
to
338513f
Compare
I needed to refactor lib/grape-swagger/doc_methods.rb to satisfy Rubocop (0.90.0) |
next if value[:code] == 204 | ||
next unless !response_model.start_with?('Swagger_doc') && (@definitions[response_model] || value[:model]) | ||
# Explicitly request no model with { model: '' } | ||
next if value[:model] == '' |
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.
mmh … ok … will have a look on it later, maybe it can be get together with no model key given
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.
@LeFnord I did like that because by default if no model key is provided (line 219) the model use for the response will be the one returned by GrapeSwagger::DocMethods::PathString#build
called here
grape-swagger/lib/grape-swagger/endpoint.rb
Line 100 in 08b8c2f
@item, path = GrapeSwagger::DocMethods::PathString.build(route, options) |
very good job, many thanks @Bhacaz |
This PR have 3 features around the API response documentation.
1. Removing the assignation of the model description from route description.
I face the same problem explain in:
And I try to continued to resolved it.
Following the PR comments and the bug suggestion, the change in this PR will set a description to the model only if it doesn't have one and with a generic sentence.
2. Generate models documentation before the routes.
When I was generating my documentation I observe that sometimes
Grape::Endpoint#response_object
try to find the model definition without succeed withGrape::Endpoint#expose_params_from_model
simply because the route documentation was generated before the model definition.3. Add the ability to specified no model (or empty body).
The last thing I add was the ability explicitly set no model (or an empty body) in the response, for example in the failures. The problem was that when none is explicitly passed,
Grape::Endpoint#response_object
is really good to found a model from the path and add it to the documentation.I hope it will be satisfying.