oas2

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2023 License: MIT Imports: 14 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddDefinition

func AddDefinition(defs map[string]Definition, name string, value reflect.Value)

func AddResponseDefinitions

func AddResponseDefinitions(defs map[string]Definition, schema Schema, name string, statusCode int, body interface{})

func Errors

func Errors(errs ...error) map[error]interface{}

func GenDefinitions

func GenDefinitions(defs map[string]Definition) string

func GenPaths

func GenPaths(resps []OASResponses, paths string) string

func Handler

func Handler(apiDocFn APIDocFunc, schema Schema) http.HandlerFunc

Types

type APIDocFunc

type APIDocFunc func(schema Schema) string

type Definition

type Definition struct {
	Type                 string
	ItemTypeOrProperties interface{}
}

type GetFailuresFunc

type GetFailuresFunc func(name string) map[error]interface{}

type GetSuccessFunc

type GetSuccessFunc func(body interface{}) interface{}

type GoStruct

type GoStruct struct {
	Name       string
	Properties []Property
}

type GoTypeRegistry

type GoTypeRegistry struct {
	// contains filtered or unexported fields
}

GoTypeRegistry is a mapping from "fully qualified type name" to "local type name".

func NewGoTypeRegistry

func NewGoTypeRegistry() *GoTypeRegistry

func (*GoTypeRegistry) FullName

func (r *GoTypeRegistry) FullName(typ reflect.Type) string

func (*GoTypeRegistry) Name

func (r *GoTypeRegistry) Name(typ reflect.Type) string

func (*GoTypeRegistry) Properties

func (r *GoTypeRegistry) Properties(typ reflect.Type) []Property

func (*GoTypeRegistry) Register

func (r *GoTypeRegistry) Register(typ reflect.Type, name string) bool

Register tries to register the given typ and returns whether typ is successfully registered.

func (*GoTypeRegistry) SetProperties

func (r *GoTypeRegistry) SetProperties(typ reflect.Type, properties []Property)

type ItemType

type ItemType JSONType

type JSONType

type JSONType struct {
	Kind        string
	Type        string
	Format      string
	Description string
}

type OASResponse

type OASResponse struct {
	StatusCode int
	SchemaName string
}

type OASResponses

type OASResponses struct {
	ContentTypes map[string]bool
	Success      OASResponse
	Failures     map[int]OASResponse
}

func GetOASResponses

func GetOASResponses(schema Schema, name string, statusCode int, body interface{}) OASResponses

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

func NewParser

func NewParser() *Parser

func (*Parser) AddDefinition

func (p *Parser) AddDefinition(name string, value reflect.Value, embedded bool)

func (*Parser) Definitions

func (p *Parser) Definitions() map[string]Definition

type Property

type Property struct {
	Name string
	Type JSONType
}

type Response

type Response struct {
	StatusCode  int
	ContentType string
	Body        interface{}
}

type ResponseSchema

type ResponseSchema struct {
	Codecs          httpcodec.Codecs
	GetSuccessFunc  GetSuccessFunc
	GetFailuresFunc GetFailuresFunc
}

func (*ResponseSchema) FailureResponses

func (rs *ResponseSchema) FailureResponses(name string) (resps []Response)

func (*ResponseSchema) SuccessResponse

func (rs *ResponseSchema) SuccessResponse(name string, statusCode int, body interface{}) Response

type Schema

type Schema interface {
	SuccessResponse(name string, statusCode int, body interface{}) Response
	FailureResponses(name string) []Response
}

Jump to

Keyboard shortcuts

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