Skip to content

Commit

Permalink
add Reflector.NullableFromType option
Browse files Browse the repository at this point in the history
  • Loading branch information
candiduslynx committed Oct 6, 2023
1 parent 9b6bb6e commit 3689abc
Show file tree
Hide file tree
Showing 3 changed files with 352 additions and 7 deletions.
315 changes: 315 additions & 0 deletions fixtures/test_user_nullable_from_type.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,315 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/invopop/jsonschema/test-user",
"$ref": "#/$defs/TestUser",
"$defs": {
"Bytes": {
"type": "string",
"contentEncoding": "base64"
},
"GrandfatherType": {
"properties": {
"family_name": {
"type": "string"
}
},
"additionalProperties": false,
"type": "object",
"required": [
"family_name"
]
},
"MapType": {
"type": "object"
},
"TestUser": {
"properties": {
"id": {
"type": "integer"
},
"some_base_property": {
"type": "integer"
},
"grand": {
"$ref": "#/$defs/GrandfatherType"
},
"SomeUntaggedBaseProperty": {
"type": "boolean"
},
"PublicNonExported": {
"type": "integer"
},
"MapType": {
"oneOf": [
{
"$ref": "#/$defs/MapType"
},
{
"type": "null"
}
]
},
"name": {
"type": "string",
"maxLength": 20,
"minLength": 1,
"pattern": ".*",
"title": "the name",
"description": "this is a property",
"default": "alex",
"readOnly": true,
"examples": [
"joe",
"lucy"
]
},
"password": {
"type": "string",
"writeOnly": true
},
"friends": {
"oneOf": [
{
"items": {
"type": "integer"
},
"type": "array",
"description": "list of IDs, omitted when empty"
},
{
"type": "null"
}
]
},
"tags": {
"oneOf": [
{
"additionalProperties": {
"type": "string"
},
"type": "object"
},
{
"type": "null"
}
]
},
"options": {
"oneOf": [
{
"type": "object"
},
{
"type": "null"
}
]
},
"TestFlag": {
"type": "boolean"
},
"TestFlagFalse": {
"type": "boolean",
"default": false
},
"TestFlagTrue": {
"type": "boolean",
"default": true
},
"birth_date": {
"type": "string",
"format": "date-time"
},
"website": {
"type": "string",
"format": "uri"
},
"network_address": {
"oneOf": [
{
"type": "string",
"format": "ipv4"
},
{
"type": "null"
}
]
},
"photo": {
"oneOf": [
{
"type": "string",
"contentEncoding": "base64"
},
{
"type": "null"
}
]
},
"photo2": {
"oneOf": [
{
"$ref": "#/$defs/Bytes"
},
{
"type": "null"
}
]
},
"feeling": {
"oneOf": [
{
"type": "string"
},
{
"type": "integer"
}
]
},
"age": {
"type": "integer",
"maximum": 120,
"exclusiveMaximum": 121,
"minimum": 18,
"exclusiveMinimum": 17
},
"email": {
"type": "string",
"format": "email"
},
"uuid": {
"type": "string",
"format": "uuid"
},
"Baz": {
"type": "string",
"foo": [
"bar",
"bar1"
],
"hello": "world"
},
"bool_extra": {
"type": "string",
"isFalse": false,
"isTrue": true
},
"color": {
"type": "string",
"enum": [
"red",
"green",
"blue"
]
},
"rank": {
"type": "integer",
"enum": [
1,
2,
3
]
},
"mult": {
"type": "number",
"enum": [
1.0,
1.5,
2.0
]
},
"roles": {
"oneOf": [
{
"items": {
"type": "string",
"enum": [
"admin",
"moderator",
"user"
]
},
"type": "array"
},
{
"type": "null"
}
]
},
"priorities": {
"oneOf": [
{
"items": {
"type": "integer",
"enum": [
-1,
0,
1
]
},
"type": "array"
},
{
"type": "null"
}
]
},
"offsets": {
"oneOf": [
{
"items": {
"type": "number",
"enum": [
1.570796,
3.141592,
6.283185
]
},
"type": "array"
},
{
"type": "null"
}
]
},
"anything": {
"oneOf": [
true,
{
"type": "null"
}
]
},
"raw": {
"oneOf": [
true,
{
"type": "null"
}
]
}
},
"additionalProperties": false,
"type": "object",
"required": [
"id",
"some_base_property",
"grand",
"SomeUntaggedBaseProperty",
"PublicNonExported",
"MapType",
"name",
"password",
"TestFlag",
"photo",
"photo2",
"age",
"email",
"uuid",
"Baz",
"color",
"roles",
"raw"
]
}
}
}
Loading

0 comments on commit 3689abc

Please sign in to comment.