@Parameter(required = false) 不能大摇大摆地打开 api v3

@Parameter(required = false) not working in swagger open api v3

我的项目是 java spring boot 2 with maven 。我使用 springdoc-openapi-ui 依赖项。问题是 @Parameter(required = false) 不适用于我的 api 参数。

我不知道有多少 swagger 注释 Springdoc-openapi 支持,但根据 PetApiDemo/findByStatus 中的自己的示例或/findByTags 端点你可以通过应用 @RequestParam(required = false) 查看,这是一个 Spring 注释!一个参数已成为可选参数。

import org.springframework.web.bind.annotation.RequestParam;
default ResponseEntity<List<Pet>> findPetsByStatus(@Parameter(explode = Explode.TRUE, name = "status", in = ParameterIn.QUERY, description = "Status values that need to be considered for filter", style = ParameterStyle.FORM, schema = @Schema(type = "string", defaultValue = "available", allowableValues = { "available", "pending", "sold" })) @Valid @RequestParam(value = "status", required = false) List<String> status) {
    return getDelegate().findPetsByStatus(status);
}