Documentation ¶
Index ¶
- func MakeSchema(t reflect.Type, schema Schema) error
- type Components
- type Contact
- type ContentDescriptor
- type DocumentSpec1
- type Error
- type Example
- type ExamplePairing
- type ExternalDocs
- type Info
- type License
- type Link
- type Method
- type Pointer
- type PointerStore
- type PointerTree
- type Schema
- type SchemaRegistry
- type Server
- type ServerVariable
- type Tag
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Components ¶
type Components struct { ContentDescriptors *SchemaRegistry `json:"contentDescriptors,omitempty"` Schemas *SchemaRegistry `json:"schemas,omitempty"` Examples *SchemaRegistry `json:"examples,omitempty"` Links *SchemaRegistry `json:"links,omitempty"` Errors *SchemaRegistry `json:"errors,omitempty"` ExamplePairingObjects *SchemaRegistry `json:"examplePairingObjects,omitempty"` Tags *SchemaRegistry `json:"tags,omitempty"` }
type ContentDescriptor ¶
type DocumentSpec1 ¶
type DocumentSpec1 struct { OpenRPC string `json:"openrpc"` Info *Info `json:"info"` Servers []*Server `json:"servers,omitempty"` Methods []*Method `json:"methods"` Components *Components `json:"components,omitempty"` ExternalDocs *ExternalDocs `json:"externalDocs,omitempty"` }
func NewDocument ¶
func NewDocument(methods []*Method, info *Info) *DocumentSpec1
NewDocument populates with references the components obj
type ExamplePairing ¶
type ExternalDocs ¶
type Method ¶
type Method struct { Name string `json:"name"` Tags []Tag `json:"tags,omitempty"` Summary string `json:"summary,omitempty"` Description string `json:"description,omitempty"` ExternalDocs *ExternalDocs `json:"externalDocs,omitempty"` Params []*ContentDescriptor `json:"params"` Result *ContentDescriptor `json:"result"` Deprecated bool `json:"deprecated,omitempty"` Servers []Server `json:"servers,omitempty"` Errors []Error `json:"errors,omitempty"` Links []Link `json:"links,omitempty"` ParamStructure string `json:"paramStructure,omitempty"` Examples []*ExamplePairing `json:"examples,omitempty"` }
type Pointer ¶
type Pointer interface { //Refs returns a slice containing all the (ordered) references of a pointer Refs() []string //String formats the references as a slash-separated string String() string json.Marshaler }
Pointer represents a generic json pointer
func NewPointer ¶
type PointerStore ¶
type PointerStore struct {
// contains filtered or unexported fields
}
PointerStore is a simple collection of json pointers
func NewPointerRegistry ¶
func NewPointerRegistry() *PointerStore
func (*PointerStore) Set ¶
func (r *PointerStore) Set(pointer Pointer, item Schema)
type PointerTree ¶
type PointerTree struct {
// contains filtered or unexported fields
}
PointerTree is used to represent the hierarchy of properties of a json object
func NewPointerTree ¶
func NewPointerTree(ptr Pointer) *PointerTree
func (*PointerTree) Find ¶
func (pt *PointerTree) Find(match Pointer) *PointerTree
func (*PointerTree) Insert ¶
func (pt *PointerTree) Insert(p Pointer) *PointerTree
func (*PointerTree) MarshalJSON ¶
func (pt *PointerTree) MarshalJSON() ([]byte, error)
func (*PointerTree) ResolvePointers ¶
func (pt *PointerTree) ResolvePointers(reg *PointerStore) (json.RawMessage, error)
ResolvePointers recursively marshals a tree; if a tree has no children it is treated as a pointer and used to fetch a Schema from the registry
type SchemaRegistry ¶
type SchemaRegistry struct {
// contains filtered or unexported fields
}
SchemaRegistry is a collection of Schemas
func NewRegistry ¶
func NewRegistry(unmarshalFrom Pointer) (*SchemaRegistry, error)
func NewSchemaRegistry ¶
func NewSchemaRegistry(unmarshalFrom Pointer) (*SchemaRegistry, error)
NewSchemaRegistry returns a new JSON schema registry with 5 basic schemas already registered; the Pointer argument is used to select the subtree from which to start marshaling, can be nil
func (*SchemaRegistry) AddTypeException ¶
func (s *SchemaRegistry) AddTypeException(typ reflect.Type)
AddTypeException signals that the type t should always be represented as a string regardless what its kind is
func (*SchemaRegistry) MarshalJSON ¶
func (s *SchemaRegistry) MarshalJSON() ([]byte, error)
func (*SchemaRegistry) RegisterType ¶
func (s *SchemaRegistry) RegisterType(t reflect.Type, registerAsString bool) (Pointer, string, error)
Register creates a new schema for the provided type, and returns the Pointer by which it is referenced
func (*SchemaRegistry) String ¶
func (s *SchemaRegistry) String() string