不是有效的参数定义

时间:2017-04-05 10:04:46

标签: yaml swagger

    app:layout_behavior="@string/appbar_scrolling_view_behavior"

    <ScrollView android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/trial"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
        xmlns:android="http://schemas.android.com/apk/res/android">

----- your code

</ScrollView>

这是片段。它表示在 /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: '' 的行上有一个错误的参数定义。可能是什么问题?

1 个答案:

答案 0 :(得分:0)

错误可能会产生误导,问题在于其他参数:

  1. Content-Type标头应使用consumes关键字而非参数定义:

    /cancel:
        post:
          consumes:
          - application/json
          - application/xml
    
  2. 标头参数需要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: []