added test for map of primitives

This commit is contained in:
Shreyas Goenka 2023-01-17 15:47:31 +01:00
parent f556e62c3b
commit 91617e50c1
No known key found for this signature in database
GPG Key ID: 92A07DF49CCB0622
1 changed files with 22 additions and 0 deletions

View File

@ -292,6 +292,28 @@ func TestStructOfSliceSchema(t *testing.T) {
assert.Equal(t, expected, string(jsonSchema))
}
func TestMapOfPrimitivesSchema(t *testing.T) {
var elem map[string]int
schema, err := NewSchema(reflect.TypeOf(elem))
assert.NoError(t, err)
jsonSchema, err := json.MarshalIndent(schema, " ", " ")
assert.NoError(t, err)
expected :=
`{
"type": "object",
"additionalProperties": {
"type": "number"
}
}`
t.Log("[DEBUG] actual: ", string(jsonSchema))
t.Log("[DEBUG] expected: ", expected)
assert.Equal(t, expected, string(jsonSchema))
}
func TestObjectSchema(t *testing.T) {
type Person struct {
Name string `json:"name"`