New Upstream Release - golang-github-go-openapi-validate

Ready changes

Summary

Merged new upstream version: 0.22.1 (was: 0.21.0).

Resulting package

Built on 2023-06-05T16:04 (took 5m25s)

The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:

apt install -t fresh-releases golang-github-go-openapi-validate-dev

Lintian Result

Diff

diff --git a/debian/changelog b/debian/changelog
index 272b4c4..e721253 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+golang-github-go-openapi-validate (0.22.1-1) UNRELEASED; urgency=low
+
+  * New upstream release.
+
+ -- Debian Janitor <janitor@jelmer.uk>  Mon, 05 Jun 2023 15:59:43 -0000
+
 golang-github-go-openapi-validate (0.21.0-1) unstable; urgency=medium
 
   * Team upload.
diff --git a/default_validator.go b/default_validator.go
index 3e0d8c7..bd14c2a 100644
--- a/default_validator.go
+++ b/default_validator.go
@@ -92,7 +92,7 @@ func (d *defaultValidator) validateDefaultValueValidAgainstSchema() *Result {
 	res := new(Result)
 	s := d.SpecValidator
 
-	for method, pathItem := range s.analyzer.Operations() {
+	for method, pathItem := range s.expandedAnalyzer().Operations() {
 		for path, op := range pathItem {
 			// parameters
 			for _, param := range paramHelp.safeExpandedParamsFor(path, method, op.ID, res, s) {
diff --git a/example_validator.go b/example_validator.go
index f4b7a2d..c8bffd7 100644
--- a/example_validator.go
+++ b/example_validator.go
@@ -68,7 +68,7 @@ func (ex *exampleValidator) validateExampleValueValidAgainstSchema() *Result {
 	res := new(Result)
 	s := ex.SpecValidator
 
-	for method, pathItem := range s.analyzer.Operations() {
+	for method, pathItem := range s.expandedAnalyzer().Operations() {
 		for path, op := range pathItem {
 			// parameters
 			for _, param := range paramHelp.safeExpandedParamsFor(path, method, op.ID, res, s) {
diff --git a/helpers.go b/helpers.go
index 5d901dd..48ebfab 100644
--- a/helpers.go
+++ b/helpers.go
@@ -210,7 +210,7 @@ type paramHelper struct {
 }
 
 func (h *paramHelper) safeExpandedParamsFor(path, method, operationID string, res *Result, s *SpecValidator) (params []spec.Parameter) {
-	operation, ok := s.analyzer.OperationFor(method, path)
+	operation, ok := s.expandedAnalyzer().OperationFor(method, path)
 	if ok {
 		// expand parameters first if necessary
 		resolvedParams := []spec.Parameter{}
@@ -224,7 +224,7 @@ func (h *paramHelper) safeExpandedParamsFor(path, method, operationID string, re
 		// remove params with invalid expansion from Slice
 		operation.Parameters = resolvedParams
 
-		for _, ppr := range s.analyzer.SafeParamsFor(method, path,
+		for _, ppr := range s.expandedAnalyzer().SafeParamsFor(method, path,
 			func(p spec.Parameter, err error) bool {
 				// since params have already been expanded, there are few causes for error
 				res.AddErrors(someParametersBrokenMsg(path, method, operationID))
diff --git a/spec.go b/spec.go
index cdf5627..dff01f0 100644
--- a/spec.go
+++ b/spec.go
@@ -624,7 +624,7 @@ func (s *SpecValidator) validateParameters() *Result {
 	// - path param must be required
 	res := new(Result)
 	rexGarbledPathSegment := mustCompileRegexp(`.*[{}\s]+.*`)
-	for method, pi := range s.analyzer.Operations() {
+	for method, pi := range s.expandedAnalyzer().Operations() {
 		methodPaths := make(map[string]map[string]string)
 		for path, op := range pi {
 			pathToAdd := pathHelp.stripParametersInPath(path)
@@ -793,3 +793,12 @@ func (s *SpecValidator) checkUniqueParams(path, method string, op *spec.Operatio
 func (s *SpecValidator) SetContinueOnErrors(c bool) {
 	s.Options.ContinueOnErrors = c
 }
+
+// expandedAnalyzer returns expanded.Analyzer when it is available.
+// otherwise just analyzer.
+func (s *SpecValidator) expandedAnalyzer() *analysis.Spec {
+	if s.expanded != nil && s.expanded.Analyzer != nil {
+		return s.expanded.Analyzer
+	}
+	return s.analyzer
+}
diff --git a/values.go b/values.go
index c88d35d..e7ad8c1 100644
--- a/values.go
+++ b/values.go
@@ -248,7 +248,7 @@ func MinimumUint(path, in string, data, min uint64, exclusive bool) *errors.Vali
 // MultipleOf validates if the provided number is a multiple of the factor
 func MultipleOf(path, in string, data, factor float64) *errors.Validation {
 	// multipleOf factor must be positive
-	if factor < 0 {
+	if factor <= 0 {
 		return errors.MultipleOfMustBePositive(path, in, factor)
 	}
 	var mult float64
@@ -266,7 +266,7 @@ func MultipleOf(path, in string, data, factor float64) *errors.Validation {
 // MultipleOfInt validates if the provided integer is a multiple of the factor
 func MultipleOfInt(path, in string, data int64, factor int64) *errors.Validation {
 	// multipleOf factor must be positive
-	if factor < 0 {
+	if factor <= 0 {
 		return errors.MultipleOfMustBePositive(path, in, factor)
 	}
 	mult := data / factor
@@ -278,6 +278,10 @@ func MultipleOfInt(path, in string, data int64, factor int64) *errors.Validation
 
 // MultipleOfUint validates if the provided unsigned integer is a multiple of the factor
 func MultipleOfUint(path, in string, data, factor uint64) *errors.Validation {
+	// multipleOf factor must be positive
+	if factor == 0 {
+		return errors.MultipleOfMustBePositive(path, in, factor)
+	}
 	mult := data / factor
 	if mult*factor != data {
 		return errors.NotMultipleOf(path, in, factor, data)
diff --git a/values_test.go b/values_test.go
index 042eac9..cb25465 100644
--- a/values_test.go
+++ b/values_test.go
@@ -252,6 +252,13 @@ func TestValuMultipleOf(t *testing.T) {
 	err = MultipleOf("test", "body", 8, 0.2)
 	assert.Nil(t, err)
 
+	// zero
+	err = MultipleOf("test", "body", 9, 0)
+	assert.Error(t, err)
+
+	err = MultipleOf("test", "body", 9.1, 0)
+	assert.Error(t, err)
+
 	// negative
 
 	err = MultipleOf("test", "body", 3, 0.4)
@@ -431,6 +438,18 @@ func TestValues_MultipleOfNative(t *testing.T) {
 
 	var err *errors.Validation
 
+	err = MultipleOfNativeType("path", "in", int64(5), 0)
+	if assert.NotNil(t, err) {
+		code := int(err.Code())
+		assert.Equal(t, code, int(errors.MultipleOfMustBePositiveCode))
+	}
+
+	err = MultipleOfNativeType("path", "in", uint64(5), 0)
+	if assert.NotNil(t, err) {
+		code := int(err.Code())
+		assert.Equal(t, code, int(errors.MultipleOfMustBePositiveCode))
+	}
+
 	err = MultipleOfNativeType("path", "in", int64(5), -1)
 	if assert.NotNil(t, err) {
 		code := int(err.Code())

Debdiff

File lists identical (after any substitutions)

No differences were encountered in the control files

More details

Full run details