在 springdoc-openapi-ui 中启用授权按钮以进行基本身份验证
2022-09-03 13:37:52
如何在spredoc-openapi-ui(OpenAPI 3.0)中启用“授权”按钮进行基本身份验证。/swagger-ui.html
必须向 Spring 和类添加哪些注释?@Controller
@Configuration
如何在spredoc-openapi-ui(OpenAPI 3.0)中启用“授权”按钮进行基本身份验证。/swagger-ui.html
必须向 Spring 和类添加哪些注释?@Controller
@Configuration
使用 Bean 中的注释为 OpenAPI 3.0 定义全局安全方案:@io.swagger.v3.oas.annotations.security.SecurityScheme
@Configuration
@Configuration
@OpenAPIDefinition(info = @Info(title = "My API", version = "v1"))
@SecurityScheme(
name = "basicAuth",
type = SecuritySchemeType.HTTP,
scheme = "basic"
)
public class OpenApi30Config {
}
注释方式@RestController
@SecurityRequirement(name = "basicAuth")
@RestController
@SecurityRequirement(name = "basicAuth")
public class Controller {}
或
通过引用定义的安全方案来注释每个需要基本身份验证的方法:@RestController
@io.swagger.v3.oas.annotations.Operation
@Operation(summary = "My endpoint", security = @SecurityRequirement(name = "basicAuth"))