Skip to content

Commit

Permalink
Copy pattern property to items
Browse files Browse the repository at this point in the history
  • Loading branch information
samlown committed Sep 6, 2023
1 parent ed817e0 commit 1e3a9df
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 1e3a9df

Please sign in to comment.