swagger - Micronaut:生成到请求正文中的身份验证主体

标签 swagger openapi micronaut

我正在尝试使用 swagger-codegen 从 Micronaut 服务器生成客户端代码。经过身份验证的 POST 和 PUT 路由会出现问题(对于 GET 和 DELETE 效果很好)。

当我在 Controller 中有这样的方法时:

@Override
@Post("/")
public Single<? extends HttpResponse> updateStatus(Authentication authentication, GameReference gameReference) {
    // ...
}

该方法的最终结果如下所示:

post:
  tags:
  - /presence
  description: Updates status
  operationId: updateStatus
  parameters: []
  requestBody:
    content:
      application/json:
        schema:
          type: object
          properties:
            authentication:
              $ref: '#/components/schemas/Authentication'
            gameReference:
              $ref: '#/components/schemas/GameReference'
    required: true
  responses:
    default:
      description: HTTP 204 for successful updates.
      content:
        application/json: {}

因此,身份验证主体已内置到请求正文中,并且在生成的客户端代码中,该方法的参数将是具有身份验证和 GameReference 的对象。

我尝试解决此问题的方法:

  • 在身份验证参数前添加@Parameter(hidden = true)。没有改变任何东西。
  • 使用 swagger 注释进行身份验证,例如 @SecuritySchema 和 @SecurityDeftion。身份验证原理仍然会生成到 swagger yaml 中。

这是 Micronauts Swagger 实现中的一个错误还是有办法解决这个问题?请注意,这对于 GET 和 DELETE 非常有效。验证原则被忽略。

最佳答案

关于swagger - Micronaut:生成到请求正文中的身份验证主体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54295894/

相关文章:

java - 在哪里放置 swagger 生成的服务器代码的代码

spring-mvc -/swagger-resources/configuration/ui 404 错误

swagger - flask restplus 路径变量默认值

swagger - 如何将 OpenAPI 2.0 转换为 OpenAPI 3.0?

validation - Swagger 3.0 架构错误 "should NOT have additional properties"

java - 有没有办法可以在 micronaut 中注入(inject)一个其构造函数具有参数的类?

java - 错误 : Classes that should be initialized at run time got initialized during image building: org. conscrypt.Conscrypt 被无意初始化

swagger - Swagger CodeGen Https SSL连接

java - QueryParam 在 Swagger API 中声明为不需要

swagger - 在 Micronaut 中设置 Swagger 配置