diff --git a/functions/openapi/schema_type.go b/functions/openapi/schema_type.go index ddab9773..1384f11c 100644 --- a/functions/openapi/schema_type.go +++ b/functions/openapi/schema_type.go @@ -83,22 +83,7 @@ func (st SchemaTypeCheck) validateNumber(schema *base.Schema, context *model.Rul } } - if schema.Value.Minimum != nil { - if *schema.Value.Minimum < 0 { - result := st.buildResult("`minimum` should be a number greater than or equal to `0`", - fmt.Sprintf("%s.%s", schema.GenerateJSONPath(), "minimum"), - schema, schema.Value.GoLow().Minimum.KeyNode, context) - results = append(results, result) - } - } - if schema.Value.Maximum != nil { - if *schema.Value.Maximum < 0 { - result := st.buildResult("`maximum` should be a number greater than or equal to `0`", - fmt.Sprintf("%s.%s", schema.GenerateJSONPath(), "maximum"), - schema, schema.Value.GoLow().Maximum.KeyNode, context) - results = append(results, result) - } if schema.Value.Minimum != nil { if *schema.Value.Maximum < *schema.Value.Minimum { result := st.buildResult("`maximum` should be a number greater than or equal to `minimum`", @@ -109,22 +94,7 @@ func (st SchemaTypeCheck) validateNumber(schema *base.Schema, context *model.Rul } } - if schema.Value.ExclusiveMinimum != nil { - if schema.Value.ExclusiveMinimum.IsB() && schema.Value.ExclusiveMinimum.B < 0 { - result := st.buildResult("`exclusiveMinimum` should be a number greater than or equal to `0`", - fmt.Sprintf("%s.%s", schema.GenerateJSONPath(), "exclusiveMinimum"), - schema, schema.Value.GoLow().ExclusiveMinimum.KeyNode, context) - results = append(results, result) - } - } - if schema.Value.ExclusiveMaximum != nil { - if schema.Value.ExclusiveMaximum.IsB() && schema.Value.ExclusiveMaximum.B < 0 { - result := st.buildResult("`exclusiveMaximum` should be a number greater than or equal to `0`", - fmt.Sprintf("%s.%s", schema.GenerateJSONPath(), "exclusiveMaximum"), - schema, schema.Value.GoLow().ExclusiveMaximum.KeyNode, context) - results = append(results, result) - } if schema.Value.ExclusiveMinimum != nil { if schema.Value.ExclusiveMinimum.IsB() && schema.Value.ExclusiveMinimum.B > schema.Value.ExclusiveMaximum.B { result := st.buildResult("`exclusiveMaximum` should be greater than or equal to `exclusiveMinimum`", diff --git a/functions/openapi/schema_type_test.go b/functions/openapi/schema_type_test.go index 3ba4fdcd..a9fcccd7 100644 --- a/functions/openapi/schema_type_test.go +++ b/functions/openapi/schema_type_test.go @@ -277,9 +277,7 @@ components: def := SchemaTypeCheck{} res := def.RunRule(nil, ctx) - assert.Len(t, res, 1) - assert.Equal(t, "`minimum` should be a number greater than or equal to `0`", res[0].Message) - assert.Equal(t, "$.components.schemas['Gum'].minimum", res[0].Path) + assert.Len(t, res, 0) } func TestSchemaType_Minimum_Zero(t *testing.T) { @@ -407,9 +405,7 @@ components: def := SchemaTypeCheck{} res := def.RunRule(nil, ctx) - assert.Len(t, res, 1) - assert.Equal(t, "`maximum` should be a number greater than or equal to `0`", res[0].Message) - assert.Equal(t, "$.components.schemas['Gum'].maximum", res[0].Path) + assert.Len(t, res, 0) } func TestSchemaType_MinMaximum(t *testing.T) { @@ -476,9 +472,8 @@ components: def := SchemaTypeCheck{} res := def.RunRule(nil, ctx) - assert.Len(t, res, 1) - assert.Equal(t, "`exclusiveMinimum` should be a number greater than or equal to `0`", res[0].Message) - assert.Equal(t, "$.components.schemas['Gum'].exclusiveMinimum", res[0].Path) + assert.Len(t, res, 0) + } func TestSchemaType_ExclusiveMinimum_Zero(t *testing.T) { @@ -542,9 +537,7 @@ components: def := SchemaTypeCheck{} res := def.RunRule(nil, ctx) - assert.Len(t, res, 1) - assert.Equal(t, "`exclusiveMaximum` should be a number greater than or equal to `0`", res[0].Message) - assert.Equal(t, "$.components.schemas['Gum'].exclusiveMaximum", res[0].Path) + assert.Len(t, res, 0) } func TestSchemaType_ExclusiveMaximum_Zero(t *testing.T) {