I am developing a REST API with Spring, springfox, Jackson and my model class contains a ZoneId
as property:
@JsonProperty
private ZoneId timeZone;
I included jackson-datatype-jsr310 version 2.9.0.pr4 in my dependencies, so it is serializing and deserializing fine as expected. But my swagger-ui shows a lot of model objects like ZoneId
, ZoneOffset
, ZoneOffsetTransition
etc now which is very confusing since the zone ID is serialized as simple string. Same situation in generated API spec. How can I prevent swagger to expose these (unused) model objects?
You could try @ApiModelProperty
setting dataType
to string
:
@JsonProperty
@ApiModelProperty(dataType = "string")
private ZoneId timeZone;
If dataType
gets ignored, you can use Docket
:
@Bean
public Docket configureDocket() {
return new Docket(DocumentationType.SWAGGER_2)
.directModelSubstitute(ZoneId .class, String.class);
}