Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
danjor opened this issue Mar 25, 2016 · 1 comment
Closed

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

danjor opened this issue Mar 25, 2016 · 1 comment

Comments

@danjor
Copy link

danjor commented Mar 25, 2016

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.

@webron
Copy link
Contributor

webron commented Mar 25, 2016

@danjor - that's not supported by the spec. See OAI/OpenAPI-Specification#300.

@webron webron closed this as completed Mar 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants