Skip to content

Commit

Permalink
Add test case for format key in arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
jawn-smith committed Jul 5, 2022
1 parent 71da2e8 commit c594e8d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions reflect_test.go
Expand Up @@ -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")
}

0 comments on commit c594e8d

Please sign in to comment.