Documentation ¶
Overview ¶
package swaggos
Index ¶
- Constants
- func UI(prefix string, baseURL string) http.Handler
- type Attribute
- type Group
- func (g *Group) Delete(path string) *Path
- func (g *Group) Form(name string, desc string, required bool) *Group
- func (g *Group) Get(path string) *Path
- func (g *Group) Group(prefix string) *Group
- func (g *Group) Header(name string, desc string, required bool) *Group
- func (g *Group) Options(path string) *Path
- func (g *Group) Patch(path string) *Path
- func (g *Group) Post(path string) *Path
- func (g *Group) Put(path string) *Path
- func (g *Group) Query(name string, desc string, required bool) *Group
- func (g *Group) Swaggos() *Swaggos
- func (g *Group) Tag(t string) *Group
- type Oauth2Config
- type Oauth2Flow
- type Option
- type Path
- func (p *Path) BadRequest(v interface{}) *Path
- func (p *Path) Body(v interface{}) *Path
- func (p *Path) ContentType(req, resp string)
- func (p *Path) Description(s string) *Path
- func (p *Path) Forbidden(v interface{}) *Path
- func (p *Path) Form(name string, attribute Attribute) *Path
- func (p *Path) FormFile(name string, attribute Attribute) *Path
- func (p *Path) FormObject(v interface{}) *Path
- func (p *Path) Header(name string, attribute Attribute) *Path
- func (p *Path) JSON(v interface{}) *Path
- func (p *Path) Query(name string, attribute Attribute) *Path
- func (p *Path) QueryObject(v interface{}) *Path
- func (p *Path) ServerError(v interface{}) *Path
- func (p *Path) Summary(v string) *Path
- func (p *Path) Tag(v ...string) *Path
- func (p *Path) UnAuthorization(v interface{}) *Path
- type Swaggos
- func (swaggos *Swaggos) APIKeyAuth(name string, position string) *Swaggos
- func (swaggos *Swaggos) BasicAuth() *Swaggos
- func (swaggos *Swaggos) Build() ([]byte, error)
- func (swaggos *Swaggos) Consumes(s ...string)
- func (swaggos *Swaggos) Define(v interface{}) spec.Ref
- func (swaggos *Swaggos) Delete(path string) *Path
- func (swaggos *Swaggos) Extend(url string, desc string)
- func (swaggos *Swaggos) Form(name string, desc string, required bool) *Swaggos
- func (swaggos *Swaggos) Get(path string) *Path
- func (swaggos *Swaggos) Group(path string) *Group
- func (swaggos *Swaggos) Header(name string, desc string, required bool)
- func (swaggos *Swaggos) HostInfo(host string, basePath string) *Swaggos
- func (swaggos *Swaggos) JWT(keyName string) *Swaggos
- func (swaggos *Swaggos) Oauth2AccessCode(authURL string, tokURL string, scopes []string) *Swaggos
- func (swaggos *Swaggos) Oauth2Client(tokURL string, scopes []string) *Swaggos
- func (swaggos *Swaggos) Oauth2Config(config Oauth2Config) *Swaggos
- func (swaggos *Swaggos) Oauth2Implicit(authURL string, scopes []string) *Swaggos
- func (swaggos *Swaggos) Oauth2Password(tokenURL string, scopes []string) *Swaggos
- func (swaggos *Swaggos) Options(path string) *Path
- func (swaggos *Swaggos) Patch(path string) *Path
- func (swaggos *Swaggos) Post(path string) *Path
- func (swaggos *Swaggos) Produces(s ...string)
- func (swaggos *Swaggos) Put(path string) *Path
- func (swaggos *Swaggos) Query(name string, desc string, required bool) *Swaggos
- func (swaggos *Swaggos) Response(status int, v interface{}) *Swaggos
- func (swaggos *Swaggos) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (swaggos *Swaggos) Yaml() ([]byte, error)
Constants ¶
const ( // AccessCodeFlow accessCode flow AccessCodeFlow Oauth2Flow = "accessCode" // ImplicitFlow implicit flow ImplicitFlow = "implicit" // PasswordFlow password flow PasswordFlow = "password" // ApplicationFlow application flow ApplicationFlow = "application" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Attribute ¶
type Attribute struct { Model string `json:"model"` Description string `json:"description"` Required bool `json:"required"` Type string `json:"type"` Example interface{} `json:"example"` Nullable bool `json:"nullable,omitempty"` Format string `json:"format,omitempty"` Title string `json:"title,omitempty"` Default interface{} `json:"default,omitempty"` Maximum *float64 `json:"maximum,omitempty"` Minimum *float64 `json:"minimum,omitempty"` MaxLength *int64 `json:"maxLength,omitempty"` MinLength *int64 `json:"minLength,omitempty"` Pattern string `json:"pattern,omitempty"` MaxItems *int64 `json:"maxItems,omitempty"` MinItems *int64 `json:"minItems,omitempty"` Enum []interface{} `json:"enum,omitempty"` Ignore bool `json:"ignore"` JSON string `json:"json"` }
Attribute defines field attribute
func DescRequired ¶
DescRequired description and required
func DescRequiredDefault ¶
DescRequiredDefault description and default value
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group is a path group for same prefix
type Oauth2Config ¶ added in v0.0.2
type Oauth2Config struct { Flow Oauth2Flow AuthorizationURL string TokenURL string Scopes []string }
Oauth2Config is config for oauth2
type Option ¶
type Option func(o *Swaggos)
Option option is swaggos option
func DefaultOptions ¶
func DefaultOptions() []Option
DefaultOptions is the default option with: request Content-Type - application/json response Content-Type - application/json default schemas http/https
type Path ¶
type Path struct {
// contains filtered or unexported fields
}
Path defines a router spec
func (*Path) BadRequest ¶
BadRequest serve BadRequest to path
func (*Path) ContentType ¶
ContentType create request and response Content-Type
func (*Path) Description ¶
Description create description of the path
func (*Path) FormObject ¶
FormObject create form object params
func (*Path) QueryObject ¶
QueryObject parse an object to query
func (*Path) ServerError ¶
ServerError serve 500 to path
func (*Path) UnAuthorization ¶
UnAuthorization create 401 to path
type Swaggos ¶
type Swaggos struct {
// contains filtered or unexported fields
}
Swaggos is the base builder
func (*Swaggos) APIKeyAuth ¶ added in v0.0.5
APIKeyAuth set api-key auth support name is the key name position is the key position such as: header/cookie/query
func (*Swaggos) Define ¶
Define defines a object or a array to swagger definitions area. it will find all sub-items and build them into swagger tree. it returns the definitions ref.
func (*Swaggos) Oauth2AccessCode ¶ added in v0.0.2
Oauth2AccessCode setup swagger oauth2 by access code
func (*Swaggos) Oauth2Client ¶ added in v0.0.2
Oauth2Client setup swagger oauth2 by client
func (*Swaggos) Oauth2Config ¶ added in v0.0.2
func (swaggos *Swaggos) Oauth2Config(config Oauth2Config) *Swaggos
Oauth2Config setup oauth2 access type
func (*Swaggos) Oauth2Implicit ¶ added in v0.0.2
Oauth2Implicit setup swagger oauth2 by implicit
func (*Swaggos) Oauth2Password ¶ added in v0.0.2
Oauth2Password setup swagger oauth2 by password