jsonschema-gentypes
jsonschema-gentypes copied to clipboard
Ignoring / not generating code for required fields when oneOf
I am using jsconschema-gentypes for synchronizing types between a rust codebase and python ( very usefull!)
However, currenctly struggling since jsonschema-gentypes seems to ignored required shared fields on objects that are also "onOf" (enums).
For example, the following schema should generate a "Deal" type that also has a "agio" (required) field - but it's completely missing in the generated python code:
{ "$schema": "http://json-schema.org/draft-07/schema#", "title": "Both", "type": "object", "required": [ "input", "output" ], "properties": { "input": { "$ref": "#/definitions/Deal" }, "output": { "$ref": "#/definitions/Deal" } }, "definitions": { "Deal": { "type": "object", "oneOf": [ { "type": "object", "required": [ "maturity" ], "properties": { "maturity": { "type": "string", "format": "date" } } } ], "required": [ "agio" ], "properties": { "agio": { "type": "number", "format": "double" } } } } }
I. the floowing is a valid object:
{ "input": { "maturity": "2022-12-02", "agio": 1 }, "output": { "maturity": "2022-12-02", "agio": 1 }, }
Effectively, I miss this case...