swagger

package
v0.0.0-...-7c1bd55 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2017 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package swagger struct definition

Index

Constants

View Source
const Version = "2.0"

Version show the current swagger version

Variables

View Source
var CommonMIMETypes = []string{
	"application/json",
	"application/javascript",
	"application/xml",
	"application/x-www-form-urlencoded",
	"application/protobuf",
	"application/msgpack",
	"text/html",
	"text/plain",
	"multipart/form-data",
	"application/octet-stream",
}

CommonMIMETypes common MIME types

Functions

func Asset

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDir

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.

func AssetFS

func AssetFS() *assetfs.AssetFS

func AssetInfo

func AssetInfo(name string) (os.FileInfo, error)

AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetNames

func AssetNames() []string

AssetNames returns the names of the assets.

func CreateProperties

func CreateProperties(obj interface{}) map[string]*Property

CreateProperties creates properties

func MustAsset

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.

func ParamType

func ParamType(value interface{}) string

ParamType type of the parameter value passed in

func RestoreAsset

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory

func RestoreAssets

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively

func SliceInfo

func SliceInfo(value interface{}) (subtyp string, first interface{}, count int)

SliceInfo slice parameter information

Types

type Contact

type Contact struct {
	Email string `json:"email,omitempty"`
}

Contact object

type Definition

type Definition struct {
	Type       string               `json:"type,omitempty"` // "object"
	Properties map[string]*Property `json:"properties,omitempty"`
	Xml        *Xml                 `json:"xml,omitempty"`
}

Definition object

type Info

type Info struct {
	Title          string   `json:"title"`
	ApiVersion     string   `json:"version"`
	Description    string   `json:"description"`
	Contact        *Contact `json:"contact"`
	TermsOfService string   `json:"termsOfService"`
	License        *License `json:"license,omitempty"`
}

Info object

type Items

type Items struct {
	Ref     string      `json:"$ref,omitempty"`
	Type    string      `json:"type"`           // "string"
	Enum    interface{} `json:"enum,omitempty"` // slice
	Default interface{} `json:"default,omitempty"`
}

Items object

type License

type License struct {
	Name string `json:"name"`
	Url  string `json:"url"`
}

License object

type Opera

type Opera struct {
	Tags        []string              `json:"tags"`
	Summary     string                `json:"summary"`
	Description string                `json:"description"`
	OperationId string                `json:"operationId"`
	Consumes    []string              `json:"consumes,omitempty"`
	Produces    []string              `json:"produces,omitempty"`
	Parameters  []*Parameter          `json:"parameters,omitempty"`
	Responses   map[string]*Resp      `json:"responses,omitempty"` // {"httpcode":resp}
	Security    []map[string][]string `json:"security,omitempty"`
}

Opera object

type Parameter

type Parameter struct {
	In               string      `json:"in"` // the position of the parameter
	Name             string      `json:"name"`
	Description      string      `json:"description"`
	Required         bool        `json:"required"`
	Type             string      `json:"type,omitempty"` // "array"|"integer"|"object"
	Items            *Items      `json:"items,omitempty"`
	Schema           *Schema     `json:"schema,omitempty"`
	CollectionFormat string      `json:"collectionFormat,omitempty"` // "multi"
	Format           string      `json:"format,omitempty"`           // "int64"
	Default          interface{} `json:"default,omitempty"`
}

Parameter object

type Property

type Property struct {
	Type        string      `json:"type,omitempty"`   // "array"|"integer"|"object"
	Format      string      `json:"format,omitempty"` // "int64"
	Description string      `json:"description,omitempty"`
	Enum        []string    `json:"enum,omitempty"`
	Example     interface{} `json:"example,omitempty"`
	Default     interface{} `json:"default,omitempty"`
}

Property object

type Resp

type Resp struct {
	Schema      *Schema `json:"schema,omitempty"`
	Description string  `json:"description,omitempty"`
}

Resp object

type Schema

type Schema struct {
	Ref                  string            `json:"$ref,omitempty"`
	Type                 string            `json:"type,omitempty"` // "array"|"integer"|"object"
	Items                *Items            `json:"items,omitempty"`
	Description          string            `json:"description,omitempty"`
	AdditionalProperties map[string]string `json:"additionalProperties,omitempty"`
}

Schema object

type Swagger

type Swagger struct {
	Version             string                            `json:"swagger"`
	Info                *Info                             `json:"info"`
	Host                string                            `json:"host"`
	BasePath            string                            `json:"basePath"`
	Tags                []*Tag                            `json:"tags"`
	Schemes             []string                          `json:"schemes"`
	Paths               map[string]map[string]*Opera      `json:"paths,omitempty"` // {"prefix":{"method":{...}}}
	SecurityDefinitions map[string]map[string]interface{} `json:"securityDefinitions,omitempty"`
	Definitions         map[string]*Definition            `json:"definitions,omitempty"`
	ExternalDocs        map[string]string                 `json:"externalDocs,omitempty"`
}

Swagger object

type Tag

type Tag struct {
	Name        string `json:"name"`
	Description string `json:"description"`
}

Tag object

type Xml

type Xml struct {
	Name    string `json:"name"`
	Wrapped bool   `json:"wrapped,omitempty"`
}

Xml object

Jump to

Keyboard shortcuts

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