Documentation
¶
Index ¶
- func InitSchema(s Schema, doPopLists, doRandom bool) (map[string]interface{}, error)
- func ReplaceRefs(data map[string]interface{}, doSkipRefs bool) error
- func SerializeGraphQL(s Schema, w io.Writer) error
- func SerializeSchema(s Schema, w io.Writer, doPretty bool) error
- func ToGraphQLSchema(s Schema) (*graphqlsch.Schema, error)
- func ToGraphQLTypes(rootSchema Schema, rootName string) ([]graphqlsch.Type, error)
- type ArraySchema
- type FromExampleParams
- type Primitive
- type Schema
- type SchemaInclReq
- func (s *SchemaInclReq) GetDescription() string
- func (s *SchemaInclReq) GetProperties() map[string]interface{}
- func (s *SchemaInclReq) GetRequired() []string
- func (s *SchemaInclReq) GetSchemaField() string
- func (s *SchemaInclReq) GetTitle() string
- func (s *SchemaInclReq) GetType() Type
- func (s *SchemaInclReq) SetDescription(d string)
- func (s *SchemaInclReq) SetProperties(ps map[string]interface{})
- func (s *SchemaInclReq) SetProperty(k string, v interface{})
- func (s *SchemaInclReq) SetRequired(r []string)
- func (s *SchemaInclReq) SetSchemaField(sf string)
- func (s *SchemaInclReq) SetTitle(t string)
- func (s *SchemaInclReq) SetType(t Type)
- type SchemaOmitReq
- func (s *SchemaOmitReq) GetDescription() string
- func (s *SchemaOmitReq) GetProperties() map[string]interface{}
- func (s *SchemaOmitReq) GetRequired() []string
- func (s *SchemaOmitReq) GetSchemaField() string
- func (s *SchemaOmitReq) GetTitle() string
- func (s *SchemaOmitReq) GetType() Type
- func (s *SchemaOmitReq) SetDescription(d string)
- func (s *SchemaOmitReq) SetProperties(ps map[string]interface{})
- func (s *SchemaOmitReq) SetProperty(k string, v interface{})
- func (s *SchemaOmitReq) SetRequired(r []string)
- func (s *SchemaOmitReq) SetSchemaField(sf string)
- func (s *SchemaOmitReq) SetTitle(t string)
- func (s *SchemaOmitReq) SetType(t Type)
- type Type
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitSchema ¶
InitSchema is the only exposed method in this file InitSchema is a method on Schema which returns an instance of the schema.
InitSchema assumes all $ref fields are already either 1) resolved and replaced by a network request 2) replaced by an empty object
func ReplaceRefs ¶
func ToGraphQLSchema ¶
func ToGraphQLSchema(s Schema) (*graphqlsch.Schema, error)
func ToGraphQLTypes ¶
func ToGraphQLTypes(rootSchema Schema, rootName string) ([]graphqlsch.Type, error)
Types ¶
type ArraySchema ¶
type ArraySchema struct { Type Type `json:"type"` Items interface{} `json:"items"` }
func NewArray ¶
func NewArray(items interface{}) ArraySchema
func TodoRenameThisFunctionLmao ¶
func TodoRenameThisFunctionLmao(data []interface{}, params *FromExampleParams) (ArraySchema, error)
type FromExampleParams ¶
type Primitive ¶
func NewBoolean ¶
func NewBoolean() Primitive
func NewNull ¶
func NewNull(params *FromExampleParams) Primitive
type Schema ¶
type Schema interface { GetSchemaField() string SetSchemaField(string) GetTitle() string SetTitle(string) GetType() Type SetType(Type) GetDescription() string SetDescription(string) GetProperties() map[string]interface{} SetProperties(map[string]interface{}) SetProperty(string, interface{}) GetRequired() []string SetRequired([]string) }
This only exists because we need two different types for the same exact struct---a struct representing JSON schema---where the struct tags of one of the types are different from the struct tags of the other type. This way, we can omit the `required` field during serialization.
func FromExample ¶
func FromExample(ex *example.Example, params *FromExampleParams) (Schema, error)
type SchemaInclReq ¶
type SchemaInclReq struct { SchemaField string `json:"$schema,omitempty"` Title string `json:"title"` Type Type `json:"type"` Description string `json:"description,omitempty"` Properties map[string]interface{} `json:"properties"` Required []string `json:"required"` }
func NewInclReq ¶
func NewInclReq() *SchemaInclReq
func (*SchemaInclReq) GetDescription ¶
func (s *SchemaInclReq) GetDescription() string
func (*SchemaInclReq) GetProperties ¶
func (s *SchemaInclReq) GetProperties() map[string]interface{}
func (*SchemaInclReq) GetRequired ¶
func (s *SchemaInclReq) GetRequired() []string
func (*SchemaInclReq) GetSchemaField ¶
func (s *SchemaInclReq) GetSchemaField() string
func (*SchemaInclReq) GetTitle ¶
func (s *SchemaInclReq) GetTitle() string
func (*SchemaInclReq) GetType ¶
func (s *SchemaInclReq) GetType() Type
func (*SchemaInclReq) SetDescription ¶
func (s *SchemaInclReq) SetDescription(d string)
func (*SchemaInclReq) SetProperties ¶
func (s *SchemaInclReq) SetProperties(ps map[string]interface{})
func (*SchemaInclReq) SetProperty ¶
func (s *SchemaInclReq) SetProperty(k string, v interface{})
func (*SchemaInclReq) SetRequired ¶
func (s *SchemaInclReq) SetRequired(r []string)
func (*SchemaInclReq) SetSchemaField ¶
func (s *SchemaInclReq) SetSchemaField(sf string)
func (*SchemaInclReq) SetTitle ¶
func (s *SchemaInclReq) SetTitle(t string)
func (*SchemaInclReq) SetType ¶
func (s *SchemaInclReq) SetType(t Type)
type SchemaOmitReq ¶
type SchemaOmitReq struct { SchemaField string `json:"$schema,omitempty"` Title string `json:"title"` Type Type `json:"type"` Description string `json:"description,omitempty"` Properties map[string]interface{} `json:"properties"` Required []string `json:"required,omitempty"` }
func NewOmitReq ¶
func NewOmitReq() *SchemaOmitReq
func (*SchemaOmitReq) GetDescription ¶
func (s *SchemaOmitReq) GetDescription() string
func (*SchemaOmitReq) GetProperties ¶
func (s *SchemaOmitReq) GetProperties() map[string]interface{}
func (*SchemaOmitReq) GetRequired ¶
func (s *SchemaOmitReq) GetRequired() []string
func (*SchemaOmitReq) GetSchemaField ¶
func (s *SchemaOmitReq) GetSchemaField() string
func (*SchemaOmitReq) GetTitle ¶
func (s *SchemaOmitReq) GetTitle() string
func (*SchemaOmitReq) GetType ¶
func (s *SchemaOmitReq) GetType() Type
func (*SchemaOmitReq) SetDescription ¶
func (s *SchemaOmitReq) SetDescription(d string)
func (*SchemaOmitReq) SetProperties ¶
func (s *SchemaOmitReq) SetProperties(ps map[string]interface{})
func (*SchemaOmitReq) SetProperty ¶
func (s *SchemaOmitReq) SetProperty(k string, v interface{})
func (*SchemaOmitReq) SetRequired ¶
func (s *SchemaOmitReq) SetRequired(r []string)
func (*SchemaOmitReq) SetSchemaField ¶
func (s *SchemaOmitReq) SetSchemaField(sf string)
func (*SchemaOmitReq) SetTitle ¶
func (s *SchemaOmitReq) SetTitle(t string)
func (*SchemaOmitReq) SetType ¶
func (s *SchemaOmitReq) SetType(t Type)
Click to show internal directories.
Click to hide internal directories.