How to inherit and use swagger’s schema annotation

27 Views Asked by At

I would like to inherit and use swagger’s schema annotation. For example, a swagger document is being created in the name field within a java class as shown below.

@Schema(title = "birthDay", example = "2001-01-01T00:00:00.000Z")
private LocalDateTime birth;

However, since many classes also use fields similar to birth, I don't want to code @Schema(title = "birthDay" ... every time.

How can I create a custom annotation @SchemaBirthDay

I would like to write birthDay and example = 2001-01-01 in the Swagger document.

Even though I created the @SchemaBirthDay annotation and declared @Schema, it is not written in the Swagger document.

My environment:

  • java 17
  • 'org.springframework.boot' version '3.2.3'
  • implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2'
0

There are 0 best solutions below