最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

Document a field starting, available since a version with Swagger OpenAPIv3 with Java Spring Boot, - Stack Overflow

matteradmin3PV0评论

I have a POJO request which I am trying to document with swagger and openapiv3.

The code is straightforward:

@RestController
class ReportController {


  @GetMapping("/getReport")
  String getReport(@RequestBody Report report) {
record Report(
        @Schema(description = "Some field", minLength = 1, maxLength = 10) String somefield,
        String someFieldOnlyAvailableSinceVersion2) {
}

I am hoping to have an annotation, something like @Version("v2"), @Since("v2"), which can tell in the generated document page that the field is available only since version.

What I am trying so far is:

record Report(
        @Schema(description = "Some field", minLength = 1, maxLength = 10) String somefield,
        @Schema(description = "Some field only available since version 2", minLength = 1, maxLength = 5)String someFieldOnlyAvailableSinceVersion2) {
}

While there is some info displayed in the generated doc, I was hoping for an annotation that can mention the version since.

The question is not about validating the field with spring validation.

What would be the way to tell swagger openapiv3 the field is only available since a particular version?

Post a comment

comment list (0)

  1. No comments so far