Documentation
¶
Index ¶
- Constants
- Variables
- type Component
- type Field
- type HandleSchemaFunc
- type HandlerRegistry
- type Kind
- type Method
- type MethodSignature
- type Parameter
- type Parser
- type Process
- type Receiver
- type Resolve
- type Root
- type SchemaContext
- func (s *SchemaContext) ImplementMethods(documents map[jsonschema.ID]Component)
- func (s *SchemaContext) Process(document Root, name string, schema *jsonschema.Schema) (Component, error)
- func (s *SchemaContext) RegisterMethodSignature(receiver string, methods ...*MethodSignature)
- func (s *SchemaContext) ResolveSchema(ref jsonschema.Reference, arr ...*jsonschema.Schema) (*jsonschema.Schema, error)
- func (s *SchemaContext) ResolveTypename(ref jsonschema.Reference, base *jsonschema.Schema) (string, error)
- type Type
Constants ¶
View Source
const MethodSignatureTemplate = `` /* 277-byte string literal not displayed */
View Source
const MethodTemplate = `` /* 211-byte string literal not displayed */
Variables ¶
View Source
var (
ErrNotRegistred = errors.New("This Handler is not registered.")
)
Functions ¶
This section is empty.
Types ¶
type HandleSchemaFunc ¶
type HandleSchemaFunc func(*SchemaContext, Root, string, *jsonschema.Schema) (Component, error)
type HandlerRegistry ¶
type HandlerRegistry struct {
// contains filtered or unexported fields
}
func NewHandlerRegistry ¶
func NewHandlerRegistry() *HandlerRegistry
func (HandlerRegistry) RegisterHandler ¶
func (s HandlerRegistry) RegisterHandler(kind Kind, handler HandleSchemaFunc)
func (HandlerRegistry) ResolveHandler ¶
func (s HandlerRegistry) ResolveHandler(kind Kind) HandleSchemaFunc
type Method ¶
type Method struct {
Comment string
Receiver string
*MethodSignature
Body string
}
func NewMethodFromSignature ¶
func NewMethodFromSignature(receiver string, methodSignature *MethodSignature) *Method
func (*Method) WithInputs ¶
func (*Method) WithOutputs ¶
type MethodSignature ¶
func NewMethodSignature ¶
func NewMethodSignature(name string) *MethodSignature
func (*MethodSignature) WithInputs ¶
func (s *MethodSignature) WithInputs(inputs ...*Parameter) *MethodSignature
func (*MethodSignature) WithOutputs ¶
func (s *MethodSignature) WithOutputs(outputs ...*Parameter) *MethodSignature
type Parameter ¶
func NewParameter ¶
type Parser ¶
type Parser interface {
Parse(schemas map[jsonschema.ID]*jsonschema.Schema, references map[jsonschema.ID]*jsonschema.Schema) (map[jsonschema.ID]Component, error)
}
func NewParser ¶
func NewParser(packageName string, registry *HandlerRegistry) Parser
type Resolve ¶
type Resolve func(schema *jsonschema.Schema, document Root) HandleSchemaFunc
type SchemaContext ¶
type SchemaContext struct {
PackageName string
// contains filtered or unexported fields
}
SchemaContext is the collection of all schema's being processed
func NewSchemaContext ¶
func NewSchemaContext(packageName string, resolve Resolve, references map[jsonschema.ID]*jsonschema.Schema) *SchemaContext
NewSchemaContext return's a SchemaContext
func (*SchemaContext) ImplementMethods ¶
func (s *SchemaContext) ImplementMethods(documents map[jsonschema.ID]Component)
ImplementMethods add's any methods that any struct might need to implement for any interfaces
func (*SchemaContext) Process ¶
func (s *SchemaContext) Process(document Root, name string, schema *jsonschema.Schema) (Component, error)
Process a schema and return it as a tree of Types
func (*SchemaContext) RegisterMethodSignature ¶
func (s *SchemaContext) RegisterMethodSignature(receiver string, methods ...*MethodSignature)
RegisterMethodSignature add's any methods onto the named receiver across all schemas so you can implement a interface from a reference etc
func (*SchemaContext) ResolveSchema ¶
func (s *SchemaContext) ResolveSchema(ref jsonschema.Reference, arr ...*jsonschema.Schema) (*jsonschema.Schema, error)
ResolveSchema takes a Reference and uses it to walk the schema to find the matching subschema
func (*SchemaContext) ResolveTypename ¶
func (s *SchemaContext) ResolveTypename(ref jsonschema.Reference, base *jsonschema.Schema) (string, error)
ResolveTypename takes a Reference and uses it to walk the schema to find the matching typename to reference
Source Files
¶
Click to show internal directories.
Click to hide internal directories.