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

java - How to put a custom annotation on path variable in openApi - Stack Overflow

programmeradmin0浏览0评论

In our project, we generate controllers with OpenAPI generator. In one of those controllers, there's an endpoint with a path variable, on which I need to put our custom annotation @Encrypted, like below:

@RequestMapping(
            method = RequestMethod.GET,
            value = "/notification/{id}/download",
            produces = { "application/pdf", "application/json" }
            )
ResponseEntity<.springframework.core.io.Resource> downloadNotification(
        @Size(max = 255)  @PathVariable("id") @Encrypted String id
            );

and this is specification. I tried x-field-extra-annotation:

/notification/{id}/download:
  get:
    parameters:
      - name: id
        schema:
          maxLength: 255
          type: string
        in: path
        required: true
        x-field-extra-annotation: "@sbbol.annotation.Encrypted"

However, OpenAPI ignores it, and I get an endpoint without my annotation:

ResponseEntity<.springframework.core.io.Resource> downloadNotification(
        @Size(max = 255)  @PathVariable("id") String id
            );

Is there a way to put a custom annotation on a path variable in OpenAPI?

发布评论

评论列表(0)

  1. 暂无评论