swagger

package
v0.0.0-...-d4aa6c0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2016 License: BSD-2-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const SwaggerVersion = "2.0"

Variables

This section is empty.

Functions

func TypeOf

func TypeOf(t reflect.Type, defaultType Type) (tp Type, items Type)

Types

type API

type API struct {
	SwaggerVersion string            `json:"swagger"`
	Info           Info              `json:"info,omitempty"`
	Host           string            `json:"host"`
	Basepath       string            `json:"basePath"`
	Schemes        []string          `json:"schemes"`
	Consumes       []string          `json:"consumes"`
	Produces       []string          `json:"produces"`
	Paths          map[string]Path   `json:"paths"`
	Definitions    map[string]Schema `json:"definitions,omitempty"`
	Parameters     map[string]Param  `json:"parameters,omitempty"`
}

API describes the base of the API

func NewAPI

func NewAPI(host, title, description, version, basePath string, schemes []string) *API

func (*API) AddPath

func (a *API) AddPath(path string) Path

type Contact

type Contact struct {
	Name  string `json:"name,omitempty"`
	Email string `json:"email,omitempty"`
	URL   string `json:"url,omitempty"`
}

Contact Info

type Info

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

Info describes the meta-info of the API

type License

type License struct {
	Name string `json:"name,omitempty"`
	URL  string `json:"url,omitempty"`
}

License info

type Method

type Method struct {
	Description string              `json:"description,omitempty"`
	Operationid string              `json:"operationId,omitempty"`
	Produces    []string            `json:"produces,omitempty"`
	Parameters  []Param             `json:"parameters,omitempty"`
	Responses   map[string]Response `json:"responses"`
	Tags        []string            `json:"tags",omitempty`
}

Method describes an API method

type Param

type Param struct {
	Name        string `json:"name,omitempty"`
	Description string `json:"description,omitempty"`
	Required    bool   `json:"required,omitempty"`
	Type        Type   `json:"type,omitempty"`
	Items       Type   `json:"items,omitempty"`

	Format    string      `json:"format,omitempty"`
	Default   interface{} `json:"default,omitempty"`
	Max       float64     `json:"maximum,omitempty"`
	HasMax    bool        `json:"-"`
	Min       float64     `json:"minimum,omitempty"`
	HasMin    bool        `json:"-"`
	MaxLength int         `json:"maxLength,omitempty"`
	MinLength int         `json:"minLength,omitempty"`
	Pattern   string      `json:"pattern,omitempty"`
	Enum      []string    `json:"enum,omitempty"`
	In        string      `json:"in,omitempty"`
	Global    bool        `json:"-"`
	Ref       string      `json:"$ref,omitempty"`
}

Param describes a single request param

type Path

type Path map[string]Method

type Response

type Response struct {
	Description string `json:"description"`
	Schema      Schema `json:"schema"`
}

Response describes a response schema

type Schema

type Schema *jsonschema.Schema

Schema is a generic jsonschema definition - TBD how we want to represent it

type Type

type Type string
const (
	String  Type = "string"
	Number  Type = "number"
	Boolean Type = "boolean"
	Integer Type = "integer"
	Array   Type = "array"
	Object  Type = "object"
)

Type Defintions

Jump to

Keyboard shortcuts

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