-
Notifications
You must be signed in to change notification settings - Fork 470
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
Standalone appearance of nested routes #220
Conversation
789d5cf
to
067363d
Compare
@@ -191,6 +191,27 @@ You can specify a swagger nickname to use instead of the auto generated name by | |||
desc 'Get a full list of pets', nickname: 'getAllPets' | |||
``` | |||
|
|||
## Expose nested namespace as standalone route | |||
Use the `nested = false` option to expose nested actions as standalone resources. | |||
This option can help to struture and keep the swagger schema simple. |
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.
typo: struCture
By flattening these aren't you documenting routes that don't exist? What am I missing? |
Hm, I don't really get what you are trying to say ;-) The main goal of my implementation is to realize what was described in issue #130: The documentation should generate:
instead of :
Therefore I specify the From my point of view, all the routes (Grape::Route) did already exist before, however they were seen as operations on a resource (here: the store) instead of being operations of the namespace(-resource) themselves. The pull request still has some major flaws, especially with nested namespaces, etc. |
(route.instance_variable_get(:@options)[:namespace] == "/#{name}" || route.instance_variable_get(:@options)[:namespace] == "/:version/#{name}") | ||
end.compact | ||
|
||
if namespace.options[:nested] == false |
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.
unless namespace.options[:nested]
, or better, switch the order inside the if
and do if namespace.options[:nested] ... else
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.
Basically you are right, but this would change the default behavior. If I want to keep the current default behavior I can either check for if namespace.options[:nested] == false
(current) or if !namespace.options.key?(:nested) || namespace.options[:nested]
(opposite).
We could also change the key name to sth. like as_resource: true
or standalone: true
, but personally I prefer the nested: false
and would keep the current if
statement.
Ok, I get this now. I am down with merging this whenever you're ready (and amend with some minor things from my comments above). I wonder whether we should refactor |
…includes README update.
067363d
to
6539914
Compare
I updated the pull request once again. Included changes are:
|
This is great, I am merging. |
Standalone appearance of nested routes
I ran into a regression/issue with this change, see https://github.com/tim-vandecasteele/grape-swagger/issues/227. Digging through it now, but would appreciate some help. |
Confirmed, seems to be caused by these changes. I'm looking through the code right now and give an update once I found or resolve the issue. |
I have a fix in https://github.com/tim-vandecasteele/grape-swagger/pull/228, would you please check it out? |
Seems good and should fix the issue. |
Functionality seems to be broken in 0.20. As far as we can see, the code and documentation of this feature was migrated but the tests aren't. |
Are you looking at the 0.20 tag for everything? Open an issue? |
Rerences issue #130 and the comment by @antek-drzewiecki. Also includes the README update.
Here is what I did:
combined_namespace_routes
that includes all routes if no nested namespace shall appear as standalone resource. If one shall appear as standalone resource it is not added to theparent_route
but will be its own route._
with-
and/
with_
or use a custom url for the route if specified in theswagger_name
option.header
andpath
versioning.Let me know what you think!