-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Why does #/bodyParameter require a "name"? #278
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
Comments
It's for documentation purposes. In previous versions, it had to be 'body'. In 2.0, it can be pretty much anything that you may find descriptive to the body itself. |
Wouldn't it make sense to use a different term(e.g. label although there is a "description" field which pretty much solves the documentation issue) ? Isn't |
I don't follow your last question. |
here's a practical usage of why you need to have names on parameters: var pet = {
id: 100,
name: "dog"};
swagger.apis.pet.addPet({body: pet}); This is doable because the input parameter has a name attached to it. And of course, the operation can have query params, header params, path params, etc. |
@webron See the example below. It seems to me that in this case "name" is actually the name of the parameter and is no longer documentation. If the "name" would serve as documentation only it shouldn't be required (just like description) isn't it? My concern is that serving a double purpose adds confusion and complexity to the schema even if it doesn't need (there is a "description" field, right?).
|
@fehguy just gave you an actual use case example as to why it is needed. There's no real double purpose here. Also, the schema is not the issue, it reflects the spec itself, which requires it. |
@webron the issue is about the specifications. Let me know if there is any other place where it should be discussed. Another reason is that in practice is optional because the client doesn't send it to the server if the request is JSON so I think it doesn't make sense to be required by the schema. @fehguy I assume that's an example from the current javascript client implementation but I doubt it can't be done using a new field name/keyword which could be conflict free. |
Then fair enough, it is technically possible to not have a |
It could be implicit, but it would be generated by display tools. Look at swagger-ui, that provides you with the name as an identifier for the field. It would still end up calling it |
I think the labels ( Parameter and Value) displayed on swagger-ui totally make sense for form encoded requests but for JSON requests they are confusing . A parameter implies that it has a value but the JSON requests require raw json only without parameter/value identifiers. |
I have to agree with @themihai on this for |
@zanona The idea behind the body parameter name is to possibly give an extra meaning to the parameter, but it doesn't change it. Nowhere in the spec does it say that it wraps anything, and the spec is explicit that there can only be one body parameter. |
Meta issue: #565 |
Resolved by #670. |
I'm wondering why
bodyParameter
schema requires a "name". Makes sense only if the parameter is sent/setin
query
or perhapspath
but doesn't make sense if the parameterin
value isbody
isn't it? Unlike the query string parameters json/xml objects don't have a name."bodyParameter": { "type": "object", "required": [ "name", "in", "schema" ],
The text was updated successfully, but these errors were encountered: