Skip to content
This repository has been archived by the owner on May 15, 2023. It is now read-only.

Body parameter #118

Open
bgaluszka opened this issue Sep 26, 2016 · 7 comments
Open

Body parameter #118

bgaluszka opened this issue Sep 26, 2016 · 7 comments

Comments

@bgaluszka
Copy link

bgaluszka commented Sep 26, 2016

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..

@Remco75
Copy link
Contributor

Remco75 commented Sep 26, 2016

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 ;-)

@bgaluszka
Copy link
Author

Point was that bodyParameters shouldn't be an array, looped through etc. :)

@Remco75
Copy link
Contributor

Remco75 commented Sep 27, 2016

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

@noahdietz
Copy link
Contributor

noahdietz commented Sep 27, 2016

@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. :)

@baynezy
Copy link
Contributor

baynezy commented Aug 29, 2017

@bgaluszka - I believe that this has been resolved in #140 . Can you confirm?

@bgaluszka
Copy link
Author

@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 :)

@noahdietz
Copy link
Contributor

noahdietz commented Aug 29, 2017

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).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants