gen

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2021 License: Apache-2.0 Imports: 19 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Elem

type Elem struct {
	Sub  bool // true if Elem has parent Elem
	Type *ir.Type
	Var  string
	Tag  ir.Tag
	More bool
}

Elem variable helper for recursive array or object encoding or decoding.

func (Elem) NextVar

func (e Elem) NextVar() string

NextVar returns name of variable for decoding recursive call.

Needed to make variable names unique.

type ErrNotImplemented

type ErrNotImplemented struct {
	Name string
}

func (*ErrNotImplemented) Error

func (e *ErrNotImplemented) Error() string

type ErrUnsupportedContentTypes

type ErrUnsupportedContentTypes struct {
	ContentTypes []string
}

func (*ErrUnsupportedContentTypes) Error

type FileSystem

type FileSystem interface {
	WriteFile(baseName string, source []byte) error
}

FileSystem represents a directory of generated package.

type Generator

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

func NewGenerator

func NewGenerator(spec *ogen.Spec, opts Options) (*Generator, error)

func (*Generator) WriteSource

func (g *Generator) WriteSource(fs FileSystem, pkgName string) error

WriteSource writes generated definitions to fs.

type Options

type Options struct {
	VerboseRoute         bool
	SpecificMethodPath   string
	IgnoreNotImplemented []string
}

type ResponseElem

type ResponseElem struct {
	Response *ir.StatusResponse
	Ptr      bool
}

type Route

type Route struct {
	Method    string         // GET, POST, DELETE
	Operation *ir.Operation  // getUserInfo
	Path      []*ir.PathPart // /api/v1/user/{name}/info
}

type RouteCase

type RouteCase struct {
	Static   []*RouteEge
	Variable *RouteEge
}

type RouteEge

type RouteEge struct {
	ID        int
	Path      string // path part
	Param     *ir.Parameter
	Next      []*RouteEge
	Operation *ir.Operation
}

func (RouteEge) Case

func (e RouteEge) Case() RouteCase

func (RouteEge) HasNext

func (e RouteEge) HasNext() bool

type Router

type Router struct {
	Methods []RouterMethod
	// contains filtered or unexported fields
}

Router state for routing path to handlers.

func (*Router) Graph

func (r *Router) Graph() error

func (*Router) Register

func (r *Router) Register(route Route)

type RouterMethod

type RouterMethod struct {
	Method string
	Edges  []*RouteEge
}

func (RouterMethod) Root

func (m RouterMethod) Root() *RouteEge

type TemplateConfig

type TemplateConfig struct {
	Package    string
	Operations []*ir.Operation
	Types      map[string]*ir.Type
	URITypes   map[*ir.Type]struct{}
	Interfaces map[string]*ir.Type
	Error      *ir.StatusResponse
	ErrorType  *ir.Type
	Methods    []RouterMethod
}

func (TemplateConfig) RegexStrings added in v0.5.0

func (t TemplateConfig) RegexStrings() (r []string)

RegexStrings returns slice of all unique regex validators.

Jump to

Keyboard shortcuts

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