Swagger-YAML Bad Mapping条目

时间:2017-01-28 21:33:27

标签: rest yaml swagger

我尝试使用Swagger和YAML生成REST API定义, 但在$ref: '#/definitions/Token'我收到了错误

  

映射条目的错误缩进

      parameters:
        - name: environmentID
          in: query
          description: id from the gamificationenvironment
          required: true
          type: integer
          format: int32
        - name: authorizationToken
          in: query
          description: Authorization token to create a new environment
          required: true
              schema:
                type: object
    --> Error   $ref: '#/definitions/Token'
      responses:
        201:
          description: GamificationID for the Admin
          schema:
            type: object
            items:
              $ref: '#/definitions/Environment'
        default:
          description: Unexpected error
          schema:
              $ref: '#/definitions/Error'

definitions:
  Token:
    required:
      - authentificationKey
      - user
    properties:
      authentificationKey:
        type: string
      senderID:
        type: integer
        format: int32
      user:
        type: string
        type: integer
        format: int64
  Error:
    type: object
    properties:
      code:
        type: integer
        format: int32
      message:
        type: string
      fields:
        type: string

enter image description here

我的问题是: 为什么使用$ref的映射正在响应和 在参数我得到一个错误?

1 个答案:

答案 0 :(得分:4)

这部分在语法上是不正确的:

         required: true
             schema:
               type: object
               $ref: '#/definitions/Token'

schema:应与required:处于同一级别。