lex

package
v0.0.0-...-45ae864 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EncodingCBOR = "application/cbor"
	EncodingJSON = "application/json"
	EncodingANY  = "*/*"
)

Variables

This section is empty.

Functions

func BuildExtDefMap

func BuildExtDefMap(ss []*Schema, prefixes []string) map[string]*ExtDef

func CreateHandlerStub

func CreateHandlerStub(pkg string, impmap map[string]string, dir string, schemas []*Schema, handlers bool) error

func FixRecordReferences

func FixRecordReferences(schemas []*Schema, defmap map[string]*ExtDef, prefix string)

TODO: this method is necessary because in lexicon there is no way to know if a type needs to be marshaled with a "$type" field up front, you can only know for sure by seeing where the type is used.

func GenCodeForSchema

func GenCodeForSchema(pkg string, prefix string, fname string, reqcode bool, s *Schema, defmap map[string]*ExtDef, imports map[string]string) error

func WriteServerHandlers

func WriteServerHandlers(w io.Writer, schemas []*Schema, pkg string, impmap map[string]string) error

func WriteXrpcServer

func WriteXrpcServer(w io.Writer, schemas []*Schema, pkg string, impmap map[string]string) error

Types

type ExtDef

type ExtDef struct {
	Type *TypeSchema
}

type InputType

type InputType struct {
	Encoding string      `json:"encoding"`
	Schema   *TypeSchema `json:"schema"`
}

type OutputType

type OutputType struct {
	Encoding string      `json:"encoding"`
	Schema   *TypeSchema `json:"schema"`
}

type Param

type Param struct {
	Type     string `json:"type"`
	Maximum  int    `json:"maximum"`
	Required bool   `json:"required"`
}

type Schema

type Schema struct {
	Lexicon int                    `json:"lexicon"`
	ID      string                 `json:"id"`
	Defs    map[string]*TypeSchema `json:"defs"`
	// contains filtered or unexported fields
}

func ReadSchema

func ReadSchema(f string) (*Schema, error)

func (*Schema) AllTypes

func (s *Schema) AllTypes(prefix string, defMap map[string]*ExtDef) []outputType

func (*Schema) Name

func (s *Schema) Name() string

type TypeSchema

type TypeSchema struct {
	Type        string      `json:"type"`
	Key         string      `json:"key"`
	Description string      `json:"description"`
	Parameters  *TypeSchema `json:"parameters"`
	Input       *InputType  `json:"input"`
	Output      *OutputType `json:"output"`
	Record      *TypeSchema `json:"record"`

	Ref        string                 `json:"ref"`
	Refs       []string               `json:"refs"`
	Required   []string               `json:"required"`
	Properties map[string]*TypeSchema `json:"properties"`
	MaxLength  int                    `json:"maxLength"`
	Items      *TypeSchema            `json:"items"`
	Const      any                    `json:"const"`
	Enum       []string               `json:"enum"`
	Closed     bool                   `json:"closed"`

	Default any `json:"default"`
	Minimum any `json:"minimum"`
	Maximum any `json:"maximum"`
	// contains filtered or unexported fields
}

func (*TypeSchema) TypeName

func (s *TypeSchema) TypeName() string

func (*TypeSchema) WriteHandlerStub

func (s *TypeSchema) WriteHandlerStub(w io.Writer, fname, shortname, impname string) error

func (*TypeSchema) WriteRPC

func (s *TypeSchema) WriteRPC(w io.Writer, typename string) error

func (*TypeSchema) WriteRPCHandler

func (s *TypeSchema) WriteRPCHandler(w io.Writer, fname, shortname, impname string) error

func (*TypeSchema) WriteType

func (ts *TypeSchema) WriteType(name string, w io.Writer) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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