kin-openapi icon indicating copy to clipboard operation
kin-openapi copied to clipboard

arrays of objects as query parameters cause a crush

Open orensolo opened this issue 3 years ago • 0 comments

Hi,

Query parameters that are defined as arrays of objects (i.e not primitives) causing kin-openapi to crush with panic (schema has non primitive type ...)

This also the case when the items in the query paramaters array are defined with polymorphism like anyof, allof etc.

It seems that kin-openapi assumes that all query parameters arrays must contain only primitives. But this is a valid schema.

For example :

Consider the schema:

 paths:
  /nf-instances:
   get:
   - description: Names of the services offered by the NF
        explode: false
        in: query
        name: service-names
        required: false
        schema:
          items:
            $ref: '#/components/schemas/ServiceName'
          minItems: 1
          type: array
          uniqueItems: true
    ...
       ServiceName:
      anyOf:
      - $ref: '#/components/schemas/ServiceName_anyOf'
      - type: string
      description: Service names known to NRF

And consider the following request:

nf-instances?service-names=npcf-am-policy-control

This request causes a panic. because the service-names items type is not a primitive.

Thanks, Oren

orensolo avatar Sep 29 '22 13:09 orensolo