openapi

package
v0.0.0-...-2b8a88d Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const ComponentSchemasPath = "#/components/schemas/"

Variables

View Source
var ErrNotStruct = fmt.Errorf("expected a struct")

Functions

func GetTypeName

func GetTypeName(typ reflect.Type) string

func LoadParamStruct

func LoadParamStruct(obj interface{}, input LoadParamInput) (reflect.Value, error)

LoadParamStruct takes a request, the param struct to populate, and the query params. The obj will have the fields populated based on the openapi schema

func LoadPathParam

func LoadPathParam(paths map[string]string, p *openapi3.Parameter, typ reflect.Type, c *container.Container) (reflect.Value, error)

func LoadQueryParam

func LoadQueryParam(r *http.Request, typ reflect.Type, param *openapi3.Parameter, c *container.Container) (result reflect.Value, err error)

func ParamsFromObj

func ParamsFromObj(obj interface{}, schemas Schemas, typs RegisteredTypes) (openapi3.Parameters, error)

func ParamsFromType

func ParamsFromType(typ reflect.Type, schemas Schemas, typs RegisteredTypes) (openapi3.Parameters, error)

func SchemaFromObj

func SchemaFromObj(obj interface{}, schemas Schemas, typs RegisteredTypes) *openapi3.SchemaRef

SchemaFromObj returns an openapi3 schema for the object. For paramters, use ParamsFromObj.

func VarToInterface

func VarToInterface(obj interface{}) (interface{}, error)

Types

type Components

type Components struct {
	Parameters      map[reflect.Type]openapi3.Parameters
	Schemas         Schemas
	RegisteredTypes RegisteredTypes
}

Components is used to store shared data between various parts of the openapi doc

func NewComponents

func NewComponents() Components

type Info

type Info openapi3.Info

Info is specified by OpenAPI/Swagger standard version 3.0.

type LoadParamInput

type LoadParamInput struct {
	*openapi3filter.RequestValidationInput
	Params []*openapi3.ParameterRef
}

type OpenAPI

type OpenAPI struct {
	*openapi3.T
	RegisteredTypes RegisteredTypes
}

type OpenAPIDescriptor

type OpenAPIDescriptor interface {
	OpenAPIDescription() string
}

type Parameter

type Parameter struct {
	openapi3.Parameter
}

func GetParameterType

func GetParameterType(tag reflect.StructTag) Parameter

getParameterType will set the correct "in" value from the tag

func (Parameter) IsValid

func (p Parameter) IsValid() bool

type Parameters

type Parameters map[string]*openapi3.ParameterRef

type RegisteredTypes

type RegisteredTypes map[reflect.Type]TypeOption

type SchemaID

type SchemaID interface {
	SchemaID() string
}

SchemaID is used to override the name of the schema type

type SchemaInline

type SchemaInline interface {
	SchemaInline() bool
}

SchemaInline is used to determine whether or not to pull this schema out to the schemas collection

type Schemas

type Schemas map[string]*openapi3.SchemaRef

type TypeOption

type TypeOption struct {
	SchemaRef *openapi3.SchemaRef
	// optional schema, if set ignore schema name and inline this type
	Schema *openapi3.Schema
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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