How to set @ApiModelProperty dataType to String for Swagger documentation

后端 未结 3 734
[愿得一人]
[愿得一人] 2021-01-17 09:40

I am using Spring MVC (via Spring Boot) and have integrated Swagger API documentation using the swagger-spring-mvc library.

I have a class that looks something like

3条回答
  •  暖寄归人
    2021-01-17 09:57

    @ApiModel
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    public class Model {
        @JsonDeserialize(using = LocalDateTimeDeserializer.class)
        @JsonSerialize(using = LocalDateTimeSerializer.class)
        @JsonProperty("myDate")
        @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
        private final LocalDateTime myDateTime;
    
    }
    

提交回复
热议问题