I have problems with automatically generated model schema by Swagger. I have a collection field of type List<String>
which I want to serialize as plain string and I have separate serializer for that. Jackson is doing its job well, but not schema generator. It resolves type of the field as object despite of explictly set attribute dataType
:
public class FilialDetails {
@ApiModelProperty(dataType = "string", example = "10000101010")
@JsonInclude(JsonInclude.Include.NON_NULL)
// custom serializer treats collection as subset of known, pre-populated list
// and serializes it as series of 0 and 1
@JsonSerialize(using = ServicesSerializer.class)
private List<String> services;
}
Generated properties definition (excerpt):
"properties": {
"services": {
"type": "object",
"example": 10000101010
}
}
I need string
in schema definition, not object
, how it's possible? I'm using io.springfox:springfox-boot-starter:3.0.0
in my project.
I had to specify fully qualified type name for string
@ApiModelProperty(dataType = "java.lang.String", example = "10000101010")
private List<String> services;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.