0

我的 OpenAPI 配置

我需要将标头密钥从授权更改为 Authorization-internal

    @Bean
    public OpenAPI customOpenAPI(OpenApiConfig config) {
        return new OpenAPI().addSecurityItem(new SecurityRequirement().addList("security-schemes"))
            .components(new Components().addSecuritySchemes("security-schemes", securitySchema()))
            .info(new Info().title(config.getTitle()).contact(contact())
            .version(config.getAppVersion())
            .description(config.getDescription())
            .termsOfService("https://www.batata.com.br/site/")
            .license(new License().name("Banco - Batata 1.0").url("https://www.batata.com.br/site/")));
    }

    private Contact contact() {
        return new Contact().name("Banco Batata").url("https://www.batata.com.br/site/").email("developer@batata.com");
    }

    @Bean
    private SecurityScheme securitySchema() {
        return new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("bearer").bearerFormat("JWT")
                .in(SecurityScheme.In.HEADER).name("Authorization-internal");
    }

生成的图像

4

1 回答 1

0

OpenAPI 3 规范不允许显式添加授权标头。欲了解更多信息,请阅读:

Note: Header parameters named Accept, Content-Type and Authorization are not allowed. To describe these headers

https://swagger.io/docs/specification/describing-parameters/#header-parameters

于 2020-08-13T17:33:23.437 回答