-
Notifications
You must be signed in to change notification settings - Fork 476
Support description option body_param #49
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
* If it's true, all non-path params are replaced with one parameter of type "body". * If it's an array, only parameters included in it are replaced. * If body_param option is present, body parameter is added even if no parameters are defined. * We lose the replaced parameters' names and their descriptions.
@tim-vandecasteele Is there any reason not to merge this? |
Sorry this took so long. A few people are taking over the project and things are going to move forward now. I am not convinced this is a good idea. If you're posting a multipart form, you got What do you think? |
Guess so. Since Grape unifies both query and body parameters as far as the user code is concerned, this shouldn't be necessary. But we've been using this as a escape hatch to be able to use Swagger UI for requests that are not supported by grape-swagger, such as any parameter with array value, or a nested structure, etc (#39). Not sure if all these can be supported with Swagger. If so, that would be a better alternative. Otherwise, I think it's more important to allow performing all kinds of requests that Grape supports, rather than allow only those we can support it a "nice" way. |
I am looking for some (strong) opinions of what to do with this PR :) |
If I'm reading https://github.com/tim-vandecasteele/grape-swagger/issues/42#issuecomment-20442937 correctly, this is something that Swagger supports, so we should probably support it as well. Whether or not this PR is the way to support it remains to be discussed. I've read through the file changes, and I can't quite get my head wrapped around the use case. Can someone (@dgutov?) elaborate more? |
@CraigCottingham
Could you ask a specific question? |
|
In #101 is a screen-shot show how swagger can document a body which should be a json string. The good thing is, when you use an entity. You can got to For In my point of view the only thing needed to do is enhance the documantation and maybe add in grape a dsl like |
@dspaeth-faber I would be interested in a |
@dblock Like I did figure out today this is a little bit more complex. When you start with the The post data:
When you want to get the hole body as one hash in your endpoint you have to recreate it: body= { id: params['id'], some_data: params['some_data'] }
# but I would like to get
body=params['body'] I did walk around this for my self be wrapping the params hash into my Entity But this make's the |
The body POSTed is parsed by a parser. The raw value goes into The default JSON parser parses JSON content-type into params. Grape/Rack also supports form multipart content. |
Does it make sense for Grape? How would it work differently from I think the body-ness works better as additional metadata, for example like implemented in this pull request. @CraigCottingham Sorry for being brief:
|
@dgutov In my point of view it makes a lot of sence. The documentation hash is noise. When I try to understand api code I will in the first place skip the documentation hash but read the statements. For instance When I do some thing wrong with this statement I will get feedback instantly. But the documantion Hash gives no feedback. Some day some one will complain the documentation is wrong that's all. Furthor validation that they only can be placed where they are defined (query, form, body) would be good thing too. |
Can we revive this discussion? Does anyone has put a thought into this? |
👍 but no, I have not put any thought into this |
What now? |
Am I right, we can't use something like this still? I mean sending json data. So we limited with But content type header overwritten at the end with urlencoded one: |
please re-target against |
Actually, I'm not sure this approach should be preferred anymore. From trying out the That doesn't always work, though. For instance, it adds a body parameter for requires :words, type: Array do
requires :letter1, type: String
requires :letter2, type: String
end then the resulting interface shows an obviously broken form with two fields ( Anyway, it seems like fixing the edge cases like this can be a better way forward. |
This is a proposal to fix #42. See the included commit message for details.
With this change, we can at least have textarea input for complex types that couldn't be represented with form fields.
The included parameter names and descriptions are lost. We could try to put them in some formatted way into
notes
, but since there's no guarantee that it supports markdown, the result would be messy.Ideally, this should be eventually solved in #39.