Documentation ¶
Index ¶
- Constants
- type Analyzer
- type Swagger
- type SwaggerContact
- type SwaggerExternalDocumentation
- type SwaggerHeader
- type SwaggerInfo
- type SwaggerItems
- type SwaggerLicense
- type SwaggerOperation
- type SwaggerParam
- type SwaggerParamOrRef
- type SwaggerPathItem
- type SwaggerProperty
- type SwaggerRef
- type SwaggerResponse
- type SwaggerSchema
- type SwaggerSecurityScheme
- type SwaggerTag
- type Swaggerer
Constants ¶
View Source
const ( SwaggerVersion = "2.0" ApiDomain = "api.romana.io" )
View Source
const ( SwaggerInBody = "body" SwaggerInQuery = "query" SwaggerInPath = "path" SwaggerInFormData = "formData" SwaggerInHeader = "header" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Analyzer ¶
type Analyzer struct {
// contains filtered or unexported fields
}
Analyzer uses various reflection/introspection/code analysis methods to analyze code and store metadata about it, for various purposes. It works on a level of a Go "repository" (see https://golang.org/doc/code.html#Organization).
func NewAnalyzer ¶
NewAnalyzer creates a new Analyzer object for analysis of Go project in the provided path.
type Swagger ¶
type Swagger struct { Swagger string `yaml:"swagger,omitempty"` Info SwaggerInfo `yaml:"info,omitempty"` Host string `yaml:"host,omitempty"` BasePath string `yaml:"basePath,omitempty"` Schemes []string `yaml:"schemes,omitempty"` Consumes []string `yaml:"consumes,omitempty"` Produces []string `yaml:"produces,omitempty"` Paths map[string]*SwaggerPathItem `yaml:"paths,omitempty"` Definitions map[string]*SwaggerSchema `yaml:"definitions,omitempty"` }
func NewSwagger ¶
func NewSwagger() Swagger
type SwaggerContact ¶
type SwaggerExternalDocumentation ¶
type SwaggerExternalDocumentation struct { Description string `yaml:"description,omitempty"` URL string `yaml:"url,omitempty"` }
See http://swagger.io/specification/#externalDocumentationObject
type SwaggerHeader ¶
type SwaggerHeader struct { Type string `yaml:"type,omitempty"` Format string `yaml:"format,omitempty"` Default interface{} `yaml:"default,omitempty"` MultipleOf int `yaml:"multipleOf,omitempty"` Maximum int `yaml:"maximum,omitempty"` ExclusiveMaximum bool `yaml:"exclusiveMaximum,omitempty"` Minimum int `yaml:"minimum,omitempty"` ExclusiveMinimum bool `yaml:"exclusiveMinimum,omitempty"` MaxLength int `yaml:"maxLength,omitempty"` MinLength int `yaml:"minLength,omitempty"` Pattern string `yaml:"pattern,omitempty"` MaxItems int `yaml:"maxItems,omitempty"` MinItems int `yaml:"minItems,omitempty"` UniqueItems bool `yaml:"uniqueItems,omitempty"` MaxProperties int `yaml:"maxProperties,omitempty"` MinProperties int `yaml:"minProperties,omitempty"` Required bool `yaml:"required,omitempty"` Enum []interface{} `yaml:"enum,omitempty"` Items *SwaggerItems `yaml:"items,omitempty"` Properties map[string]SwaggerProperty `yaml:"properties,omitempty"` }
type SwaggerInfo ¶
type SwaggerInfo struct { Title string `yaml:"title,omitempty"` Description string `yaml:"description,omitempty"` TermsOfService string `yaml:"termsOfService,omitempty"` Contact SwaggerContact `yaml:"contact,omitempty"` License SwaggerLicense `yaml:"license,omitempty"` Version string `yaml:"version,omitempty"` }
type SwaggerItems ¶
type SwaggerItems struct { Type string `yaml:"type,omitempty"` Format string `yaml:"format,omitempty"` Default interface{} `yaml:"default,omitempty"` MultipleOf int `yaml:"multipleOf,omitempty"` Maximum int `yaml:"maximum,omitempty"` ExclusiveMaximum bool `yaml:"exclusiveMaximum,omitempty"` Minimum int `yaml:"minimum,omitempty"` ExclusiveMinimum bool `yaml:"exclusiveMinimum,omitempty"` MaxLength int `yaml:"maxLength,omitempty"` MinLength int `yaml:"minLength,omitempty"` Pattern string `yaml:"pattern,omitempty"` MaxItems int `yaml:"maxItems,omitempty"` MinItems int `yaml:"minItems,omitempty"` UniqueItems bool `yaml:"uniqueItems,omitempty"` MaxProperties int `yaml:"maxProperties,omitempty"` MinProperties int `yaml:"minProperties,omitempty"` Required bool `yaml:"required,omitempty"` Enum []interface{} `yaml:"enum,omitempty"` Items *SwaggerItems `yaml:"items,omitempty"` Properties map[string]SwaggerProperty `yaml:"properties,omitempty"` }
type SwaggerLicense ¶
type SwaggerOperation ¶
type SwaggerOperation struct { Tags []string `yaml:"tags,omitempty"` Summary string `yaml:"summary,omitempty"` Description string `yaml:"description,omitempty"` ExternalDocs SwaggerExternalDocumentation `yaml:"externalDocs,omitempty"` OperationId string `yaml:"operationId,omitempty"` Consumes []string `yaml:"consumes,omitempty"` Produces []string `yaml:"produces,omitempty"` Parameters []SwaggerParamOrRef `yaml:"parameters,omitempty"` Responses map[string]SwaggerResponse `yaml:"responses,omitempty"` Schemes []string `yaml:"schemes,omitempty"` Deprecated bool `yaml:"deprecated,omitempty"` SecurityDefinitions map[string]SwaggerSecurityScheme `yaml:"securityDefinitions,omitempty"` Security []map[string][]string `yaml:"security,omitempty"` }
type SwaggerParam ¶
type SwaggerParam struct { Name string `yaml:"name,omitempty"` In string `yaml:"in,omitempty"` Description string `yaml:"description,omitempty"` Required bool `yaml:"required,omitempty"` Schema SwaggerSchema `yaml:"required,omitempty"` AllowEmptyValue bool `yaml:"allowEmptyValue,omitempty"` Type string `yaml:"type,omitempty"` Format string `yaml:"format,omitempty"` Default interface{} `yaml:"default,omitempty"` MultipleOf int `yaml:"multipleOf,omitempty"` Maximum int `yaml:"maximum,omitempty"` ExclusiveMaximum bool `yaml:"exclusiveMaximum,omitempty"` Minimum int `yaml:"minimum,omitempty"` ExclusiveMinimum bool `yaml:"exclusiveMinimum,omitempty"` MaxLength int `yaml:"maxLength,omitempty"` MinLength int `yaml:"minLength,omitempty"` Pattern string `yaml:"pattern,omitempty"` MaxItems int `yaml:"maxItems,omitempty"` MinItems int `yaml:"minItems,omitempty"` UniqueItems bool `yaml:"uniqueItems,omitempty"` MaxProperties int `yaml:"maxProperties,omitempty"` MinProperties int `yaml:"minProperties,omitempty"` Enum []interface{} `yaml:"enum,omitempty"` Items *SwaggerItems `yaml:"items,omitempty"` Properties map[string]SwaggerProperty `yaml:"properties,omitempty"` }
type SwaggerParamOrRef ¶
type SwaggerParamOrRef struct { Name string `yaml:"name,omitempty"` In string `yaml:"in,omitempty"` Description string `yaml:"description,omitempty"` Required bool `yaml:"required,omitempty"` Schema SwaggerSchema `yaml:"schema,omitempty"` AllowEmptyValue bool `yaml:"allowEmptyValue,omitempty"` Type string `yaml:"type,omitempty"` Format string `yaml:"format,omitempty"` Default interface{} `yaml:"default,omitempty"` MultipleOf int `yaml:"multipleOf,omitempty"` Maximum int `yaml:"maximum,omitempty"` ExclusiveMaximum bool `yaml:"exclusiveMaximum,omitempty"` Minimum int `yaml:"minimum,omitempty"` ExclusiveMinimum bool `yaml:"exclusiveMinimum,omitempty"` MaxLength int `yaml:"maxLength,omitempty"` MinLength int `yaml:"minLength,omitempty"` Pattern string `yaml:"pattern,omitempty"` MaxItems int `yaml:"maxItems,omitempty"` MinItems int `yaml:"minItems,omitempty"` UniqueItems bool `yaml:"uniqueItems,omitempty"` MaxProperties int `yaml:"maxProperties,omitempty"` MinProperties int `yaml:"minProperties,omitempty"` Enum []interface{} `yaml:"enum,omitempty"` Items *SwaggerItems `yaml:"items,omitempty"` Properties map[string]SwaggerProperty `yaml:"properties,omitempty"` Ref string `yaml:"$ref,omitempty"` }
type SwaggerPathItem ¶
type SwaggerPathItem struct { Ref string `yaml:"$ref,omitempty"` Get SwaggerOperation `yaml:"get,omitempty"` Put SwaggerOperation `yaml:"put,omitempty"` Post SwaggerOperation `yaml:"post,omitempty"` Delete SwaggerOperation `yaml:"delete,omitempty"` Options SwaggerOperation `yaml:"options,omitempty"` Head SwaggerOperation `yaml:"head,omitempty"` Patch SwaggerOperation `yaml:"patch,omitempty"` Parameters []SwaggerParamOrRef `yaml:"parameters,omitempty"` }
type SwaggerProperty ¶
type SwaggerProperty struct { Description string `yaml:"description,omitempty"` Type string `yaml:"type,omitempty"` Format string `yaml:"format,omitempty"` Default interface{} `yaml:"default,omitempty"` MultipleOf int `yaml:"multipleOf,omitempty"` Maximum int `yaml:"maximum,omitempty"` ExclusiveMaximum bool `yaml:"exclusiveMaximum,omitempty"` Minimum int `yaml:"minimum,omitempty"` ExclusiveMinimum bool `yaml:"exclusiveMinimum,omitempty"` MaxLength int `yaml:"maxLength,omitempty"` MinLength int `yaml:"minLength,omitempty"` Pattern string `yaml:"pattern,omitempty"` MaxItems int `yaml:"maxItems,omitempty"` MinItems int `yaml:"minItems,omitempty"` UniqueItems bool `yaml:"uniqueItems,omitempty"` MaxProperties int `yaml:"maxProperties,omitempty"` MinProperties int `yaml:"minProperties,omitempty"` // Required bool `yaml:"required,omitempty"` Enum []interface{} `yaml:"enum,omitempty"` Items *SwaggerItems `yaml:"items,omitempty"` Properties map[string]SwaggerProperty `yaml:"properties,omitempty"` Ref string `yaml:"$ref,omitempty"` }
type SwaggerRef ¶
type SwaggerRef struct {
Ref string `yaml:"$ref,omitempty"`
}
type SwaggerResponse ¶
type SwaggerResponse struct { Description string `yaml:"description,omitempty"` Schema SwaggerSchema `yaml:"schema,omitempty"` Headers map[string]SwaggerHeader `yaml:"headers,omitempty"` Examples map[string]interface{} `yaml:"examples,omitempty"` }
type SwaggerSchema ¶
type SwaggerSchema struct { Ref string `yaml:"$ref,omitempty"` Title string `yaml:"title,omitempty"` Description string `yaml:"description,omitempty"` Type string `yaml:"type,omitempty"` Format string `yaml:"format,omitempty"` Default interface{} `yaml:"default,omitempty"` MultipleOf int `yaml:"multipleOf,omitempty"` Maximum int `yaml:"maximum,omitempty"` ExclusiveMaximum bool `yaml:"exclusiveMaximum,omitempty"` Minimum int `yaml:"minimum,omitempty"` ExclusiveMinimum bool `yaml:"exclusiveMinimum,omitempty"` MaxLength int `yaml:"maxLength,omitempty"` MinLength int `yaml:"minLength,omitempty"` Pattern string `yaml:"pattern,omitempty"` MaxItems int `yaml:"maxItems,omitempty"` MinItems int `yaml:"minItems,omitempty"` UniqueItems bool `yaml:"uniqueItems,omitempty"` MaxProperties int `yaml:"maxProperties,omitempty"` MinProperties int `yaml:"minProperties,omitempty"` Enum []interface{} `yaml:"enum,omitempty"` Items *SwaggerItems `yaml:"items,omitempty"` // See http://json-schema.org/latest/json-schema-validation.html#anchor61 Required []string `yaml:"required,omitempty"` Properties map[string]SwaggerProperty `yaml:"properties,omitempty"` }
type SwaggerSecurityScheme ¶
type SwaggerSecurityScheme struct { Type string `yaml:"type,omitempty"` Description string `yaml:"description,omitempty"` Name string `yaml:"name,omitempty"` In string `yaml:"in,omitempty"` Flow string `yaml:"flow,omitempty"` AuthorizationURL string `yaml:"authorizationUrl,omitempty"` Scopes map[string]string `yaml:"scopes,omitempty"` }
type SwaggerTag ¶
type SwaggerTag struct { Name string `yaml:"name,omitempty"` Description string `yaml:"description,omitempty"` ExternalDocs SwaggerExternalDocumentation `yaml:"externalDocs,omitempty"` }
type Swaggerer ¶
type Swaggerer struct {
// contains filtered or unexported fields
}
func NewSwaggerer ¶
NewSwaggerer creates a new instance of Swaggerer.
func (*Swaggerer) Process ¶
Process processes the code yielding a []byte of the YAML representation of the Swagger defintion. The processing rules are as follows:
- For each common.Service found, go over its Routes (whatever Routes() method yields) and based on that create the paths and operations.
- For structs, field-level comments are taken from the description value of "romana" structure tag. For example: type Policy struct { Direction string `json:"direction,omitempty" romana:"desc:Direction is one of 'ingress' or egress'."` ... }
Click to show internal directories.
Click to hide internal directories.