Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion fixtures/equals_in_pattern.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
}
Expand Down
2 changes: 1 addition & 1 deletion reflect.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 3 additions & 2 deletions reflect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down