Syntax error in Swagger Editor

741 views
Skip to first unread message

Ian G

unread,
Sep 20, 2017, 9:29:49 PM9/20/17
to Swagger
Hi

I am getting confused as to what is wrong with the following code. 

swagger: '2.0'
info:
  version: '1.0.0'
  title: Sample API for editing
  description: Trying to debug this API in the editor
 

paths:
  "/v1/places/{PlaceID}/devices":
    get:
      summary: List Devices fo a location
      description: An Array of all devices in location.
      produces:
        - application/json
      parameters: 
        - name: PlaceID        
          in: path
          type: integer
      responses:
        200:
          description: OK
          schema: 
            $ref: "#/definitions/PlaceWithPort"

definitions:
  PlaceWithPort:
    type: object
    properties:
      placeId:
        type: integer     
      name:
        type: string
      devices:
        items:
          properties:
            deviceId:
              type: integer
            name:
              type: string
            type:
              type: string
          type: object
        type: array

basePath: /getInventoryBySite/1.0.0
schemes:
 - https

When I enter this into the Swagger.Editor it generates the following errors.

Errors

Schema error at paths['/v1/places/{PlaceID}/devices'].get.parameters[0]

should NOT have additional properties additionalProperty: type, name, in

Schema error at paths['/v1/places/{PlaceID}/devices'].get.parameters[0].in

should be equal to one of the allowed values allowedValues: body, header, formData, query
Jump to line 17


What I am doing wrong... 

Ron Ratovsky

unread,
Sep 27, 2017, 3:02:31 PM9/27/17
to swagger-sw...@googlegroups.com

Path parameters must always be required. Add:

required: true

to the parameter definition and the errors would disappear.

Reply all
Reply to author
Forward
0 new messages