Skip to content

Array in query using $ref for items does not validate #81

@danjor

Description

@danjor

For query parameter, using a type array and items property containing $ref to definition of the object is not validated.

swagger: "2.0"
info:
  version: 1.0.1
  title: API
  description: API
  contact:
    name: Api team
basePath: /api
schemes:
  - http
consumes:
  - application/json
produces:
  - application/json
paths:
  /getSomething:
    get:
      operationId: getSomething
      parameters:
        - name: type
          in: query
          required: false
          type: array
          items:
            $ref: '#/definitions/myType'
      responses:
        default:
          description: unexpected error
          schema:
            type: string
definitions:
  myType:
    type: string
    enum: ["ab", "cd", "ef"]

I get that from validator :

{
  "schemaValidationMessages": [
    {
      "level": "error",
      "domain": "validation",
      "keyword": "oneOf",
      "message": "instance failed to match exactly one schema (matched 0 out of 2)",
      "schema": {
        "loadingURI": "http://swagger.io/v2/schema.json#",
        "pointer": "/definitions/parametersList/items"
      },
      "instance": {
        "pointer": "/paths/~1getSomething/get/parameters/0"
      }
    }
  ]
}

This doesn't work as well without enum property in the myType definition.

In my case, I need to define myType as an enum once, and refer to it from the parameter definition.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions