samarthgupta437
6 years agoOccasional Visitor
oneOf with discriminator converting to LinkedHashMap in java server
I have used oneOf along with discriminator property in my openapi 3 spec. I generated the "jaxrs-jersey" server code using codegen tool.
However when I send sample JSON payload in POST request dataType of the received variable where "oneOf" is used is of type "java.util.LinkedHashMap" , eventhough discriminator property value is provided in POST payload.
attaching sample YAMl file.
components: schemas: Home: type: object additionalProperties: false properties: name: $ref: '#/components/schemas/Names' sofaStyle: oneOf: - $ref: '#/components/schemas/Sofa1' - $ref: '#/components/schemas/Sofa2' discriminator: propertyName: styleType required: - name - sofaStyle Names: type: object properties: name: type: string enum: - "home1" - "home2" required: - name SofaStyleType: type: object properties: styleType: type: string required: - styleType discriminator: propertyName: styleType Sofa1: allOf: - $ref: '#/components/schemas/SofaStyleType' - type: object properties: identifier: type: string enum: - "big" Sofa2: allOf: - $ref: '#/components/schemas/SofaStyleType' - type: object properties: identifier: type: string enum: - "small"
sample json input
{ "name" : { "name" : "home1" }, "sofaStyle" : { "identifier" : "big", "styleType" :"Sofa1" } }
I am looking for a way to easily identify and get object of Sofa1 or Sofa2