Documentation ¶
Index ¶
- func GoTypeToSwagger(t reflect.Type) (string, string, string)
- func ModelName(t reflect.Type) string
- type Api
- type ApiDeclaration
- type ApiKey
- type Authorization
- type Endpoint
- type GrantType
- type Model
- type ModelProperty
- type NestedItems
- type OAuth
- type Operation
- type Parameter
- type Path
- type ResourceListing
- type Response
- type ResponseMessage
- type Schema
- type SwaggerApiInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GoTypeToSwagger ¶
Transforms a go type to swagger type/format it is incomplete for now
Types ¶
type Api ¶
type Api struct { Operations []Operation `json:"operations,omitempty"` Models map[string]Model `json:"models,omitempty"` }
Api is https://github.com/swagger-api/swagger-spec/blob/master/versions/1.2.md#522-api-object
type ApiDeclaration ¶
type ApiDeclaration struct { SwaggerApiInfo SwaggerApiInfo `json:"info"` Swagger string `json:"swagger"` BasePath string `json:"basePath,omitempty"` Paths map[string]map[string]Operation `json:"paths"` Definitions map[string]Model `json:"definitions"` }
ApiDeclaration is https://github.com/swagger-api/swagger-spec/blob/master/versions/1.2.md#52-api-declaration
func NewApiDeclaration ¶
func NewApiDeclaration(version string, basePath string) *ApiDeclaration
NewApiDeclaration returns a bootstrapedApiDeclaration
func (*ApiDeclaration) AddModel ¶
func (decl *ApiDeclaration) AddModel(m Model)
AddModel does just what it says
func (*ApiDeclaration) GetSDKPaths ¶
func (decl *ApiDeclaration) GetSDKPaths() map[string]map[string]Operation
GetSDKPaths filters out non relevant paths/operations for the SDKS at the moment just skips Operation marked as IsMonitoring
func (*ApiDeclaration) ToJSON ¶
func (decl *ApiDeclaration) ToJSON() string
ToJSON is a shortcut to json.MarshalIndent
type ApiKey ¶
type ApiKey struct { Type string `json:"type"` // e.g. apiKey PassAs string `json:"passAs"` // e.g. header }
ApiKey is https://github.com/wordnik/swagger-core/wiki/authorizations
type Authorization ¶
Authorization is https://github.com/wordnik/swagger-core/wiki/authorizations
type Endpoint ¶
type Endpoint struct { Url string `json:"url"` ClientIdName string `json:"clientIdName"` ClientSecretName string `json:"clientSecretName"` TokenName string `json:"tokenName"` }
Endpoint is https://github.com/wordnik/swagger-core/wiki/authorizations
type GrantType ¶
type GrantType struct { LoginEndpoint Endpoint `json:"loginEndpoint"` TokenName string `json:"tokenName"` // e.g. access_code TokenRequestEndpoint Endpoint `json:"tokenRequestEndpoint"` TokenEndpoint Endpoint `json:"tokenEndpoint"` }
GrantType is https://github.com/wordnik/swagger-core/wiki/authorizations
type Model ¶
type Model struct { Id string `json:"-"` Description string `json:"description,omitempty"` Required []string `json:"required,omitempty"` Properties map[string]*ModelProperty `json:"properties"` }
Model is https://github.com/swagger-api/swagger-spec/blob/master/versions/1.2.md#527-model-object
type ModelProperty ¶
type ModelProperty struct { Type string `json:"type,omitempty"` RefId string `json:"$ref,omitempty"` Format string `json:"format,omitempty"` Description string `json:"description,omitempty"` Items *NestedItems `json:"items,omitempty"` AdditionalProperties *NestedItems `json:"additionalProperties,omitempty"` Enum []string `json:"enum,omitempty"` Required bool `json:"-"` HideOnListing bool `json:"-"` //Hide this property on listing methods, activated with the swag omitinlisting }
ModelProperty is https://github.com/swagger-api/swagger-spec/blob/master/versions/1.2.md#528-properties-object
type NestedItems ¶
type NestedItems struct { Type string `json:"type,omitempty"` RefId string `json:"$ref,omitempty"` Items *NestedItems `json:"items,omitempty"` AdditionalProperties *NestedItems `json:"additionalProperties,omitempty"` }
TODO Unify this struct and swagger.Schema in a common struct to accomodate model, params, response types
type OAuth ¶
type OAuth struct { Type string `json:"type"` // e.g. oauth2 Scopes []string `json:"scopes"` // e.g. PUBLIC GrantTypes map[string]GrantType `json:"grantTypes"` }
OAuth is https://github.com/wordnik/swagger-core/wiki/authorizations
type Operation ¶
type Operation struct { HttpMethod string `json:"-"` Nickname string `json:"-"` Items map[string]string `json:"items,omitempty"` Type string `json:"-"` Summary string `json:"summary,omitempty"` Description string `json:"description,omitempty"` Parameters []Parameter `json:"parameters,omitempty"` ResponseMessages []ResponseMessage `json:"responseMessages,omitempty"` // optional Consumes []string `json:"consumes,omitempty"` Produces []string `json:"produces,omitempty"` Authorizations []Authorization `json:"authorizations,omitempty"` Responses map[string]Response `json:"responses"` Tags []string `json:"tags,omitempty"` IsMonitoring bool `json:"-"` Deprecated bool `json:"deprecated"` }
func NewOperation ¶
func NewOperation(httpMethod, nickname, summary, typ, description string, deprecated bool) (op Operation)
NewOperation returns an op
func (*Operation) AddParameter ¶
AddParameter adds a param to operation
type Parameter ¶
type Parameter struct { ParamType string `json:"in"` // path,query,body,header,form Name string `json:"name"` Description string `json:"description"` Required bool `json:"required"` AllowMultiple bool `json:"-"` // then it's an array Type string `json:"type,omitempty"` // integer Format string `json:"format,omitempty"` // int64 Enum []string `json:"enum,omitempty"` CollectionFormat string `json:"collectionFormat,omitempty"` // csv/ssv/tsv/pipe/multi, defaults to csv on swagger spec RefId string `json:"$ref,omitempty"` Minimum int `json:"minimum,omitempty"` Maximum int `json:"maximum,omitempty"` Default string `json:"default,omitempty"` Items map[string]string `json:"items,omitempty"` Schema *Schema `json:"schema,omitempty"` }
type Path ¶
Swagger Path https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#pathItemObject
type ResourceListing ¶
type ResourceListing struct { ApiVersion string `json:"apiVersion"` SwaggerVersion string `json:"swaggerVersion"` // e.g 1.2 }
ResourceListing is https://github.com/swagger-api/swagger-spec/blob/master/versions/1.2.md#51-resource-listing
type ResponseMessage ¶
type ResponseMessage struct { Code int `json:"code"` Message string `json:"message"` ResponseModel string `json:"responseModel"` }
ResponseMessage is https://github.com/swagger-api/swagger-spec/blob/master/versions/1.2.md#525-response-message-object