Skip to content

CodeGen - Self referencing array in json schema results in stackoverflow #236

@windowslucker1121

Description

@windowslucker1121

Hey Folks,
can someone provide me a helping hand in this scenario:

I have a schema defined, which should have some data and can have multiple objects of itself in an array like defined below:

    "$schema": "http://json-schema.org/draft-04/schema",
    "title": "ProcessNode Schema",
    "type": "object",
    "description": "glTF extension for ProcessNode.",
    "properties": {
        "Process": {
            "type": "array",
            "items": {
                "$ref": "#"
            },
            "description": "A list of Process elements.",
            "minItems": 0
        },
        "EventHandler": {
            "description": "A list of EventHandler elements",
            "type":"array",
            "items":{
                "method": {
                    "type":"string"
                }
            },
            "minItems": 0
          },
        "Function": {
            "type": "string"
        },        
       "id": {
            "type": "string",
            "description": "Unique identifier for the ProcessNode."
        }
     },
    "required": [
        "id"
    ]
}

But when running the CodeGen Tool it is resulting in an stackoverflow:

Stack overflow.
   at System.Linq.Enumerable.Select[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.Collections.Generic.IEnumerable`1<System.__Canon>, System.Func`2<System.__Canon,System.__Canon>)

.
.
.
.
   at SharpGLTF.SchemaReflection.SchemaTypesReader._UseType(Context, NJsonSchema.JsonSchema, Boolean)
   at SharpGLTF.SchemaReflection.SchemaTypesReader._UseType(Context, NJsonSchema.JsonSchema, Boolean)
   at SharpGLTF.SchemaReflection.SchemaTypesReader._UseType(Context, NJsonSchema.JsonSchema, Boolean)
   at SharpGLTF.SchemaReflection.SchemaTypesReader._UseType(Context, NJsonSchema.JsonSchema, Boolean)
   at SharpGLTF.SchemaReflection.SchemaTypesReader._UseType(Context, NJsonSchema.JsonSchema, Boolean)
   at SharpGLTF.SchemaReflection.SchemaTypesReader.Generate(NJsonSchema.CodeGeneration.CSharp.CSharpTypeResolver)
   at SharpGLTF.SchemaProcessing.LoadSchemaContext(System.String)

how would i prevent that, or tell the codegen tool that it should only process this node on the top level once and reference it then?

I cant find anything like my schema in the already defined schemas and i cant seem to find a apropriate function in the codegen tool, thats why im out of expertise here.

Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions