Documentation
¶
Overview ¶
Package draft202012 defines the keywords used by JSON schema version 2020-12.
Index ¶
- Constants
- Variables
- type Builder
- func (b *Builder) AddAdditionalProperties(arg *schema.Schema) *Builder
- func (b *Builder) AddAllOf(arg []*schema.Schema) *Builder
- func (b *Builder) AddAny(keyword *schema.Keyword, v any) *Builder
- func (b *Builder) AddAnyOf(arg []*schema.Schema) *Builder
- func (b *Builder) AddBool(keyword *schema.Keyword, v bool) *Builder
- func (b *Builder) AddComment(arg string) *Builder
- func (b *Builder) AddConst(arg any) *Builder
- func (b *Builder) AddContains(arg *schema.Schema) *Builder
- func (b *Builder) AddContentEncoding(arg string) *Builder
- func (b *Builder) AddContentMediaType(arg string) *Builder
- func (b *Builder) AddContentSchema(arg *schema.Schema) *Builder
- func (b *Builder) AddDefault(arg any) *Builder
- func (b *Builder) AddDependencies(arg map[string]schema.ArrayOrSchema) *Builder
- func (b *Builder) AddDependentRequired(arg any) *Builder
- func (b *Builder) AddDependentSchemas(arg map[string]*schema.Schema) *Builder
- func (b *Builder) AddDeprecated(arg bool) *Builder
- func (b *Builder) AddDescription(arg string) *Builder
- func (b *Builder) AddElse(arg *schema.Schema) *Builder
- func (b *Builder) AddEnum(arg any) *Builder
- func (b *Builder) AddExamples(arg any) *Builder
- func (b *Builder) AddExclusiveMaximum(arg float64) *Builder
- func (b *Builder) AddExclusiveMinimum(arg float64) *Builder
- func (b *Builder) AddFloat(keyword *schema.Keyword, v float64) *Builder
- func (b *Builder) AddFormat(arg string) *Builder
- func (b *Builder) AddIf(arg *schema.Schema) *Builder
- func (b *Builder) AddInt(keyword *schema.Keyword, v int64) *Builder
- func (b *Builder) AddItems(arg *schema.Schema) *Builder
- func (b *Builder) AddItemsSchema(s *schema.Schema) *Builder
- func (b *Builder) AddMapArrayOrSchema(keyword *schema.Keyword, v map[string]schema.ArrayOrSchema) *Builder
- func (b *Builder) AddMapSchema(keyword *schema.Keyword, v map[string]*schema.Schema) *Builder
- func (b *Builder) AddMaxContains(arg int64) *Builder
- func (b *Builder) AddMaxItems(arg int64) *Builder
- func (b *Builder) AddMaxLength(arg int64) *Builder
- func (b *Builder) AddMaxProperties(arg int64) *Builder
- func (b *Builder) AddMaximum(arg float64) *Builder
- func (b *Builder) AddMinContains(arg int64) *Builder
- func (b *Builder) AddMinItems(arg int64) *Builder
- func (b *Builder) AddMinLength(arg int64) *Builder
- func (b *Builder) AddMinProperties(arg int64) *Builder
- func (b *Builder) AddMinimum(arg float64) *Builder
- func (b *Builder) AddMultipleOf(arg float64) *Builder
- func (b *Builder) AddNot(arg *schema.Schema) *Builder
- func (b *Builder) AddOneOf(arg []*schema.Schema) *Builder
- func (b *Builder) AddPattern(arg string) *Builder
- func (b *Builder) AddPatternProperties(arg map[string]*schema.Schema) *Builder
- func (b *Builder) AddPrefixItems(arg []*schema.Schema) *Builder
- func (b *Builder) AddProperties(arg map[string]*schema.Schema) *Builder
- func (b *Builder) AddPropertyNames(arg *schema.Schema) *Builder
- func (b *Builder) AddReadOnly(arg bool) *Builder
- func (b *Builder) AddRequired(arg []string) *Builder
- func (b *Builder) AddSchema(keyword *schema.Keyword, v *schema.Schema) *Builder
- func (b *Builder) AddSchemaOrSchemas(keyword *schema.Keyword, v schema.PartSchemaOrSchemas) *Builder
- func (b *Builder) AddSchemaParts(parts []schema.Part) *Builder
- func (b *Builder) AddSchemas(keyword *schema.Keyword, v []*schema.Schema) *Builder
- func (b *Builder) AddString(keyword *schema.Keyword, v string) *Builder
- func (b *Builder) AddStrings(keyword *schema.Keyword, v []string) *Builder
- func (b *Builder) AddThen(arg *schema.Schema) *Builder
- func (b *Builder) AddTitle(arg string) *Builder
- func (b *Builder) AddType(args ...string) *Builder
- func (b *Builder) AddUnevaluatedItems(arg *schema.Schema) *Builder
- func (b *Builder) AddUnevaluatedProperties(arg *schema.Schema) *Builder
- func (b *Builder) AddUniqueItems(arg bool) *Builder
- func (b *Builder) AddWriteOnly(arg bool) *Builder
- func (b *Builder) BoolSchema(acceptAll bool) *schema.Schema
- func (b *Builder) Build() *schema.Schema
- func (b *Builder) NewSubBuilder() *Builder
Constants ¶
const SchemaID = "https://json-schema.org/draft/2020-12/schema"
Variables ¶
var Vocabulary = &schema.Vocabulary{ Name: "draft2020-12", Schema: SchemaID, Keywords: keywordMap, Cmp: keywordCmp, Resolve: resolveSchema, }
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder is a JSON schema builder. Builder provides a list of methods that may be used to add new elements to the schema. This should be used by programs that need to create a JSON schema from scratch, rather than unmarshaling it from a JSON representation or using [schemareflect.Reflect] to construct it from a Go type.
Programs should use NewBuilder or NewSubBuilder to get a Builder.
func Infer ¶
Infer adds schema elements to b designed to validate JSON values that unmarshal into values of the given type. See builder.Infer for details.
func InferType ¶
InferType is like Infer buts takes a reflect.Type rather than a type argument.
func NewBuilder ¶
func NewBuilder() *Builder
NewBuilder returns a Builder to use to build a JSON schema. Use this to build an entirely new schema.
func NewSubBuilder ¶
func NewSubBuilder() *Builder
NewSubBuilder returns a Builder like NewBuilder, but is for a schema that will be part of some larger schema.
func (*Builder) AddAdditionalProperties ¶
AddAdditionalProperties adds the additionalProperties keyword to the schema.
func (*Builder) AddComment ¶
AddComment adds the $comment keyword to the schema.
func (*Builder) AddContains ¶
AddContains adds the contains keyword to the schema.
func (*Builder) AddContentEncoding ¶
AddContentEncoding adds the contentEncoding keyword to the schema.
func (*Builder) AddContentMediaType ¶
AddContentMediaType adds the contentMediaType keyword to the schema.
func (*Builder) AddContentSchema ¶
AddContentSchema adds the contentSchema keyword to the schema.
func (*Builder) AddDefault ¶
AddDefault adds the default keyword to the schema.
func (*Builder) AddDependencies ¶
func (b *Builder) AddDependencies(arg map[string]schema.ArrayOrSchema) *Builder
AddDependencies adds the dependencies keyword to the schema.
func (*Builder) AddDependentRequired ¶
AddDependentRequired adds the dependentRequired keyword to the schema.
func (*Builder) AddDependentSchemas ¶
AddDependentSchemas adds the dependentSchemas keyword to the schema.
func (*Builder) AddDeprecated ¶
AddDeprecated adds the deprecated keyword to the schema.
func (*Builder) AddDescription ¶
AddDescription adds the description keyword to the schema.
func (*Builder) AddExamples ¶
AddExamples adds the examples keyword to the schema.
func (*Builder) AddExclusiveMaximum ¶
AddExclusiveMaximum adds the exclusiveMaximum keyword to the schema.
func (*Builder) AddExclusiveMinimum ¶
AddExclusiveMinimum adds the exclusiveMinimum keyword to the schema.
func (*Builder) AddItemsSchema ¶
AddItemsSchema is for builder.Infer. Use the AddItems method instead.
func (*Builder) AddMapArrayOrSchema ¶
func (b *Builder) AddMapArrayOrSchema(keyword *schema.Keyword, v map[string]schema.ArrayOrSchema) *Builder
AddMapArrayOrSchema adds a keyword with an argument of type MapArrayOrSchema.
func (*Builder) AddMapSchema ¶
AddMapSchema adds a keyword with an argument of type MapSchema.
func (*Builder) AddMaxContains ¶
AddMaxContains adds the maxContains keyword to the schema.
func (*Builder) AddMaxItems ¶
AddMaxItems adds the maxItems keyword to the schema.
func (*Builder) AddMaxLength ¶
AddMaxLength adds the maxLength keyword to the schema.
func (*Builder) AddMaxProperties ¶
AddMaxProperties adds the maxProperties keyword to the schema.
func (*Builder) AddMaximum ¶
AddMaximum adds the maximum keyword to the schema.
func (*Builder) AddMinContains ¶
AddMinContains adds the minContains keyword to the schema.
func (*Builder) AddMinItems ¶
AddMinItems adds the minItems keyword to the schema.
func (*Builder) AddMinLength ¶
AddMinLength adds the minLength keyword to the schema.
func (*Builder) AddMinProperties ¶
AddMinProperties adds the minProperties keyword to the schema.
func (*Builder) AddMinimum ¶
AddMinimum adds the minimum keyword to the schema.
func (*Builder) AddMultipleOf ¶
AddMultipleOf adds the multipleOf keyword to the schema.
func (*Builder) AddPattern ¶
AddPattern adds the pattern keyword to the schema.
func (*Builder) AddPatternProperties ¶
AddPatternProperties adds the patternProperties keyword to the schema.
func (*Builder) AddPrefixItems ¶
AddPrefixItems adds the prefixItems keyword to the schema.
func (*Builder) AddProperties ¶
AddProperties adds the properties keyword to the schema.
func (*Builder) AddPropertyNames ¶
AddPropertyNames adds the propertyNames keyword to the schema.
func (*Builder) AddReadOnly ¶
AddReadOnly adds the readOnly keyword to the schema.
func (*Builder) AddRequired ¶
AddRequired adds the required keyword to the schema.
func (*Builder) AddSchemaOrSchemas ¶
func (b *Builder) AddSchemaOrSchemas(keyword *schema.Keyword, v schema.PartSchemaOrSchemas) *Builder
AddSchemaOrSchemas adds a keyword with an argument of type SchemaOrSchemas.
func (*Builder) AddSchemaParts ¶
AddSchemaParts adds a list of parts.
func (*Builder) AddSchemas ¶
AddSchemas adds a keyword with an argument of type Schemas.
func (*Builder) AddStrings ¶
AddStrings adds a keyword with an argument of type Strings.
func (*Builder) AddUnevaluatedItems ¶
AddUnevaluatedItems adds the unevaluatedItems keyword to the schema.
func (*Builder) AddUnevaluatedProperties ¶
AddUnevaluatedProperties adds the unevaluatedProperties keyword to the schema.
func (*Builder) AddUniqueItems ¶
AddUniqueItems adds the uniqueItems keyword to the schema.
func (*Builder) AddWriteOnly ¶
AddWriteOnly adds the writeOnly keyword to the schema.
func (*Builder) BoolSchema ¶
BoolSchema returns a newly built schema. If acceptAll is true the schema accepts all instance values, if false it accepts none. This is the JSON schema true and false values.
func (*Builder) NewSubBuilder ¶
NewSubBuilder returns a new Builder with the same vocabulary. This is like the NewSubBuilder function in that it is for schemas that will be part of some larger schema.