簡體   English   中英

springdoc-openapi-ui生成的swagger-ui中如何更改請求header中授權key的名稱

[英]How to change the name of the authorization key in the request header in the swagger-ui generated by springdoc-openapi-ui

我的 OpenAPI 配置

我需要將 header 密鑰從授權更改為 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");
    }

生成的圖像

OpenAPI 3 規范不允許顯式添加授權 header。 欲了解更多信息,請閱讀:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM