Documentation ¶
Overview ¶
Code generated by go-bindata. DO NOT EDIT. sources: internal/static/favicon.png internal/static/redoc.standalone.js internal/static/swagger-ui-bundle.js internal/static/swagger-ui.css
Index ¶
- Constants
- Variables
- func Asset(name string) ([]byte, error)
- func AssetDir(name string) ([]string, error)
- func AssetInfo(name string) (os.FileInfo, error)
- func AssetNames() []string
- func FastApiRoutePath(path string) string
- func GetDefaultV(tag reflect.StructTag, otype DataType) (v any)
- func IsArray(object any) bool
- func IsFieldRequired(tag reflect.StructTag) bool
- func MakeOauth2RedirectHtml() string
- func MakeRedocUiHtml(title, openapiUrl, jsUrl, faviconUrl string) string
- func MakeSwaggerUiHtml(title, openapiUrl, jsUrl, cssUrl, faviconUrl string) string
- func MustAsset(name string) []byte
- func QueryFieldTag(tag reflect.StructTag, label string, undefined string) string
- func QueryJsonName(tag reflect.StructTag, undefined string) string
- func ReflectObjectType(obj any) reflect.Type
- func RestoreAsset(dir, name string) error
- func RestoreAssets(dir, name string) error
- func StringsToFloats(strs []string) []float64
- func StringsToInts(strs []string) []int
- type ArgsType
- type BaseModel
- func (b *BaseModel) ID() string
- func (b *BaseModel) IsRequired() bool
- func (b *BaseModel) Metadata() (*Metadata, error)
- func (b *BaseModel) Schema() (m map[string]any)
- func (b *BaseModel) SchemaDesc() string
- func (b *BaseModel) SchemaName(exclude ...bool) string
- func (b *BaseModel) SchemaType() DataType
- type ComponentScheme
- type Components
- type Contact
- type DataType
- type Field
- func (f *Field) InnerSchema() (m map[string]map[string]any)
- func (f *Field) IsArray() bool
- func (f *Field) IsRequired() bool
- func (f *Field) Metadata() (*Metadata, error)
- func (f *Field) Schema() (m map[string]any)
- func (f *Field) SchemaDesc() string
- func (f *Field) SchemaName(exclude ...bool) string
- func (f *Field) SchemaType() DataType
- func (f *Field) SetId(id string)
- type HTTPValidationError
- func (v *HTTPValidationError) Error() string
- func (v *HTTPValidationError) Schema() map[string]any
- func (v *HTTPValidationError) SchemaDesc() string
- func (v *HTTPValidationError) SchemaName(exclude ...bool) string
- func (v *HTTPValidationError) SchemaType() DataType
- func (v *HTTPValidationError) String() string
- type Info
- type License
- type MetaCache
- type MetaField
- type Metadata
- func (m *Metadata) AddField(field *MetaField, depth int)
- func (m *Metadata) Fields() []*MetaField
- func (m *Metadata) FromModel(model SchemaIface)
- func (m *Metadata) FromReflectType(rt reflect.Type)
- func (m *Metadata) Id() string
- func (m *Metadata) InnerFields() []*MetaField
- func (m *Metadata) IsRequired() bool
- func (m *Metadata) Metadata() (*Metadata, error)
- func (m *Metadata) Name() string
- func (m *Metadata) ReflectType() reflect.Type
- func (m *Metadata) Schema() map[string]any
- func (m *Metadata) SchemaDesc() string
- func (m *Metadata) SchemaName(exclude ...bool) string
- func (m *Metadata) SchemaType() DataType
- func (m *Metadata) String() string
- type ModelContentSchema
- type OpenApi
- type Operation
- type Parameter
- type ParameterBase
- type ParameterInType
- type ParameterSchema
- type PathItem
- type PathModelContent
- type Paths
- type QModel
- func (q *QModel) InnerSchema() (m map[string]map[string]any)
- func (q *QModel) IsRequired() bool
- func (q *QModel) Metadata() (*Metadata, error)
- func (q *QModel) Schema() (m map[string]any)
- func (q *QModel) SchemaDesc() string
- func (q *QModel) SchemaName(exclude ...bool) string
- func (q *QModel) SchemaType() DataType
- func (q *QModel) SetId(id string)
- type QueryModel
- type QueryParameter
- type Reference
- type RequestBody
- type Response
- type SchemaIface
- type ValidationError
Constants ¶
const ( ValidationErrorName string = "ValidationError" HttpValidationErrorName string = "HTTPValidationError" )
const ( SwaggerCssName = "swagger-ui.css" FaviconName = "favicon.png" FaviconIcoName = "favicon.ico" SwaggerJsName = "swagger-ui-bundle.js" RedocJsName = "redoc.standalone.js" JsonUrl = "openapi.json" SwaggerFaviconUrl = "https://fastapi.tiangolo.com/img/" + FaviconName SwaggerCssUrl = "https://cdn.jsdelivr.net/npm/swagger-ui-dist@5/" + SwaggerCssName SwaggerJsUrl = "https://cdn.jsdelivr.net/npm/swagger-ui-dist@5/" + SwaggerJsName RedocJsUrl = "https://cdn.jsdelivr.net/npm/redoc@next/bundles/" + RedocJsName )
用于swagger的一些静态文件,来自FastApi
const ( PathParamPrefix = ":" // 路径参数起始字符 PathSeparator = "/" // 路径分隔符 OptionalPathParamSuffix = "?" // 可选路径参数结束字符 )
const ( MIMETextXML string = "text/xml" MIMETextHTML string = "text/html" MIMETextPlain string = "text/plain" MIMETextCSS string = "text/css" MIMETextJavaScript string = "text/javascript" MIMEApplicationXML string = "application/xml" MIMEApplicationJSON string = "application/json" MIMEApplicationForm string = "application/x-www-form-urlencoded" MIMEOctetStream string = "application/octet-stream" MIMEMultipartForm string = "multipart/form-data" MIMETextXMLCharsetUTF8 string = "text/xml; charset=utf-8" MIMETextHTMLCharsetUTF8 string = "text/html; charset=utf-8" MIMETextPlainCharsetUTF8 string = "text/plain; charset=utf-8" MIMETextCSSCharsetUTF8 string = "text/css; charset=utf-8" MIMETextJavaScriptCharsetUTF8 string = "text/javascript; charset=utf-8" MIMEApplicationXMLCharsetUTF8 string = "application/xml; charset=utf-8" MIMEApplicationJSONCharsetUTF8 string = "application/json; charset=utf-8" )
const ( RefName = "$ref" RefPrefix = "#/components/schemas/" ArrayTypePrefix = "ArrayOf" // 对于数组类型,关联到一个新模型 InnerModelNamePrefix = "fastapi." )
const AnonymousModelNameConnector = "_"
AnonymousModelNameConnector 为匿名结构体生成一个名称, 连接符
const ApiVersion = "3.1.0"
const HeaderContentType = "Content-Type"
Variables ¶
var ( Int8 = makeMetadata( "Int8", "8位有符号的数字类型", `json:"int8" gte:"-128" lte:"127"`, IntegerType, ) Int16 = makeMetadata( "Int16", "16位有符号的数字类型", `json:"int16" gte:"-32768" lte:"32767"`, IntegerType, ) Int32 = makeMetadata( "Int32", "32位有符号的数字类型", `json:"int32" gte:"-2147483648" lte:"2147483647"`, IntegerType, ) Int64 = makeMetadata( "Int64", "64位有符号的数字类型", `json:"int64" gte:"-9223372036854775808" lte:"9223372036854775807"`, IntegerType, ) Int = makeMetadata( "Int", "有符号的数字类型", `json:"int" gte:"-9223372036854775808" lte:"9223372036854775807"`, IntegerType, ) Uint8 = makeMetadata( "Uint8", "8位无符号的数字类型", `json:"uint8" gte:"0" lte:"255"`, IntegerType, ) Uint16 = makeMetadata( "Uint16", "16位无符号的数字类型", `json:"uint16" gte:"0" lte:"65535"`, IntegerType, ) Uint32 = makeMetadata( "Uint32", "32位无符号的数字类型", `json:"uint32" gte:"0" lte:"4294967295"`, IntegerType, ) Uint64 = makeMetadata( "Uint64", "64位无符号的数字类型", `json:"uint64" gte:"0" lte:"18446744073709551615"`, IntegerType, ) Float32 = makeMetadata( "Float32", "32位的浮点类型", `json:"float32"`, NumberType, ) Float64 = makeMetadata( "Float64", "64位的浮点类型", `json:"float64"`, NumberType, ) Float = makeMetadata( "Float", "64位的浮点类型", `json:"float"`, NumberType, ) String = makeMetadata( "String", "字符串类型", `json:"string" min:"0" max:"255"`, StringType, ) Bool = makeMetadata( "Bool", "布尔类型", `json:"boolean" oneof:"true false"`, BoolType, ) )
var Resp422 = &Response{ StatusCode: http.StatusUnprocessableEntity, Description: http.StatusText(http.StatusUnprocessableEntity), Content: &PathModelContent{ MIMEType: MIMEApplicationJSON, Schema: &ValidationError{}, }, }
var ValidationErrorDefinition = &ValidationError{}
ValidationErrorDefinition 422 表单验证错误模型
var ValidationErrorResponseDefinition = &HTTPValidationError{}
ValidationErrorResponseDefinition 请求体相应体错误消息
Functions ¶
func Asset ¶
Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.
func AssetDir ¶
AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:
data/ foo.txt img/ a.png b.png
then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.
func AssetInfo ¶
AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.
func FastApiRoutePath ¶
FastApiRoutePath 将 fiber.App 格式的路径转换成 FastApi 格式的路径
Example: 必选路径参数: Input: "/api/rcst/:no" Output: "/api/rcst/{no}" 可选路径参数: Input: "/api/rcst/:no?" Output: "/api/rcst/{no}" 常规路径: Input: "/api/rcst/no" Output: "/api/rcst/no"
func GetDefaultV ¶ added in v0.1.5
GetDefaultV 从Tag中提取字段默认值
func IsFieldRequired ¶ added in v0.1.5
IsFieldRequired 从tag中判断此字段是否是必须的
func MakeOauth2RedirectHtml ¶
func MakeOauth2RedirectHtml() string
func MakeRedocUiHtml ¶
func MakeSwaggerUiHtml ¶
func MustAsset ¶
MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.
func QueryFieldTag ¶ added in v0.1.5
QueryFieldTag 查找struct字段的Tag
@param tag reflect.StructTag 字段的Tag @param label string 要查找的标签 @param undefined string 当查找的标签不存在时返回的默认值 @return string 查找到的标签值, 不存在则返回提供的默认值
func QueryJsonName ¶ added in v0.1.5
QueryJsonName 查询字段定义的json名称
func ReflectObjectType ¶ added in v0.1.5
ReflectObjectType 获取任意对象的类型,若为指针,则反射具体的类型
func RestoreAsset ¶
RestoreAsset restores an asset under the given directory
func RestoreAssets ¶
RestoreAssets restores an asset under the given directory recursively
func StringsToFloats ¶ added in v0.1.5
StringsToFloats 将字符串数组转换成float64数组, 简单实现
@param strs []string 输入字符串数组 @return []float64 输出float64数组
func StringsToInts ¶ added in v0.1.5
StringsToInts 将字符串数组转换成int数组, 简单实现
@param strs []string 输入字符串数组 @return []int 输出int数组
Types ¶
type ArgsType ¶ added in v0.1.5
type ArgsType struct {
// contains filtered or unexported fields
}
func (ArgsType) IsAnonymousStruct ¶ added in v0.1.5
type BaseModel ¶ added in v0.1.5
type BaseModel struct{}
BaseModel 基本数据模型, 对于上层的 app.Route 其请求和相应体都应为继承此结构体的结构体 在 OpenApi 文档模型中,此模型的类型始终为 "object"; 对于 BaseModel 其字段仍然可能会 BaseModel
func (*BaseModel) IsRequired ¶ added in v0.1.5
func (*BaseModel) Schema ¶ added in v0.1.5
Schema 输出为OpenAPI文档模型,字典格式
{ "title": "examle.MyTimeslot", "type": "object" "description": "examle.mytimeslot", "required": [], "properties": { "control_timeslot": { "title": "control_timeslot", "type": "array" "description": "控制时隙编号数组", "required": false, "items": { "type": "integer" }, }, "superframe_count": { "title": "superframe_count", "type": "integer" "description": "超帧计数", "required": false, }, }, },
func (*BaseModel) SchemaDesc ¶ added in v0.1.5
SchemaDesc 结构体文档注释
func (*BaseModel) SchemaName ¶ added in v0.1.5
SchemaName 获取结构体的名称,默认包含包名
@param exclude []bool 是否排除包名LL
func (*BaseModel) SchemaType ¶ added in v0.1.5
SchemaType 模型类型
type ComponentScheme ¶
type ComponentScheme struct { Model *Metadata `json:"model" description:"模型定义"` Name string `json:"name" description:"模型名称,包含包名"` }
ComponentScheme openapi 的模型文档部分
type Components ¶
type Components struct {
Scheme []*ComponentScheme `json:"scheme" description:"模型文档"`
}
Components openapi 的模型部分 需要重写序列化方法
func (*Components) MarshalJSON ¶
func (c *Components) MarshalJSON() ([]byte, error)
MarshalJSON 重载序列化方法
type Contact ¶
type Contact struct { Name string `json:"name" description:"姓名/名称"` Url string `json:"url" description:"链接"` Email string `json:"email" description:"联系方式"` }
Contact 联系方式, 显示在 info 字段内部 无需重写序列化方法
type DataType ¶ added in v0.1.5
type DataType string
func ReflectKindToOType ¶ added in v0.1.5
ReflectKindToOType 转换reflect.Kind为swagger类型说明
@param ReflectKind reflect.Kind 反射类型
type Field ¶ added in v0.1.5
type Field struct { Title string `json:"title,omitempty" description:"字段名称"` Type DataType `json:"type,omitempty" description:"openapi 数据类型"` Tag reflect.StructTag `json:"tag" description:"字段标签"` Description string `json:"description,omitempty" description:"说明"` ItemRef string `description:"子元素类型, 仅Type=array/object时有效"` // contains filtered or unexported fields }
Field 基本数据模型, 此模型不可再分, 同时也是 BaseModel 的字段类型 但此类型不再递归记录,仅记录一个关联模型为基本
func (*Field) InnerSchema ¶ added in v0.1.5
InnerSchema 内部字段模型文档, 全名:文档
func (*Field) Schema ¶ added in v0.1.5
Schema 生成字段的详细描述信息
// 字段为结构体类型 "position_sat": { "title": "position_sat", "type": "object" "description": "position_sat", "required": false, "$ref": "#/comonents/schemas/example.PositionGeo", } // 字段为数组类型, 数组元素为基本类型 "traffic_timeslot": { "title": "traffic_timeslot", "type": "array" "description": "业务时隙编号数组", "required": false, "items": { "type": "integer" }, } // 字段为数组类型, 数组元素为自定义结构体类型 "Detail": { "title": "Detail", "type": "array" "description": "Detail", "required": true, "items": { "$ref": "#/comonents/schemas/ValidationError" }, }
func (*Field) SchemaName ¶ added in v0.1.5
SchemaName swagger文档字段名
type HTTPValidationError ¶ added in v0.1.5
type HTTPValidationError struct { BaseModel Detail []*ValidationError `json:"detail" description:"Detail" binding:"required"` }
func (*HTTPValidationError) Error ¶ added in v0.1.5
func (v *HTTPValidationError) Error() string
func (*HTTPValidationError) Schema ¶ added in v0.1.5
func (v *HTTPValidationError) Schema() map[string]any
func (*HTTPValidationError) SchemaDesc ¶ added in v0.1.5
func (v *HTTPValidationError) SchemaDesc() string
func (*HTTPValidationError) SchemaName ¶ added in v0.1.5
func (v *HTTPValidationError) SchemaName(exclude ...bool) string
func (*HTTPValidationError) SchemaType ¶ added in v0.1.5
func (v *HTTPValidationError) SchemaType() DataType
func (*HTTPValidationError) String ¶ added in v0.1.5
func (v *HTTPValidationError) String() string
type Info ¶
type Info struct { Title string `json:"title" description:"显示在文档顶部的标题"` Version string `json:"version" description:"显示在标题右上角的程序版本号"` Description string `json:"description,omitempty" description:"显示在标题下方的说明"` Contact Contact `json:"contact,omitempty" description:"联系方式"` License License `json:"license,omitempty" description:"许可证"` TermsOfService string `json:"termsOfService,omitempty" description:"服务条款(不常用)"` }
Info 文档说明信息 无需重写序列化方法
type License ¶
type License struct { Name string `json:"name" description:"名称"` Url string `json:"url" description:"链接"` }
License 权利证书, 显示在 info 字段内部 无需重写序列化方法
type MetaCache ¶ added in v0.1.5
type MetaCache struct {
// contains filtered or unexported fields
}
MetaCache Metadata 缓存
type MetaField ¶ added in v0.1.5
type MetaField struct { Field Exported bool `description:"是否是导出字段"` Anonymous bool `description:"是否是嵌入字段"` // contains filtered or unexported fields }
MetaField 模型的字段元数据,可以与 Metadata 互相转换
func (*MetaField) ToMetadata ¶ added in v0.1.5
ToMetadata 是否仍然是个基本模型
type Metadata ¶ added in v0.1.5
type Metadata struct {
// contains filtered or unexported fields
}
Metadata 数据模型 BaseModel 的元信息
func BaseModelToMetadata ¶ added in v0.1.5
func BaseModelToMetadata(model SchemaIface) *Metadata
BaseModelToMetadata 提取基本数据模型的元信息
@param model SchemaIface 基本数据模型 @return *Metadata 基本数据模型的元信息
func List ¶ added in v0.1.5
func List(model SchemaIface) *Metadata
func (*Metadata) FromModel ¶ added in v0.1.5
func (m *Metadata) FromModel(model SchemaIface)
FromModel 从模型构造元数据,仅支持结构体
func (*Metadata) FromReflectType ¶ added in v0.1.5
FromReflectType 从反射类型种构造元数据
func (*Metadata) InnerFields ¶ added in v0.1.5
InnerFields 内部字段
func (*Metadata) IsRequired ¶ added in v0.1.5
func (*Metadata) ReflectType ¶ added in v0.1.5
func (*Metadata) Schema ¶ added in v0.1.5
Schema 输出为OpenAPI文档模型,字典格式 数组类型: 需要单独处理, 取其 fields 的第一个元素作为子资源素的实际类型 基本数据类型:取其 fields 的第一个元素, description同样取fields 的第一个元素 结构体类型: 需处理全部的 fields 和 innerFields
func (*Metadata) SchemaDesc ¶ added in v0.1.5
SchemaDesc 结构体文档注释
func (*Metadata) SchemaName ¶ added in v0.1.5
SchemaName 获取结构体的名称,默认包含包名
func (*Metadata) SchemaType ¶ added in v0.1.5
SchemaType 模型类型
type ModelContentSchema ¶
type OpenApi ¶
type OpenApi struct { Info *Info `json:"info,omitempty" description:"联系信息"` Components *Components `json:"components" description:"模型文档"` Paths *Paths `json:"paths" description:"路由列表,同一路由存在多个方法文档"` Version string `json:"openapi" description:"Open API版本号"` // contains filtered or unexported fields }
OpenApi 模型类, 移除 FastApi 中不常用的属性
func NewOpenApi ¶
NewOpenApi 构造一个新的 OpenApi 文档
func (*OpenApi) AddDefinition ¶
AddDefinition 添加一个模型文档
func (*OpenApi) QueryPathItem ¶
QueryPathItem 查询路由对象, 不存在则新建
type Operation ¶
type Operation struct { Tags []string `json:"tags,omitempty" description:"路由标签"` Summary string `json:"summary,omitempty" description:"摘要描述"` Description string `json:"description,omitempty" description:"说明"` OperationId string `json:"operationId,omitempty" description:"唯一ID"` // no use, keep // 路径参数和查询参数, 对于路径相同,方法不同的路由来说,其查询参数可以不一样,但其路径参数都是一样的 Parameters []*Parameter `json:"parameters,omitempty" description:"路径参数和查询参数"` // 请求体,通过 MakeOperationRequestBody 构建 RequestBody *RequestBody `json:"requestBody,omitempty" description:"请求体"` // 响应文档,对于任一个路由,均包含2个响应实例:200 + 422, 通过函数 MakeOperationResponses 构建 Responses []*Response `json:"responses,omitempty" description:"响应体"` Deprecated bool `json:"deprecated,omitempty" description:"是否禁用"` }
Operation 路由HTTP方法: Get/Post/Patch/Delete 等操作方法
func (*Operation) MarshalJSON ¶
MarshalJSON 重写序列化方法,修改 Responses 和 RequestBody 字段
type Parameter ¶
type Parameter struct { Default any `json:"default,omitempty" description:"默认值"` Schema *ParameterSchema `json:"schema,omitempty" description:"字段模型"` ParameterBase }
Parameter 路径参数或者查询参数
func QModelToParameter ¶
type ParameterBase ¶
type ParameterBase struct { Name string `json:"name" description:"名称"` Description string `json:"description,omitempty" description:"说明"` In ParameterInType `json:"in" description:"参数位置"` Required bool `json:"required" description:"是否必须"` Deprecated bool `json:"deprecated" description:"是否禁用"` }
ParameterBase 各种参数的基类
type ParameterInType ¶
type ParameterInType string
const ( InQuery ParameterInType = "query" InHeader ParameterInType = "header" InPath ParameterInType = "path" InCookie ParameterInType = "cookie" )
type ParameterSchema ¶
type PathItem ¶
type PathItem struct { Get *Operation `json:"get,omitempty" description:"GET方法"` Put *Operation `json:"put,omitempty" description:"PUT方法"` Post *Operation `json:"post,omitempty" description:"POST方法"` Patch *Operation `json:"patch,omitempty" description:"PATCH方法"` Delete *Operation `json:"delete,omitempty" description:"DELETE方法"` Head *Operation `json:"head,omitempty" description:"header方法"` Trace *Operation `json:"trace,omitempty" description:"trace方法"` Path string `json:"-" description:"请求绝对路径"` }
PathItem 路由选项,由于同一个路由可以存在不同的操作方法,因此此选项可以存在多个 Operation
type PathModelContent ¶
type PathModelContent struct { Schema ModelContentSchema `json:"schema" description:"模型引用文档"` MIMEType string `json:"-"` }
PathModelContent 路由中请求体 RequestBody 和 响应体中返回值 Responses 模型
func (*PathModelContent) MarshalJSON ¶
func (p *PathModelContent) MarshalJSON() ([]byte, error)
MarshalJSON 自定义序列化
type QModel ¶ added in v0.1.5
type QModel struct { Title string `json:"title,omitempty" description:"字段标题"` Name string `json:"name,omitempty" description:"字段名称"` Tag reflect.StructTag `json:"tag,omitempty" description:"TAG"` Type DataType `json:"otype,omitempty" description:"openapi 数据类型"` InPath bool `json:"in_path,omitempty" description:"是否是路径参数"` }
QModel 查询参数或路径参数模型, 此类型会进一步转换为 openapi.Parameter
func ParseToQueryModels ¶ added in v0.1.5
func ParseToQueryModels(q QueryParameter) []*QModel
ParseToQueryModels 将一个结构体转换为 QueryModel
func (*QModel) InnerSchema ¶ added in v0.1.5
InnerSchema 内部字段模型文档, 全名:文档
func (*QModel) Schema ¶ added in v0.1.5
Schema 输出为OpenAPI文档模型,字典格式
{ "required": true, "schema": { "title": "names", "type": "string", "default": "jack" }, "name": "names", "in": "query"/"path" }
func (*QModel) SchemaName ¶ added in v0.1.5
SchemaName 获取名称,以json字段为准
type QueryModel ¶ added in v0.1.5
type QueryModel struct{}
QueryModel 查询参数基类
func (*QueryModel) Fields ¶ added in v0.1.5
func (q *QueryModel) Fields() []*QModel
type QueryParameter ¶ added in v0.1.5
type QueryParameter interface { }
type Reference ¶
type Reference struct { // 关联模型, 取值为 openapi.RefPrefix + modelName Name string `json:"-" description:"关联模型"` }
Reference 引用模型,用于模型字段和路由之间互相引用
func (*Reference) MarshalJSON ¶
type RequestBody ¶
type RequestBody struct { Content *PathModelContent `json:"content,omitempty" description:"请求体模型"` Required bool `json:"required" description:"是否必须"` }
RequestBody 路由 请求体模型文档
func MakeOperationRequestBody ¶
func MakeOperationRequestBody(model *Metadata) *RequestBody
MakeOperationRequestBody 将路由中的 *openapi.Metadata 转换成 openapi 的请求体 RequestBody
type Response ¶
type Response struct { Content *PathModelContent `json:"content" description:"返回值模型"` Description string `json:"description,omitempty" description:"说明"` StatusCode int `json:"-" description:"状态码"` }
Response 路由返回体,包含了返回状态码,状态码说明和返回值模型
func MakeOperationResponses ¶
MakeOperationResponses 将路由中的 *openapi.Metadata 转换成 openapi 的返回体 []*Response
type SchemaIface ¶ added in v0.1.5
type SchemaIface interface { // Schema 输出为OpenAPI文档模型,字典格式 Schema() (m map[string]any) // SchemaName 获取结构体的名称,默认包含包名 SchemaName(exclude ...bool) string // SchemaDesc 结构体文档注释 SchemaDesc() string // SchemaType 模型类型 SchemaType() DataType // IsRequired 字段是否必须 IsRequired() bool // Metadata 获取反射后的字段元信息, 允许上层处理 Metadata() (*Metadata, error) }
type ValidationError ¶ added in v0.1.5
type ValidationError struct { BaseModel Ctx map[string]any `json:"service" description:"Service"` Msg string `json:"msg" description:"Message" binding:"required"` Type string `json:"type" description:"Error Type" binding:"required"` Loc []string `json:"loc" description:"Location" binding:"required"` }
ValidationError 参数校验错误
func (*ValidationError) Error ¶ added in v0.1.5
func (v *ValidationError) Error() string
func (*ValidationError) Schema ¶ added in v0.1.5
func (v *ValidationError) Schema() (m map[string]any)
func (*ValidationError) SchemaDesc ¶ added in v0.1.5
func (v *ValidationError) SchemaDesc() string
func (*ValidationError) SchemaName ¶ added in v0.1.5
func (v *ValidationError) SchemaName(exclude ...bool) string
func (*ValidationError) SchemaType ¶ added in v0.1.5
func (v *ValidationError) SchemaType() DataType