From 8139731b51819290bbbfd846f8f59aad9c4b64fe Mon Sep 17 00:00:00 2001 From: Gus Antoniassi Date: Tue, 29 Nov 2022 12:21:00 -0300 Subject: [PATCH] chore: parse escaped double colon (\\:) example struct tag (#1402) * chore: parse escaped double colon (\\:) example struct tag Replaces the regular string splitting by a ":" made during the "example" tag parsing so that it will not split escaped double colons, allowing string examples containing a double colon to be escaped using double backlashes. * refactor: use strings.SplitN to split the string by the first double colon found Co-authored-by: Gustavo --- parser.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parser.go b/parser.go index 041e5c1ac..ea77311d5 100644 --- a/parser.go +++ b/parser.go @@ -1441,7 +1441,7 @@ func defineTypeOfExample(schemaType, arrayType, exampleValue string) (interface{ result := map[string]interface{}{} for _, value := range values { - mapData := strings.Split(value, ":") + mapData := strings.SplitN(value, ":", 2) if len(mapData) == 2 { v, err := defineTypeOfExample(arrayType, "", mapData[1])