Forum Discussion

dipakm's avatar
dipakm
Occasional Visitor
5 years ago

Getting error in swaggger editor for valid YAML

I have following yaml which I was trying to use in swagger editor. 

 

 

swagger: '2.0'
info:
  title: API specification
  license:
    name: 'This is my API.'
  description: Sample API
  version: '1'
host: my.api.com
schemes:
  - https
basePath: '/baseUri'
consumes:
  - application/json
produces:
  - application/json
paths:
  '/endpoint':
  get:
    tags:
      - operationTag
    summary: Sample endpoint
    description: Sample endpoint description.
    operationId: GetSampleData
    parameters:
      - in: query
        name: sampleInput
        description: sample input
        required: true
        type: string
    responses:
      '200':
        description: OK
        schema:
          $ref: '#/definitions/ResponseModel'
      '401':
        description: Unauthorized
        schema:
          $ref: "https://raw.githubusercontent.com/airwatch-api/swagger/master/CommonDefinitions.yaml#/definitions/BaseExceptionModel"
      '400':
        description:  >-
           {
            8003: Input cannot be empty,
           }
        schema:
          $ref: "https://raw.githubusercontent.com/airwatch-api/swagger/master/CommonDefinitions.yaml#/definitions/BaseExceptionModel"
      '404':
        description: >-
           {
            2000: Input not registered
           }
        schema:
          $ref: "https://raw.githubusercontent.com/airwatch-api/swagger/master/CommonDefinitions.yaml#/definitions/BaseExceptionModel"
         
definitions:
  ResponseModel:
    type: object
    description: Response model.
    properties:
      option:
        description: response option
        type: boolean

 

 

 

I keep on getting following errors. Can someone help me resolving these?

Structural error at pathsshould only have path names that start with `/`
Jump to line 16
Structural error at paths./endpointshould be object
Jump to line 17
  • The indentation is wrong. The lines starting from "get:" and until "definitions:" should have an extra indent. In other words, get should be inside '/endpoint'.

     

    # Correct
    paths:
      '/endpoint':
        get:   # <---------
          ...

     

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)

    The indentation is wrong. The lines starting from "get:" and until "definitions:" should have an extra indent. In other words, get should be inside '/endpoint'.

     

    # Correct
    paths:
      '/endpoint':
        get:   # <---------
          ...