I've created my .yml (reduced):
openapi: 3.0.1
...
components:
messages:
...
schemas:
device:
type: object
properties:
identifier:
type: string
manufacturer:
type: string
model:
type: string
controllerId:
type: number
controller:
type: object
properties:
controllerId:
ref: '#/components/schemas/controllerId'
device:
ref: '#/components/schemas/device'
I let generate java classes for Vertx by
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>5.3.0</version>
Properties with type:
are generated as expected but all properties with ref:
are generated as JsonNullable<Object>
.
Because of that the jackson-ObjectMapper
reads the values as LinkedHashMap
instead of e. g. Device
in Controller
's field.
I copied the generated classes and fixed the generics so the mapper reads the values to the expected classes.
Do you have any idea how to write the .yml that the generator creates JsonNullable<Device>
instead of JsonNullable<Object>
?
Or is there any configuration of the generator I didn't found yet to solve this problem?
Reading the specs...
I had to change ref:
to $ref
and the correct member type is generated.