From 2d9e25269795297a2ed2712700fc03398a7aac12 Mon Sep 17 00:00:00 2001 From: chenqi99 Date: Sun, 26 May 2024 08:25:46 +0800 Subject: [PATCH] execution --- .../openapi-mock/openapi/generator/data/numberGenerator.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/internal/pkg/helper/openapi-mock/openapi/generator/data/numberGenerator.go b/internal/pkg/helper/openapi-mock/openapi/generator/data/numberGenerator.go index b153011cf..366a1fa77 100644 --- a/internal/pkg/helper/openapi-mock/openapi/generator/data/numberGenerator.go +++ b/internal/pkg/helper/openapi-mock/openapi/generator/data/numberGenerator.go @@ -53,7 +53,8 @@ func (generator *numberGenerator) getMinMax(schema *openapi3.Schema) (float64, f func (generator *numberGenerator) generateUniformRandomValue(schema *openapi3.Schema) float64 { minimum := 0 - maximum := math.MaxInt64 + maximum := math.MaxInt32 + if schema.ExclusiveMin { minimum++ } @@ -62,8 +63,8 @@ func (generator *numberGenerator) generateUniformRandomValue(schema *openapi3.Sc } delta := maximum - minimum - value1 := float64(generator.random.Intn(delta)+minimum) / float64(math.MaxInt64) - value2 := float64(generator.random.Intn(delta)+minimum) / float64(math.MaxInt64) + value1 := float64(generator.random.Intn(delta)+minimum) / float64(maximum) + value2 := float64(generator.random.Intn(delta)+minimum) / float64(maximum) return value1 * value2 }