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

时间:2019-01-21 18:30:21

标签: swagger openapi micronaut

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

当我在控制器中有这样的方法时:

@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)。没有任何改变。
  • 使用摇摇欲坠的批注进行身份验证,例如@SecuritySchema和@SecurityDefention。身份验证原则仍然会被广泛应用到Yaml中。

这是Micronauts Swagger实现中的错误还是有解决此问题的方法?请注意,这对于GET和DELETE效果很好。在那里,身份验证原理被忽略。

1 个答案:

答案 0 :(得分:0)

相关问题