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

Types inside of definitions not generated for nbformat jsonschema #1

Open
erem-stripe opened this issue May 6, 2021 · 2 comments
Open

Comments

@erem-stripe
Copy link

erem-stripe commented May 6, 2021

Hi there @jimblackler ! This is a really cool project. I was trying to generate java types around Jupyter's nbformat.v4.schema.json. While generation succeeded, it seems that none of the types inside of definitions were generated, and the cell type which contains any of raw_cell, markdown_cell, or code_cell instead generated as generic JSONObjects.

Any idea why this might be? I've attached the generated java from your online sample

@jimblackler
Copy link
Owner

Hi, thanks a lot for the report. It seems at least that it gives up at 'cell', caused by oneOf that it doesn't attempt to handle.

    "cell": {
      "type": "object",
      "oneOf": [
        {"$ref": "#/definitions/raw_cell"},
        {"$ref": "#/definitions/markdown_cell"},
        {"$ref": "#/definitions/code_cell"}
      ]
    },

The reason I don't handle oneOf, anyOf and allOf is that these keywords cause a sudden huge leap in the complexity of translating from the validation spec to a formal language structure. They can describe potential data forms that don't have an obvious counterpart in languages like Java.

It's possible that something could be designed for case of a schema consisting of only oneOf. The problem is that a client would have to actually validate the object to understand which of the (in this case three) schemas defined the object.

I'll have a think about it, but I can't think of anything practical at the moment.

@erem-stripe
Copy link
Author

Hi Jim! Thanks for getting back to me. Your explanation makes sense. One compromise that still might make sense would be to not expand the oneOf but to still generate all the types inside of definitions. Then at least we could manually do checks and instantiate the types when we encounter a oneOf. What do you think?

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