swagger

package
v0.0.0-...-85b7a69 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2018 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const SwaggerGlobalParam = "_swaggerGlobalParamKey"

Variables

This section is empty.

Functions

func InitializeApiRoutes

func InitializeApiRoutes(r kelly.Kelly, config *Config, docLoader DocLoader)

func SetGlobalParam

func SetGlobalParam(extra *StructParam) kelly.AnnotationHandlerFunc

func SliceContain

func SliceContain(s []string, e string) bool

func Swagger

func Swagger(extra *StructParam) kelly.AnnotationHandlerFunc

func SwaggerFile

func SwaggerFile(entry string) kelly.AnnotationHandlerFunc

Types

type Config

type Config struct {
	// "api前缀,例如/api/v1",默认为空
	BasePath string

	// swagger文档标题
	Title string

	// swagger文档描述
	Description string

	// 文档版本
	DocVersion string

	// swagger ui的地址
	SwaggerUiUrl string

	// 文档Url地址,例如开发服务器http://baidu.com
	// 如果本值是doc,那么http://baidu.com/doc就可以重定向到@SwaggerUiUrl
	SwaggerUrlPrefix string

	// swagger文档的地址,用于调试,release直接打包到二进制里面。默认为空
	DocFilePath string

	// 用于支持swagger ui认证头的参数
	Headers []SecurityDefinition

	// 是否调试模式
	Debug bool
}

type DocLoader

type DocLoader func(key string) ([]byte, error)

type JsonSchemaObj

type JsonSchemaObj struct {
	Description string                    `json:"description,omitempty" yaml:"description"`
	Type        string                    `json:"type,omitempty" yaml:"type" binding:"required,min=1"`
	Items       *JsonSchemaObj            `json:"items,omitempty" yaml:"items"`
	Properties  map[string]*JsonSchemaObj `json:"properties,omitempty" yaml:"properties"`
	Required    []string                  `json:"required,omitempty" yaml:"required"`
	Schema      *JsonSchemaObj            `json:"schema,omitempty" yaml:"schema"`
}

func (*JsonSchemaObj) ParseObject

func (obj *JsonSchemaObj) ParseObject(variable interface{})

type SecurityDefinition

type SecurityDefinition struct {
	Description string `json:"description,omitempty"`
	Type        string `json:"type"`
	In          string `json:"in"`
	Name        string `json:"name"`
}

type StructParam

type StructParam struct {
	FormData     interface{}
	JsonData     interface{}
	QueryData    interface{}
	PathData     interface{}
	ResponseData interface{}
	Description  string
	Summary      string
	Tags         []string
}

type SuccessResp

type SuccessResp struct {
	Message string `json:"message,omitempty" yaml:"message"`
	Result  int    `json:"result" yaml:"result"`
}

type SwaggerDocFile

type SwaggerDocFile map[string]SwaggerMethodEntry

type SwaggerEntry

type SwaggerEntry struct {
	Post   *SwaggerMethodEntry `json:"post,omitempty"`
	Get    *SwaggerMethodEntry `json:"get,omitempty"`
	Put    *SwaggerMethodEntry `json:"put,omitempty"`
	Delete *SwaggerMethodEntry `json:"delete,omitempty"`
	Patch  *SwaggerMethodEntry `json:"patch,omitempty"`
}

func (*SwaggerEntry) SetMethod

func (sentry *SwaggerEntry) SetMethod(method string, entry SwaggerMethodEntry)

type SwaggerMethodEntry

type SwaggerMethodEntry struct {
	Description string                    `json:"description,omitempty" yaml:"description"`
	Summary     string                    `json:"summary" yaml:"summary"`
	Tags        []string                  `json:"tags" yaml:"tags" binding:"required,dive,required"`
	Parameters  []*SwaggerMethodParameter `json:"parameters" yaml:"parameters" binding:"dive"`
	Produces    []string                  `json:"produces,omitempty" yaml:"produces"`
	Responses   map[int]*JsonSchemaObj    `json:"responses" yaml:"responses" binding:"required"`
}

func NewSwaggerMethodEntry

func NewSwaggerMethodEntry(param *StructParam) *SwaggerMethodEntry

type SwaggerMethodParameter

type SwaggerMethodParameter struct {
	Description string         `json:"description,omitempty" yaml:"description"`
	In          string         `json:"in" yaml:"in" binding:"eq=query|eq=path|eq=formData|eq=body|eq=header"`
	Name        string         `json:"name" yaml:"name" binding:"required,max=100,min=1"`
	Required    bool           `json:"required" yaml:"required"`
	Type        string         `json:"type" yaml:"type" binding:"eq=string|eq=integer|eq=number|eq=boolean|eq=array|eq=object|eq=file"`
	Schema      *JsonSchemaObj `json:"schema,omitempty" yaml:"schema"`
}

Jump to

Keyboard shortcuts

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