Documentation
¶
Overview ¶
包 goai 实现并提供针对 OpenApi 规范的文档生成。
https://editor.swagger.io/ md5:cb37ff4d3e18479e
Index ¶
- Constants
- type AddInput
- type Callback
- type CallbackRef
- type Callbacks
- type Components
- type Config
- type Contact
- type Content
- type Discriminator
- type Encoding
- type Example
- type ExampleRef
- type Examples
- type ExternalDocs
- type Header
- type HeaderRef
- type Headers
- type Info
- type License
- type Link
- type LinkRef
- type Links
- type MediaType
- type OAuthFlow
- type OAuthFlows
- type OpenApiV3
- type Operation
- type Parameter
- type ParameterRef
- type Parameters
- type ParametersMap
- type Path
- type Paths
- type RequestBodies
- type RequestBody
- type RequestBodyRef
- type Response
- type ResponseRef
- type Responses
- type Schema
- type SchemaRef
- type SchemaRefs
- type Schemas
- func (s *Schemas) Clone() Schemas
- func (s *Schemas) Get(name string) *SchemaRef
- func (s *Schemas) Map() map[string]SchemaRef
- func (s Schemas) MarshalJSON() ([]byte, error)
- func (s *Schemas) Removes(names []interface{})
- func (s *Schemas) X设置值(name string, ref SchemaRef)
- func (s *Schemas) X遍历(f func(key string, ref SchemaRef) bool)
- type SecurityRequirement
- type SecurityRequirements
- type SecurityScheme
- type SecuritySchemeRef
- type SecuritySchemes
- type Server
- type ServerVariable
- type Servers
- type Tag
- type Tags
- type XExtensions
Constants ¶
const ( TypeInteger = `integer` TypeNumber = `number` TypeBoolean = `boolean` TypeArray = `array` TypeString = `string` TypeFile = `file` TypeObject = `object` FormatInt32 = `int32` FormatInt64 = `int64` FormatDouble = `double` FormatByte = `byte` FormatBinary = `binary` FormatDate = `date` FormatDateTime = `date-time` FormatPassword = `password` )
const ( ParameterInHeader = `header` ParameterInPath = `path` ParameterInQuery = `query` ParameterInCookie = `cookie` )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddInput ¶
type AddInput struct {
Path string // Path 如果在结构体标签的Meta中没有配置自定义路径,那么它会指定该路径。 md5:8948516e136d8d65
Prefix string // Prefix 指定自定义的路由路径前缀,它将与结构标签中 Meta 的 path 标签结合使用。 md5:e1653a4036580c9c
Method string // Method 指定了自定义的 HTTP 方法,如果这个没有在结构体标签的 Meta 中配置。 md5:2d3c92a67e5a1f3a
Object interface{} // "Object"可以是一个结构体实例或路由函数。 md5:f828ebcbf7a4f386
}
AddInput 是 OpenApiV3.Add 函数的结构化参数。 md5:0f162b41efe0b3d5
type CallbackRef ¶
func (CallbackRef) MarshalJSON ¶
func (r CallbackRef) MarshalJSON() ([]byte, error)
type Callbacks ¶
type Callbacks map[string]*CallbackRef
type Components ¶
type Components struct {
Schemas Schemas `json:"schemas,omitempty"`
Parameters ParametersMap `json:"parameters,omitempty"`
Headers Headers `json:"headers,omitempty"`
RequestBodies RequestBodies `json:"requestBodies,omitempty"`
Responses Responses `json:"responses,omitempty"`
SecuritySchemes SecuritySchemes `json:"securitySchemes,omitempty"`
Examples Examples `json:"examples,omitempty"`
Links Links `json:"links,omitempty"`
Callbacks Callbacks `json:"callbacks,omitempty"`
}
Components是根据OpenAPI/Swagger标准版本3.0指定的。 md5:ac796372f37158be
type Config ¶
type Config struct {
ReadContentTypes []string // ReadContentTypes 指定了在未配置 MIME 类型时的默认消费 MIME 类型。 md5:a693e149658e6922
WriteContentTypes []string // WriteContentTypes 指定如果没有配置 MIME 类型,则用于生成的默认 MIME 类型。 md5:08e1c2c9661386cb
CommonRequest interface{} // 所有路径的常见请求结构。 md5:abc50dd97166429e
CommonRequestDataField string // 通用请求字段名,将被替换为特定业务请求结构。例如:`Data`、`Request`。 md5:91f6acb0ea17d306
CommonResponse interface{} // 所有路径的通用响应结构。 md5:1b61004412fdcd06
CommonResponseDataField string // 要替换为特定业务响应结构的常见响应字段名称,例如:`Data`、`Response.`。 md5:bb674debcf674e63
IgnorePkgPath bool // 忽略包名,使用schema名称。 md5:d3c2c4cc40dd7ee2
}
Config 为 OpenApiV3 实现提供了额外的配置功能。 md5:094e64f2ea1fb1e8
type Contact ¶
type Contact struct {
Name string `json:"name,omitempty"`
URL string `json:"url,omitempty"`
Email string `json:"email,omitempty"`
}
Contact 是根据 OpenAPI/Swagger 标准版本3.0规定的。 md5:604c32a512535948
type Discriminator ¶
type Discriminator struct {
PropertyName string `json:"propertyName"`
Mapping map[string]string `json:"mapping,omitempty"`
}
Discriminator是根据OpenAPI/Swagger标准版本3.0指定的。 md5:7587308535782993
type Encoding ¶
type Encoding struct {
ContentType string `json:"contentType,omitempty"`
Headers Headers `json:"headers,omitempty"`
Style string `json:"style,omitempty"`
Explode *bool `json:"explode,omitempty"`
AllowReserved bool `json:"allowReserved,omitempty"`
}
Encoding 按照 OpenAPI/Swagger 3.0 标准指定。 md5:f20471879db70e3a
type Example ¶
type Example struct {
Summary string `json:"summary,omitempty"`
Description string `json:"description,omitempty"`
Value interface{} `json:"value,omitempty"`
ExternalValue string `json:"externalValue,omitempty"`
}
Example 是由 OpenAPI/Swagger 3.0 标准指定的。 md5:fcd88edc2f1e687d
type ExampleRef ¶
func (ExampleRef) MarshalJSON ¶
func (r ExampleRef) MarshalJSON() ([]byte, error)
type Examples ¶
type Examples map[string]*ExampleRef
type ExternalDocs ¶
type ExternalDocs struct {
URL string `json:"url,omitempty"`
Description string `json:"description,omitempty"`
}
ExternalDocs 是由 OpenAPI/Swagger 标准版本 3.0 定义的。 md5:351fbd5301af5e56
func (*ExternalDocs) UnmarshalValue ¶
func (ed *ExternalDocs) UnmarshalValue(value interface{}) error
type Header ¶
type Header struct {
Parameter
}
Header遵循OpenAPI/Swagger 3.0标准。 参见:https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.0.md#headerObject md5:df7c9f506710dc39
type HeaderRef ¶
func (HeaderRef) MarshalJSON ¶
type Info ¶
type Info struct {
Title string `json:"title"`
Description string `json:"description,omitempty"`
TermsOfService string `json:"termsOfService,omitempty"`
Contact *Contact `json:"contact,omitempty"`
License *License `json:"license,omitempty"`
Version string `json:"version"`
}
Info是根据OpenAPI/Swagger标准版本3.0定义的。 md5:5426a3817852daba
type Link ¶
type Link struct {
OperationID string `json:"operationId,omitempty"`
OperationRef string `json:"operationRef,omitempty"`
Description string `json:"description,omitempty"`
Parameters map[string]interface{} `json:"parameters,omitempty"`
Server *Server `json:"server,omitempty"`
RequestBody interface{} `json:"requestBody,omitempty"`
}
Link 是由OpenAPI/Swagger标准版本3.0定义的。 md5:7e7a4f467c0cd7ed
type LinkRef ¶
func (LinkRef) MarshalJSON ¶
type MediaType ¶
type MediaType struct {
Schema *SchemaRef `json:"schema,omitempty"`
Example interface{} `json:"example,omitempty"`
Examples Examples `json:"examples,omitempty"`
Encoding map[string]*Encoding `json:"encoding,omitempty"`
}
MediaType 是由 OpenAPI/Swagger 3.0 标准定义的。 md5:1bb86450c61271e0
type OAuthFlows ¶
type OpenApiV3 ¶
type OpenApiV3 struct {
Config Config `json:"-"`
OpenAPI string `json:"openapi"`
Components Components `json:"components,omitempty"`
Info Info `json:"info"`
Paths Paths `json:"paths"`
Security *SecurityRequirements `json:"security,omitempty"`
Servers *Servers `json:"servers,omitempty"`
Tags *Tags `json:"tags,omitempty"`
ExternalDocs *ExternalDocs `json:"externalDocs,omitempty"`
}
OpenApiV3 是根据以下规范定义的结构体: https://swagger.io/specification/ https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.0.md
这个注释说明OpenApiV3这个结构体是依据Swagger/OpenAPI规范定义的,具体参照了给定的两个链接,分别指向Swagger官方网站的规范描述和OpenAPI Specification在GitHub上的3.0.0版本文档。 md5:0153ee143f23e076
type Operation ¶
type Operation struct {
Tags []string `json:"tags,omitempty"`
Summary string `json:"summary,omitempty"`
Description string `json:"description,omitempty"`
OperationID string `json:"operationId,omitempty"`
Parameters Parameters `json:"parameters,omitempty"`
RequestBody *RequestBodyRef `json:"requestBody,omitempty"`
Responses Responses `json:"responses"`
Deprecated bool `json:"deprecated,omitempty"`
Callbacks *Callbacks `json:"callbacks,omitempty"`
Security *SecurityRequirements `json:"security,omitempty"`
Servers *Servers `json:"servers,omitempty"`
ExternalDocs *ExternalDocs `json:"externalDocs,omitempty"`
XExtensions XExtensions `json:"-"`
}
Operation 表示符合OpenAPI/Swagger 3.0标准的“操作”定义。 md5:311e40263896a777
func (Operation) MarshalJSON ¶
type Parameter ¶
type Parameter struct {
Name string `json:"name,omitempty"`
In string `json:"in,omitempty"`
Description string `json:"description,omitempty"`
Style string `json:"style,omitempty"`
Explode *bool `json:"explode,omitempty"`
AllowEmptyValue bool `json:"allowEmptyValue,omitempty"`
AllowReserved bool `json:"allowReserved,omitempty"`
Deprecated bool `json:"deprecated,omitempty"`
Required bool `json:"required,omitempty"`
Schema *SchemaRef `json:"schema,omitempty"`
Example interface{} `json:"example,omitempty"`
Examples *Examples `json:"examples,omitempty"`
Content *Content `json:"content,omitempty"`
XExtensions XExtensions `json:"-"`
}
参数由 OpenAPI/Swagger 3.0 标准定义。 参见 https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.0.md#parameterObject md5:c86f94d3392df58e
func (Parameter) MarshalJSON ¶
type ParameterRef ¶
func (ParameterRef) MarshalJSON ¶
func (r ParameterRef) MarshalJSON() ([]byte, error)
type Parameters ¶
type Parameters []ParameterRef
Parameters 是由 OpenAPI/Swagger 3.0 标准指定的。 md5:40f2fa7f283687bf
type ParametersMap ¶
type ParametersMap map[string]*ParameterRef
type Path ¶
type Path struct {
Ref string `json:"$ref,omitempty"`
Summary string `json:"summary,omitempty"`
Description string `json:"description,omitempty"`
Connect *Operation `json:"connect,omitempty"`
Delete *Operation `json:"delete,omitempty"`
Get *Operation `json:"get,omitempty"`
Head *Operation `json:"head,omitempty"`
Options *Operation `json:"options,omitempty"`
Patch *Operation `json:"patch,omitempty"`
Post *Operation `json:"post,omitempty"`
Put *Operation `json:"put,omitempty"`
Trace *Operation `json:"trace,omitempty"`
Servers Servers `json:"servers,omitempty"`
Parameters Parameters `json:"parameters,omitempty"`
XExtensions XExtensions `json:"-"`
}
Path遵循OpenAPI/Swagger标准版本3.0。 md5:26b252ebd7fb17bd
func (Path) MarshalJSON ¶
MarshalJSON 实现了接口 MarshalJSON 以供 json.Marshal 使用。 md5:43c3b36e60a18f9a
type RequestBodies ¶
type RequestBodies map[string]*RequestBodyRef
type RequestBody ¶
type RequestBody struct {
Description string `json:"description,omitempty"`
Required bool `json:"required,omitempty"`
Content Content `json:"content,omitempty"`
}
requestBody 是由 OpenAPI/Swagger 3.0 标准定义的。 md5:c7f34291e4ca763f
type RequestBodyRef ¶
type RequestBodyRef struct {
Ref string
Value *RequestBody
}
func (RequestBodyRef) MarshalJSON ¶
func (r RequestBodyRef) MarshalJSON() ([]byte, error)
type Response ¶
type Response struct {
Description string `json:"description"`
Headers Headers `json:"headers,omitempty"`
Content Content `json:"content,omitempty"`
Links Links `json:"links,omitempty"`
XExtensions XExtensions `json:"-"`
}
响应由 OpenAPI/Swagger 3.0 标准规定。 md5:fbc3562465353f4d
func (Response) MarshalJSON ¶
type ResponseRef ¶
func (ResponseRef) MarshalJSON ¶
func (r ResponseRef) MarshalJSON() ([]byte, error)
type Responses ¶
type Responses map[string]ResponseRef
Responses 是由 OpenAPI/Swagger 3.0 标准指定的。 md5:6a58747083cc2ced
type Schema ¶
type Schema struct {
OneOf SchemaRefs `json:"oneOf,omitempty"`
AnyOf SchemaRefs `json:"anyOf,omitempty"`
AllOf SchemaRefs `json:"allOf,omitempty"`
Not *SchemaRef `json:"not,omitempty"`
Type string `json:"type,omitempty"`
Title string `json:"title,omitempty"`
Format string `json:"format,omitempty"`
Description string `json:"description,omitempty"`
Enum []interface{} `json:"enum,omitempty"`
Default interface{} `json:"default,omitempty"`
Example interface{} `json:"example,omitempty"`
ExternalDocs *ExternalDocs `json:"externalDocs,omitempty"`
UniqueItems bool `json:"uniqueItems,omitempty"`
ExclusiveMin bool `json:"exclusiveMinimum,omitempty"`
ExclusiveMax bool `json:"exclusiveMaximum,omitempty"`
Nullable bool `json:"nullable,omitempty"`
ReadOnly bool `json:"readOnly,omitempty"`
WriteOnly bool `json:"writeOnly,omitempty"`
AllowEmptyValue bool `json:"allowEmptyValue,omitempty"`
XML interface{} `json:"xml,omitempty"`
Deprecated bool `json:"deprecated,omitempty"`
Min *float64 `json:"minimum,omitempty"`
Max *float64 `json:"maximum,omitempty"`
MultipleOf *float64 `json:"multipleOf,omitempty"`
MinLength uint64 `json:"minLength,omitempty"`
MaxLength *uint64 `json:"maxLength,omitempty"`
Pattern string `json:"pattern,omitempty"`
MinItems uint64 `json:"minItems,omitempty"`
MaxItems *uint64 `json:"maxItems,omitempty"`
Items *SchemaRef `json:"items,omitempty"`
Required []string `json:"required,omitempty"`
Properties Schemas `json:"properties,omitempty"`
MinProps uint64 `json:"minProperties,omitempty"`
MaxProps *uint64 `json:"maxProperties,omitempty"`
AdditionalProperties *SchemaRef `json:"additionalProperties,omitempty"`
Discriminator *Discriminator `json:"discriminator,omitempty"`
XExtensions XExtensions `json:"-"`
ValidationRules string `json:"-"`
}
Schema 按照 OpenAPI/Swagger 3.0 标准指定。 md5:6f1f02d1c3d44b09
func (Schema) MarshalJSON ¶
type SchemaRef ¶
func (SchemaRef) MarshalJSON ¶
type SchemaRefs ¶
type SchemaRefs []SchemaRef
type Schemas ¶
type Schemas struct {
// contains filtered or unexported fields
}
func (Schemas) MarshalJSON ¶
type SecurityRequirement ¶
type SecurityRequirements ¶
type SecurityRequirements []SecurityRequirement
type SecurityScheme ¶
type SecurityScheme struct {
Type string `json:"type,omitempty"`
Description string `json:"description,omitempty"`
Name string `json:"name,omitempty"`
In string `json:"in,omitempty"`
Scheme string `json:"scheme,omitempty"`
BearerFormat string `json:"bearerFormat,omitempty"`
Flows *OAuthFlows `json:"flows,omitempty"`
OpenIdConnectUrl string `json:"openIdConnectUrl,omitempty"`
}
type SecuritySchemeRef ¶
type SecuritySchemeRef struct {
Ref string
Value *SecurityScheme
}
func (SecuritySchemeRef) MarshalJSON ¶
func (r SecuritySchemeRef) MarshalJSON() ([]byte, error)
type SecuritySchemes ¶
type SecuritySchemes map[string]SecuritySchemeRef
type Server ¶
type Server struct {
URL string `json:"url"`
Description string `json:"description,omitempty"`
Variables map[string]*ServerVariable `json:"variables,omitempty"`
}
Server由OpenAPI/Swagger标准版本3.0定义。 md5:e48b24980b097496
type ServerVariable ¶
type ServerVariable struct {
Enum []string `json:"enum,omitempty"`
Default string `json:"default,omitempty"`
Description string `json:"description,omitempty"`
}
ServerVariable 是由OpenAPI/Swagger标准版本3.0定义的。 md5:7cbb925477ff19bd
type Tag ¶
type Tag struct {
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
ExternalDocs *ExternalDocs `json:"externalDocs,omitempty"`
}
Tag由OpenAPI/Swagger 3.0标准指定。 md5:94223e7c6dcb7c0f
type XExtensions ¶
XExtensions 存储了 `x-` 自定义扩展。 md5:e19838946aa45df7
Source Files
¶
- goai.go
- goai_callback.go
- goai_components.go
- goai_config.go
- goai_example.go
- goai_external_docs.go
- goai_header.go
- goai_info.go
- goai_link.go
- goai_mediatype.go
- goai_operation.go
- goai_parameter.go
- goai_parameter_ref.go
- goai_path.go
- goai_requestbody.go
- goai_response.go
- goai_response_ref.go
- goai_security.go
- goai_server.go
- goai_shema.go
- goai_shema_ref.go
- goai_shemas.go
- goai_tags.go
- goai_xextensions.go