请求POST主体由键/值对和一个对象(用于Swagger)参数组成

时间:2018-01-09 09:45:00

标签: javascript json rest xmlhttprequest swagger

到目前为止,我已经使用application/x-www-form-urlencoded来传递正文中的键值对,如果我必须传递一个对象applicaton/json

post:
  tags:
    - "users"
  summary: "Create User"
  operationId: "createUser"
  consumes:
  - "application/x-www-form-urlencoded"
  parameters:
  - name: "username"
    in: "formData"
    description: "Name of User"
    required: true
    type: "string"
  - name: "email"
    in: "formData"
    description: "Email"
    required: true
    type: "string"

现在我想添加一个对象:

{
  "member":{
   "name":string,
   "email":string
 }
}

我在定义中描述:

definitions:
  member:
    type:"object"
    properties:
      name:
        type: string
      email:
        type: string

如何在招摇中做到这一点?

以下是文档:https://swagger.io/docs/specification/describing-request-body/ 但我不明白我如何能够保留身体中正常的键值对。

0 个答案:

没有答案