【发布时间】:2020-05-17 07:21:02
【问题描述】:
我正在使用Spring Boot REST OpenAPI 3 规范。在此示例中,我希望在向每个端点发出请求时全局设置要传递的标头 (Custom-Header-Version=v1)。
现在的问题是我有 100 个 REST 端点,对于每个端点,我需要继续添加 @Parameter(in = ParameterIn.HEADER .....,这个配置,而不是我希望在全局范围内设置它。如果我们可以在 OpenAPI 中做到这一点,有什么办法吗?
有没有办法从 Spring doc ui 中删除 SmartBear 标志?
@RestController
@RequestMapping("/api")
@Tag(name = "contact", description = "the Contact API")
public class HelloController {
@Operation(summary = "Find Contacts by name", description = "Name search by %name% format", tags = {"contact"})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "successful operation", content = @Content(array = @ArraySchema(schema = @Schema(implementation = PersonDTO.class))))})
@Parameter(in = ParameterIn.HEADER, description = "Custom Header To be Pass", name = "Accept-version"
, content = @Content(schema = @Schema(type = "string", defaultValue = "v1", allowableValues = {"v1"}, implementation = PersonDTO.class)))
@GetMapping(value = "/contacts", headers = {"Custom-Header-Version=v1"})
public ResponseEntity<List<PersonDTO>> findAll(
@Parameter(description = "Page number, default is 1") @RequestParam(value = "page", defaultValue = "1") int pageNumber,
@Parameter(description = "Name of the contact for search.") @RequestParam(required = false) String name) {
return null;
}
}
【问题讨论】:
标签: spring spring-boot swagger springdoc