Swagger 不允许虚张声势

Swagger 不允许虚张声势,swagger,swagger-ui,Swagger,Swagger Ui,我试图将请求主体添加到一个swagger文件中,但当我使用requestBody时,它总是说不允许附加属性:requestBody我尝试了multple-in参数,如下所示 parameters - in: body name: email description: The user to create. schema: $ref: "#/definitions/User"

我试图将请求主体添加到一个swagger文件中,但当我使用requestBody时,它总是说
不允许附加属性:requestBody
我尝试了multple
-in
参数,如下所示

      parameters
        - in: body
          name: email
          description: The user to create.
          schema:
            $ref: "#/definitions/User"
        - in: body
          name: password
          description: The user to create.
          schema:
            $ref: "#/definitions/User"
但是它说
操作不能有多个body参数
,所以我不确定如何引用所有req.body值。还有,如果我有多个主体参数和一个/:id路径呢? 我对招摇过市还是个新手,所以我非常感谢大家对我的帮助

swagger: "2.0"
info:
  version: "1.0.0"
  title: Hello World App during dev, should point to your local machine
basePath: /v1
schemes:
  # tip: remove http to make production-grade
  - http
  - https
paths:
  /user/signup:
    x-swagger-router-controller: user
    post:
      description: signup POST
      operationId: signup
      parameters:
        - in: body
          name: email
          description: The user to create.
          schema:
            $ref: "#/definitions/User"
        - in: body
          name: password
          description: The user to create.
          schema:
            $ref: "#/definitions/User"
      responses:
        "200":
          description: Success got all the listings
          schema:
            $ref: "/definitions/User"
        "500":
          description: Unexpected Error
          schema:
            type: object
            properties:
              message:
                type: string

  /user/login:
    x-swagger-router-controller: user
    post:
      description: Login request
      operationId: login
      parameters:
        - in: body
          name: login
          description: The user to create.
          schema:
            $ref: "#/definitions/Login"
      responses:
        "200":
          description: Success got all the listings
          schema:
            $ref: "/definitions/Login"
        "500":
          description: Unexpected Error
          schema:
            type: object
            properties:
              message:
                type: string

definitions:
  User:
    properties:
      id:
        type: integer
      email:
        type: string
      password:
        type: string
      instagramName:
        type: string
      over21:
        type: boolean
      role:
        type: string
      fullName:
        type: string
      address1:
        type: string
      address2:
        type: string
      city:
        type: string
      state:
        type: string
      zip:
        type: string
      passwordCreated:
        type: string

  Login:
    properties:
      id:
        type: string
      email:
        type: string
      password:
        type: string


您不需要在:body参数中有多个
,它们都已在用户模式中定义(每个请求都只有一个body)。
 这正是应该做的。只需删除第二个“主体”,并可能重命名另一个:

parameters:
  - in: body
    name: user
    description: The user to create.
    schema:
      $ref: "#/definitions/User"
如果需要路径参数,可以在:path
中将其定义为
。您还需要将其添加到路径本身:

paths:
  /user/signup/{id}:
    x-swagger-router-controller: user
    post:
      description: signup POST
      operationId: signup
      parameters:
        - in: path
          name: id
          description: User id
          type: string
          required: true
        - in: body
          name: user
          description: The user to create.
          schema:
            $ref: "#/definitions/User"

In:body
相反,您可以有多个
In:path
参数。路径参数必须包括
required:true

您不需要多个
in:body
参数,它们都已在用户架构中定义(每个请求都只有一个body)。
 这正是应该做的。只需删除第二个“主体”,并可能重命名另一个:

parameters:
  - in: body
    name: user
    description: The user to create.
    schema:
      $ref: "#/definitions/User"
如果需要路径参数,可以在:path
中将其定义为
。您还需要将其添加到路径本身:

paths:
  /user/signup/{id}:
    x-swagger-router-controller: user
    post:
      description: signup POST
      operationId: signup
      parameters:
        - in: path
          name: id
          description: User id
          type: string
          required: true
        - in: body
          name: user
          description: The user to create.
          schema:
            $ref: "#/definitions/User"
In:body
相反,您可以有多个
In:path
参数。路径参数必须包括
必需:true