From 6445b878e3f67752ccd7b31fc38c0842998f9f8b Mon Sep 17 00:00:00 2001 From: Sam Lown Date: Mon, 9 May 2022 22:18:43 +0000 Subject: [PATCH] Testing array and map root types --- fixtures/array_type.json | 13 +++++++++++++ fixtures/map_type.json | 10 ++++++++++ reflect_test.go | 4 ++++ 3 files changed, 27 insertions(+) create mode 100644 fixtures/array_type.json create mode 100644 fixtures/map_type.json diff --git a/fixtures/array_type.json b/fixtures/array_type.json new file mode 100644 index 0000000..a354029 --- /dev/null +++ b/fixtures/array_type.json @@ -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" + } + } +} \ No newline at end of file diff --git a/fixtures/map_type.json b/fixtures/map_type.json new file mode 100644 index 0000000..dba13a2 --- /dev/null +++ b/fixtures/map_type.json @@ -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" + } + } +} \ No newline at end of file diff --git a/reflect_test.go b/reflect_test.go index f688bec..ab71dcb 100644 --- a/reflect_test.go +++ b/reflect_test.go @@ -44,6 +44,8 @@ type SomeBaseType struct { type MapType map[string]interface{} +type ArrayType []string + type nonExported struct { PublicNonExported int privateNonExported int @@ -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 {