Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Security Schema by AutoConfigure #2780

Open
yuseok-kim-edushare opened this issue Nov 14, 2024 · 0 comments
Open

Add Security Schema by AutoConfigure #2780

yuseok-kim-edushare opened this issue Nov 14, 2024 · 0 comments

Comments

@yuseok-kim-edushare
Copy link

yuseok-kim-edushare commented Nov 14, 2024

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": []
        }
    ],
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant