Documentation ¶
Index ¶
- Constants
- Variables
- func IsBasicType(typeName string) bool
- func IsIgnoredPackage(packageName string) bool
- func ParserFileFilter(info os.FileInfo) bool
- type Api
- type ApiDeclaration
- type ApiKey
- type ApiRef
- type Authorization
- type Endpoint
- type ErrorResponse
- type GrantType
- type Infomation
- type Model
- type ModelProperty
- type ModelPropertyItems
- type OAuth
- type Operation
- func (operation *Operation) ParseAcceptComment(commentLine string) error
- func (operation *Operation) ParseComment(comment string) error
- func (operation *Operation) ParseParamComment(commentLine string) error
- func (operation *Operation) ParseResponseComment(commentLine string) error
- func (operation *Operation) ParseRouterComment(commentLine string) error
- func (operation *Operation) SetItemsType(itemsType string)
- type OperationItems
- type Parameter
- type Parser
- func (parser *Parser) AddOperation(op *Operation)
- func (parser *Parser) CheckRealPackagePath(packagePath string) string
- func (parser *Parser) FindModelDefinition(modelName string, currentPackage string) (*ast.TypeSpec, string)
- func (parser *Parser) GetApiDescriptionJson() []byte
- func (parser *Parser) GetModelDefinition(model string, packageName string) *ast.TypeSpec
- func (parser *Parser) GetPackageAst(packagePath string) map[string]*ast.Package
- func (parser *Parser) GetRealPackagePath(packagePath string) string
- func (parser *Parser) GetResourceListingJson() []byte
- func (parser *Parser) IsImplementMarshalInterface(typeName string) bool
- func (parser *Parser) ParseApi(packageNames string)
- func (parser *Parser) ParseApiDescription(packageName string)
- func (parser *Parser) ParseGeneralApiInfo(mainApiFile string)
- func (parser *Parser) ParseImportStatements(packageName string) map[string]bool
- func (parser *Parser) ParseSubApiDescription(commentLine string)
- func (parser *Parser) ParseTypeDefinitions(packageName string)
- func (parser *Parser) ScanPackages(packages []string) []string
- type Protocol
- type ResourceListing
- type ResponseMessage
Constants ¶
View Source
const ( ContentTypeJson = "application/json" ContentTypeXml = "application/xml" ContentTypePlain = "text/plain" ContentTypeHtml = "text/html" )
View Source
const SwaggerVersion = "1.2"
Variables ¶
View Source
var CommentIsEmptyError = errors.New("Comment is empty")
Functions ¶
func IsBasicType ¶
func IsIgnoredPackage ¶
func ParserFileFilter ¶
Types ¶
type Api ¶
type ApiDeclaration ¶
type ApiDeclaration struct { ApiVersion string `json:"apiVersion"` SwaggerVersion string `json:"swaggerVersion"` BasePath string `json:"basePath"` ResourcePath string `json:"resourcePath"` // must start with / Consumes []string `json:"-"` Produces []string `json:"produces,omitempty"` Apis []*Api `json:"apis,omitempty"` Models map[string]*Model `json:"models,omitempty"` }
https://github.com/wordnik/swagger-core/blob/scala_2.10-1.3-RC3/schemas/api-declaration-schema.json
func NewApiDeclaration ¶
func NewApiDeclaration() *ApiDeclaration
func (*ApiDeclaration) AddConsumedTypes ¶
func (api *ApiDeclaration) AddConsumedTypes(op *Operation)
func (*ApiDeclaration) AddModels ¶
func (api *ApiDeclaration) AddModels(op *Operation)
func (*ApiDeclaration) AddOperation ¶
func (api *ApiDeclaration) AddOperation(op *Operation)
func (*ApiDeclaration) AddProducesTypes ¶
func (api *ApiDeclaration) AddProducesTypes(op *Operation)
func (*ApiDeclaration) AddSubApi ¶
func (api *ApiDeclaration) AddSubApi(op *Operation)
type ApiKey ¶
type Authorization ¶
type Endpoint ¶
type ErrorResponse ¶
type GrantType ¶
type Infomation ¶
type Infomation struct { Title string `json:"title,omitempty"` Description string `json:"description,omitempty"` Contact string `json:"contact,omitempty"` TermsOfServiceUrl string `json:"termsOfServiceUrl,omitempty"` License string `json:"license,omitempty"` LicenseUrl string `json:"licenseUrl,omitempty"` }
type Model ¶
type Model struct { Id string `json:"id"` Required []string `json:"required,omitempty"` Properties map[string]*ModelProperty `json:"properties"` // contains filtered or unexported fields }
func (*Model) ParseFieldList ¶
type ModelProperty ¶
type ModelProperty struct { Type string `json:"type"` Description string `json:"description"` Items ModelPropertyItems `json:"items,omitempty"` Format string `json:"format"` }
func NewModelProperty ¶
func NewModelProperty() *ModelProperty
func (*ModelProperty) GetTypeAsString ¶
func (p *ModelProperty) GetTypeAsString(fieldType interface{}) string
func (*ModelProperty) SetItemType ¶
func (p *ModelProperty) SetItemType(itemType string)
type ModelPropertyItems ¶
type OAuth ¶
type Operation ¶
type Operation struct { HttpMethod string `json:"httpMethod"` Nickname string `json:"nickname"` Type string `json:"type"` Items OperationItems `json:"items,omitempty"` Summary string `json:"summary,omitempty"` Notes string `json:"notes,omitempty"` Parameters []Parameter `json:"parameters,omitempty"` ResponseMessages []ResponseMessage `json:"responseMessages,omitempty"` Consumes []string `json:"-"` Produces []string `json:"produces,omitempty"` Authorizations []Authorization `json:"authorizations,omitempty"` Protocols []Protocol `json:"protocols,omitempty"` Path string `json:"-"` ForceResource string `json:"-"` Models []*Model `json:"-"` // contains filtered or unexported fields }
func NewOperation ¶
func (*Operation) ParseAcceptComment ¶
@Accept json
func (*Operation) ParseComment ¶
func (*Operation) ParseParamComment ¶
Parse params return []string of param properties @Param queryText form string true "The email for login"
[param name] [param type] [data type] [is mandatory?] [Comment]
func (*Operation) ParseResponseComment ¶
@Success 200 {object} model.OrderRow "Error message, if code != 200"
func (*Operation) ParseRouterComment ¶
@Router /customer/get-wishlist/{wishlist_id} [get]
func (*Operation) SetItemsType ¶
type OperationItems ¶
type Parameter ¶
type Parameter struct { ParamType string `json:"paramType"` // path,query,body,header,form Name string `json:"name"` Description string `json:"description"` DataType string `json:"dataType"` // 1.2 needed? Type string `json:"type"` // integer Format string `json:"format"` // int64 AllowMultiple bool `json:"allowMultiple"` Required bool `json:"required"` Minimum int `json:"minimum"` Maximum int `json:"maximum"` }
type Parser ¶
type Parser struct { Listing *ResourceListing TopLevelApis map[string]*ApiDeclaration PackagesCache map[string]map[string]*ast.Package CurrentPackage string TypeDefinitions map[string]map[string]*ast.TypeSpec PackagePathCache map[string]string PackageImports map[string]map[string][]string BasePath string IsController func(*ast.FuncDecl) bool TypesImplementingMarshalInterface map[string]string }
func (*Parser) AddOperation ¶
func (*Parser) CheckRealPackagePath ¶
func (*Parser) FindModelDefinition ¶
func (*Parser) GetApiDescriptionJson ¶
func (*Parser) GetModelDefinition ¶
func (*Parser) GetPackageAst ¶
func (*Parser) GetRealPackagePath ¶
func (*Parser) GetResourceListingJson ¶
func (*Parser) IsImplementMarshalInterface ¶
func (*Parser) ParseApiDescription ¶
func (*Parser) ParseGeneralApiInfo ¶
Read web/main.go to get General info
func (*Parser) ParseImportStatements ¶
func (*Parser) ParseSubApiDescription ¶
Parse sub api declaration @SubApi Very fancy API [/fancy-api]
func (*Parser) ParseTypeDefinitions ¶
func (*Parser) ScanPackages ¶
type ResourceListing ¶
type ResourceListing struct { ApiVersion string `json:"apiVersion"` SwaggerVersion string `json:"swaggerVersion"` // BasePath string `json:"basePath"` Apis []*ApiRef `json:"apis"` Infos Infomation `json:"info"` }
type ResponseMessage ¶
Click to show internal directories.
Click to hide internal directories.