From 148a9ac753144445f090668e8d362672b4debc61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Mouton?= Date: Wed, 3 Dec 2025 15:31:21 +0100 Subject: [PATCH] Fix whitespace handling in type mismatch error messages --- common.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/common.go b/common.go index 0cc4dc2..2852c72 100644 --- a/common.go +++ b/common.go @@ -67,11 +67,11 @@ func parseInput[TInput any](app *OApiApp, c *fiber.Ctx, path string, options *Op fieldNameParts := strings.Split(fullFieldName, ".") fieldName := fieldNameParts[len(fieldNameParts)-1] - // Extract expected type - expectedType := fieldParts[1] + // Extract expected type and trim whitespace + expectedType := strings.TrimSpace(fieldParts[1]) - // Extract actual type from the first part - typePart := strings.TrimPrefix(parts[0], "json: cannot unmarshal ") + // Extract actual type from the first part and trim whitespace + typePart := strings.TrimSpace(strings.TrimPrefix(parts[0], "json: cannot unmarshal ")) return input, fmt.Errorf("invalid type for field '%s': expected %s but got %s", fieldName, expectedType, typePart)