diff --git a/reflect.go b/reflect.go index e333e38..badc5df 100644 --- a/reflect.go +++ b/reflect.go @@ -834,6 +834,8 @@ func (t *Schema) arrayKeywords(tags []string) { f, _ := strconv.ParseFloat(val, 64) t.Items.Enum = append(t.Items.Enum, f) } + case "format": + t.Items.Format = val } } } diff --git a/reflect_test.go b/reflect_test.go index ab71dcb..4c06cb4 100644 --- a/reflect_test.go +++ b/reflect_test.go @@ -477,3 +477,20 @@ func TestSplitOnUnescapedCommas(t *testing.T) { require.Equal(t, test.expected, actual) } } + +func TestArrayFormat(t *testing.T) { + type URIArray struct { + TestURIs []string `jsonschema:"type=array,format=uri"` + } + + var jsonReflector Reflector + schema := jsonReflector.Reflect(&URIArray{}) + + URIInterface, found := schema.Definitions["URIArray"].Properties.Get("TestURIs") + require.Equal(t, found, true) + + var URIArrayProperties *Schema = URIInterface.(*Schema) + + URIArrayType := URIArrayProperties.Items.Format + require.Equal(t, URIArrayType, "uri") +}