swagger-test-templates
swagger-test-templates copied to clipboard
Body parameter
Currently this code https://github.com/apigee-127/swagger-test-templates/blob/master/templates/request/post/post.handlebars#L24-L28
json: {
{{#each bodyParameters}}
{{this.name}}: 'DATA GOES HERE'{{#unless @last}},{{/unless}}
{{/each}}
}
based on this description
parameters:
- name: User
description: User
in: body
required: true
schema:
type: object
required:
- email
properties:
email:
description: Email
type: string
format: email
default: [email protected]
generates body that looks like this
{
"User": {
'DATA GOES HERE'
}
}
but I think it should look like this
{
'DATA GOES HERE'
}
this is because by http://swagger.io/specification/#parameterObject body is The payload that's appended to the HTTP request. Since there can only be one payload, there can only be one body parameter. The name of the body parameter has no effect on the parameter itself and is used for documentation purposes only.
.
Yeah, I agree it looks a bit funny. ATM we are building the ability to include request-data during test generation, so you don't have to see the 'DATA GOES HERE' anymore ;-)
Point was that bodyParameters
shouldn't be an array, looped through etc. :)
check, I think we should fix that. @noahdietz do you have any thought about this? I think we should do #117 first before doing anymore work on the templates, right now it's very frustrating to work on them
@Remco75 agreed, #117 should be merged first before addressing this.
This will make for a straight forward change and good test of our workflow after #117 is finished. :)
@bgaluszka - I believe that this has been resolved in #140 . Can you confirm?
@baynezy unfortunately I don't have that code/spec anymore since we changed our toolkit and moved to swagger 3.0 :/ I've looked on that part of code and it still there https://github.com/apigee-127/swagger-test-templates/blob/master/templates/request/post/post.handlebars#L29-L31, so unless it's not used it's not fixed :)
Really, I think the request body should be prepared as an object and just dropped in to the template. Example in a rewrite I'm playing with (excuse the awkward formatting, whitespace in handlebars is annoying).