Documentation
¶
Index ¶
- type AdditionalProperties
- type Default
- type Discriminator
- type Enum
- type Example
- type ExternalResolver
- type Infer
- type LocationError
- type NoExternal
- type Num
- type Parser
- type PatternProperty
- type Property
- type RawPatternProperties
- type RawPatternProperty
- type RawProperties
- type RawProperty
- type RawSchema
- type RawValue
- type ReferenceResolver
- type RootResolver
- type Schema
- type SchemaType
- type Settings
- type XML
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdditionalProperties ¶
AdditionalProperties is JSON Schema additionalProperties validator description.
func (AdditionalProperties) MarshalJSON ¶
func (p AdditionalProperties) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler.
func (AdditionalProperties) MarshalYAML ¶ added in v0.44.0
func (p AdditionalProperties) MarshalYAML() (interface{}, error)
MarshalYAML implements yaml.Marshaler.
func (*AdditionalProperties) UnmarshalJSON ¶
func (p *AdditionalProperties) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler.
func (*AdditionalProperties) UnmarshalYAML ¶ added in v0.44.0
func (p *AdditionalProperties) UnmarshalYAML(node *yaml.Node) error
UnmarshalYAML implements yaml.Unmarshaler.
type Discriminator ¶
type Discriminator struct {
// REQUIRED. The name of the property in the payload that will hold the discriminator value.
PropertyName string `json:"propertyName" yaml:"propertyName"`
// An object to hold mappings between payload values and schema names or references.
Mapping map[string]string `json:"mapping,omitempty" yaml:"mapping,omitempty"`
}
Discriminator discriminates types for OneOf, AllOf, AnyOf.
See https://spec.openapis.org/oas/v3.1.0#discriminator-object.
type Enum ¶ added in v0.38.0
type Enum []json.RawMessage
Enum is JSON Schema enum validator description.
func (Enum) MarshalYAML ¶ added in v0.44.0
MarshalYAML implements yaml.Marshaler.
type ExternalResolver ¶ added in v0.36.0
ExternalResolver resolves external links.
type Infer ¶ added in v0.41.0
type Infer struct {
// contains filtered or unexported fields
}
Infer returns a JSON Schema that is inferred from the given JSON.
type LocationError ¶ added in v0.43.0
LocationError is a wrapper for an error that has a location.
type NoExternal ¶ added in v0.37.0
type NoExternal struct{}
NoExternal is ExternalResolver that always returns error.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser parses JSON schemas.
type PatternProperty ¶ added in v0.23.0
PatternProperty is a property pattern.
type Property ¶
type Property struct {
Name string // Property name.
Description string // Property description.
Schema *Schema // Property schema.
Required bool // Whether the field is required or not.
}
Property is a JSON Schema Object property.
type RawPatternProperties ¶ added in v0.23.0
type RawPatternProperties []RawPatternProperty
RawPatternProperties is unparsed JSON Schema patternProperties validator description.
func (RawPatternProperties) MarshalJSON ¶ added in v0.23.0
func (p RawPatternProperties) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler.
func (RawPatternProperties) MarshalYAML ¶ added in v0.44.0
func (p RawPatternProperties) MarshalYAML() (interface{}, error)
MarshalYAML implements yaml.Marshaler.
func (*RawPatternProperties) UnmarshalJSON ¶ added in v0.23.0
func (p *RawPatternProperties) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler.
func (*RawPatternProperties) UnmarshalYAML ¶ added in v0.44.0
func (p *RawPatternProperties) UnmarshalYAML(node *yaml.Node) error
UnmarshalYAML implements yaml.Unmarshaler.
type RawPatternProperty ¶ added in v0.23.0
RawPatternProperty is item of RawPatternProperties.
type RawProperties ¶
type RawProperties []RawProperty
RawProperties is unparsed JSON Schema properties validator description.
func (RawProperties) MarshalJSON ¶
func (p RawProperties) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler.
func (RawProperties) MarshalYAML ¶ added in v0.44.0
func (p RawProperties) MarshalYAML() (interface{}, error)
MarshalYAML implements yaml.Marshaler.
func (*RawProperties) UnmarshalJSON ¶
func (p *RawProperties) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler.
func (*RawProperties) UnmarshalYAML ¶ added in v0.44.0
func (p *RawProperties) UnmarshalYAML(node *yaml.Node) error
UnmarshalYAML implements yaml.Unmarshaler.
type RawProperty ¶
RawProperty is item of RawProperties.
type RawSchema ¶
type RawSchema struct {
Ref string `json:"$ref,omitempty" yaml:"$ref,omitempty"`
Summary string `json:"summary,omitempty" yaml:"summary,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Type string `json:"type,omitempty" yaml:"type,omitempty"`
Format string `json:"format,omitempty" yaml:"format,omitempty"`
Properties RawProperties `json:"properties,omitempty" yaml:"properties,omitempty"`
AdditionalProperties *AdditionalProperties `json:"additionalProperties,omitempty" yaml:"additionalProperties,omitempty"`
PatternProperties RawPatternProperties `json:"patternProperties,omitempty" yaml:"patternProperties,omitempty"`
Required []string `json:"required,omitempty" yaml:"required,omitempty"`
Items *RawSchema `json:"items,omitempty" yaml:"items,omitempty"`
Nullable bool `json:"nullable,omitempty" yaml:"nullable,omitempty"`
AllOf []*RawSchema `json:"allOf,omitempty" yaml:"allOf,omitempty"`
OneOf []*RawSchema `json:"oneOf,omitempty" yaml:"oneOf,omitempty"`
AnyOf []*RawSchema `json:"anyOf,omitempty" yaml:"anyOf,omitempty"`
Enum Enum `json:"enum,omitempty" yaml:"enum,omitempty"`
MultipleOf Num `json:"multipleOf,omitempty" yaml:"multipleOf,omitempty"`
Maximum Num `json:"maximum,omitempty" yaml:"maximum,omitempty"`
ExclusiveMaximum bool `json:"exclusiveMaximum,omitempty" yaml:"exclusiveMaximum,omitempty"`
Minimum Num `json:"minimum,omitempty" yaml:"minimum,omitempty"`
ExclusiveMinimum bool `json:"exclusiveMinimum,omitempty" yaml:"exclusiveMinimum,omitempty"`
MaxLength *uint64 `json:"maxLength,omitempty" yaml:"maxLength,omitempty"`
MinLength *uint64 `json:"minLength,omitempty" yaml:"minLength,omitempty"`
Pattern string `json:"pattern,omitempty" yaml:"pattern,omitempty"`
MaxItems *uint64 `json:"maxItems,omitempty" yaml:"maxItems,omitempty"`
MinItems *uint64 `json:"minItems,omitempty" yaml:"minItems,omitempty"`
UniqueItems bool `json:"uniqueItems,omitempty" yaml:"uniqueItems,omitempty"`
MaxProperties *uint64 `json:"maxProperties,omitempty" yaml:"maxProperties,omitempty"`
MinProperties *uint64 `json:"minProperties,omitempty" yaml:"minProperties,omitempty"`
Default Default `json:"default,omitempty" yaml:"default,omitempty"`
Deprecated bool `json:"deprecated,omitempty" yaml:"deprecated,omitempty"`
ContentEncoding string `json:"contentEncoding,omitempty" yaml:"contentEncoding,omitempty"`
ContentMediaType string `json:"contentMediaType,omitempty" yaml:"contentMediaType,omitempty"`
Discriminator *Discriminator `json:"discriminator,omitempty" yaml:"discriminator,omitempty"`
XML *XML `json:"xml,omitempty" yaml:"xml,omitempty"`
Example Example `json:"example,omitempty" yaml:"example,omitempty"`
XAnnotations map[string]json.RawMessage `json:"-" yaml:"-"`
Locator location.Locator `json:"-" yaml:",inline"`
}
RawSchema is unparsed JSON Schema.
type RawValue ¶ added in v0.43.0
type RawValue json.RawMessage
RawValue is a raw JSON value.
func (RawValue) MarshalJSON ¶ added in v0.43.1
MarshalJSON implements json.Marshaler.
func (RawValue) MarshalYAML ¶ added in v0.44.0
MarshalYAML implements yaml.Marshaler.
func (*RawValue) UnmarshalJSON ¶ added in v0.43.1
UnmarshalJSON implements json.Unmarshaler.
type ReferenceResolver ¶
ReferenceResolver resolves JSON schema references.
type RootResolver ¶ added in v0.22.0
type RootResolver struct {
// contains filtered or unexported fields
}
RootResolver is ReferenceResolver implementation.
func NewRootResolver ¶ added in v0.22.0
func NewRootResolver(root *yaml.Node) *RootResolver
NewRootResolver creates new RootResolver.
func (*RootResolver) ResolveReference ¶ added in v0.22.0
func (r *RootResolver) ResolveReference(ref string) (rawSchema *RawSchema, err error)
ResolveReference implements ReferenceResolver.
type Schema ¶
type Schema struct {
XOgenName string // Annotation to set type name.
Ref string // Whether schema is referenced.
Type SchemaType
Format string // Schema format, optional.
ContentEncoding string
ContentMediaType string
Summary string // Schema summary from Reference Object, optional.
Description string // Schema description, optional.
Deprecated bool
Item *Schema // Only for Array and Object with additional properties.
AdditionalProperties *bool // Whether Object has additional properties.
PatternProperties []PatternProperty // Only for Object.
Enum []interface{} // Only for Enum.
Properties []Property // Only for Object.
Nullable bool // Whether schema is nullable or not. Any types.
OneOf []*Schema
AnyOf []*Schema
AllOf []*Schema
Discriminator *Discriminator
XML *XML
// Numeric validation (Integer, Number).
Maximum Num
ExclusiveMaximum bool
Minimum Num
ExclusiveMinimum bool
MultipleOf Num
// String validation.
MaxLength *uint64
MinLength *uint64
Pattern string
// Array validation.
MaxItems *uint64
MinItems *uint64
UniqueItems bool
// Object validation.
MaxProperties *uint64
MinProperties *uint64
Examples []Example
// Default schema value.
Default interface{}
DefaultSet bool
location.Locator `json:"-" yaml:"-"`
}
Schema is a JSON Schema.
func (*Schema) AddExample ¶
AddExample adds example for this Schema.
type SchemaType ¶
type SchemaType string
SchemaType is a JSON Schema type.
const ( // Empty is empty (unset) schema type. Empty SchemaType = "" // OneOf, AnyOf, AllOf. // Object is "object" schema type. Object SchemaType = "object" // Array is "array" schema type. Array SchemaType = "array" // Integer is "integer" schema type. Integer SchemaType = "integer" // Number is "number" schema type. Number SchemaType = "number" // String is "string" schema type. String SchemaType = "string" // Boolean is "boolean" schema type. Boolean SchemaType = "boolean" // Null is "null" schema type. Null SchemaType = "null" )
type Settings ¶
type Settings struct {
// External is external resolver. If nil, NoExternal resolver is used.
External ExternalResolver
// Resolver is a root resolver.
Resolver ReferenceResolver
// Filename is a name of the file being parsed.
//
// Used for error messages.
Filename string
// DepthLimit limits the number of nested references. Default is 1000.
DepthLimit int
// Enables type inference.
//
// For example:
//
// {
// "items": {
// "type": "string"
// }
// }
//
// In that case schemaParser will handle that schema as "array" schema, because it has "items" field.
InferTypes bool
}
Settings is parser settings.
type XML ¶ added in v0.44.0
type XML struct {
// Replaces the name of the element/attribute used for the described schema property.
//
// When defined within items, it will affect the name of the individual XML elements within the list.
//
// When defined alongside type being array (outside the items), it will affect the wrapping element
// and only if wrapped is true.
//
// If wrapped is false, it will be ignored.
Name string `json:"name,omitempty" yaml:"name,omitempty"`
// The URI of the namespace definition.
//
// This MUST be in the form of an absolute URI.
Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"`
// The prefix to be used for the name.
Prefix string `json:"prefix,omitempty" yaml:"prefix,omitempty"`
// Declares whether the property definition translates to an attribute instead of an element.
//
// Default value is false.
Attribute bool `json:"attribute,omitempty" yaml:"attribute,omitempty"`
// MAY be used only for an array definition. Signifies whether the array is wrapped
// (for example, `<books><book/><book/></books>`) or unwrapped (`<book/><book/>`).
//
// The definition takes effect only when defined alongside type being array (outside the items).
//
// Default value is false.
Wrapped bool `json:"wrapped,omitempty" yaml:"wrapped,omitempty"`
}
XML is a metadata object that allows for more fine-tuned XML model definitions.