go-apiops icon indicating copy to clipboard operation
go-apiops copied to clipboard

`oneOf` support in openapi2kong parameter schemas

Open mheap opened this issue 1 year ago • 4 comments

The request validator plugin configuration generated by openapi2kong is invalid when using oneOf

/test/data-type:
  get:
    parameters:
      - in: query
        name: mixed_number
        required: true
        schema:
          oneOf:
            - type: string
            - type: integer

Kong Gateway does not support mixed content types in a single parameter (FTI-2182), so go-apiops should return an error instead of generating an invalid configuration.

Acceptance Criteria

  • [ ] Parameter queries that use oneOf to specify multiple type fields in a single parameter result in an error being returned

mheap avatar Sep 24 '24 10:09 mheap

This logic (checking for oneOf) will not suffice, it should match the logic of the request validator plugin to prevent edge cases.

Tieske avatar Sep 24 '24 19:09 Tieske

We’re playing whack-a-mole with bug reports. Can you help us enumerate the options?

mheap avatar Sep 24 '24 20:09 mheap

see docs: https://docs.konghq.com/hub/kong-inc/request-validator/configuration/#config-parameter_schema-schema

The top-level jsonschema object MUST have a type property. An edgecase to be aware of is that the top-level can actually be a $ref, in that case, follow the refs and ensure that the first non-ref has a type property. See internal ticket FTI-5958

Tieske avatar Sep 25 '24 10:09 Tieske

Also; only applies to parameter schemas.

Tieske avatar Sep 25 '24 10:09 Tieske