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
- func (s *Schemas) Clone() Schemas
- func (s *Schemas) Get(name string) *SchemaRef
- func (s *Schemas) Iterator(f func(key string, ref SchemaRef) bool)
- func (s *Schemas) Map() map[string]SchemaRef
- func (s Schemas) MarshalJSON() ([]byte, error)
- func (s *Schemas) Removes(names []interface{})
- func (s *Schemas) Set(name string, ref SchemaRef)
- 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` 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 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"` 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 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"` URL string `json:"url,omitempty"` Email string `json:"email,omitempty"` }
Contact is specified by OpenAPI/Swagger standard version 3.0.
type Discriminator ¶
type Discriminator struct { PropertyName string `json:"propertyName"` Mapping map[string]string `json:"mapping,omitempty"` }
Discriminator is specified by OpenAPI/Swagger standard version 3.0.
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 is specified by OpenAPI/Swagger 3.0 standard.
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 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.
func (*ExternalDocs) UnmarshalValue ¶
func (ed *ExternalDocs) UnmarshalValue(value interface{}) error
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"` 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 is specified by OpenAPI/Swagger standard version 3.0.
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 is specified by OpenAPI/Swagger standard version 3.0.
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 is specified by OpenAPI/Swagger 3.0 standard.
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 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"` 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 represents "operation" specified by OpenAPI/Swagger 3.0 standard.
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:"-"` }
Parameter is specified by OpenAPI/Swagger 3.0 standard. See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.0.md#parameterObject
func (Parameter) MarshalJSON ¶
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"` 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:"-"` }
func (Path) MarshalJSON ¶
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 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"` Headers Headers `json:"headers,omitempty"` Content Content `json:"content,omitempty"` Links Links `json:"links,omitempty"` XExtensions XExtensions `json:"-"` }
Response is specified by OpenAPI/Swagger 3.0 standard.
func (Response) MarshalJSON ¶
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"` 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 is specified by OpenAPI/Swagger 3.0 standard.
func (*Schema) Clone ¶ added in v2.4.2
Clone only clones necessary attributes. TODO clone all attributes, or improve package deepcopy.
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 is specified by OpenAPI/Swagger standard version 3.0.
type ServerVariable ¶
type ServerVariable struct { Enum []string `json:"enum,omitempty"` Default string `json:"default,omitempty"` Description string `json:"description,omitempty"` }
ServerVariable is specified by OpenAPI/Swagger standard version 3.0.
type Tag ¶
type Tag struct { Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` ExternalDocs *ExternalDocs `json:"externalDocs,omitempty"` }
Tag is specified by OpenAPI/Swagger 3.0 standard.
type XExtensions ¶
XExtensions stores the `x-` custom extensions.
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