2017-04-05 60 views
0
/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: '#/definitions/CancelRequest'的行上有一个错误的参数定义。可能是什么问题?没有有效的参数定义

回答

0

的误差可能是误导性的,问题是与其它参数:

/cancel: 
    post: 
     consumes: 
     - application/json 
     - application/xml 
  • 部首参数要求:

    1. Content-Type头应该用consumes关键字,而不是一个参数来定义一个type(而不是schema)和type必须是一个简单的类型,不能是$ref。因此,它应该是:

      - name: Authorization 
           in: header 
           required: true 
           description: '' 
           type: string # <------- 
      

      然而,在Authorization头的情况下,你应该使用一个security definition来代替。例如,如果您的API使用基本认证:

      securityDefinitions: 
          BasicAuth: 
          type: basic 
      
      paths: 
          /cancel: 
          post: 
           security: 
           - BasicAuth: [] 
      
  • 相关问题