Closed thanakijwanavit closed 2 years ago
the correct output would be
$schema: http://json-schema.org/draft-06/schema#
definitions:
TestSubData:
description: 'TestSubData(a: int = 0)'
properties:
a:
default: 0
type: integer
type:
- object
- "null"
description: 'TestData(subData: Union[__main__.TestSubData, NoneType] = None)'
properties:
subData:
$ref: '#/definitions/TestSubData'
type: object
thank you
You can use Nullable[TestSubData]
to allow nulls. It should give you something like:
$schema: http://json-schema.org/draft-06/schema#
definitions:
TestSubData:
description: 'TestSubData(a: int = 0)'
properties:
a:
default: 0
type: integer
type: object
description: 'TestData(subData: Union[__main__.TestSubData, dataclasses_jsonschema.type_defs._NULL_TYPE]
= None)'
properties:
subData:
oneOf:
- $ref: '#/definitions/TestSubData'
- type: 'null'
type: object
optional object is not working for example
the schema i got is
you can see that
{'subData':None}
will be rejected eventhough it is a valid data according to the dataclass