draft202012

package
v0.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2025 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Overview

Package draft202012 defines the keywords used by JSON schema version 2020-12.

Index

Constants

View Source
const SchemaID = "https://json-schema.org/draft/2020-12/schema"

Variables

View Source
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

func Infer[T any](b *Builder, opts *builder.InferOpts) (*Builder, error)

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

func InferType(b *Builder, typ reflect.Type, opts *builder.InferOpts) (*Builder, error)

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

func (b *Builder) AddAdditionalProperties(arg *schema.Schema) *Builder

AddAdditionalProperties adds the additionalProperties keyword to the schema.

func (*Builder) AddAllOf

func (b *Builder) AddAllOf(arg []*schema.Schema) *Builder

AddAllOf adds the allOf keyword to the schema.

func (*Builder) AddAny

func (b *Builder) AddAny(keyword *schema.Keyword, v any) *Builder

AddAny adds a keyword with an argument of type Any.

func (*Builder) AddAnyOf

func (b *Builder) AddAnyOf(arg []*schema.Schema) *Builder

AddAnyOf adds the anyOf keyword to the schema.

func (*Builder) AddBool

func (b *Builder) AddBool(keyword *schema.Keyword, v bool) *Builder

AddBool adds a keyword with an argument of type Bool.

func (*Builder) AddComment

func (b *Builder) AddComment(arg string) *Builder

AddComment adds the $comment keyword to the schema.

func (*Builder) AddConst

func (b *Builder) AddConst(arg any) *Builder

AddConst adds the const keyword to the schema.

func (*Builder) AddContains

func (b *Builder) AddContains(arg *schema.Schema) *Builder

AddContains adds the contains keyword to the schema.

func (*Builder) AddContentEncoding

func (b *Builder) AddContentEncoding(arg string) *Builder

AddContentEncoding adds the contentEncoding keyword to the schema.

func (*Builder) AddContentMediaType

func (b *Builder) AddContentMediaType(arg string) *Builder

AddContentMediaType adds the contentMediaType keyword to the schema.

func (*Builder) AddContentSchema

func (b *Builder) AddContentSchema(arg *schema.Schema) *Builder

AddContentSchema adds the contentSchema keyword to the schema.

func (*Builder) AddDefault

func (b *Builder) AddDefault(arg any) *Builder

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

func (b *Builder) AddDependentRequired(arg any) *Builder

AddDependentRequired adds the dependentRequired keyword to the schema.

func (*Builder) AddDependentSchemas

func (b *Builder) AddDependentSchemas(arg map[string]*schema.Schema) *Builder

AddDependentSchemas adds the dependentSchemas keyword to the schema.

func (*Builder) AddDeprecated

func (b *Builder) AddDeprecated(arg bool) *Builder

AddDeprecated adds the deprecated keyword to the schema.

func (*Builder) AddDescription

func (b *Builder) AddDescription(arg string) *Builder

AddDescription adds the description keyword to the schema.

func (*Builder) AddElse

func (b *Builder) AddElse(arg *schema.Schema) *Builder

AddElse adds the else keyword to the schema.

func (*Builder) AddEnum

func (b *Builder) AddEnum(arg any) *Builder

AddEnum adds the enum keyword to the schema.

func (*Builder) AddExamples

func (b *Builder) AddExamples(arg any) *Builder

AddExamples adds the examples keyword to the schema.

func (*Builder) AddExclusiveMaximum

func (b *Builder) AddExclusiveMaximum(arg float64) *Builder

AddExclusiveMaximum adds the exclusiveMaximum keyword to the schema.

func (*Builder) AddExclusiveMinimum

func (b *Builder) AddExclusiveMinimum(arg float64) *Builder

AddExclusiveMinimum adds the exclusiveMinimum keyword to the schema.

func (*Builder) AddFloat

func (b *Builder) AddFloat(keyword *schema.Keyword, v float64) *Builder

AddFloat adds a keyword with an argument of type Float.

func (*Builder) AddFormat

func (b *Builder) AddFormat(arg string) *Builder

AddFormat adds the format keyword to the schema.

func (*Builder) AddIf

func (b *Builder) AddIf(arg *schema.Schema) *Builder

AddIf adds the if keyword to the schema.

func (*Builder) AddInt

func (b *Builder) AddInt(keyword *schema.Keyword, v int64) *Builder

AddInt adds a keyword with an argument of type Int.

func (*Builder) AddItems

func (b *Builder) AddItems(arg *schema.Schema) *Builder

AddItems adds the items keyword to the schema.

func (*Builder) AddItemsSchema

func (b *Builder) AddItemsSchema(s *schema.Schema) *Builder

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

func (b *Builder) AddMapSchema(keyword *schema.Keyword, v map[string]*schema.Schema) *Builder

AddMapSchema adds a keyword with an argument of type MapSchema.

func (*Builder) AddMaxContains

func (b *Builder) AddMaxContains(arg int64) *Builder

AddMaxContains adds the maxContains keyword to the schema.

func (*Builder) AddMaxItems

func (b *Builder) AddMaxItems(arg int64) *Builder

AddMaxItems adds the maxItems keyword to the schema.

func (*Builder) AddMaxLength

func (b *Builder) AddMaxLength(arg int64) *Builder

AddMaxLength adds the maxLength keyword to the schema.

func (*Builder) AddMaxProperties

func (b *Builder) AddMaxProperties(arg int64) *Builder

AddMaxProperties adds the maxProperties keyword to the schema.

func (*Builder) AddMaximum

func (b *Builder) AddMaximum(arg float64) *Builder

AddMaximum adds the maximum keyword to the schema.

func (*Builder) AddMinContains

func (b *Builder) AddMinContains(arg int64) *Builder

AddMinContains adds the minContains keyword to the schema.

func (*Builder) AddMinItems

func (b *Builder) AddMinItems(arg int64) *Builder

AddMinItems adds the minItems keyword to the schema.

func (*Builder) AddMinLength

func (b *Builder) AddMinLength(arg int64) *Builder

AddMinLength adds the minLength keyword to the schema.

func (*Builder) AddMinProperties

func (b *Builder) AddMinProperties(arg int64) *Builder

AddMinProperties adds the minProperties keyword to the schema.

func (*Builder) AddMinimum

func (b *Builder) AddMinimum(arg float64) *Builder

AddMinimum adds the minimum keyword to the schema.

func (*Builder) AddMultipleOf

func (b *Builder) AddMultipleOf(arg float64) *Builder

AddMultipleOf adds the multipleOf keyword to the schema.

func (*Builder) AddNot

func (b *Builder) AddNot(arg *schema.Schema) *Builder

AddNot adds the not keyword to the schema.

func (*Builder) AddOneOf

func (b *Builder) AddOneOf(arg []*schema.Schema) *Builder

AddOneOf adds the oneOf keyword to the schema.

func (*Builder) AddPattern

func (b *Builder) AddPattern(arg string) *Builder

AddPattern adds the pattern keyword to the schema.

func (*Builder) AddPatternProperties

func (b *Builder) AddPatternProperties(arg map[string]*schema.Schema) *Builder

AddPatternProperties adds the patternProperties keyword to the schema.

func (*Builder) AddPrefixItems

func (b *Builder) AddPrefixItems(arg []*schema.Schema) *Builder

AddPrefixItems adds the prefixItems keyword to the schema.

func (*Builder) AddProperties

func (b *Builder) AddProperties(arg map[string]*schema.Schema) *Builder

AddProperties adds the properties keyword to the schema.

func (*Builder) AddPropertyNames

func (b *Builder) AddPropertyNames(arg *schema.Schema) *Builder

AddPropertyNames adds the propertyNames keyword to the schema.

func (*Builder) AddReadOnly

func (b *Builder) AddReadOnly(arg bool) *Builder

AddReadOnly adds the readOnly keyword to the schema.

func (*Builder) AddRequired

func (b *Builder) AddRequired(arg []string) *Builder

AddRequired adds the required keyword to the schema.

func (*Builder) AddSchema

func (b *Builder) AddSchema(keyword *schema.Keyword, v *schema.Schema) *Builder

AddSchema adds a keyword with an argument of type 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

func (b *Builder) AddSchemaParts(parts []schema.Part) *Builder

AddSchemaParts adds a list of parts.

func (*Builder) AddSchemas

func (b *Builder) AddSchemas(keyword *schema.Keyword, v []*schema.Schema) *Builder

AddSchemas adds a keyword with an argument of type Schemas.

func (*Builder) AddString

func (b *Builder) AddString(keyword *schema.Keyword, v string) *Builder

AddString adds a keyword with an argument of type String.

func (*Builder) AddStrings

func (b *Builder) AddStrings(keyword *schema.Keyword, v []string) *Builder

AddStrings adds a keyword with an argument of type Strings.

func (*Builder) AddThen

func (b *Builder) AddThen(arg *schema.Schema) *Builder

AddThen adds the then keyword to the schema.

func (*Builder) AddTitle

func (b *Builder) AddTitle(arg string) *Builder

AddTitle adds the title keyword to the schema.

func (*Builder) AddType

func (b *Builder) AddType(args ...string) *Builder

AddType adds the type keyword with one or more strings to the schema.

func (*Builder) AddUnevaluatedItems

func (b *Builder) AddUnevaluatedItems(arg *schema.Schema) *Builder

AddUnevaluatedItems adds the unevaluatedItems keyword to the schema.

func (*Builder) AddUnevaluatedProperties

func (b *Builder) AddUnevaluatedProperties(arg *schema.Schema) *Builder

AddUnevaluatedProperties adds the unevaluatedProperties keyword to the schema.

func (*Builder) AddUniqueItems

func (b *Builder) AddUniqueItems(arg bool) *Builder

AddUniqueItems adds the uniqueItems keyword to the schema.

func (*Builder) AddWriteOnly

func (b *Builder) AddWriteOnly(arg bool) *Builder

AddWriteOnly adds the writeOnly keyword to the schema.

func (*Builder) BoolSchema

func (b *Builder) BoolSchema(acceptAll bool) *schema.Schema

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) Build

func (b *Builder) Build() *schema.Schema

Build returns a newly built schema.

func (*Builder) NewSubBuilder

func (b *Builder) NewSubBuilder() *Builder

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL