Forum Discussion

mebigfatguy's avatar
mebigfatguy
Regular Visitor
3 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 https://editor.swagger.io/ i get

Structural error at components.schemas.Area.properties.key

should NOT have additional properties additionalProperty: jsonSchema
 



No RepliesBe the first to reply