-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Proposal: new desc dsl with a block instead of option Hash #757
Conversation
Sorry for being late at this. Today we have things like |
params is taken from the docs. The example within the docs is the following: desc 'Statuses index', {
params: API::Entities::Status.documentation
} It should not replace the "other" I did create this PR because the hash syntax like this: desc "some descs",
entity: API::Entities::Entity,
named: 'a name',
headers :[XAuthToken: {
description: 'Valdates your identity',
required: true
}
get nil, http_codes: [
[401, 'Unauthorized', API::Entities::BaseError],
[404, 'not found', API::Entities::Error]
] do can't be read so smoothly in my point of view. |
Yeah, I think I agree. Why would this not let you set anything unknown via a |
What I mean is this: desc 'Statuses index', {
params: API::Entities::Status.documentation,
my_param1: 'value',
my_param1: 'value2'
} Every one can introduce new paramters like |
route_setting :description, options.merge(description: description) | ||
def desc(description, options = {}, &config_block) | ||
if block_given? | ||
config_class = Grape::DSL::Configuration.new_desc_config |
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.
I am not in love with the new_desc_config
name. Maybe just create
?
I am OK with this. I think it might need some README updates, especially ensuring that all those hard-coded parameters are documented. |
aeadfc2
to
7362b09
Compare
7362b09
to
0e13e9a
Compare
@dblock I think I did address all your hints. If some thing is missing drop a line. |
I'm merging this. |
Proposal: new desc dsl with a block instead of option Hash
Thanks :) |
@dspaeth-faber i've got a question. When using grape-swagger, if success parameter expects an entity, how do you document HTTP Status codes and descriptions for success entities? For example a get request would normally result in an 200 status code, and a post would result in a 201. Is it something that grape-swagger will have to find out? |
@antek-drzewiecki sorry I had have some days off. I will turn to this in the next days. regards |
As far as I know there is no official way to document success http code |
Hi @dspaeth-faber, thanks for replying. You are correct, I could not find a official way to document success codes. Given the example of the placeOrder endpoint. My preference is to add a My preference is to document errors and success codes the following way:
Which should responseMessage array with both codes. A workaround for me could be to add success entity to the failure codes. |
Maybe the better way is to first create an issue within swagger-spec how this guys want to handle success codes. When they have made a commitment we can add it to grape. As long as this does not happen we can missuse maybe the |
Good point @dspaeth-faber . Ill make a issue there. Currently swagger-spec has a way to define authorization ( operations object ) attributes on an endpoint level. How should we handle the authorization? Im getting the feeling this is not really an issue of Grape. Tough my gem WineBouncer, used the hash for defining endpoint authorization, which grape-swagger parses into their authorisations array. It would be nice to define endpoint protection with belonging scopes. |
The new block syntax does not know anything of I think the authorization section within the documentation for swagger should some how be generated from the auth :oauth, { ... } do |...|
end |
Like @mbleigh suggest in #620 I like to introduce a DSL like for
desc
:with this PR.
It's not complete like it was discussed within #620, but it's like every time a starting point.
Furthor more with this PR Options are strictly checked within Grape and cant be missused
like discussed here a little tim-vandecasteele/grape-swagger#49. So that grape will be the master.