I am building RESTful Web services using Apache Camel (version 2.15.3), producing JSON output. Camel-swagger is used for API documentation.
There is a DTO which has a java.time.ZonedDateTime
field. Since that object can be very ugly in JSON, I applied a custom Serializer for that field. It looks like this in the DTO:
@JsonSerialize(using = ZonedDateTimeSerializer.class)
private ZonedDateTime created;
The ZonedDateTimeSerializer class is just creating a ZonedDateTimeVO class, which is my custom form of ZonedDateTime.
With this setup, swagger creates a model for my DTO with the ZonedDateTime property (type: $ref ZonedDateTime
). It also creates the models for ZonedDateTime and its field objects. This is not valid, since the endpoints are not returning a ZonedDateTime (but my custom representation). I'd like to tell swagger to create a model for my custom ZonedDateTimeVO class.
I tried so far: annotating the created
field in my DTO with @ApiModelProperty(dataType = "ZonedDateTimeVO")
annotation and adding @ApiModel
annotation to ZonedDateTimeVO class.
This way swagger creates a model for my DTO with property of ZonedDateTimeVO (type: $ref ZonedDateTimeVO), but it does not create a model for ZonedDateTimeVO itself. That is the problem actually, I cannot make swagger "scan" or "find" my custom type.
How should I do it?