10
votes

I try to generate a REST API definition with Swagger and YAML, but at $ref: '#/definitions/Token' I get the error

Bad indentation of a mapping entry

      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

My Question is: Why does the Mapping with $ref is working at the responses and at the paramets I get an error ?

1
You sure you don't have tabs before that $ref? what would happen if you swap that line with another $ref line? - Shiping
I swapped it with the $ref from error without any success - FoldFence

1 Answers

13
votes

This part is syntactically incorrect:

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

schema: should be at same level as required:.