Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swagger-YAML Bad Mapping entry

Tags:

rest

yaml

swagger

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 ?

like image 632
FoldFence Avatar asked Jan 28 '17 21:01

FoldFence


1 Answers

This part is syntactically incorrect:

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

schema: should be at same level as required:.

like image 104
flyx Avatar answered Nov 15 '22 23:11

flyx