user3871
user3871

Reputation: 12708

YAML Syntax Error: Incomplete explicit mapping pair; a key node is missed at

I'm writing swagger spec in YAML and getting vague errors. I've mapped my paths and definitions I think correctly, and not sure what this error means:

YAML Syntax Error Incomplete explicit mapping pair; a key node is missed at line 66, column 30: format: int64schema: ^t

Lines:

 Line 65:         type: integer
 Line 66:         format: int64

Swagger:

  /product/{productId}:
    get:
      tags:
        - content
      summary: Find product item by ID
      description: Returns a product item when ID < 10.  ID > 10 or nonintegers will simulate API error conditions
      operationId: getProductItemByID
      produces:
        - application/json
        - application/xml
      parameters:
        - in: path
          name: productId
          description: ID of menu item that needs to be fetched
          required: true
          type: integer
          format: int64
          schema:
            $ref: "#/definitions/Product"
      responses:
        "404":
          description: Product item not found
        "200":
          description: successful operation
          schema:
            $ref: "#/definitions/Product"
        "400":
          description: Invalid ID supplied
      security:
        - api_key: []
        - my_auth:
          - write
          - read

Then at bottom of swagger file in definitions:

definitions:

  Product:
    type: object
    properties:
      id:
        type: integer
        format: int64
      category:
        $ref: '#/definitions/Category'
      name:
        type: string
      detail:
        type: string

Upvotes: 5

Views: 23055

Answers (1)

Nelson G.
Nelson G.

Reputation: 5441

From swagger 2.0 spec, if 'in' parameter is a "path" you can't use a schema. I think there is a mistake and you should use :

/product/{productId}:
  get:
    tags:
      - content
    summary: Find product item by ID
    description: Returns a product item when ID < 10.  ID > 10 or nonintegers will simulate API error conditions
    operationId: getProductItemByID
    produces:
      - application/json
      - application/xml
    parameters:
      - in: path
        name: productId
        description: ID of menu item that needs to be fetched
        required: true
        type: integer
        format: int64
    responses:
      "404":
        description: Product item not found
      "200":
        description: successful operation
        schema:
          $ref: "#/definitions/Product"
      "400":
        description: Invalid ID supplied
...

Upvotes: 4

Related Questions