Skip to content

Multi-query parameter validation not working #366

@stojan-jovic

Description

@stojan-jovic

Validation for query parameter with multiple values (i.e. array values in form-style query expansion) not working, at least from version 0.13.3 of openapi-core.

Example request:

http://localhost:8000/v1/test?a=1&a=2

Appropriate OpenAPI spec to validate above parameters as a = ['1', '2']:

parameters:
  - in: query
    name: a
    description: Test query parameter.
    schema:
      type: array
      items:
        type: string
    required: true

Validation error:

openapi_core.unmarshalling.schemas.exceptions.InvalidSchemaValue: Value [['1', '2']] not valid for schema of type array: (<ValidationError: "['1', '2'] is not of type string">,)

Till version 0.13.8 it was possible to "cheat" validation by describing schema as:

parameters:
  - in: query
    name: a
    description: Test query parameter.
    schema: {}
    required: true

Unfortunately, above workaround not working anymore (from version 0.14.0), but strangely, schema can be described as follows:

parameters:
  - in: query
    name: a
    description: Test query parameter.
    schema:
      type: array
      items:
        type: array
        items:
          type: string
    required: true

However, this is not proper way to describe query parameter with multiple values and should be fixed!

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/contribIndicates an issue on contrib area.kind/bugIndicates an issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy