OneOfs with Discriminator Mappings in External Files Will Break With Inline Bundling
OneOf that with discriminators in external files break with inline bundling. Small Example
Parent File
/shopping:
get:
responses:
'200':
description: Catalog page response
content:
application/json:
schema:
$ref: 'internal_schemas.yaml#/components/schemas/ResponseCatalogSection'
Child Files
ResponseCatalogSection:
oneOf:
- $ref: '#/components/schemas/ResponseCatalogTileGroupSection'
- $ref: '#/components/schemas/ResponseCatalogTableSection'
discriminator:
propertyName: type
mapping:
"TILE_GROUP_SECTION": '#/components/schemas/ResponseCatalogTileGroupSection'
"TABLE_GROUP_SECTION": '#/components/schemas/ResponseCatalogTableSection'
Once the inline bundler runs, the bundler will move
ResponseCatalogSection:
oneOf:
- $ref: '#/components/schemas/ResponseCatalogTileGroupSection'
- $ref: '#/components/schemas/ResponseCatalogTableSection'
discriminator:
propertyName: type
mapping:
"TILE_GROUP_SECTION": '#/components/schemas/ResponseCatalogTileGroupSection'
"TABLE_GROUP_SECTION": '#/components/schemas/ResponseCatalogTableSection'
to the main file, but the references will not come along with it nor will it inline. Not inlining is the CORRECT behavior, since I belive that's something I fixed in the past. But my fixed missed this case.
In this case, we either need to copy the references to the main file, or skip inlining this type of case at all. Since skipping has some prior precedence (when it comes to recursive refs), that's probably the solution to inline bundling.
I think I might have a fix somewhere for this (since I wrote the code). These stupid discriminators are gonna be the death of me
You can join me, sitting somewhere near the bottom (I think) of this endless pit we call OpenAPI. No matter what, it keeps getting deeper. You can't solve it. It's a puzzle that looks like it's solved, and then someone finds a way to use oneOf or anyOf in a new and terrifying way.
I'm over it. It's cursed. If only you could see the work I've done trying to get discriminators and oneOfs to work in a Java client recently