Documentation
¶
Index ¶
- type AdditionalProperties
- type Default
- type Discriminator
- type Enum
- func (n *Enum) MarshalJSON() ([]byte, error)
- func (n Enum) MarshalNextJSON(opts json.MarshalOptions, e *json.Encoder) error
- func (n *Enum) UnmarshalJSON(data []byte) error
- func (n *Enum) UnmarshalNextJSON(opts json.UnmarshalOptions, d *json.Decoder) error
- func (n *Enum) UnmarshalYAML(node *yaml.Node) error
- type Example
- type ExternalResolver
- type Infer
- type LocationError
- type NoExternal
- type Num
- func (n *Num) MarshalJSON() ([]byte, error)
- func (n Num) MarshalNextJSON(opts json.MarshalOptions, e *json.Encoder) error
- func (n *Num) UnmarshalJSON(data []byte) error
- func (n *Num) UnmarshalNextJSON(opts json.UnmarshalOptions, d *json.Decoder) error
- func (n *Num) UnmarshalYAML(node *yaml.Node) error
- type Parser
- type PatternProperty
- type Property
- type RawPatternProperties
- type RawPatternProperty
- type RawProperties
- type RawProperty
- type RawSchema
- type RawValue
- func (n *RawValue) MarshalJSON() ([]byte, error)
- func (n RawValue) MarshalNextJSON(opts json.MarshalOptions, e *json.Encoder) error
- func (n *RawValue) UnmarshalJSON(data []byte) error
- func (n *RawValue) UnmarshalNextJSON(opts json.UnmarshalOptions, d *json.Decoder) error
- func (n *RawValue) UnmarshalYAML(node *yaml.Node) error
- type ReferenceResolver
- type RootResolver
- type Schema
- type SchemaType
- type Settings
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) MarshalNextJSON ¶ added in v0.42.0
func (p AdditionalProperties) MarshalNextJSON(opts json.MarshalOptions, e *json.Encoder) error
MarshalNextJSON implements json.MarshalerV2.
func (*AdditionalProperties) UnmarshalNextJSON ¶ added in v0.42.0
func (p *AdditionalProperties) UnmarshalNextJSON(opts json.UnmarshalOptions, d *json.Decoder) error
UnmarshalNextJSON implements json.UnmarshalerV2.
type Discriminator ¶
type Discriminator struct {
PropertyName string `json:"propertyName"`
Mapping map[string]string `json:"mapping,omitempty,omitzero"`
}
Discriminator is JSON Schema discriminator description.
type Enum ¶ added in v0.38.0
Enum is JSON Schema enum validator description.
func (*Enum) MarshalJSON ¶ added in v0.43.1
MarshalJSON implements json.MarshalerV1.
func (Enum) MarshalNextJSON ¶ added in v0.43.1
MarshalNextJSON implements json.MarshalerV2.
func (*Enum) UnmarshalJSON ¶ added in v0.38.0
UnmarshalJSON implements json.UnmarshalerV1.
func (*Enum) UnmarshalNextJSON ¶ added in v0.42.0
UnmarshalNextJSON implements json.UnmarshalerV2.
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
type LocationError struct {
// contains filtered or unexported fields
}
LocationError is a wrapper for an error that has a location.
func (*LocationError) Error ¶ added in v0.43.0
func (e *LocationError) Error() string
Error implements error.
func (*LocationError) FormatError ¶ added in v0.43.0
func (e *LocationError) FormatError(p errors.Printer) (next error)
FormatError implements errors.Formatter.
func (*LocationError) Unwrap ¶ added in v0.43.0
func (e *LocationError) Unwrap() error
Unwrap implements errors.Wrapper.
type NoExternal ¶ added in v0.37.0
type NoExternal struct{}
NoExternal is ExternalResolver that always returns error.
type Num ¶ added in v0.16.0
Num represents JSON number.
func (*Num) MarshalJSON ¶ added in v0.17.1
MarshalJSON implements json.MarshalerV1.
func (Num) MarshalNextJSON ¶ added in v0.42.0
MarshalNextJSON implements json.MarshalerV2.
func (*Num) UnmarshalJSON ¶ added in v0.16.0
UnmarshalJSON implements json.UnmarshalerV1.
func (*Num) UnmarshalNextJSON ¶ added in v0.42.0
UnmarshalNextJSON implements json.UnmarshalerV2.
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) MarshalNextJSON ¶ added in v0.42.0
func (r RawPatternProperties) MarshalNextJSON(opts json.MarshalOptions, e *json.Encoder) error
MarshalNextJSON implements json.MarshalerV2.
func (*RawPatternProperties) UnmarshalNextJSON ¶ added in v0.42.0
func (r *RawPatternProperties) UnmarshalNextJSON(opts json.UnmarshalOptions, d *json.Decoder) error
UnmarshalNextJSON implements json.UnmarshalerV2.
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) MarshalNextJSON ¶ added in v0.42.0
func (p RawProperties) MarshalNextJSON(opts json.MarshalOptions, e *json.Encoder) error
MarshalNextJSON implements json.MarshalerV2.
func (*RawProperties) UnmarshalNextJSON ¶ added in v0.42.0
func (p *RawProperties) UnmarshalNextJSON(opts json.UnmarshalOptions, d *json.Decoder) error
UnmarshalNextJSON implements json.UnmarshalerV2.
type RawProperty ¶
RawProperty is item of RawProperties.
type RawSchema ¶
type RawSchema struct {
Ref string `json:"$ref,omitempty,omitzero"`
Summary string `json:"summary,omitempty,omitzero"`
Description string `json:"description,omitempty,omitzero"`
Type string `json:"type,omitempty,omitzero"`
Format string `json:"format,omitempty,omitzero"`
Properties RawProperties `json:"properties,omitempty,omitzero"`
AdditionalProperties *AdditionalProperties `json:"additionalProperties,omitempty,omitzero"`
PatternProperties RawPatternProperties `json:"patternProperties,omitempty,omitzero"`
Required []string `json:"required,omitempty,omitzero"`
Items *RawSchema `json:"items,omitempty,omitzero"`
Nullable bool `json:"nullable,omitempty,omitzero"`
AllOf []*RawSchema `json:"allOf,omitempty,omitzero"`
OneOf []*RawSchema `json:"oneOf,omitempty,omitzero"`
AnyOf []*RawSchema `json:"anyOf,omitempty,omitzero"`
Discriminator *Discriminator `json:"discriminator,omitempty,omitzero"`
Enum Enum `json:"enum,omitempty,omitzero"`
MultipleOf Num `json:"multipleOf,omitempty,omitzero"`
Maximum Num `json:"maximum,omitempty,omitzero"`
ExclusiveMaximum bool `json:"exclusiveMaximum,omitempty,omitzero"`
Minimum Num `json:"minimum,omitempty,omitzero"`
ExclusiveMinimum bool `json:"exclusiveMinimum,omitempty,omitzero"`
MaxLength *uint64 `json:"maxLength,omitempty,omitzero"`
MinLength *uint64 `json:"minLength,omitempty,omitzero"`
Pattern string `json:"pattern,omitempty,omitzero"`
MaxItems *uint64 `json:"maxItems,omitempty,omitzero"`
MinItems *uint64 `json:"minItems,omitempty,omitzero"`
UniqueItems bool `json:"uniqueItems,omitempty,omitzero"`
MaxProperties *uint64 `json:"maxProperties,omitempty,omitzero"`
MinProperties *uint64 `json:"minProperties,omitempty,omitzero"`
Default Default `json:"default,omitempty,omitzero"`
Example Example `json:"example,omitempty,omitzero"`
Deprecated bool `json:"deprecated,omitempty,omitzero"`
ContentEncoding string `json:"contentEncoding,omitempty,omitzero"`
ContentMediaType string `json:"contentMediaType,omitempty,omitzero"`
XAnnotations map[string]json.RawValue `json:",inline"`
ogenjson.Locator `json:"-"`
}
RawSchema is unparsed JSON Schema.
type RawValue ¶ added in v0.43.0
RawValue is a raw JSON value.
func (*RawValue) MarshalJSON ¶ added in v0.43.1
MarshalJSON implements json.MarshalerV1.
func (RawValue) MarshalNextJSON ¶ added in v0.43.0
MarshalNextJSON implements json.MarshalerV2.
func (*RawValue) UnmarshalJSON ¶ added in v0.43.1
UnmarshalJSON implements json.UnmarshalerV1.
func (*RawValue) UnmarshalNextJSON ¶ added in v0.43.0
UnmarshalNextJSON implements json.UnmarshalerV2.
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 []byte) *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
// 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 []json.RawValue
// Default schema value.
Default interface{}
DefaultSet bool
ogenjson.Locator
}
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.