openapi20

package
v0.0.0-...-3af62b6 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeInteger = "integer"
	TypeNumber  = "number"
	TypeString  = "string"
	TypeBoolean = "boolean"
	TypeArray   = "array"
	TypeObject  = "object"

	FormatNone     = ""
	FormatInt32    = "int32"
	FormatInt64    = "int64"
	FormatFloat    = "float"
	FormatDouble   = "double"
	FormatByte     = "byte"
	FormatBinary   = "binary"
	FormatDate     = "date"
	FormatDateTime = "date-time"
	FormatPassword = "password"
)

Variables

View Source
var (
	IntegerType  = DataTypeDesc{Type: TypeInteger, Format: FormatInt32}
	LongType     = DataTypeDesc{Type: TypeInteger, Format: FormatInt64}
	Uint64Type   = DataTypeDesc{Type: TypeString, Format: "uint64"} // non-standart type
	FloatType    = DataTypeDesc{Type: TypeNumber, Format: FormatFloat}
	DoubleType   = DataTypeDesc{Type: TypeNumber, Format: FormatDouble}
	StringType   = DataTypeDesc{Type: TypeString, Format: FormatNone}
	ByteType     = DataTypeDesc{Type: TypeString, Format: FormatByte}
	BinaryType   = DataTypeDesc{Type: TypeString, Format: FormatBinary}
	BooleanType  = DataTypeDesc{Type: TypeBoolean, Format: FormatNone}
	DateType     = DataTypeDesc{Type: TypeString, Format: FormatDate}
	DateTimeType = DataTypeDesc{Type: TypeString, Format: FormatDateTime}
	PasswordType = DataTypeDesc{Type: TypeString, Format: FormatPassword}
)

Datatypes from https://swagger.io/specification/v2/

Functions

This section is empty.

Types

type Contact

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

type DataTypeDesc

type DataTypeDesc struct {
	Type   string
	Format string
}

func (DataTypeDesc) Schema

func (d DataTypeDesc) Schema() *Schema

type Definitions

type Definitions map[string]*Schema

func (Definitions) MarshalJSON

func (d Definitions) MarshalJSON() ([]byte, error)

type ExternalDocs

type ExternalDocs struct {
	URL         string `json:"url"`
	Description string `json:"description,omitempty"`
}

type Generator

type Generator struct{}

func NewGenerator

func NewGenerator() *Generator

func (*Generator) GenerateSchema

func (g *Generator) GenerateSchema(host, preifx string, svc *protogen.Service) (*Swagger, error)
type Header struct {
	Description string `json:"description,omitempty"`
	Type        string `json:"type"`
	Format      string `json:"format,omitempty"`
}

type Headers

type Headers map[string]*Header

func (Headers) MarshalJSON

func (h Headers) MarshalJSON() ([]byte, error)

type Info

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

type License

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

type Operation

type Operation struct {
	OperationID  string        `json:"operationId,omitempty"`
	Summary      string        `json:"summary,omitempty"`
	Description  string        `json:"description,omitempty"`
	Tags         []string      `json:"tags,omitempty"`
	Consumes     []string      `json:"consumes,omitempty"`
	Produces     []string      `json:"produces,omitempty"`
	Parameters   []Parameter   `json:"parameters,omitempty"`
	Responses    Responses     `json:"responses"`
	ExternalDocs *ExternalDocs `json:"externalDocs,omitempty"`
}

type Parameter

type Parameter struct {
	Name        string  `json:"name"`
	In          string  `json:"in"`
	Required    bool    `json:"required"`
	Description string  `json:"description,omitempty"`
	Schema      *Schema `json:"schema,omitempty"`
}

type Path

type Path struct {
	GET  *Operation `json:"get,omitempty"`
	POST *Operation `json:"post,omitempty"`
}

type Paths

type Paths map[string]*Path

func (Paths) MarshalJSON

func (p Paths) MarshalJSON() ([]byte, error)

type Properties

type Properties map[string]*Schema

func (Properties) MarshalJSON

func (p Properties) MarshalJSON() ([]byte, error)

type Response

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

type Responses

type Responses map[int]*Response

func (Responses) MarshalJSON

func (r Responses) MarshalJSON() ([]byte, error)

type Schema

type Schema struct {
	Ref string
	Def *SchemaDef
}

func (*Schema) MarshalJSON

func (s *Schema) MarshalJSON() ([]byte, error)

type SchemaDef

type SchemaDef struct {
	Title                string        `json:"title,omitempty"`
	Description          string        `json:"description,omitempty"`
	Type                 StringOrArray `json:"type"`
	Format               string        `json:"format,omitempty"`
	Required             []string      `json:"required,omitempty"`
	Default              interface{}   `json:"default,omitempty"`
	Minimum              *float64      `json:"minimum,omitempty"`
	Maximum              *float64      `json:"maximum,omitempty"`
	MultipleOf           *float64      `json:"multipleOf,omitempty"`
	ExclusiveMinimum     bool          `json:"exclusiveMinimum,omitempty"`
	ExclusiveMaximum     bool          `json:"exclusiveMaximum,omitempty"`
	MaxItems             *int64        `json:"maxItems,omitempty"`
	MinItems             *int64        `json:"minItems,omitempty"`
	Properties           Properties    `json:"properties,omitempty"`
	AdditionalProperties *Schema       `json:"additionalProperties,omitempty"`
	Items                *Schema       `json:"items,omitempty"`
	Enum                 []string      `json:"enum,omitempty"`
	AllOf                []*Schema     `json:"allOf,omitempty"`
}

type StringOrArray

type StringOrArray []string

func (StringOrArray) MarshalJSON

func (s StringOrArray) MarshalJSON() ([]byte, error)

type Swagger

type Swagger struct {
	Swagger     Version20   `json:"swagger"`
	Info        Info        `json:"info"`
	Host        string      `json:"host,omitempty"`
	BasePath    string      `json:"basePath"`
	Schemes     []string    `json:"schemes,omitempty"`
	Consumes    []string    `json:"consumes,omitempty"`
	Produces    []string    `json:"produces,omitempty"`
	Paths       Paths       `json:"paths"`
	Definitions Definitions `json:"definitions,omitempty"`
}

type Version20

type Version20 struct{}

func (Version20) MarshalJSON

func (Version20) MarshalJSON() ([]byte, error)

Jump to

Keyboard shortcuts

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