Documentation
¶
Index ¶
- Constants
- func CompileCoercion(ctx *jsonschema.CompilerContext, obj map[string]any, allowCoercion bool) (jsonschema.SchemaExt, error)
- func CompileDeprecated(ctx *jsonschema.CompilerContext, obj map[string]any, version VersionType) (jsonschema.SchemaExt, error)
- func CompileDiscriminator(_ *jsonschema.CompilerContext, obj map[string]any, _ VersionType) (jsonschema.SchemaExt, error)
- func CompileExample(ctx *jsonschema.CompilerContext, obj map[string]any, version VersionType) (jsonschema.SchemaExt, error)
- func CompileNullable(_ *jsonschema.CompilerContext, obj map[string]any, version VersionType) (jsonschema.SchemaExt, error)
- func IsCoercibleType(schemaType any) bool
- func NewOpenAPIVocabulary(version VersionType) *jsonschema.Vocabulary
- func NewOpenAPIVocabularyWithCoercion(version VersionType, allowCoercion bool) *jsonschema.Vocabulary
- type CoercionError
- type DiscriminatorPropertyMissingError
- type OpenAPIKeywordError
- type VersionType
Constants ¶
const OpenAPIVocabularyURL = "https://pb33f.io/openapi-validator/vocabulary"
OpenAPIVocabularyURL is the vocabulary URL for OpenAPI-specific keywords
Variables ¶
This section is empty.
Functions ¶
func CompileCoercion ¶
func CompileCoercion(ctx *jsonschema.CompilerContext, obj map[string]any, allowCoercion bool) (jsonschema.SchemaExt, error)
CompileCoercion compiles the coercion extension if coercion is allowed and applicable
func CompileDeprecated ¶
func CompileDeprecated(ctx *jsonschema.CompilerContext, obj map[string]any, version VersionType) (jsonschema.SchemaExt, error)
compileDeprecated compiles the deprecated keyword
func CompileDiscriminator ¶
func CompileDiscriminator(_ *jsonschema.CompilerContext, obj map[string]any, _ VersionType) (jsonschema.SchemaExt, error)
CompileDiscriminator compiles the OpenAPI discriminator keyword
func CompileExample ¶
func CompileExample(ctx *jsonschema.CompilerContext, obj map[string]any, version VersionType) (jsonschema.SchemaExt, error)
compileExample compiles the example keyword
func CompileNullable ¶
func CompileNullable(_ *jsonschema.CompilerContext, obj map[string]any, version VersionType) (jsonschema.SchemaExt, error)
compileNullable compiles the nullable keyword based on OpenAPI version
func IsCoercibleType ¶
IsCoercibleType checks if the schema type is one that supports coercion
func NewOpenAPIVocabulary ¶
func NewOpenAPIVocabulary(version VersionType) *jsonschema.Vocabulary
NewOpenAPIVocabulary creates a vocabulary for OpenAPI-specific keywords version determines which keywords are allowed/forbidden
func NewOpenAPIVocabularyWithCoercion ¶
func NewOpenAPIVocabularyWithCoercion(version VersionType, allowCoercion bool) *jsonschema.Vocabulary
NewOpenAPIVocabularyWithCoercion creates a vocabulary with optional scalar coercion
Types ¶
type CoercionError ¶
CoercionError represents an error during scalar type coercion
func (*CoercionError) Error ¶
func (e *CoercionError) Error() string
func (*CoercionError) KeywordPath ¶
func (e *CoercionError) KeywordPath() []string
func (*CoercionError) LocalizedString ¶
func (e *CoercionError) LocalizedString(printer *message.Printer) string
type DiscriminatorPropertyMissingError ¶
type DiscriminatorPropertyMissingError struct {
PropertyName string
}
DiscriminatorPropertyMissingError represents an error when discriminator property is missing
func (*DiscriminatorPropertyMissingError) Error ¶
func (e *DiscriminatorPropertyMissingError) Error() string
func (*DiscriminatorPropertyMissingError) KeywordPath ¶
func (e *DiscriminatorPropertyMissingError) KeywordPath() []string
func (*DiscriminatorPropertyMissingError) LocalizedString ¶
func (e *DiscriminatorPropertyMissingError) LocalizedString(printer *message.Printer) string
type OpenAPIKeywordError ¶
OpenAPIKeywordError represents an error with an OpenAPI-specific keyword
func (*OpenAPIKeywordError) Error ¶
func (e *OpenAPIKeywordError) Error() string
type VersionType ¶
type VersionType int
VersionType represents OpenAPI specification versions
const ( // Version30 represents OpenAPI 3.0.x Version30 VersionType = iota // Version31 represents OpenAPI 3.1.x (and later) Version31 )