Skip to content

Add Security Schema by AutoConfigure #2780

Closed
@yuseok-kim-edushare

Description

@yuseok-kim-edushare

Is your feature request related to a problem? Please describe.

  • When I'm Developing Spring Cloud based Microservices
  • then I meet Springdoc-Openapi-starter couldn't make OpenAPI with global security schemes in AutoConfiguration of Spring Boot's

Describe the solution you'd like

  • If We pre-defined global security scheme, in yaml or properties could be managed by Spring Cloud Config Server
springdoc:
  api-docs:
    path: /v3/api-docs
  swagger-ui:
    path: /swagger-ui.html
  security-schemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

like we already defined on config class and RESTcontroller

@Configuration
public class SwaggerConfig {

	@Bean
	public OpenAPI customOpenAPI() {
		return new OpenAPI().components(new Components()
			.addSecuritySchemes("basicScheme", new SecurityScheme()
				.type(SecurityScheme.Type.HTTP).bearerFormat("JWT").scheme("bearer")));
	}
}
---
@OpenAPIDefinition(security = @SecurityRequirement(name = "bearerScheme"))
@Slf4j
@RestController
@RequestMapping("/v1")
@RequiredArgsConstructor
public class ProfileRestController {
  • What is the expected result using OpenAPI Description (yml or json)?
    • like following json, springdoc-openapi automatic created api-doc will like following
{
    "openapi": "3.0.1",
    "servers": [
        {
            "url": "http://localhost:53646",
            "description": "Generated server url"
        }
    ],
    "security": [
        {
            "bearerScheme": []
        }
    ],

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions