Documentation ¶
Index ¶
- Variables
- func SchemaMutationExpand(root *spec.Schema) func(s *spec.Schema) error
- func SchemaMutationRemoveDefinitionsField(root *spec.Schema) func(s *spec.Schema) error
- func SchemaMutationRequireDefaultOn(root *spec.Schema) func(s *spec.Schema) error
- type ContentDescriptorRegisterer
- type Document
- func (d *Document) Discover() (*meta_schema.OpenrpcDocument, error)
- func (d *Document) RegisterListener(listener net.Listener)
- func (d *Document) RegisterReceiver(receiver interface{})
- func (d *Document) RegisterReceiverName(name string, receiver interface{})
- func (d *Document) WithMeta(meta MetaRegisterer) *Document
- func (d *Document) WithReflector(reflector ReceiverRegisterer) *Document
- type EthereumReflectorT
- func (e *EthereumReflectorT) GetMethodName(moduleName string, r reflect.Value, m reflect.Method, astFunc *ast.FuncDecl) (string, error)
- func (e *EthereumReflectorT) GetMethodParams(r reflect.Value, m reflect.Method, astFunc *ast.FuncDecl) ([]meta_schema.ContentDescriptorObject, error)
- func (e *EthereumReflectorT) GetMethodResult(r reflect.Value, m reflect.Method, astFunc *ast.FuncDecl) (meta_schema.ContentDescriptorObject, error)
- func (e *EthereumReflectorT) IsMethodEligible(method reflect.Method) bool
- func (e *EthereumReflectorT) ReceiverMethods(name string, receiver interface{}) ([]meta_schema.MethodObject, error)
- type MetaRegisterer
- type MetaT
- type MethodRegisterer
- type ReceiverReflectorT
- type ReceiverRegisterer
- type SchemaRegisterer
- type ServerRegisterer
- type StandardReflectorT
- func (c *StandardReflectorT) GetContentDescriptorDeprecated(r reflect.Value, m reflect.Method, field *ast.Field) (bool, error)
- func (c *StandardReflectorT) GetContentDescriptorDescription(r reflect.Value, m reflect.Method, field *ast.Field) (string, error)
- func (c *StandardReflectorT) GetContentDescriptorName(r reflect.Value, m reflect.Method, field *ast.Field) (string, error)
- func (c *StandardReflectorT) GetContentDescriptorRequired(r reflect.Value, m reflect.Method, field *ast.Field) (bool, error)
- func (c *StandardReflectorT) GetContentDescriptorSummary(r reflect.Value, m reflect.Method, field *ast.Field) (string, error)
- func (c *StandardReflectorT) GetMethodDeprecated(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (bool, error)
- func (c *StandardReflectorT) GetMethodDescription(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (string, error)
- func (c *StandardReflectorT) GetMethodErrors(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (*meta_schema.MethodObjectErrors, error)
- func (c *StandardReflectorT) GetMethodExamples(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (*meta_schema.MethodObjectExamples, error)
- func (c *StandardReflectorT) GetMethodExternalDocs(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (*meta_schema.ExternalDocumentationObject, error)
- func (c *StandardReflectorT) GetMethodLinks(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (*meta_schema.MethodObjectLinks, error)
- func (c *StandardReflectorT) GetMethodName(moduleName string, r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (string, error)
- func (c *StandardReflectorT) GetMethodParamStructure(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (string, error)
- func (c *StandardReflectorT) GetMethodParams(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) ([]meta_schema.ContentDescriptorObject, error)
- func (c *StandardReflectorT) GetMethodResult(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (cd meta_schema.ContentDescriptorObject, err error)
- func (c *StandardReflectorT) GetMethodServers(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (*meta_schema.Servers, error)
- func (c *StandardReflectorT) GetMethodSummary(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (string, error)
- func (c *StandardReflectorT) GetMethodTags(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (*meta_schema.MethodObjectTags, error)
- func (c *StandardReflectorT) GetSchema(r reflect.Value, m reflect.Method, field *ast.Field, ty reflect.Type) (meta_schema.JSONSchema, error)
- func (c *StandardReflectorT) GetServers() func(listeners []net.Listener) (*meta_schema.Servers, error)
- func (c *StandardReflectorT) IsMethodEligible(method reflect.Method) bool
- func (c *StandardReflectorT) ReceiverMethods(name string, receiver interface{}) ([]meta_schema.MethodObject, error)
- func (c *StandardReflectorT) SchemaExamples(ty reflect.Type) (examples *meta_schema.Examples, err error)
- func (c *StandardReflectorT) SchemaIgnoredTypes() []interface{}
- func (c *StandardReflectorT) SchemaMutations(ty reflect.Type) []func(*spec.Schema) func(*spec.Schema) error
- func (c *StandardReflectorT) SchemaTypeMap() func(ty reflect.Type) *jsonschema.Type
Constants ¶
This section is empty.
Variables ¶
var EthereumReflector = &EthereumReflectorT{}
var StandardReflector = &StandardReflectorT{}
Functions ¶
Types ¶
type ContentDescriptorRegisterer ¶
type ContentDescriptorRegisterer interface { SchemaRegisterer GetContentDescriptorName(r reflect.Value, m reflect.Method, field *ast.Field) (string, error) GetContentDescriptorSummary(r reflect.Value, m reflect.Method, field *ast.Field) (string, error) GetContentDescriptorDescription(r reflect.Value, m reflect.Method, field *ast.Field) (string, error) GetContentDescriptorRequired(r reflect.Value, m reflect.Method, field *ast.Field) (bool, error) GetContentDescriptorDeprecated(r reflect.Value, m reflect.Method, field *ast.Field) (bool, error) GetSchema(r reflect.Value, m reflect.Method, field *ast.Field, ty reflect.Type) (schema meta_schema.JSONSchema, err error) }
type Document ¶
type Document struct {
// contains filtered or unexported fields
}
func (*Document) Discover ¶
func (d *Document) Discover() (*meta_schema.OpenrpcDocument, error)
func (*Document) RegisterListener ¶
func (*Document) RegisterReceiver ¶
func (d *Document) RegisterReceiver(receiver interface{})
func (*Document) RegisterReceiverName ¶
func (*Document) WithMeta ¶
func (d *Document) WithMeta(meta MetaRegisterer) *Document
func (*Document) WithReflector ¶
func (d *Document) WithReflector(reflector ReceiverRegisterer) *Document
type EthereumReflectorT ¶
type EthereumReflectorT struct {
StandardReflectorT
}
func (*EthereumReflectorT) GetMethodName ¶
func (*EthereumReflectorT) GetMethodParams ¶
func (e *EthereumReflectorT) GetMethodParams(r reflect.Value, m reflect.Method, astFunc *ast.FuncDecl) ([]meta_schema.ContentDescriptorObject, error)
func (*EthereumReflectorT) GetMethodResult ¶
func (e *EthereumReflectorT) GetMethodResult(r reflect.Value, m reflect.Method, astFunc *ast.FuncDecl) (meta_schema.ContentDescriptorObject, error)
func (*EthereumReflectorT) IsMethodEligible ¶
func (e *EthereumReflectorT) IsMethodEligible(method reflect.Method) bool
func (*EthereumReflectorT) ReceiverMethods ¶
func (e *EthereumReflectorT) ReceiverMethods(name string, receiver interface{}) ([]meta_schema.MethodObject, error)
type MetaRegisterer ¶
type MetaRegisterer interface { ServerRegisterer GetInfo() func() (info *meta_schema.InfoObject) GetExternalDocs() func() (exdocs *meta_schema.ExternalDocumentationObject) }
MetaRegisterer implements methods that must come from the mind of the developer. They describe the document (well, provide document description values) that cannot be parsed from anything available.
type MetaT ¶
type MetaT struct { GetServersFn func() func(listeners []net.Listener) (*meta_schema.Servers, error) GetInfoFn func() (info *meta_schema.InfoObject) GetExternalDocsFn func() (exdocs *meta_schema.ExternalDocumentationObject) }
MetaT implements the MetaRegisterer interface. An application can use this struct to define an inline interface for an OpenRPC document.
func (*MetaT) GetExternalDocs ¶
func (m *MetaT) GetExternalDocs() func() (exdocs *meta_schema.ExternalDocumentationObject)
func (*MetaT) GetInfo ¶
func (m *MetaT) GetInfo() func() (info *meta_schema.InfoObject)
func (*MetaT) GetServers ¶
type MethodRegisterer ¶
type MethodRegisterer interface { ContentDescriptorRegisterer IsMethodEligible(method reflect.Method) bool GetMethodName(moduleName string, r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (string, error) GetMethodTags(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (*meta_schema.MethodObjectTags, error) GetMethodDescription(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (string, error) GetMethodSummary(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (string, error) GetMethodDeprecated(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (bool, error) GetMethodParamStructure(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (string, error) GetMethodErrors(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (*meta_schema.MethodObjectErrors, error) GetMethodExternalDocs(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (*meta_schema.ExternalDocumentationObject, error) GetMethodServers(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (*meta_schema.Servers, error) GetMethodLinks(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (*meta_schema.MethodObjectLinks, error) GetMethodExamples(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (*meta_schema.MethodObjectExamples, error) GetMethodParams(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) ([]meta_schema.ContentDescriptorObject, error) GetMethodResult(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (meta_schema.ContentDescriptorObject, error) }
type ReceiverReflectorT ¶
type ReceiverReflectorT struct { FnReceiverMethods func(name string, receiver interface{}) ([]meta_schema.MethodObject, error) FnIsMethodEligible func(method reflect.Method) bool FnGetMethodName func(moduleName string, r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (string, error) FnGetMethodTags func(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (*meta_schema.MethodObjectTags, error) FnGetMethodDescription func(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (string, error) FnGetMethodSummary func(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (string, error) FnGetMethodDeprecated func(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (bool, error) FnGetMethodParamStructure func(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (string, error) FnGetMethodErrors func(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (*meta_schema.MethodObjectErrors, error) FnGetMethodExternalDocs func(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (*meta_schema.ExternalDocumentationObject, error) FnGetMethodServers func(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (*meta_schema.Servers, error) FnGetMethodLinks func(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (*meta_schema.MethodObjectLinks, error) FnGetMethodExamples func(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (*meta_schema.MethodObjectExamples, error) FnGetMethodParams func(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) ([]meta_schema.ContentDescriptorObject, error) FnGetMethodResult func(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (meta_schema.ContentDescriptorObject, error) FnGetContentDescriptorName func(r reflect.Value, m reflect.Method, field *ast.Field) (string, error) FnGetContentDescriptorSummary func(r reflect.Value, m reflect.Method, field *ast.Field) (string, error) FnGetContentDescriptorDescription func(r reflect.Value, m reflect.Method, field *ast.Field) (string, error) FnGetContentDescriptorRequired func(r reflect.Value, m reflect.Method, field *ast.Field) (bool, error) FnGetContentDescriptorDeprecated func(r reflect.Value, m reflect.Method, field *ast.Field) (bool, error) FnGetSchema func(r reflect.Value, m reflect.Method, field *ast.Field, ty reflect.Type) (schema meta_schema.JSONSchema, err error) FnSchemaIgnoredTypes func() []interface{} FnSchemaTypeMap func() func(ty reflect.Type) *jsonschema.Type FnSchemaMutations func(ty reflect.Type) []func(*spec.Schema) func(*spec.Schema) error FnSchemaExamples func(ty reflect.Type) (examples *meta_schema.Examples, err error) }
ReceiverReflectorT holds a field for each ReceiverRegisterer interface method. StandardReflectorT embeds this struct, together with self.FnMethod != nil checks, as a way to easily override defaults from the consuming application side. See example4_test.go for an an example.
type ReceiverRegisterer ¶
type ReceiverRegisterer interface { MethodRegisterer ReceiverMethods(name string, receiver interface{}) ([]meta_schema.MethodObject, error) }
type SchemaRegisterer ¶
type SchemaRegisterer interface { // Since our implementation will be piggy-backed on jsonschema.Reflector, // this is where our field-by-field Getter abstraction ends. // If we didn't rely so heavily on this dependency, we would use // a pattern like method and content descriptor, where fields are defined // individually per reflector. // JSON Schemas have a lot of fields. // // And including meta_schema.go, we're using 3 data types to develop this object. // - alecthomas/jsonschema.Schema: use .Reflector to reflect the schema from its Go declaration. // - openapi/spec.Schema: the "official" spec data type from swagger // - <generated> meta_schema.go.JSONSchema as eventual local implementation type. // // Since the native language for this data type is JSON, I (the developer) assume // that using the standard lib to Un/Marshal between these data types is as good a glue as any. // Unmarshaling will be slow, but should only ever happen once up front, so I'm not concerned with performance. // // SchemaIgnoredTypes reply will be passed directly to the jsonschema.Reflector.IgnoredTypes field. SchemaIgnoredTypes() []interface{} // SchemaTypeMap will be passed directory to the jsonschema.Reflector.TypeMapper field. SchemaTypeMap() func(ty reflect.Type) *jsonschema.Type // SchemaMutations will be run in a depth-first walk on the reflected schema. // They will be run in order. // Function wrapping allows closure fn to have context of root schema. SchemaMutations(ty reflect.Type) []func(*spec.Schema) func(*spec.Schema) error SchemaExamples(ty reflect.Type) (examples *meta_schema.Examples, err error) }
type ServerRegisterer ¶
type ServerRegisterer interface {
GetServers() func(listeners []net.Listener) (*meta_schema.Servers, error)
}
ServerRegisterer implements a method translating a slice of net Listeners into document `.servers`.
type StandardReflectorT ¶
type StandardReflectorT struct {
ReceiverReflectorT
}
func (*StandardReflectorT) GetContentDescriptorDeprecated ¶
func (*StandardReflectorT) GetContentDescriptorDescription ¶
func (*StandardReflectorT) GetContentDescriptorName ¶
func (*StandardReflectorT) GetContentDescriptorRequired ¶
func (*StandardReflectorT) GetContentDescriptorSummary ¶
func (*StandardReflectorT) GetMethodDeprecated ¶
func (*StandardReflectorT) GetMethodDescription ¶
func (*StandardReflectorT) GetMethodErrors ¶
func (c *StandardReflectorT) GetMethodErrors(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (*meta_schema.MethodObjectErrors, error)
func (*StandardReflectorT) GetMethodExamples ¶
func (c *StandardReflectorT) GetMethodExamples(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (*meta_schema.MethodObjectExamples, error)
func (*StandardReflectorT) GetMethodExternalDocs ¶
func (c *StandardReflectorT) GetMethodExternalDocs(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (*meta_schema.ExternalDocumentationObject, error)
func (*StandardReflectorT) GetMethodLinks ¶
func (c *StandardReflectorT) GetMethodLinks(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (*meta_schema.MethodObjectLinks, error)
func (*StandardReflectorT) GetMethodName ¶
func (*StandardReflectorT) GetMethodParamStructure ¶
func (*StandardReflectorT) GetMethodParams ¶
func (c *StandardReflectorT) GetMethodParams(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) ([]meta_schema.ContentDescriptorObject, error)
func (*StandardReflectorT) GetMethodResult ¶
func (c *StandardReflectorT) GetMethodResult(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (cd meta_schema.ContentDescriptorObject, err error)
func (*StandardReflectorT) GetMethodServers ¶
func (c *StandardReflectorT) GetMethodServers(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (*meta_schema.Servers, error)
func (*StandardReflectorT) GetMethodSummary ¶
func (*StandardReflectorT) GetMethodTags ¶
func (c *StandardReflectorT) GetMethodTags(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (*meta_schema.MethodObjectTags, error)
TODO: These.
func (*StandardReflectorT) GetSchema ¶
func (c *StandardReflectorT) GetSchema(r reflect.Value, m reflect.Method, field *ast.Field, ty reflect.Type) (meta_schema.JSONSchema, error)
func (*StandardReflectorT) GetServers ¶
func (c *StandardReflectorT) GetServers() func(listeners []net.Listener) (*meta_schema.Servers, error)
func (*StandardReflectorT) IsMethodEligible ¶
func (c *StandardReflectorT) IsMethodEligible(method reflect.Method) bool
func (*StandardReflectorT) ReceiverMethods ¶
func (c *StandardReflectorT) ReceiverMethods(name string, receiver interface{}) ([]meta_schema.MethodObject, error)
func (*StandardReflectorT) SchemaExamples ¶ added in v0.0.34
func (c *StandardReflectorT) SchemaExamples(ty reflect.Type) (examples *meta_schema.Examples, err error)
func (*StandardReflectorT) SchemaIgnoredTypes ¶
func (c *StandardReflectorT) SchemaIgnoredTypes() []interface{}
func (*StandardReflectorT) SchemaMutations ¶
func (*StandardReflectorT) SchemaTypeMap ¶
func (c *StandardReflectorT) SchemaTypeMap() func(ty reflect.Type) *jsonschema.Type
Directories ¶
Path | Synopsis |
---|---|
internal
|
|
fakearithmetic
Package fakearithmetic is used exclusively for test and example cases, and is not intended for any use otherwise.
|
Package fakearithmetic is used exclusively for test and example cases, and is not intended for any use otherwise. |
fakegeometry
Package fakegeometry is used exclusively for test and example cases, and is not intended for any use otherwise.
|
Package fakegeometry is used exclusively for test and example cases, and is not intended for any use otherwise. |