Yaml 不是有效的参数定义

Yaml 不是有效的参数定义,yaml,swagger,Yaml,Swagger,这是片段。它说在$ref:'#/definitions/CancelRequest'的行中有一个错误的参数定义。可能有什么问题?该错误可能具有误导性,问题在于其他参数: 内容类型标题应使用消费关键字而不是参数定义: /cancel: post: description: '' summary: Cancel operationId: Cancel produces: - application/json param

这是片段。它说在
$ref:'#/definitions/CancelRequest'
的行中有一个错误的参数定义。可能有什么问题?

该错误可能具有误导性,问题在于其他参数:

  • 内容类型
    标题应使用
    消费
    关键字而不是参数定义:

     /cancel:
        post:
          description: ''
          summary: Cancel
          operationId: Cancel
          produces:
          - application/json
          parameters:
          - name: Body
            in: body
            required: true
            description: ''
            schema:
              $ref: '#/definitions/CancelRequest'
          - name: Authorization
            in: header
            required: true
            description: ''
            schema: 
              $ref: '#/definitions/Authorization'
          - name: Content-Type
            in: header
            required: true
            type: string
            description: ''
    
  • 标题参数需要
    类型
    (不是
    架构
    ),并且
    类型
    必须是简单类型,不能是
    $ref
    。因此,它应该是:

    /cancel:
        post:
          consumes:
          - application/json
          - application/xml
    
  •     - name: Authorization
          in: header
          required: true
          description: ''
          type: string    # <-------
    
    securityDefinitions:
      BasicAuth:
        type: basic
    
    paths:
      /cancel:
        post:
          security:
          - BasicAuth: []