Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 33 additions & 12 deletions examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,32 @@ func ExampleReflect() {
// ]
// },
// "friends": {
// "items": {
// "type": "integer"
// },
// "type": "array",
// "description": "The list of IDs, omitted when empty"
// "oneOf": [
// {
// "items": {
// "type": "integer"
// },
// "type": "array",
// "description": "The list of IDs, omitted when empty"
// },
// {
// "type": "null"
// }
// ]
// },
// "tags": {
// "type": "object",
// "a": "b",
// "foo": [
// "bar",
// "bar1"
// "oneOf": [
// {
// "type": "object",
// "a": "b",
// "foo": [
// "bar",
// "bar1"
// ]
// },
// {
// "type": "null"
// }
// ]
// },
// "birth_date": {
Expand All @@ -86,10 +100,17 @@ func ExampleReflect() {
// "metadata": {
// "oneOf": [
// {
// "type": "string"
// "oneOf": [
// {
// "type": "string"
// },
// {
// "type": "array"
// }
// ]
// },
// {
// "type": "array"
// "type": "null"
// }
// ]
// },
Expand Down
4 changes: 2 additions & 2 deletions fixtures/allow_additional_props.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@
"mult": {
"type": "number",
"enum": [
1,
1.0,
1.5,
2
2.0
]
},
"roles": {
Expand Down
8 changes: 4 additions & 4 deletions fixtures/array_handling.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
"ArrayHandler": {
"properties": {
"min_len": {
"default": [
"qwerty"
],
"items": {
"type": "string",
"minLength": 2
},
"type": "array"
"type": "array",
"default": [
"qwerty"
]
},
"min_val": {
"items": {
Expand Down
47 changes: 47 additions & 0 deletions fixtures/clashing_types.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/invopop/jsonschema/testdata/odd",
"$ref": "#/$defs/github.com~1invopop~1jsonschema~1testdata~1Odd",
"$defs": {
"github.com/invopop/jsonschema/testdata/Odd": {
"properties": {
"dummy1": {
"$ref": "#/$defs/github.com~1invopop~1jsonschema~1testdata~1pkg~1types~1Dummy"
},
"dummy2": {
"$ref": "#/$defs/github.com~1invopop~1jsonschema~1testdata~1pkg2~1types~1Dummy"
}
},
"additionalProperties": false,
"type": "object",
"required": [
"dummy1",
"dummy2"
]
},
"github.com/invopop/jsonschema/testdata/pkg/types/Dummy": {
"properties": {
"A": {
"type": "string"
}
},
"additionalProperties": false,
"type": "object",
"required": [
"A"
]
},
"github.com/invopop/jsonschema/testdata/pkg2/types/Dummy": {
"properties": {
"B": {
"type": "integer"
}
},
"additionalProperties": false,
"type": "object",
"required": [
"B"
]
}
}
}
4 changes: 2 additions & 2 deletions fixtures/defaults_expanded_toplevel.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@
"mult": {
"type": "number",
"enum": [
1,
1.0,
1.5,
2
2.0
]
},
"roles": {
Expand Down
4 changes: 2 additions & 2 deletions fixtures/ignore_type.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@
"mult": {
"type": "number",
"enum": [
1,
1.0,
1.5,
2
2.0
]
},
"roles": {
Expand Down
4 changes: 2 additions & 2 deletions fixtures/no_reference.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@
"mult": {
"type": "number",
"enum": [
1,
1.0,
1.5,
2
2.0
]
},
"roles": {
Expand Down
4 changes: 2 additions & 2 deletions fixtures/no_reference_anchor.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@
"mult": {
"type": "number",
"enum": [
1,
1.0,
1.5,
2
2.0
]
},
"roles": {
Expand Down
26 changes: 26 additions & 0 deletions fixtures/nullable_field.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/invopop/jsonschema/test-nullable-field",
"$ref": "#/$defs/TestNullableField",
"$defs": {
"TestNullableField": {
"properties": {
"a": {
"oneOf": [
{
"type": "string"
},
{
"type": "null"
}
]
}
},
"additionalProperties": false,
"type": "object",
"required": [
"a"
]
}
}
}
19 changes: 19 additions & 0 deletions fixtures/nullable_from_tags_field.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/invopop/jsonschema/test-nullable-field",
"$ref": "#/$defs/TestNullableField",
"$defs": {
"TestNullableField": {
"properties": {
"a": {
"type": "string"
}
},
"additionalProperties": false,
"type": "object",
"required": [
"a"
]
}
}
}
28 changes: 23 additions & 5 deletions fixtures/recursive.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,34 @@
"type": "string"
},
"children": {
"items": {
"$ref": "#/$defs/RecursiveExample"
},
"type": "array"
"oneOf": [
{
"items": {
"$ref": "#/$defs/RecursiveExample"
},
"type": "array"
},
{
"type": "null"
}
]
},
"pointer_child": {
"oneOf": [
{
"$ref": "#/$defs/RecursiveExample"
},
{
"type": "null"
}
]
}
},
"additionalProperties": false,
"type": "object",
"required": [
"text"
"text",
"pointer_child"
]
}
}
Expand Down
29 changes: 29 additions & 0 deletions fixtures/recursive_nullable_from_tags.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/invopop/jsonschema/recursive-example",
"$ref": "#/$defs/RecursiveExample",
"$defs": {
"RecursiveExample": {
"properties": {
"text": {
"type": "string"
},
"children": {
"items": {
"$ref": "#/$defs/RecursiveExample"
},
"type": "array"
},
"pointer_child": {
"$ref": "#/$defs/RecursiveExample"
}
},
"additionalProperties": false,
"type": "object",
"required": [
"text",
"pointer_child"
]
}
}
}
4 changes: 2 additions & 2 deletions fixtures/required_from_jsontags.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@
"mult": {
"type": "number",
"enum": [
1,
1.0,
1.5,
2
2.0
]
},
"roles": {
Expand Down
Loading