diff --git a/fixtures/equals_in_pattern.json b/fixtures/equals_in_pattern.json index 8174c74..36da9a0 100644 --- a/fixtures/equals_in_pattern.json +++ b/fixtures/equals_in_pattern.json @@ -12,13 +12,21 @@ "WithEqualsAndCommas": { "type": "string", "pattern": "foo,=bar" + }, + "WithEqualsArray": { + "items": { + "type": "string", + "pattern": "foo=bar" + }, + "type": "array" } }, "additionalProperties": false, "type": "object", "required": [ "WithEquals", - "WithEqualsAndCommas" + "WithEqualsAndCommas", + "WithEqualsArray" ] } } diff --git a/reflect.go b/reflect.go index 3249c8c..5d66f3b 100644 --- a/reflect.go +++ b/reflect.go @@ -845,7 +845,7 @@ func (t *Schema) arrayKeywords(tags []string) { unprocessed := make([]string, 0, len(tags)) for _, tag := range tags { - nameValue := strings.Split(tag, "=") + nameValue := strings.SplitN(tag, "=", 2) if len(nameValue) == 2 { name, val := nameValue[0], nameValue[1] switch name { diff --git a/reflect_test.go b/reflect_test.go index 94b6018..955bc7e 100644 --- a/reflect_test.go +++ b/reflect_test.go @@ -333,8 +333,9 @@ type Expression struct { } type PatternEqualsTest struct { - WithEquals string `jsonschema:"pattern=foo=bar"` - WithEqualsAndCommas string `jsonschema:"pattern=foo\\,=bar"` + WithEquals string `jsonschema:"pattern=foo=bar"` + WithEqualsAndCommas string `jsonschema:"pattern=foo\\,=bar"` + WithEqualsArray []string `jsonschema:"pattern=foo=bar"` } func TestReflector(t *testing.T) {