Fix CRD validation error for 'items' field
Signed-off-by: He Xiaoxi <xxhe@alauda.io>
This commit is contained in:
13
vendor/github.com/go-openapi/validate/schema.go
generated
vendored
13
vendor/github.com/go-openapi/validate/schema.go
generated
vendored
@@ -39,6 +39,7 @@ type SchemaValidator struct {
|
||||
validators []valueValidator
|
||||
Root interface{}
|
||||
KnownFormats strfmt.Registry
|
||||
Options *SchemaValidatorOptions
|
||||
}
|
||||
|
||||
// AgainstSchema validates the specified data against the provided schema, using a registry of supported formats.
|
||||
@@ -55,7 +56,7 @@ func AgainstSchema(schema *spec.Schema, data interface{}, formats strfmt.Registr
|
||||
// NewSchemaValidator creates a new schema validator.
|
||||
//
|
||||
// Panics if the provided schema is invalid.
|
||||
func NewSchemaValidator(schema *spec.Schema, rootSchema interface{}, root string, formats strfmt.Registry) *SchemaValidator {
|
||||
func NewSchemaValidator(schema *spec.Schema, rootSchema interface{}, root string, formats strfmt.Registry, options ...Option) *SchemaValidator {
|
||||
if schema == nil {
|
||||
return nil
|
||||
}
|
||||
@@ -71,7 +72,10 @@ func NewSchemaValidator(schema *spec.Schema, rootSchema interface{}, root string
|
||||
panic(msg)
|
||||
}
|
||||
}
|
||||
s := SchemaValidator{Path: root, in: "body", Schema: schema, Root: rootSchema, KnownFormats: formats}
|
||||
s := SchemaValidator{Path: root, in: "body", Schema: schema, Root: rootSchema, KnownFormats: formats, Options: &SchemaValidatorOptions{}}
|
||||
for _, o := range options {
|
||||
o(s.Options)
|
||||
}
|
||||
s.validators = []valueValidator{
|
||||
s.typeValidator(),
|
||||
s.schemaPropsValidator(),
|
||||
@@ -170,7 +174,7 @@ func (s *SchemaValidator) Validate(data interface{}) *Result {
|
||||
}
|
||||
|
||||
func (s *SchemaValidator) typeValidator() valueValidator {
|
||||
return &typeValidator{Type: s.Schema.Type, Format: s.Schema.Format, In: s.in, Path: s.Path}
|
||||
return &typeValidator{Type: s.Schema.Type, Nullable: s.Schema.Nullable, Format: s.Schema.Format, In: s.in, Path: s.Path}
|
||||
}
|
||||
|
||||
func (s *SchemaValidator) commonValidator() valueValidator {
|
||||
@@ -229,7 +233,7 @@ func (s *SchemaValidator) formatValidator() valueValidator {
|
||||
|
||||
func (s *SchemaValidator) schemaPropsValidator() valueValidator {
|
||||
sch := s.Schema
|
||||
return newSchemaPropsValidator(s.Path, s.in, sch.AllOf, sch.OneOf, sch.AnyOf, sch.Not, sch.Dependencies, s.Root, s.KnownFormats)
|
||||
return newSchemaPropsValidator(s.Path, s.in, sch.AllOf, sch.OneOf, sch.AnyOf, sch.Not, sch.Dependencies, s.Root, s.KnownFormats, s.Options.Options()...)
|
||||
}
|
||||
|
||||
func (s *SchemaValidator) objectValidator() valueValidator {
|
||||
@@ -244,5 +248,6 @@ func (s *SchemaValidator) objectValidator() valueValidator {
|
||||
PatternProperties: s.Schema.PatternProperties,
|
||||
Root: s.Root,
|
||||
KnownFormats: s.KnownFormats,
|
||||
Options: *s.Options,
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user