Skip to content

Commit

Permalink
Testing array and map root types
Browse files Browse the repository at this point in the history
  • Loading branch information
samlown committed May 9, 2022
1 parent fa81924 commit 6445b87
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
13 changes: 13 additions & 0 deletions fixtures/array_type.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$schema": "http://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/invopop/jsonschema/array-type",
"$ref": "#/$defs/ArrayType",
"$defs": {
"ArrayType": {
"items": {
"type": "string"
},
"type": "array"
}
}
}
10 changes: 10 additions & 0 deletions fixtures/map_type.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "http://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/invopop/jsonschema/map-type",
"$ref": "#/$defs/MapType",
"$defs": {
"MapType": {
"type": "object"
}
}
}
4 changes: 4 additions & 0 deletions reflect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ type SomeBaseType struct {

type MapType map[string]interface{}

type ArrayType []string

type nonExported struct {
PublicNonExported int
privateNonExported int
Expand Down Expand Up @@ -412,6 +414,8 @@ func TestSchemaGeneration(t *testing.T) {
return "unknown case"
},
}, "fixtures/keynamed.json"},
{MapType{}, &Reflector{}, "fixtures/map_type.json"},
{ArrayType{}, &Reflector{}, "fixtures/array_type.json"},
}

for _, tt := range tests {
Expand Down

0 comments on commit 6445b87

Please sign in to comment.