Documentation
¶
Index ¶
- Constants
- func DefaultSchemaNamer(t reflect.Type) string
- func TypeNullable(typ any, t ...reflect.Type) any
- type AddOperation
- type Components
- type Config
- type Info
- type MediaType
- type OpenAPI
- type Operation
- type Param
- type PathItem
- type RequestBody
- type Requirement
- type Response
- type Schema
- type SecurityScheme
- type Tag
Constants ¶
View Source
const ( TypeBoolean = "boolean" TypeInteger = "integer" TypeNumber = "number" TypeString = "string" TypeArray = "array" TypeObject = "object" )
JSON Schema 类型常量
View Source
const DocsHTML = `` /* 593-byte string literal not displayed */
View Source
const Version = "3.1.1"
Variables ¶
This section is empty.
Functions ¶
func DefaultSchemaNamer ¶
DefaultSchemaNamer 根据 “去域名 + 取最后两级” 策略生成名称
Types ¶
type AddOperation ¶
type AddOperation func(*Operation)
type Components ¶
type Components struct {
Schemas map[string]*Schema `yaml:"schemas,omitempty"`
SecuritySchemes map[string]*SecurityScheme `yaml:"securitySchemes,omitempty"`
}
type Config ¶
type Config struct {
// SchemaNamer 是一个函数,用于从 Go 类型生成其在 OpenAPI 组件中的唯一名称。
SchemaNamer func(t reflect.Type) string
}
Config 持有 OpenAPI 生成过程中的所有可配置策略。
type OpenAPI ¶
type OpenAPI struct {
OpenAPI string `yaml:"openapi"`
Info *Info `yaml:"info"`
Paths map[string]*PathItem `yaml:"paths,omitempty"`
Components *Components `yaml:"components"`
Security []Requirement `yaml:"security,omitempty"`
Tags []*Tag `yaml:"tags,omitempty"`
// contains filtered or unexported fields
}
type Operation ¶
type Operation struct {
Summary string `yaml:"summary,omitempty"`
Description string `yaml:"description,omitempty"`
Parameters []*Param `yaml:"parameters,omitempty"`
RequestBody *RequestBody `yaml:"requestBody,omitempty"`
Responses map[string]*Response `yaml:"responses,omitempty"`
Security []Requirement `yaml:"security,omitempty"`
Tags []string `yaml:"tags,omitempty"`
}
type PathItem ¶
type PathItem struct {
Ref string `yaml:"$ref,omitempty"`
Summary string `yaml:"summary,omitempty"`
Description string `yaml:"description,omitempty"`
Get *Operation `yaml:"get,omitempty"`
Put *Operation `yaml:"put,omitempty"`
Post *Operation `yaml:"post,omitempty"`
Delete *Operation `yaml:"delete,omitempty"`
Options *Operation `yaml:"options,omitempty"`
Head *Operation `yaml:"head,omitempty"`
Patch *Operation `yaml:"patch,omitempty"`
Trace *Operation `yaml:"trace,omitempty"`
Parameters []*Param `yaml:"parameters,omitempty"`
}
type RequestBody ¶
type Requirement ¶
type Schema ¶
type Schema struct {
Type any `yaml:"type,omitempty"`
Title string `yaml:"title,omitempty"`
Description string `yaml:"description,omitempty"`
Ref string `yaml:"$ref,omitempty"`
Format string `yaml:"format,omitempty"`
ContentEncoding string `yaml:"contentEncoding,omitempty"`
Default any `yaml:"default,omitempty"`
Items *Schema `yaml:"items,omitempty"` // For arrays
AdditionalProperties any `yaml:"additionalProperties,omitempty"` // Schema or bool
Properties map[string]*Schema `yaml:"properties,omitempty"`
Enum []any `yaml:"enum,omitempty"`
Required []string `yaml:"required,omitempty"`
}
type SecurityScheme ¶
type SecurityScheme struct {
Type string `yaml:"type"` // "http", "apiKey", "oauth2"
Description string `yaml:"description,omitempty"`
Name string `yaml:"name,omitempty"` // Header name for apiKey
In string `yaml:"in,omitempty"` // "header" for apiKey
Scheme string `yaml:"scheme,omitempty"` // "bearer" (for HTTP)
BearerFormat string `yaml:"bearerFormat,omitempty"` // "JWT" (for bearer)
}
Click to show internal directories.
Click to hide internal directories.