Skip to content

Commit

Permalink
Merge pull request #91 from invopop/items-pattern
Browse files Browse the repository at this point in the history
Copy pattern property to items
  • Loading branch information
samlown committed Sep 6, 2023
2 parents e63dc34 + 1e3a9df commit 5ac1546
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions reflect.go
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,8 @@ func (t *Schema) arrayKeywords(tags []string) {
}
case "format":
t.Items.Format = val
case "pattern":
t.Items.Pattern = val
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions reflect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -527,9 +527,9 @@ func TestSplitOnUnescapedCommas(t *testing.T) {
}
}

func TestArrayFormat(t *testing.T) {
func TestArrayExtraTags(t *testing.T) {
type URIArray struct {
TestURIs []string `jsonschema:"type=array,format=uri"`
TestURIs []string `jsonschema:"type=array,format=uri,pattern=^https://.*"`
}

r := new(Reflector)
Expand All @@ -544,4 +544,6 @@ func TestArrayFormat(t *testing.T) {
p := i.(*Schema)
pt := p.Items.Format
require.Equal(t, pt, "uri")
pt = p.Items.Pattern
require.Equal(t, pt, "^https://.*")
}

0 comments on commit 5ac1546

Please sign in to comment.