Closed tpoll closed 4 weeks ago
I realize this is a bit tricky to follow. I'll open up an example PR in jooby + a test to show what I'm looking for.
Did some deeper digging here and realized that there is something weird going on, but I think it's just from the swagger parser itself. It doesn't seem to be handling nested interfaces well. I don't think there's anything to do in jooby here.
I have some objects in my jooby API that leverage jackson's polymorphic deserialization. At a high level a simple example is as follows:
resource: https://github.com/tpoll/jooby-example/blob/main/Api1/src/main/java/com/example/api1/resources/Resource1.java#L13 models: https://github.com/tpoll/jooby-example/blob/main/Api1/src/main/java/com/example/api1/models/Pet.java
The generated openApi look like:
https://gist.github.com/tpoll/0fdc4cfcfa59945c0ee1fabcf573f6c2#file-openapi-json-L69
One challenge I've been running into is that the open api generated uses
allOf
to point mycat
object back the the underlyingpet
object. While some renders like redocly seems to handle it okay, I haven't been able to find other parsers that are able to understand these sort of back references. It seems like most other renderers wantoneOf
instead ofallOf
. Basically a structure where thepet
schema in openAPI caseoneOf [ref->cat, ref->pet]
. If I add manualoneOf
annotations via swagger, I still have issues with circular references because ofallOf
back references.Is there any context on why the structure with
allOf
was used? It looks like it's used to get the properties from the underlying interface on to the extending object, but it seems conceptually like it's not what openAPI expects. An instance of a request can only haveoneOf
the implementing classes at any time.