oapi-codegen icon indicating copy to clipboard operation
oapi-codegen copied to clipboard

Cannot use unexploded query parameter with additional properties flattened

Open alexdulin opened this issue 3 years ago • 1 comments

The additional properties flattening introduced in this commit breaks query parameters that are unexploded. Take the following example parameter schema:

in: query
name: example
description: |
  Example parameter
explode: false
schema:
  type: object
  additionalProperties:
    type: string
  maxProperties: 10
  example:
    tracker_id: "12345"
    topic: television

When used in a request as ?example=tracker_id,12345,topic,television, the runtime code fails to bind it with the following error:

Invalid format for parameter example: multiple values for single value parameter 'example'

My guess is because it is no longer a struct with flattening, it fails to meet a successful case in the switch statement here. Adding in reflect.Map along with reflect.Struct should fix it I think, but I am not familiar enough with this codebase to be certain, nor that it wouldn't break things elsewhere.

With this bug, the only workaround is to completely disable additional properties flattening with:

compatibility:
  disable-flatten-additional-properties: true

alexdulin avatar Jul 28 '22 19:07 alexdulin

@jamietanna Any chance this could get a pair of eyes? This feature has been broken for many months now. Would be greatly appreciated.

alexdulin avatar Dec 02 '22 00:12 alexdulin