Nick Jonas
Nick Jonas

Reputation: 1237

OpenAPI definition error with required path parameter

I'm just getting started with creating my first OpenAPI definition (version 2.0), and I keep getting stuck on this error:

Invalid OpenAPI file. Please fix the schema errors:\n\"/parameters/categoryParam\": domain: validation; keyword: oneOf; message: instance does not match exactly one schema; matches: 0"

It's meant to simply be a query like "/cat/count", that would return an integer of how many cats there are - "cat" being the required path parameter. What exactly is wrong with my parameter definition here?

swagger: '2.0'
info:
  description: "xxx"
  title: "xxx"
  version: "1.0.0"
host: "xxx"
consumes:
- "application/json"
produces:
- "application/json"
schemes:
- "https"
parameters:
  categoryParam:
    in: path
    name: category
    required: true
    schema:
      type: string
    description: "xxx"
paths:
  "/{category}/count":
    get:
      operationId: "get_category_count"
      parameters:
        - $ref: "#/parameters/categoryParam"
      produces:
        - application/json
      responses:
        '200':
          description: "xxx"
          schema:
            $ref: '#/definitions/Model0'
definitions:
  Model0:
    properties:
      count:
        type: string

Upvotes: 1

Views: 2207

Answers (1)

Nick Jonas
Nick Jonas

Reputation: 1237

Nevermind, dumb mistake. I needed to change:

schema:
  type: string

to just:

type: string

Upvotes: 1

Related Questions