Documentation ¶
Overview ¶
Package goai implements and provides document generating for OpenApi specification.
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
- type SecurityRequirement
- type SecurityRequirements
- type SecurityScheme
- type SecuritySchemeRef
- type SecuritySchemes
- type Server
- type ServerVariable
- type Servers
- type Tag
- type Tags
Constants ¶
const ( HttpMethodAll = `ALL` HttpMethodGet = `GET` HttpMethodPut = `PUT` HttpMethodPost = `POST` HttpMethodDelete = `DELETE` HttpMethodConnect = `CONNECT` HttpMethodHead = `HEAD` HttpMethodOptions = `OPTIONS` HttpMethodPatch = `PATCH` HttpMethodTrace = `TRACE` )
const ( TypeNumber = `number` TypeBoolean = `boolean` TypeArray = `array` TypeString = `string` 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` )
const ( TagNamePath = `path` TagNameMethod = `method` TagNameMime = `mime` TagNameType = `type` TagNameDomain = `domain` TagNameValidate = `v` )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddInput ¶
type AddInput struct { Path string // Path specifies the custom path if this is not configured in Meta of struct tag. Prefix string // Prefix specifies the custom route path prefix, which will be added with the path tag in Meta of struct tag. Method string // Method specifies the custom HTTP method if this is not configured in Meta of struct tag. Object interface{} // Object can be an instance of struct or a route function. }
AddInput is the structured parameter for function OpenApiV3.Add.
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" yaml:"schemas,omitempty"` Parameters ParametersMap `json:"parameters,omitempty" yaml:"parameters,omitempty"` Headers Headers `json:"headers,omitempty" yaml:"headers,omitempty"` RequestBodies RequestBodies `json:"requestBodies,omitempty" yaml:"requestBodies,omitempty"` Responses Responses `json:"responses,omitempty" yaml:"responses,omitempty"` SecuritySchemes SecuritySchemes `json:"securitySchemes,omitempty" yaml:"securitySchemes,omitempty"` Examples Examples `json:"examples,omitempty" yaml:"examples,omitempty"` Links Links `json:"links,omitempty" yaml:"links,omitempty"` Callbacks Callbacks `json:"callbacks,omitempty" yaml:"callbacks,omitempty"` }
Components is specified by OpenAPI/Swagger standard version 3.0.
type Config ¶
type Config struct { ReadContentTypes []string // ReadContentTypes specifies the default MIME types for consuming if MIME types are not configured. WriteContentTypes []string // WriteContentTypes specifies the default MIME types for producing if MIME types are not configured. CommonRequest interface{} // Common request structure for all paths. CommonRequestDataField string // Common request field name to be replaced with certain business request structure. Eg: `Data`, `Request.`. CommonResponse interface{} // Common response structure for all paths. CommonResponseDataField string // Common response field name to be replaced with certain business response structure. Eg: `Data`, `Response.`. IgnorePkgPath bool // Ignores package name for schema name. }
Config provides extra configuration feature for OpenApiV3 implements.
type Contact ¶
type Contact struct { Name string `json:"name,omitempty" yaml:"name,omitempty"` URL string `json:"url,omitempty" yaml:"url,omitempty"` Email string `json:"email,omitempty" yaml:"email,omitempty"` }
Contact is specified by OpenAPI/Swagger standard version 3.0.
type Discriminator ¶
type Discriminator struct { PropertyName string `json:"propertyName" yaml:"propertyName"` Mapping map[string]string `json:"mapping,omitempty" yaml:"mapping,omitempty"` }
Discriminator is specified by OpenAPI/Swagger standard version 3.0.
type Encoding ¶
type Encoding struct { ContentType string `json:"contentType,omitempty" yaml:"contentType,omitempty"` Headers Headers `json:"headers,omitempty" yaml:"headers,omitempty"` Style string `json:"style,omitempty" yaml:"style,omitempty"` Explode *bool `json:"explode,omitempty" yaml:"explode,omitempty"` AllowReserved bool `json:"allowReserved,omitempty" yaml:"allowReserved,omitempty"` }
Encoding is specified by OpenAPI/Swagger 3.0 standard.
type Example ¶
type Example struct { Summary string `json:"summary,omitempty" yaml:"summary,omitempty"` Description string `json:"description,omitempty" yaml:"description,omitempty"` Value interface{} `json:"value,omitempty" yaml:"value,omitempty"` ExternalValue string `json:"externalValue,omitempty" yaml:"externalValue,omitempty"` }
Example is specified by OpenAPI/Swagger 3.0 standard.
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 is specified by OpenAPI/Swagger standard version 3.0.
type Header ¶
type Header struct {
Parameter
}
Header is specified by OpenAPI/Swagger 3.0 standard. See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.0.md#headerObject
type HeaderRef ¶
func (HeaderRef) MarshalJSON ¶
type Info ¶
type Info struct { Title string `json:"title" yaml:"title"` Description string `json:"description,omitempty" yaml:"description,omitempty"` TermsOfService string `json:"termsOfService,omitempty" yaml:"termsOfService,omitempty"` Contact *Contact `json:"contact,omitempty" yaml:"contact,omitempty"` License *License `json:"license,omitempty" yaml:"license,omitempty"` Version string `json:"version" yaml:"version"` }
Info is specified by OpenAPI/Swagger standard version 3.0.
type License ¶
type License struct { Name string `json:"name" yaml:"name"` URL string `json:"url,omitempty" yaml:"url,omitempty"` }
License is specified by OpenAPI/Swagger standard version 3.0.
type Link ¶
type Link struct { OperationID string `json:"operationId,omitempty" yaml:"operationId,omitempty"` OperationRef string `json:"operationRef,omitempty" yaml:"operationRef,omitempty"` Description string `json:"description,omitempty" yaml:"description,omitempty"` Parameters map[string]interface{} `json:"parameters,omitempty" yaml:"parameters,omitempty"` Server *Server `json:"server,omitempty" yaml:"server,omitempty"` RequestBody interface{} `json:"requestBody,omitempty" yaml:"requestBody,omitempty"` }
Link is specified by OpenAPI/Swagger standard version 3.0.
type LinkRef ¶
func (LinkRef) MarshalJSON ¶
type MediaType ¶
type MediaType struct { Schema *SchemaRef `json:"schema,omitempty" yaml:"schema,omitempty"` Example interface{} `json:"example,omitempty" yaml:"example,omitempty"` Examples Examples `json:"examples,omitempty" yaml:"examples,omitempty"` Encoding map[string]*Encoding `json:"encoding,omitempty" yaml:"encoding,omitempty"` }
MediaType is specified by OpenAPI/Swagger 3.0 standard.
type OAuthFlow ¶
type OAuthFlow struct { AuthorizationURL string `json:"authorizationUrl,omitempty" yaml:"authorizationUrl,omitempty"` TokenURL string `json:"tokenUrl,omitempty" yaml:"tokenUrl,omitempty"` RefreshURL string `json:"refreshUrl,omitempty" yaml:"refreshUrl,omitempty"` Scopes map[string]string `json:"scopes" yaml:"scopes"` }
type OAuthFlows ¶
type OAuthFlows struct { Implicit *OAuthFlow `json:"implicit,omitempty" yaml:"implicit,omitempty"` Password *OAuthFlow `json:"password,omitempty" yaml:"password,omitempty"` ClientCredentials *OAuthFlow `json:"clientCredentials,omitempty" yaml:"clientCredentials,omitempty"` AuthorizationCode *OAuthFlow `json:"authorizationCode,omitempty" yaml:"authorizationCode,omitempty"` }
type OpenApiV3 ¶
type OpenApiV3 struct { Config Config `json:"-" yaml:"-"` OpenAPI string `json:"openapi" yaml:"openapi"` Components Components `json:"components,omitempty" yaml:"components,omitempty"` Info Info `json:"info" yaml:"info"` Paths Paths `json:"paths" yaml:"paths"` Security *SecurityRequirements `json:"security,omitempty" yaml:"security,omitempty"` Servers *Servers `json:"servers,omitempty" yaml:"servers,omitempty"` Tags *Tags `json:"tags,omitempty" yaml:"tags,omitempty"` ExternalDocs *ExternalDocs `json:"externalDocs,omitempty" yaml:"externalDocs,omitempty"` }
OpenApiV3 is the structure defined from: https://swagger.io/specification/ https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.0.md
type Operation ¶
type Operation struct { Tags []string `json:"tags,omitempty" yaml:"tags,omitempty"` Summary string `json:"summary,omitempty" yaml:"summary,omitempty"` Description string `json:"description,omitempty" yaml:"description,omitempty"` OperationID string `json:"operationId,omitempty" yaml:"operationId,omitempty"` Parameters Parameters `json:"parameters,omitempty" yaml:"parameters,omitempty"` RequestBody *RequestBodyRef `json:"requestBody,omitempty" yaml:"requestBody,omitempty"` Responses Responses `json:"responses" yaml:"responses"` Deprecated bool `json:"deprecated,omitempty" yaml:"deprecated,omitempty"` Callbacks *Callbacks `json:"callbacks,omitempty" yaml:"callbacks,omitempty"` Security *SecurityRequirements `json:"security,omitempty" yaml:"security,omitempty"` Servers *Servers `json:"servers,omitempty" yaml:"servers,omitempty"` ExternalDocs *ExternalDocs `json:"externalDocs,omitempty" yaml:"externalDocs,omitempty"` }
Operation represents "operation" specified by OpenAPI/Swagger 3.0 standard.
type Parameter ¶
type Parameter struct { Name string `json:"name,omitempty" yaml:"name,omitempty"` In string `json:"in,omitempty" yaml:"in,omitempty"` Description string `json:"description,omitempty" yaml:"description,omitempty"` Style string `json:"style,omitempty" yaml:"style,omitempty"` Explode *bool `json:"explode,omitempty" yaml:"explode,omitempty"` AllowEmptyValue bool `json:"allowEmptyValue,omitempty" yaml:"allowEmptyValue,omitempty"` AllowReserved bool `json:"allowReserved,omitempty" yaml:"allowReserved,omitempty"` Deprecated bool `json:"deprecated,omitempty" yaml:"deprecated,omitempty"` Required bool `json:"required,omitempty" yaml:"required,omitempty"` Schema *SchemaRef `json:"schema,omitempty" yaml:"schema,omitempty"` Example interface{} `json:"example,omitempty" yaml:"example,omitempty"` Examples *Examples `json:"examples,omitempty" yaml:"examples,omitempty"` Content *Content `json:"content,omitempty" yaml:"content,omitempty"` }
Parameter is specified by OpenAPI/Swagger 3.0 standard. See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.0.md#parameterObject
type ParameterRef ¶
func (ParameterRef) MarshalJSON ¶
func (r ParameterRef) MarshalJSON() ([]byte, error)
type Parameters ¶
type Parameters []ParameterRef
Parameters is specified by OpenAPI/Swagger 3.0 standard.
type ParametersMap ¶
type ParametersMap map[string]*ParameterRef
type Path ¶
type Path struct { Ref string `json:"$ref,omitempty" yaml:"$ref,omitempty"` Summary string `json:"summary,omitempty" yaml:"summary,omitempty"` Description string `json:"description,omitempty" yaml:"description,omitempty"` Connect *Operation `json:"connect,omitempty" yaml:"connect,omitempty"` Delete *Operation `json:"delete,omitempty" yaml:"delete,omitempty"` Get *Operation `json:"get,omitempty" yaml:"get,omitempty"` Head *Operation `json:"head,omitempty" yaml:"head,omitempty"` Options *Operation `json:"options,omitempty" yaml:"options,omitempty"` Patch *Operation `json:"patch,omitempty" yaml:"patch,omitempty"` Post *Operation `json:"post,omitempty" yaml:"post,omitempty"` Put *Operation `json:"put,omitempty" yaml:"put,omitempty"` Trace *Operation `json:"trace,omitempty" yaml:"trace,omitempty"` Servers Servers `json:"servers,omitempty" yaml:"servers,omitempty"` Parameters Parameters `json:"parameters,omitempty" yaml:"parameters,omitempty"` }
type RequestBodies ¶
type RequestBodies map[string]*RequestBodyRef
type RequestBody ¶
type RequestBody struct { Description string `json:"description,omitempty" yaml:"description,omitempty"` Required bool `json:"required,omitempty" yaml:"required,omitempty"` Content Content `json:"content,omitempty" yaml:"content,omitempty"` }
RequestBody is specified by OpenAPI/Swagger 3.0 standard.
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" yaml:"description"` Headers Headers `json:"headers,omitempty" yaml:"headers,omitempty"` Content Content `json:"content,omitempty" yaml:"content,omitempty"` Links Links `json:"links,omitempty" yaml:"links,omitempty"` }
Response is specified by OpenAPI/Swagger 3.0 standard.
type ResponseRef ¶
func (ResponseRef) MarshalJSON ¶
func (r ResponseRef) MarshalJSON() ([]byte, error)
type Responses ¶
type Responses map[string]ResponseRef
Responses is specified by OpenAPI/Swagger 3.0 standard.
type Schema ¶
type Schema struct { OneOf SchemaRefs `json:"oneOf,omitempty" yaml:"oneOf,omitempty"` AnyOf SchemaRefs `json:"anyOf,omitempty" yaml:"anyOf,omitempty"` AllOf SchemaRefs `json:"allOf,omitempty" yaml:"allOf,omitempty"` Not *SchemaRef `json:"not,omitempty" yaml:"not,omitempty"` Type string `json:"type,omitempty" yaml:"type,omitempty"` Title string `json:"title,omitempty" yaml:"title,omitempty"` Format string `json:"format,omitempty" yaml:"format,omitempty"` Description string `json:"description,omitempty" yaml:"description,omitempty"` Enum []interface{} `json:"enum,omitempty" yaml:"enum,omitempty"` Default interface{} `json:"default,omitempty" yaml:"default,omitempty"` Example interface{} `json:"example,omitempty" yaml:"example,omitempty"` ExternalDocs *ExternalDocs `json:"externalDocs,omitempty" yaml:"externalDocs,omitempty"` UniqueItems bool `json:"uniqueItems,omitempty" yaml:"uniqueItems,omitempty"` ExclusiveMin bool `json:"exclusiveMinimum,omitempty" yaml:"exclusiveMinimum,omitempty"` ExclusiveMax bool `json:"exclusiveMaximum,omitempty" yaml:"exclusiveMaximum,omitempty"` Nullable bool `json:"nullable,omitempty" yaml:"nullable,omitempty"` ReadOnly bool `json:"readOnly,omitempty" yaml:"readOnly,omitempty"` WriteOnly bool `json:"writeOnly,omitempty" yaml:"writeOnly,omitempty"` AllowEmptyValue bool `json:"allowEmptyValue,omitempty" yaml:"allowEmptyValue,omitempty"` XML interface{} `json:"xml,omitempty" yaml:"xml,omitempty"` Deprecated bool `json:"deprecated,omitempty" yaml:"deprecated,omitempty"` Min *float64 `json:"minimum,omitempty" yaml:"minimum,omitempty"` Max *float64 `json:"maximum,omitempty" yaml:"maximum,omitempty"` MultipleOf *float64 `json:"multipleOf,omitempty" yaml:"multipleOf,omitempty"` MinLength uint64 `json:"minLength,omitempty" yaml:"minLength,omitempty"` MaxLength *uint64 `json:"maxLength,omitempty" yaml:"maxLength,omitempty"` Pattern string `json:"pattern,omitempty" yaml:"pattern,omitempty"` MinItems uint64 `json:"minItems,omitempty" yaml:"minItems,omitempty"` MaxItems *uint64 `json:"maxItems,omitempty" yaml:"maxItems,omitempty"` Items *SchemaRef `json:"items,omitempty" yaml:"items,omitempty"` Required []string `json:"required,omitempty" yaml:"required,omitempty"` Properties Schemas `json:"properties,omitempty" yaml:"properties,omitempty"` MinProps uint64 `json:"minProperties,omitempty" yaml:"minProperties,omitempty"` MaxProps *uint64 `json:"maxProperties,omitempty" yaml:"maxProperties,omitempty"` AdditionalProperties *SchemaRef `json:"additionalProperties,omitempty" yaml:"additionalProperties"` Discriminator *Discriminator `json:"discriminator,omitempty" yaml:"discriminator,omitempty"` }
Schema is specified by OpenAPI/Swagger 3.0 standard.
type SchemaRef ¶
func (SchemaRef) MarshalJSON ¶
type SchemaRefs ¶
type SchemaRefs []SchemaRef
type SecurityRequirement ¶
type SecurityRequirements ¶
type SecurityRequirements []SecurityRequirement
type SecurityScheme ¶
type SecurityScheme struct { Type string `json:"type,omitempty" yaml:"type,omitempty"` Description string `json:"description,omitempty" yaml:"description,omitempty"` Name string `json:"name,omitempty" yaml:"name,omitempty"` In string `json:"in,omitempty" yaml:"in,omitempty"` Scheme string `json:"scheme,omitempty" yaml:"scheme,omitempty"` BearerFormat string `json:"bearerFormat,omitempty" yaml:"bearerFormat,omitempty"` Flows *OAuthFlows `json:"flows,omitempty" yaml:"flows,omitempty"` OpenIdConnectUrl string `json:"openIdConnectUrl,omitempty" yaml:"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" yaml:"url"` Description string `json:"description,omitempty" yaml:"description,omitempty"` Variables map[string]*ServerVariable `json:"variables,omitempty" yaml:"variables,omitempty"` }
Server is specified by OpenAPI/Swagger standard version 3.0.
type ServerVariable ¶
type ServerVariable struct { Enum []string `json:"enum,omitempty" yaml:"enum,omitempty"` Default string `json:"default,omitempty" yaml:"default,omitempty"` Description string `json:"description,omitempty" yaml:"description,omitempty"` }
ServerVariable is specified by OpenAPI/Swagger standard version 3.0.
type Tag ¶
type Tag struct { Name string `json:"name,omitempty" yaml:"name,omitempty"` Description string `json:"description,omitempty" yaml:"description,omitempty"` ExternalDocs *ExternalDocs `json:"externalDocs,omitempty" yaml:"externalDocs,omitempty"` }
Tag is specified by OpenAPI/Swagger 3.0 standard.