我正在将Swagger(io.swagger.v3.oas.annotations
)与Micronaut结合使用,并且试图记录某种类型的数组作为端点的响应,但是它不起作用。
我的代码遵循Swagger 2.x文档,如下所示:
@Post(uri = '/compute', consumes = MediaType.APPLICATION_JSON)
@Operation(summary = "Get nodes")
@ApiResponse(responseCode = "200",
description = "You got it",
content = @Content(
mediaType = "application/json",
array = @ArraySchema(schema = @Schema(implementation = ActionableNodeDTO.class))
)
)
HttpResponse<List<ActionableNodeDTO>> getNodes(@Body List<NodeActionDTO> nodeActions) {
def actionableNodeDTOs = nodeActionIngestService.processBasic(nodeActions)
HttpResponse.ok(actionableNodeDTOs)
}
这是Groovy。我尝试使用ActionableNodeDTO
代替ActionableNodeDTO.class
,并且简单地将HttpResponse
作为函数返回类型,无济于事。
我得到的编译时警告是:
Error reading Swagger ApiResponses for element [io.micronaut.ast.groovy.visitor.GroovyMethodElement@e65e526]: Cannot construct instance of 'io.swagger.v3.oas.models.media.MediaType' (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value
我不确定该如何处理此消息。我在这里想念什么?