Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignoring / not generating code for required fields when oneOf #639

Open
vron opened this issue Sep 5, 2023 · 1 comment
Open

Ignoring / not generating code for required fields when oneOf #639

vron opened this issue Sep 5, 2023 · 1 comment

Comments

@vron
Copy link

vron commented Sep 5, 2023

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 }, }

@sbrunner
Copy link
Owner

sbrunner commented Sep 6, 2023

Effectively, I miss this case...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants