From 1e3a9df031eb82f896b34e54abbb28851bffbef0 Mon Sep 17 00:00:00 2001 From: Sam Lown Date: Wed, 6 Sep 2023 15:39:58 +0000 Subject: [PATCH] Copy pattern property to items --- reflect.go | 2 ++ reflect_test.go | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/reflect.go b/reflect.go index 4ee0b33..fb5d12d 100644 --- a/reflect.go +++ b/reflect.go @@ -892,6 +892,8 @@ func (t *Schema) arrayKeywords(tags []string) { } case "format": t.Items.Format = val + case "pattern": + t.Items.Pattern = val } } } diff --git a/reflect_test.go b/reflect_test.go index 804e9fa..fe2a030 100644 --- a/reflect_test.go +++ b/reflect_test.go @@ -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) @@ -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://.*") }