From bd40dcfc2bc7c9014ea1f33482fb63aacbcdfe87 Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Tue, 8 Jan 2019 14:52:57 +0100 Subject: vendor: update everything * If possible, update each dependency to the latest available version. * Use releases over commit IDs and avoid vendoring branches. Signed-off-by: Valentin Rothberg --- .../github.com/xeipuuv/gojsonschema/subSchema.go | 67 ++++++++++++++++------ 1 file changed, 48 insertions(+), 19 deletions(-) (limited to 'vendor/github.com/xeipuuv/gojsonschema/subSchema.go') diff --git a/vendor/github.com/xeipuuv/gojsonschema/subSchema.go b/vendor/github.com/xeipuuv/gojsonschema/subSchema.go index 9ddbb5fc1..362d86ca9 100644 --- a/vendor/github.com/xeipuuv/gojsonschema/subSchema.go +++ b/vendor/github.com/xeipuuv/gojsonschema/subSchema.go @@ -28,6 +28,7 @@ package gojsonschema import ( "errors" + "math/big" "regexp" "strings" @@ -35,8 +36,9 @@ import ( ) const ( - KEY_SCHEMA = "$subSchema" - KEY_ID = "$id" + KEY_SCHEMA = "$schema" + KEY_ID = "id" + KEY_ID_NEW = "$id" KEY_REF = "$ref" KEY_TITLE = "title" KEY_DESCRIPTION = "description" @@ -46,6 +48,7 @@ const ( KEY_PROPERTIES = "properties" KEY_PATTERN_PROPERTIES = "patternProperties" KEY_ADDITIONAL_PROPERTIES = "additionalProperties" + KEY_PROPERTY_NAMES = "propertyNames" KEY_DEFINITIONS = "definitions" KEY_MULTIPLE_OF = "multipleOf" KEY_MINIMUM = "minimum" @@ -63,17 +66,23 @@ const ( KEY_MIN_ITEMS = "minItems" KEY_MAX_ITEMS = "maxItems" KEY_UNIQUE_ITEMS = "uniqueItems" + KEY_CONTAINS = "contains" + KEY_CONST = "const" KEY_ENUM = "enum" KEY_ONE_OF = "oneOf" KEY_ANY_OF = "anyOf" KEY_ALL_OF = "allOf" KEY_NOT = "not" + KEY_IF = "if" + KEY_THEN = "then" + KEY_ELSE = "else" ) type subSchema struct { + draft *Draft // basic subSchema meta properties - id *string + id *gojsonreference.JsonReference title *string description *string @@ -86,23 +95,19 @@ type subSchema struct { ref *gojsonreference.JsonReference // Schema referenced refSchema *subSchema - // Json reference - subSchema *gojsonreference.JsonReference // hierarchy parent *subSchema - definitions map[string]*subSchema - definitionsChildren []*subSchema itemsChildren []*subSchema itemsChildrenIsSingleSchema bool propertiesChildren []*subSchema // validation : number / integer - multipleOf *float64 - maximum *float64 - exclusiveMaximum bool - minimum *float64 - exclusiveMinimum bool + multipleOf *big.Rat + maximum *big.Rat + exclusiveMaximum *big.Rat + minimum *big.Rat + exclusiveMinimum *big.Rat // validation : string minLength *int @@ -118,27 +123,43 @@ type subSchema struct { dependencies map[string]interface{} additionalProperties interface{} patternProperties map[string]*subSchema + propertyNames *subSchema // validation : array minItems *int maxItems *int uniqueItems bool + contains *subSchema additionalItems interface{} // validation : all - enum []string + _const *string //const is a golang keyword + enum []string // validation : subSchema oneOf []*subSchema anyOf []*subSchema allOf []*subSchema not *subSchema + _if *subSchema // if/else are golang keywords + _then *subSchema + _else *subSchema +} + +func (s *subSchema) AddConst(i interface{}) error { + + is, err := marshalWithoutNumber(i) + if err != nil { + return err + } + s._const = is + return nil } func (s *subSchema) AddEnum(i interface{}) error { - is, err := marshalToJsonString(i) + is, err := marshalWithoutNumber(i) if err != nil { return err } @@ -157,7 +178,7 @@ func (s *subSchema) AddEnum(i interface{}) error { func (s *subSchema) ContainsEnum(i interface{}) (bool, error) { - is, err := marshalToJsonString(i) + is, err := marshalWithoutNumber(i) if err != nil { return false, err } @@ -181,6 +202,18 @@ func (s *subSchema) SetNot(subSchema *subSchema) { s.not = subSchema } +func (s *subSchema) SetIf(subSchema *subSchema) { + s._if = subSchema +} + +func (s *subSchema) SetThen(subSchema *subSchema) { + s._then = subSchema +} + +func (s *subSchema) SetElse(subSchema *subSchema) { + s._else = subSchema +} + func (s *subSchema) AddRequired(value string) error { if isStringInSlice(s.required, value) { @@ -195,10 +228,6 @@ func (s *subSchema) AddRequired(value string) error { return nil } -func (s *subSchema) AddDefinitionChild(child *subSchema) { - s.definitionsChildren = append(s.definitionsChildren, child) -} - func (s *subSchema) AddItemsChild(child *subSchema) { s.itemsChildren = append(s.itemsChildren, child) } -- cgit v1.2.3-54-g00ecf