-
Notifications
You must be signed in to change notification settings - Fork 476
Add response examples #675
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
lib/grape-swagger/endpoint.rb:7:3: C: Metrics/ClassLength: Class has too many lines. [289/287] class Endpoint ... ^^^^^^^^^^^^^^ lib/grape-swagger/endpoint.rb:196:5: C: Metrics/CyclomaticComplexity: Cyclomatic complexity for response_object is too high. [14/13] def response_object(route) ... ^^^^^^^^^^^^^^^^^^^^^^^^^^ lib/grape-swagger/endpoint.rb:196:5: C: Metrics/PerceivedComplexity: Perceived complexity for response_object is too high. [15/14] def response_object(route) ... ^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -264,6 +261,12 @@ def tag_object(route, path) | |||
|
|||
private | |||
|
|||
def build_reference(route, value, response_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.
Extracted this to a method to avoid lint:
lib/grape-swagger/endpoint.rb:196:5: C: Metrics/PerceivedComplexity: Perceived complexity for response_object is too high. [15/14]
@@ -294,9 +297,8 @@ def merge_params(route) | |||
end | |||
|
|||
def default_type(params) |
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.
Changed to inline block to avoid lint:
Class has too many lines
This PR is very welcome, but can review it, if I can access my machine again … was damaged 😞 – it isn’t so nice via phone 😉 … hope tomorrow |
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.
very nice and welcome work …
|
||
desc 'This returns examples' do | ||
success model: Entities::UseResponse, examples: { 'application/json' => { description: 'Names list', items: [{ id: '123', name: 'John' }] } } | ||
failure [[404, 'NotFound', Entities::ApiError, { 'application/json' => { code: 404, message: 'Not found' } }]] |
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.
question: is it also possible to use the explicit notation as hash, mean …
failure: [
{
code: 400,
message: 'NotFound',
model: Entities::ApiError,
examples: { 'application/json' => { code: 404, message: 'Not found' }
}
]
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.
Yes, added examples and docs for that notation
many thanks @gamartin :) |
* first try * tests * n test * Update README.md * Update README.md * add response examples * tests * n test * Update README.md * Update README.md * Addressed lint issues: lib/grape-swagger/endpoint.rb:7:3: C: Metrics/ClassLength: Class has too many lines. [289/287] class Endpoint ... ^^^^^^^^^^^^^^ lib/grape-swagger/endpoint.rb:196:5: C: Metrics/CyclomaticComplexity: Cyclomatic complexity for response_object is too high. [14/13] def response_object(route) ... ^^^^^^^^^^^^^^^^^^^^^^^^^^ lib/grape-swagger/endpoint.rb:196:5: C: Metrics/PerceivedComplexity: Perceived complexity for response_object is too high. [15/14] def response_object(route) ... ^^^^^^^^^^^^^^^^^^^^^^^^^^ * added examples for explicit hash notation in failure
Added support to expose response examples
desc
DSL block syntax.