swagger

package module
v0.0.0-...-05505d2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 27, 2014 License: MIT Imports: 0 Imported by: 0

README

swagger

Go package to export API doc for swagger-ui

What is swagger ?

Check out Swagger-ui

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Api

type Api struct {
	Path        string           `json:"path"` // relative or absolute, must start with /
	Description string           `json:"description"`
	Operations  []Operation      `json:"operations,omitempty"`
	Models      map[string]Model `json:"models,omitempty"`
}

func NewApi

func NewApi(path string, description string) (api Api)

func (*Api) AddOperation

func (api *Api) AddOperation(op Operation)

type ApiDeclaration

type ApiDeclaration struct {
	ApiVersion     string   `json:"apiVersion"`
	SwaggerVersion string   `json:"swaggerVersion"`
	BasePath       string   `json:"basePath"`
	ResourcePath   string   `json:"resourcePath"` // must start with /
	Apis           []Api    `json:"apis,omitempty"`
	Consumes       []string `json:"consumes,omitempty"`
	Produces       []string `json:"produces,omitempty"`
}

func NewApiDeclaration

func NewApiDeclaration(version string, basePath string, ressourcePath string) (decl ApiDeclaration)

func (*ApiDeclaration) AddApi

func (decl *ApiDeclaration) AddApi(api Api)

type ApiKey

type ApiKey struct {
	Type   string `json:"type"`   // e.g. apiKey
	PassAs string `json:"passAs"` // e.g. header
}

https://github.com/wordnik/swagger-core/wiki/authorizations

type Authorization

type Authorization struct {
	LocalOAuth OAuth  `json:"local-oauth"`
	ApiKey     ApiKey `json:"apiKey"`
}

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"`
}

https://github.com/wordnik/swagger-core/wiki/authorizations

type ErrorResponse

type ErrorResponse struct {
	Code   int    `json:"code"`
	Reason string `json:"reason"`
}

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"`
}

https://github.com/wordnik/swagger-core/wiki/authorizations

type Model

type Model struct {
	Id         string                   `json:"id"`
	Required   []string                 `json:"required"`
	Properties map[string]ModelProperty `json:"properties"`
}

type ModelProperty

type ModelProperty struct {
	Type        string            `json:"type"`
	Description string            `json:"description"`
	Items       map[string]string `json:"items,omitempty"`
}

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"`
}

https://github.com/wordnik/swagger-core/wiki/authorizations

type Operation

type Operation struct {
	HttpMethod string `json:"httpMethod"`
	Nickname   string `json:"nickname"`
	Type       string `json:"type"` // in 1.1 = DataType
	// ResponseClass    string            `json:"responseClass"` obsolete in 1.2
	Summary          string            `json:"summary,omitempty"`
	Notes            string            `json:"notes,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"`
	Protocols        []Protocol        `json:"protocols,omitempty"`
}

func NewOperation

func NewOperation(operation string, nickname string, typ string, summary string, notes string) (op Operation)

func (*Operation) AddParameter

func (op *Operation) AddParameter(param Parameter)

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
	Required    bool   `json:"required"`
	Minimum     int    `json:"minimum"`
	Maximum     int    `json:"maximum"`
}

func NewParameter

func NewParameter(name string, dataType string, description string, required bool, format string) (param Parameter)

type Protocol

type Protocol struct {
}

type ResourceListing

type ResourceListing struct {
	ApiVersion     string `json:"apiVersion"`
	SwaggerVersion string `json:"swaggerVersion"` // e.g 1.2
	// BasePath       string `json:"basePath"`  obsolete in 1.1
	Apis []Api `json:"apis"`
}

func NewRessourceListing

func NewRessourceListing(apiVersion string, apis []Api) (rl ResourceListing)

func (*ResourceListing) AddApi

func (rl *ResourceListing) AddApi(api Api)

type ResponseMessage

type ResponseMessage struct {
	Code          int    `json:"code"`
	Message       string `json:"message"`
	ResponseModel string `json:"responseModel"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL