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

noExtraProps flag not working with recursive type #562

Open
netanel-mce opened this issue Aug 3, 2023 · 5 comments
Open

noExtraProps flag not working with recursive type #562

netanel-mce opened this issue Aug 3, 2023 · 5 comments

Comments

@netanel-mce
Copy link
Contributor

netanel-mce commented Aug 3, 2023

Steps to Reproduce:
version: 0.59.0
create schema for Foo type, and turn on the flag noExtraProps.

interface ChildFoo {}

interface Foo {
    childFoo: Foo & ChildFoo;
}

The error:
Maximum call stack size exceeded.

Because we merging the object, instead of use in allOf (see #107), in recursive type we trying to build schema for parent and child again and again.

@netanel-mce
Copy link
Contributor Author

netanel-mce commented Aug 10, 2023

@domoritz what you want to got for following type, when flag noExtraProps turn on?

Type:

type Sub = {
   subChild: string;
};

type Main = {
   mainChild: Main & Sub;
}

if we generating a schema like this:

{
  "$ref": "#/definitions/Main",
  "$schema": "http://json-schema.org/draft-07/schema#",
  "definitions": {
    "Sub": {
      "additionalProperties": false,
      "type": "object",
      "properties": {
        "childSub": {
          "type": "number"
        }
      }
    },
    "Main": {
      "additionalProperties": false,
      "properties": {
        "childMain": {
          "allOf": [
            {
              "$ref": "#/definitions/Main"
            },
            {
              "$ref": "#/definitions/Sub"
            }
          ]
        }
      },
      "required": [
        "childMain"
      ],
      "type": "object"
    }
  }
}

so we will got the issue like #107
but we cannot merge the schemas, because it recursive type, so we must to use in $ref

I middle in write a PR for resolve this issue, but your should to answer of this product question

@netanel-mce
Copy link
Contributor Author

@domoritz I tried this case also on vega
but I got this schema

{
    "$ref": "#/definitions/Foo",
    "$schema": "http://json-schema.org/draft-04/schema#",
    "definitions": {
        "Foo": {
            "additionalProperties": false,
            "properties": {
                "childFoo": {
                    "additionalProperties": false,
                    "properties": {},
                    "type": "object"
                }
            },
            "required": [
                "childFoo"
            ],
            "type": "object"
        }
    }
}

without recursive.

So please help me to decide what we want to be the output for this case.

@netanel-mce
Copy link
Contributor Author

@erezmce what you think?

@netanel-mce
Copy link
Contributor Author

this type is endless, and no data to be valid for this type. so we not support it.
image

thanks @erezmce

@netanel-mce netanel-mce closed this as not planned Won't fix, can't repro, duplicate, stale Aug 20, 2023
@netanel-mce netanel-mce reopened this Dec 28, 2023
@Bewinxed
Copy link

Facing this as well, any workarounds? I'm ok with having a max-depth option if all else fails? (Mainly prisma types are problematic)

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