Documentation ¶
Index ¶
- func ColonPath(path string) string
- func DirFS(dir string, fsys fs.FS) http.FileSystem
- func UIHandler(prefix, uri string, autoDomain bool) http.Handler
- func UIPatterns(prefix string) []string
- type API
- func (a *API) AddEndpoint(es ...*Endpoint)
- func (a *API) AddEndpointFunc(fs ...func(*API))deprecated
- func (a *API) AddOptions(options ...Option)
- func (a *API) AddTag(name, description string)
- func (a *API) Clone() *API
- func (a *API) Handler() http.HandlerFunc
- func (a *API) Walk(callback func(path string, endpoint *Endpoint))
- func (a *API) WithGroup(prefixPath string) *API
- func (a *API) WithTag(name, description string) *API
- func (a *API) WithTags(tags ...Tag) *API
- type Contact
- type Endpoint
- type Endpoints
- type Header
- type Info
- type Items
- type License
- type Object
- type Option
- type Parameter
- type Property
- type Response
- type Schema
- type SecurityRequirement
- type SecurityScheme
- type Tag
- type TagDocs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ColonPath ¶
ColonPath accepts a swagger path.
e.g. /api/org/{org} and returns a colon identified path e.g. /api/org/:org
func DirFS ¶
func DirFS(dir string, fsys fs.FS) http.FileSystem
DirFS returns a http.FileSystem by the specified directory path and FS
func UIPatterns ¶
UIPatterns returns a list of all the paths needed based on the path prefix
Types ¶
type API ¶
type API struct { Swagger string `json:"swagger,omitempty"` Info Info `json:"info"` BasePath string `json:"basePath,omitempty"` Schemes []string `json:"schemes,omitempty"` Paths map[string]*Endpoints `json:"paths,omitempty"` Definitions map[string]Object `json:"definitions,omitempty"` Tags []Tag `json:"tags,omitempty"` Host string `json:"host,omitempty"` SecurityDefinitions map[string]SecurityScheme `json:"securityDefinitions,omitempty"` Security *SecurityRequirement `json:"security,omitempty"` // contains filtered or unexported fields }
API provides the top level encapsulation for the swagger definition
func (*API) AddEndpoint ¶
AddEndpoint adds the specified endpoint to the API definition; to generate an endpoint use ```endpoint.New```
func (*API) AddEndpointFunc
deprecated
func (*API) Handler ¶
func (a *API) Handler() http.HandlerFunc
Handler is a factory method that generates a http.HandlerFunc; if enableCors is true, then the handler will generate cors headers
type Contact ¶
type Contact struct {
Email string `json:"email,omitempty"`
}
Contact represents the contact entity from the swagger definition; used by Info
type Endpoint ¶
type Endpoint struct { Tags []string `json:"tags,omitempty"` Path string `json:"-"` Method string `json:"-"` Summary string `json:"summary,omitempty"` Description string `json:"description,omitempty"` OperationID string `json:"operationId,omitempty"` Produces []string `json:"produces,omitempty"` Consumes []string `json:"consumes,omitempty"` Handler interface{} `json:"-"` Parameters []Parameter `json:"parameters,omitempty"` Responses map[string]Response `json:"responses,omitempty"` // swagger spec requires security to be an array of objects Security *SecurityRequirement `json:"security,omitempty"` Deprecated bool `json:"deprecated,omitempty"` }
Endpoint represents an endpoint from the swagger doc
func (*Endpoint) BuildOperationID ¶
func (e *Endpoint) BuildOperationID()
type Endpoints ¶
type Endpoints struct { Delete *Endpoint `json:"delete,omitempty"` Head *Endpoint `json:"head,omitempty"` Get *Endpoint `json:"get,omitempty"` Options *Endpoint `json:"options,omitempty"` Post *Endpoint `json:"post,omitempty"` Put *Endpoint `json:"put,omitempty"` Patch *Endpoint `json:"patch,omitempty"` Trace *Endpoint `json:"trace,omitempty"` Connect *Endpoint `json:"connect,omitempty"` }
Endpoints represents all the swagger endpoints associated with a particular path
type Header ¶
type Header struct { Type types.ParameterType `json:"type"` Format string `json:"format"` Description string `json:"description"` }
Header represents a response header
type Info ¶
type Info struct { Description string `json:"description,omitempty"` Version string `json:"version,omitempty"` TermsOfService string `json:"termsOfService,omitempty"` Title string `json:"title,omitempty"` Contact *Contact `json:"contact,omitempty"` License License `json:"license"` }
Info represents the info entity from the swagger definition
type Items ¶
type Items struct { Type string `json:"type,omitempty"` Format string `json:"format,omitempty"` Ref string `json:"$ref,omitempty"` }
Items represents items from the swagger doc
type Object ¶
type Object struct { IsArray bool `json:"-"` GoType reflect.Type `json:"-"` Name string `json:"-"` Type string `json:"type"` Description string `json:"description,omitempty"` Format string `json:"format,omitempty"` Required []string `json:"required,omitempty"` Properties map[string]Property `json:"properties,omitempty"` }
Object represents the object entity from the swagger definition
type Parameter ¶
type Parameter struct { In string `json:"in,omitempty"` Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` Required bool `json:"required"` Schema *Schema `json:"schema,omitempty"` Type types.ParameterType `json:"type,omitempty"` Format string `json:"format,omitempty"` Default string `json:"default,omitempty"` }
Parameter represents a parameter from the swagger doc
type Property ¶
type Property struct { GoType reflect.Type `json:"-"` Type string `json:"type,omitempty"` Description string `json:"description,omitempty"` Enum []string `json:"enum,omitempty"` Format string `json:"format,omitempty"` Ref string `json:"$ref,omitempty"` Example string `json:"example,omitempty"` Items *Items `json:"items,omitempty"` }
Property represents the property entity from the swagger definition
type Response ¶
type Response struct { Description string `json:"description"` Schema *Schema `json:"schema,omitempty"` Headers map[string]Header `json:"headers,omitempty"` }
Response represents a response from the swagger doc
type Schema ¶
type Schema struct { Type string `json:"type,omitempty"` Items *Items `json:"items,omitempty"` Ref string `json:"$ref,omitempty"` Prototype interface{} `json:"-"` }
Schema represents a schema from the swagger doc
func MakeSchema ¶
func MakeSchema(prototype interface{}) *Schema
MakeSchema takes struct or pointer to a struct and returns a Schema instance suitable for use by the swagger doc
type SecurityRequirement ¶
func (*SecurityRequirement) MarshalJSON ¶
func (s *SecurityRequirement) MarshalJSON() ([]byte, error)
type SecurityScheme ¶
type SecurityScheme struct { Type string `json:"type"` Description string `json:"description,omitempty"` Name string `json:"name,omitempty"` In string `json:"in,omitempty"` Flow string `json:"flow,omitempty"` AuthorizationURL string `json:"authorizationUrl,omitempty"` TokenURL string `json:"tokenUrl,omitempty"` Scopes map[string]string `json:"scopes,omitempty"` }
SecurityScheme represents a security scheme from the swagger definition.