gen

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindParam

func FindParam(a *API, coll spec.ParameterOrRefs, in spec.ParameterIn, name string) (spec.Parameter, bool)

func HeaderFor

func HeaderFor[T any](a *API, setup SetupFunc[spec.Header]) spec.HeaderOrRef

func HeaderOf

func HeaderOf(a *API, t reflect.Type, setup SetupFunc[spec.Header]) spec.HeaderOrRef

func ParamFor

func ParamFor[T any](a *API, name string, in spec.ParameterIn, setup SetupFunc[spec.Parameter]) spec.ParameterOrRef

func ParamOf

func ParamOf(a *API, t reflect.Type, name string, in spec.ParameterIn, setup SetupFunc[spec.Parameter]) spec.ParameterOrRef

func ReqBodyFor

func ReqBodyFor[T any](a *API, setup SetupFunc[spec.RequestBody]) spec.RequestBodyOrRef

func ReqBodyOf

func ReqBodyOf(a *API, t reflect.Type, setup SetupFunc[spec.RequestBody]) spec.RequestBodyOrRef

func RequestFor

func RequestFor[T any](a *API, op *spec.Operation, paramSetup SetupFunc[spec.Parameter], bodySetup SetupFunc[spec.RequestBody])

func RequestOf

func RequestOf(a *API, t reflect.Type, op *spec.Operation, paramSetup SetupFunc[spec.Parameter], bodySetup SetupFunc[spec.RequestBody])

func RespFor

func RespFor[T any](a *API, desc string, setup SetupFunc[spec.Response]) spec.ResponseOrRef

func RespOf

func RespOf(a *API, t reflect.Type, desc string, setup SetupFunc[spec.Response]) spec.ResponseOrRef

func SchemaOrRefFor added in v0.1.1

func SchemaOrRefFor[T any](a *API) spec.SchemaOrRef

func SchemaTypeCamelCase

func SchemaTypeCamelCase(t reflect.Type) string

func SchemaTypePascalCase

func SchemaTypePascalCase(t reflect.Type) string

func SchemaTypeSnakeCase

func SchemaTypeSnakeCase(t reflect.Type) string

func WriteSpecTo

func WriteSpecTo(dir string, s spec.OpenAPI)

Types

type API

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

func New

func New(path string, info spec.Info, sec spec.SecurityRequirements, typeKeyFunc SchemaTypeKeyFunc) API

func (*API) Generate

func (a *API) Generate(dir string, pkgName string)

func (*API) Headers

func (a *API) Headers() *Headers

func (*API) NamedPath

func (a *API) NamedPath(name string, setup SetupFunc[PathItem])

func (*API) ParamPath

func (a *API) ParamPath(param spec.ParameterOrRef, setup SetupFunc[PathItem])

func (*API) Params

func (a *API) Params() *Params

func (*API) ReqBodies

func (a *API) ReqBodies() *ReqBodies

func (*API) Resps

func (a *API) Resps() *Resps

func (*API) Schemas

func (a *API) Schemas() *Schemas

func (*API) Securities

func (a *API) Securities() *Securities

func (*API) Spec

func (a *API) Spec() spec.OpenAPI

func (*API) Tags

func (a *API) Tags() *Tags

type Headers

type Headers spec.NamedHeaderOrRefs

func (*Headers) Add

func (h *Headers) Add(key string, item spec.HeaderOrRef) spec.HeaderOrRef

func (*Headers) Header

func (h *Headers) Header(item spec.HeaderOrRef) (spec.Header, bool)

type Params

func (*Params) Add

func (p *Params) Add(key string, item spec.ParameterOrRef) spec.ParameterOrRef

func (*Params) Param

func (p *Params) Param(item spec.ParameterOrRef) (spec.Parameter, bool)

type PathItem

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

func (*PathItem) DELETE

func (p *PathItem) DELETE(operationID string, setup SetupFunc[spec.Operation])

func (*PathItem) GET

func (p *PathItem) GET(operationID string, setup SetupFunc[spec.Operation])

func (*PathItem) HEAD

func (p *PathItem) HEAD(operationID string, setup SetupFunc[spec.Operation])

func (*PathItem) NamedPath

func (p *PathItem) NamedPath(name string, setup SetupFunc[PathItem])

func (*PathItem) OPTIONS

func (p *PathItem) OPTIONS(operationID string, setup SetupFunc[spec.Operation])

func (*PathItem) PATCH

func (p *PathItem) PATCH(operationID string, setup SetupFunc[spec.Operation])

func (*PathItem) POST

func (p *PathItem) POST(operationID string, setup SetupFunc[spec.Operation])

func (*PathItem) PUT

func (p *PathItem) PUT(operationID string, setup SetupFunc[spec.Operation])

func (*PathItem) ParamPath

func (p *PathItem) ParamPath(param spec.ParameterOrRef, setup SetupFunc[PathItem])

func (*PathItem) TRACE

func (p *PathItem) TRACE(operationID string, setup SetupFunc[spec.Operation])

type ReqBodies

type ReqBodies spec.NamedRequestBodyOrRefs

func (*ReqBodies) Add

func (*ReqBodies) ReqBody

func (r *ReqBodies) ReqBody(item spec.RequestBodyOrRef) (spec.RequestBody, bool)

type Resps

func (*Resps) Add

func (r *Resps) Add(key string, item spec.ResponseOrRef) spec.ResponseOrRef

func (*Resps) Resp

func (r *Resps) Resp(item spec.ResponseOrRef) (spec.Response, bool)

type SchemaTypeKeyFunc

type SchemaTypeKeyFunc func(t reflect.Type) string

type Schemas

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

func (*Schemas) Schema

func (m *Schemas) Schema(item spec.SchemaOrRef) (spec.Schema, bool)

func (*Schemas) SchemaOrRefOf

func (m *Schemas) SchemaOrRefOf(t reflect.Type) spec.SchemaOrRef

type Schemater

type Schemater interface {
	Schema() spec.Schema
}

type Securities

func (*Securities) AddAPIKey

func (s *Securities) AddAPIKey(key string, name string, in spec.SecurityIn, setup func(s *spec.SecurityScheme))

func (*Securities) AddHTTP

func (s *Securities) AddHTTP(key string, scheme string, setup func(s *spec.SecurityScheme))

func (*Securities) AddOAuth2

func (s *Securities) AddOAuth2(key string, flows spec.OAuthFlows, setup func(s *spec.SecurityScheme))

func (*Securities) AddOpenIDConnect

func (s *Securities) AddOpenIDConnect(key string, openIDConnectURL string, setup func(s *spec.SecurityScheme))

type SetupFunc

type SetupFunc[T any] func(a *API, item *T)

type Tags

type Tags []spec.Tag

func (*Tags) Add

func (t *Tags) Add(name string, desc string)

Jump to

Keyboard shortcuts

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