Documentation
¶
Index ¶
- type HRef
- type Link
- type Reference
- type ResolvedSet
- type Schema
- func (s *Schema) AreTitleLinksUnique() bool
- func (s *Schema) EmptyResult(l *Link) bool
- func (s *Schema) Generate() ([]byte, error)
- func (s *Schema) GoType() string
- func (s *Schema) IsCustomType() bool
- func (s *Schema) Resolve(r *Schema, rs ResolvedSet) *Schema
- func (s *Schema) ReturnedGoType(name string, l *Link) string
- func (s *Schema) ReturnsCustomType(l *Link) bool
- func (s *Schema) Types() (types []string, err error)
- func (s *Schema) URL() string
- func (s *Schema) Values(name string, l *Link) []string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HRef ¶
type HRef struct {
Order []string
Schemas map[string]*Schema
// contains filtered or unexported fields
}
HRef represents a Link href.
func (*HRef) MarshalJSON ¶
MarshalJSON returns *h as the JSON encoding of h.
func (*HRef) Resolve ¶
func (h *HRef) Resolve(r *Schema, rs ResolvedSet)
Resolve resolves a href inside a Schema.
func (*HRef) UnmarshalJSON ¶
UnmarshalJSON sets *h to a copy of data.
type Link ¶
type Link struct {
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
HRef *HRef `json:"href,omitempty"`
Rel string `json:"rel,omitempty"`
Method string `json:"method,omitempty"`
Schema *Schema `json:"schema,omitempty"`
TargetSchema *Schema `json:"targetSchema,omitempty"`
MediaType string `json:"mediaType,omitempty"`
EncType string `json:"encType,omitempty"`
}
Link represents a Link description.
func (*Link) AcceptsCustomType ¶
AcceptsCustomType returns true if the link schema is not a primitive type
func (*Link) GoType ¶
GoType returns Go type for the given schema as string and a bool specifying whether it is required
func (*Link) Parameters ¶
Parameters returns function parameters names and types.
func (*Link) Resolve ¶
func (l *Link) Resolve(r *Schema, rs ResolvedSet)
Resolve resolve link schema and href.
type Reference ¶
type Reference string
Reference represents a JSON Reference.
func NewReference ¶
NewReference creates a new Reference based on a reference value.
type ResolvedSet ¶
type ResolvedSet map[interface{}]bool
ResolvedSet stores a set of pointers to objects that have already been resolved to prevent infinite loops.
func (ResolvedSet) Has ¶
func (rs ResolvedSet) Has(o interface{}) bool
Has returns if a pointer has already been resolved.
func (ResolvedSet) Insert ¶
func (rs ResolvedSet) Insert(o interface{})
Insert marks a pointer as resolved.
type Schema ¶
type Schema struct {
ID string `json:"id,omitempty"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Version string `json:"version,omitempty"`
Default interface{} `json:"default,omitempty"`
ReadOnly bool `json:"readOnly,omitempty"`
Example interface{} `json:"example,omitempty"`
Format string `json:"format,omitempty"`
Type interface{} `json:"type,omitempty"`
Ref *Reference `json:"$ref,omitempty"`
Schema *Reference `json:"$schema,omitempty"`
Definitions map[string]*Schema `json:"definitions,omitempty"`
// Numbers
MultipleOf float64 `json:"multipleOf,omitempty"`
Maximum float64 `json:"maximum,omitempty"`
ExclusiveMaximum bool `json:"exclusiveMaximum,omitempty"`
Minimum float64 `json:"minimum,omitempty"`
ExclusiveMinimum bool `json:"exclusiveMinimum,omitempty"`
// Strings
MinLength int `json:"minLength,omitempty"`
MaxLength int `json:"maxLength,omitempty"`
Pattern string `json:"pattern,omitempty"`
// Objects
MinProperties int `json:"minProperties,omitempty"`
MaxProperties int `json:"maxProperties,omitempty"`
Required []string `json:"required,omitempty"`
Properties map[string]*Schema `json:"properties,omitempty"`
Dependencies map[string]interface{} `json:"dependencies,omitempty"`
AdditionalProperties interface{} `json:"additionalProperties,omitempty"`
PatternProperties map[string]*Schema `json:"patternProperties,omitempty"`
// Arrays
Items *Schema `json:"items,omitempty"`
MinItems int `json:"minItems,omitempty"`
MaxItems int `json:"maxItems,omitempty"`
UniqueItems bool `json:"uniqueItems,omitempty"`
AdditionalItems interface{} `json:"additionalItems,omitempty"`
// All
Enum []string `json:"enum,omitempty"`
// Schemas
OneOf []Schema `json:"oneOf,omitempty"`
AnyOf []Schema `json:"anyOf,omitempty"`
AllOf []Schema `json:"allOf,omitempty"`
Not *Schema `json:"not,omitempty"`
// Links
Links []*Link `json:"links,omitempty"`
}
Schema represents a JSON Schema.
func (*Schema) AreTitleLinksUnique ¶
AreTitleLinksUnique ensures that all titles are unique for a schema.
If more than one link in a given schema has the same title, we cannot accurately generate the client from the schema. Although it's not strictly a schema violation, it needs to be fixed before the client can be properly generated.
func (*Schema) EmptyResult ¶
EmptyResult retursn true if the link result should be empty.
func (*Schema) IsCustomType ¶
IsCustomType returns true if the schema declares a custom type.
func (*Schema) Resolve ¶
func (s *Schema) Resolve(r *Schema, rs ResolvedSet) *Schema
Resolve resolves reference inside the schema.
func (*Schema) ReturnedGoType ¶
ReturnedGoType returns Go type returned by the given link as a string.
func (*Schema) ReturnsCustomType ¶
ReturnsCustomType returns true if the link returns a custom type.