Documentation
¶
Overview ¶
Package openapi 管理当前进程启用的 OpenAPI 文档。
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterHTTP ¶
func RegisterHTTP(server *kratosHTTP.Server, registry *Registry, opts HTTPOptions)
RegisterHTTP 为注册表中的每份文档挂载原文接口和独立 Swagger UI。
Types ¶
type Document ¶
type Document struct {
// Key 是文档的稳定唯一标识。
Key string
// Name 是文档的展示名称。
Name string
// Data 是未经合并的 OpenAPI 文档内容。
Data []byte
}
Document 描述一份可独立访问的 OpenAPI 文档。
type HTTPOptions ¶
type HTTPOptions struct {
// DocumentPath 是原始 OpenAPI 文档的路由前缀。
DocumentPath string
// SwaggerPath 是 Swagger UI 的路由前缀。
SwaggerPath string
// Authorizer 校验原始文档请求,nil 表示允许访问。
Authorizer func(*stdhttp.Request) bool
}
HTTPOptions 配置 OpenAPI 原文和 Swagger UI 路由。
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry 保存 OpenAPI 文档及 HTTP 操作与文档的归属关系。
func NewRegistry ¶
NewRegistry 创建 OpenAPI 文档注册表。
func (*Registry) DocumentByOperation ¶
DocumentByOperation 根据 HTTP 路径和方法查询所属 OpenAPI 文档。
Click to show internal directories.
Click to hide internal directories.