路径中的模式错误不应具有附加属性 additionalProperty: type, items, name, in, description, required

Schema error at paths should NOT have additional properties additionalProperty: type, items, name, in, description, required

我在 Swaggerhub 编辑器上遇到了这 3 个错误

Schema error at paths['/addWish.php'].post.parameters[6] should NOT have additional properties additionalProperty: type, items, name, in, description, required Jump to line 74

Schema error at paths['/addWish.php'].post.parameters[6].in should be equal to one of the allowed values allowedValues: header, formData, query, path Jump to line 75

Schema error at paths['/addWish.php'].post.parameters[6].items should NOT have additional properties additionalProperty: $ref Jump to line 79

我的yaml代码附在下面。我是 API 文档的新手,所以请帮忙。

   swagger: '2.0'
info:
  description: |
    This is a sample iGaze server.  You can find 
    out more about Swagger
  version: 1.0.0
  title: iGaze Wishlist
  termsOfService: http://swagger.io/terms/
  contact:
    email: apiteam@swagger.io
  license:
    name: Apache 2.0
    url: http://www.apache.org/licenses/LICENSE-2.0.html
#  host: localhost/iGaze
# basePath: /v2
tags:
- name: wish
  description: Everything about your wishes
  externalDocs:
    description: Find out more
    url: localhost/iGaze
- name: store
  description: Access to Petstore orders
- name: user
  description: Operations about user
  externalDocs:
    description: Find out more about our store
    url: localhost/iGaze
# schemes:
# - http
paths:
  /addWish.php:
    post:
      tags:
      - Wish
      summary: Add a new wish
      operationId: addWish
      consumes:
      - application/json
      parameters:
      - name: wishPrefix
        in: path
        description: ID of pet that needs to be updated
        required: true
        type: string
      - name: wish
        in: path
        description: ID of pet that needs to be updated
        required: true
        type: string
      - name: targetDate
        in: path
        description: ID of pet that needs to be updated
        required: true
        type: string
        format: date
      - name: sharingType
        in: path
        description: ID of pet that needs to be updated
        required: true
        type: integer
      - name: latitude
        in: path
        description: ID of pet that needs to be updated
        required: true
        type: number
        format: double 
      - name: longitude
        in: path
        description: Updated name of the pet
        required: true
        type: number
        format: double
      - name: wishType  <-- Line 74
        in: body  <-- Line 75
        description: Updated name of the pet
        required: true
        type: array
        items:  <-- Line 79
          $ref: '#/definitions/Types'
      - name: userDetailsId
        in: path
        description: ID of pet that needs to be updated
        required: true
        type: string
      responses:
        200:
          description: successful operation
          schema:
            type: integer
        400:
          description: Invalid status value

  /getWishTypes.php:
    get:
      tags:
      - Types
      summary: Get Wish Types
      description:  get all wish types like dream,achievement
      operationId: getWishTypes
      produces:
      - application/json
      responses:
        200:
          description: successful operation
          schema:
            type: array
            items:
              $ref: '#/definitions/Types'
        400:
          description: Invalid status value
definitions:
  Types:
    type: object
    properties:
      wishTypesId:
        type: integer
      wishType:
        type: string
  Wish:
    type: object
    properties:
      wishId:
        type: integer
      wishPrefix:
        type: string
      wish:
        type: string
      targetDate:
        type: string
        format: date
      sharingType:
        type: integer
      latitude:
        type: number
        format: double
      longitude:
        type: number
        format: double
      userDetailsId:
        type: integer
      wishType:
        type: array
        items:
            $ref: '#/definitions/Types'

# Added by API Auto Mocking Plugin
host: virtserver.swaggerhub.com
basePath: /test7115/demo/1.0.0
schemes:
 - https
 - http

1) in: body参数的类型需要包裹在schema关键字中。这与直接使用 type 的 query/path/header/form 参数不同。

      - name: wishType
        in: body
        description: Updated name of the pet
        required: true
        schema:   # <---------
          type: array
          items:
            $ref: '#/definitions/Types'

2) in: path 参数是端点路径的一部分,因此需要在端点路径中明确提及:

/addWish.php/{wishPrefix}/{wish}:

如果您指的是查询参数,如 /addWish.php?wishPrefix=foo&wish=bar,请将参数类型更改为 in: query:

paths:
  /addWish.php:
    post:
      ...
      parameters:
      - name: wishPrefix
        in: query   # <----------
        required: true
        type: string
      ...