From 92d47ad2141d9618ac66847c0618b03a3e44763a Mon Sep 17 00:00:00 2001 From: Vincent Le Goff <vince.legoff@gmail.com> Date: Fri, 30 Dec 2022 14:33:23 +0100 Subject: [PATCH] openapi3: remove email string format (#727) --- README.md | 3 +++ openapi3/schema_formats.go | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3596289db..850b11b8a 100644 --- a/README.md +++ b/README.md @@ -201,6 +201,9 @@ func arrayUniqueItemsChecker(items []interface{}) bool { ## Sub-v0 breaking API changes +### v0.113.0 +* The string format `email` has been removed by default. To use it please call `openapi3.DefineStringFormat("email", openapi3.FormatOfStringForEmail)`. + ### v0.112.0 * `(openapi3.ValidationOptions).ExamplesValidationDisabled` has been unexported. * `(openapi3.ValidationOptions).SchemaFormatValidationEnabled` has been unexported. diff --git a/openapi3/schema_formats.go b/openapi3/schema_formats.go index 51e245411..ecbc0ebfa 100644 --- a/openapi3/schema_formats.go +++ b/openapi3/schema_formats.go @@ -10,6 +10,10 @@ import ( const ( // FormatOfStringForUUIDOfRFC4122 is an optional predefined format for UUID v1-v5 as specified by RFC4122 FormatOfStringForUUIDOfRFC4122 = `^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$` + + // FormatOfStringForEmail pattern catches only some suspiciously wrong-looking email addresses. + // Use DefineStringFormat(...) if you need something stricter. + FormatOfStringForEmail = `^[^@]+@[^@<>",\s]+$` ) // FormatCallback performs custom checks on exotic formats @@ -79,10 +83,6 @@ func validateIPv6(ip string) error { } func init() { - // This pattern catches only some suspiciously wrong-looking email addresses. - // Use DefineStringFormat(...) if you need something stricter. - DefineStringFormat("email", `^[^@]+@[^@<>",\s]+$`) - // Base64 // The pattern supports base64 and b./ase64url. Padding ('=') is supported. DefineStringFormat("byte", `(^$|^[a-zA-Z0-9+/\-_]*=*$)`)