cancel
Showing results for 
Search instead for 
Did you mean: 

Getting error in swaggger editor for valid YAML

SOLVED
Highlighted
Occasional Visitor

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
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Moderator

Re: Getting error in swaggger editor for valid YAML

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:   # <---------
      ...

 


Helen Kosova
SmartBear Technical Writer
________________________

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️

View solution in original post

1 REPLY 1
Highlighted
Moderator

Re: Getting error in swaggger editor for valid YAML

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:   # <---------
      ...

 


Helen Kosova
SmartBear Technical Writer
________________________

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️

View solution in original post

New Here?
Join us and watch the welcome video: