最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin2浏览0评论

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?

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论