Documentation ¶
Overview ¶
Package swag converts Go annotations to Swagger Documentation 2.0. See https://github.com/swaggo/swag for more information about swag.
Index ¶
- Constants
- func CheckSchemaType(typeName string)
- func GetSchemes(commentLine string) []string
- func ReadDoc() (string, error)
- func Register(name string, swagger Swagger)
- func TransToValidSchemeType(typeName string) string
- type Operation
- func (operation *Operation) ParseAcceptComment(commentLine string) error
- func (operation *Operation) ParseComment(comment string) error
- func (operation *Operation) ParseEmptyResponseComment(commentLine string) error
- func (operation *Operation) ParseParamComment(commentLine string) error
- func (operation *Operation) ParseProduceComment(commentLine string) error
- func (operation *Operation) ParseResponseComment(commentLine string) error
- func (operation *Operation) ParseRouterComment(commentLine string) error
- func (operation *Operation) ParseTagsComment(commentLine string)
- type Parser
- func (parser *Parser) GetSwagger() *spec.Swagger
- func (parser *Parser) ParseApi(searchDir string, mainApiFile string)
- func (parser *Parser) ParseDefinition(pkgName string, typeSpec *ast.TypeSpec, typeName string)
- func (parser *Parser) ParseDefinitions()
- func (parser *Parser) ParseGeneralApiInfo(mainApiFile string)
- func (parser *Parser) ParseRouterApiInfo(astFile *ast.File)
- func (parser *Parser) ParseType(astFile *ast.File)
- type Swagger
Constants ¶
const Name = "swagger"
Variables ¶
This section is empty.
Functions ¶
func CheckSchemaType ¶ added in v1.1.1
func CheckSchemaType(typeName string)
func GetSchemes ¶
GetSchemes parses swagger schemes for gived commentLine
func TransToValidSchemeType ¶ added in v1.1.1
Types ¶
type Operation ¶
type Operation struct { HttpMethod string Path string spec.Operation // contains filtered or unexported fields }
Operation describes a single API operation on a path. For more information: https://github.com/swaggo/swag#api-operation
func NewOperation ¶
func NewOperation() *Operation
NewOperation creates a new Operation with default properties. map[int]Response
func (*Operation) ParseAcceptComment ¶
ParseAcceptComment parses comment for gived `accept` comment string.
func (*Operation) ParseComment ¶
ParseComment parses comment for gived comment string and returns error if error occurs.
func (*Operation) ParseEmptyResponseComment ¶
func (*Operation) ParseParamComment ¶
Parse params return []string of param properties @Param queryText form string true "The email for login"
[param name] [paramType] [data type] [is mandatory?] [Comment]
@Param some_id path int true "Some ID"
func (*Operation) ParseProduceComment ¶
ParseProduceComment parses comment for gived `produce` comment string.
func (*Operation) ParseResponseComment ¶
ParseResponseComment parses comment for gived `response` comment string.
func (*Operation) ParseRouterComment ¶
ParseRouterComment parses comment for gived `router` comment string.
func (*Operation) ParseTagsComment ¶ added in v1.1.0
ParseTagsComment parses comment for gived `tag` comment string.
type Parser ¶
type Parser struct { // TypeDefinitions is a map that stores [package name][type name][*ast.TypeSpec] TypeDefinitions map[string]map[string]*ast.TypeSpec // contains filtered or unexported fields }
Parser implements a parser for Go source files.
func (*Parser) GetSwagger ¶
GetSwagger returns *spec.Swagger which is the root document object for the API specification.
func (*Parser) ParseDefinition ¶ added in v1.1.1
Build
func (*Parser) ParseDefinitions ¶
func (parser *Parser) ParseDefinitions()
ParseDefinitions parses Swagger Api definitions
func (*Parser) ParseGeneralApiInfo ¶
ParseGeneralApiInfo parses general api info for gived mainApiFile path
func (*Parser) ParseRouterApiInfo ¶
ParseRouterApiInfo parses router api info for gived astFile