Documentation ¶
Index ¶
- type AdditionalProperties
- type Discriminator
- type Enum
- type ExternalResolver
- type Infer
- type NoExternal
- type Num
- type Parser
- type PatternProperty
- type Property
- type RawPatternProperties
- type RawPatternProperty
- type RawProperties
- type RawProperty
- type RawSchema
- 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,omitzero"` }
Discriminator is JSON Schema discriminator description.
type Enum ¶ added in v0.38.0
Enum is JSON Schema enum validator description.
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 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) MarshalNextJSON ¶ added in v0.42.0
MarshalNextJSON implements json.MarshalerV2.
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,omitzero"` Summary string `json:"summary,omitzero"` Description string `json:"description,omitzero"` Type string `json:"type,omitzero"` Format string `json:"format,omitzero"` Properties RawProperties `json:"properties,omitzero"` AdditionalProperties *AdditionalProperties `json:"additionalProperties,omitzero"` PatternProperties RawPatternProperties `json:"patternProperties,omitzero"` Required []string `json:"required,omitzero"` Items *RawSchema `json:"items,omitzero"` Nullable bool `json:"nullable,omitzero"` AllOf []*RawSchema `json:"allOf,omitzero"` OneOf []*RawSchema `json:"oneOf,omitzero"` AnyOf []*RawSchema `json:"anyOf,omitzero"` Discriminator *Discriminator `json:"discriminator,omitzero"` Enum Enum `json:"enum,omitzero"` MultipleOf Num `json:"multipleOf,omitzero"` Maximum Num `json:"maximum,omitzero"` ExclusiveMaximum bool `json:"exclusiveMaximum,omitzero"` Minimum Num `json:"minimum,omitzero"` ExclusiveMinimum bool `json:"exclusiveMinimum,omitzero"` MaxLength *uint64 `json:"maxLength,omitzero"` MinLength *uint64 `json:"minLength,omitzero"` Pattern string `json:"pattern,omitzero"` MaxItems *uint64 `json:"maxItems,omitzero"` MinItems *uint64 `json:"minItems,omitzero"` UniqueItems bool `json:"uniqueItems,omitzero"` MaxProperties *uint64 `json:"maxProperties,omitzero"` MinProperties *uint64 `json:"minProperties,omitzero"` Default json.RawValue `json:"default,omitzero"` Example json.RawValue `json:"example,omitzero"` Deprecated bool `json:"deprecated,omitzero"` ContentEncoding string `json:"contentEncoding,omitzero"` ContentMediaType string `json:"contentMediaType,omitzero"` XAnnotations map[string]json.RawValue `json:",inline"` ogenjson.Locator `json:"-"` }
RawSchema is unparsed JSON Schema.
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 }
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 // 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.