Forum Discussion

mebigfatguy's avatar
Regular Visitor
2 years ago

Swagger annotation for "Object" type field with oneOf

I have the following class used as part of a rest request body

public static class Area {
 @Schema(oneOf = { String.class, Number.class }, description = SwaggerAPIMessages.KEY, required = true, example = "") private Object key; @Schema(description = SwaggerAPIMessages.VALUE, required = true, example = "") private double value;

public Area() { }


when i generate the swagger,  i see  no reference to the oneOf specification

"Area":{"required":["key","value"],"type":"object","properties":{"key":{"type":"object","description":"The category part for a x,y plot","jsonSchema":{"type":"object","description":"The category part for a x,y plot"}},"value":{"type":"number","description":"The value part for an x,y plot","format":"double"}},"description":"The category and value pair for an area chart series"}

When i import  it  into i get

Structural error at

should NOT have additional properties additionalProperty: jsonSchema

No RepliesBe the first to reply