Documentation
¶
Index ¶
- Constants
- func ServeSwaggerUI(conf *ConfigSwaggerUI) error
- type Component
- type Components
- type ConfigBuilder
- type ConfigSwaggerUI
- type Contact
- type ContentType
- type ContentTypes
- type ExternalDocs
- type Info
- type License
- type OAS
- func (o *OAS) AttachRoutes(fns []interface{})
- func (o *OAS) BuildDocs(conf ...ConfigBuilder) error
- func (o *OAS) Call(name string, params ...interface{}) (result []reflect.Value, err error)
- func (o *OAS) GetInfo() *Info
- func (o *OAS) GetPathByIndex(index int) *Path
- func (o *OAS) GetRegisteredRoutes() RegRoutes
- func (o *OAS) MapAnnotationsInPath(scanIn string, conf ...configAnnotation) error
- func (o *OAS) SetOASVersion(ver string)
- type OASVersion
- type Path
- type Paths
- type RegRoutes
- type RequestBody
- type Response
- type Responses
- type Schema
- type SchemaProperties
- type SchemaProperty
- type Schemas
- type Security
- type SecurityEntities
- type SecurityFlow
- type SecurityFlows
- type SecurityScheme
- type SecuritySchemes
- type SecurityScope
- type SecurityScopes
- type Server
- type Servers
- type Tag
- type Tags
- type URL
- type Version
- type XMLEntry
Constants ¶
const (
OASAnnotationInit = "// @OAS "
)
Variables ¶
This section is empty.
Functions ¶
func ServeSwaggerUI ¶
func ServeSwaggerUI(conf *ConfigSwaggerUI) error
ServeSwaggerUI does what its name implies - runs Swagger UI on mentioned set port and route.
Types ¶
type Component ¶
type Component struct {
Schemas Schemas `yaml:"schemas"`
SecuritySchemes SecuritySchemes `yaml:"securitySchemes"`
}
type Components ¶
type Components []Component
type ConfigBuilder ¶
type ConfigBuilder struct {
CustomPath string
}
ConfigBuilder represents a config structure which will be used for the YAML Builder (BuildDocs fn).
This structure was introduced to enable possible extensions to the OAS.BuildDocs() without introducing breaking API changes.
type ConfigSwaggerUI ¶
type ContentType ¶
type ContentTypes ¶
type ContentTypes []ContentType
type ExternalDocs ¶
type Info ¶
type Info struct {
Title string `yaml:"title"`
Description string `yaml:"description"`
TermsOfService URL `yaml:"termsOfService"`
Contact Contact `yaml:"contact"`
License License `yaml:"license"`
Version Version `yaml:"version"`
}
func (*Info) SetContact ¶
SetContact setts the contact on the Info struct.
func (*Info) SetLicense ¶
SetLicense sets the license on the Info struct.
type OAS ¶
type OAS struct {
OASVersion OASVersion `yaml:"openapi"`
Info Info `yaml:"info"`
ExternalDocs ExternalDocs `yaml:"externalDocs"`
Servers Servers `yaml:"servers"`
Tags Tags `yaml:"tags"`
Paths Paths `yaml:"paths"`
Components Components `yaml:"components"`
RegisteredRoutes RegRoutes `yaml:"-"`
}
OAS - represents Open API Specification structure, in its approximated Go form.
func (*OAS) AttachRoutes ¶
func (o *OAS) AttachRoutes(fns []interface{})
func (*OAS) BuildDocs ¶
func (o *OAS) BuildDocs(conf ...ConfigBuilder) error
BuildDocs marshals the OAS struct to YAML and saves it to the chosen output file.
Returns an error if there is any.
func (*OAS) GetPathByIndex ¶
func (*OAS) GetRegisteredRoutes ¶
func (*OAS) MapAnnotationsInPath ¶
MapAnnotationsInPath scanIn is relevant from initiator calling it.
It accepts the path in which to scan for annotations within Go files.
func (*OAS) SetOASVersion ¶
SetOASVersion sets the OAS version, by casting string to OASVersion type.
type Path ¶
type Path struct {
Route string `yaml:"route"`
HTTPMethod string `yaml:"httpMethod"`
Tags []string `yaml:"tags"`
Summary string `yaml:"summary"`
OperationID string `yaml:"operationId"`
RequestBody RequestBody `yaml:"requestBody"`
Responses Responses `yaml:"responses"`
Security SecurityEntities `yaml:"security,omitempty"`
HandlerFuncName string `yaml:"-"`
}
type RequestBody ¶
type RequestBody struct {
Description string `yaml:"description"`
Content ContentTypes `yaml:"content"`
Required bool `yaml:"required"`
}
type Response ¶
type Response struct {
Code uint `yaml:"code"`
Description string `yaml:"description"`
Content ContentTypes `yaml:"content"`
}
type Schema ¶
type Schema struct {
Name string
Type string
Properties SchemaProperties
XML XMLEntry `yaml:"xml, omitempty"`
Ref string // $ref: '#/components/schemas/Pet' // TODO: Should this be omitted if empty?
}
type SchemaProperties ¶
type SchemaProperties []SchemaProperty
type SchemaProperty ¶
type SecurityEntities ¶
type SecurityEntities []Security
type SecurityFlow ¶
type SecurityFlow struct {
Type string `yaml:"type,omitempty"`
AuthURL URL `yaml:"authorizationUrl,omitempty"`
Scopes SecurityScopes `yaml:"scopes,omitempty"`
}
type SecurityFlows ¶
type SecurityFlows []SecurityFlow
type SecurityScheme ¶
type SecurityScheme struct {
Name string `yaml:"name,omitempty"`
Type string `yaml:"type,omitempty"`
In string `yaml:"in,omitempty"`
Flows SecurityFlows `yaml:"flows,omitempty"`
}
type SecuritySchemes ¶
type SecuritySchemes []SecurityScheme
type SecurityScope ¶
type SecurityScopes ¶
type SecurityScopes []SecurityScope
type Tag ¶
type Tag struct {
Name string `yaml:"name"`
Description string `yaml:"description"`
ExternalDocs ExternalDocs `yaml:"externalDocs"`
}