OpenAPI-Specification icon indicating copy to clipboard operation
OpenAPI-Specification copied to clipboard

API has more than one body parameter?

Open xinyu7git opened this issue 11 years ago • 10 comments

my yml file:

        parameters:
          #  {"role":"twemproxy","type":"lvs","master_id":1,"standby_id":2} 
            - name: role
              in: body
              description: pool role,twemproxy or mysql.
              required: true
              schema:
               $ref: '#/definitions/Pool'  
            - name: type
              in: body
              description: pool role,twemproxy or mysql.
              required: true
              schema:
               $ref: '#/definitions/Pool'  

why swagger-editer only support one body parameter? My rest api 's request data is : {"role":"twemproxy","type":"lvs","master_id":1,"standby_id":2} how should i write my yml file?

xinyu7git avatar Apr 17 '15 11:04 xinyu7git

That's not two body parameters, that's a single one. One object containing the role, type, master_id and standby_id properties.

webron avatar Apr 17 '15 11:04 webron

@webron so....how should i write my yml file?

xinyu7git avatar Apr 18 '15 12:04 xinyu7git

image

the body object is : image

but how should i name the parameters ( in the picture,it's 'a' ) ? .... i don't think it looks well to understand....

my parameters config: image

xinyu7git avatar Apr 18 '15 13:04 xinyu7git

It looks like you may have hit a bug in swagger-editor, so please open an issue there. You've named your parameter data and that's what it should display.

webron avatar Apr 19 '15 14:04 webron

it's my fault to show the parameter'name to 'a'. e.... if the parameter is in body,the parameter's name is not used in the request,is it? so,i think the name should show "role","master_id","standby_id","type". if the name is data,it makes me confused.

xinyu7git avatar Apr 20 '15 03:04 xinyu7git

The name of the body parameter is not used in creating the request, it's just used for documentation purposes.

webron avatar Apr 20 '15 08:04 webron

ok,thank you.

xinyu7git avatar Apr 20 '15 10:04 xinyu7git

So how it should be defined? I also want to define every property of the request.body in /post and /put. How can I do it?

YevheniiHerasymchuk avatar Dec 08 '17 16:12 YevheniiHerasymchuk

How should what be defined?

webron avatar Dec 08 '17 23:12 webron

I meant the possibility to define body object with a lot of properties. But solved it in this way:

     parameters:
        - name: body
          in: body
          schema:
            $ref: "#/definitions/PostData"

YevheniiHerasymchuk avatar Dec 11 '17 09:12 YevheniiHerasymchuk