opened
Kink77
username_0
<!--
Please follow the issue template below for bug reports and feature requests.
Also please indicate in the issue title which language/library is concerned. Eg:  [JAVA] Bug generating foo with bar 
-->

##### Description

Getting a stackoverflow exception when trying to generate a client for csharp-netcore

##### openapi-generator version

version 5.1.0

##### OpenAPI declaration file content or url

https://gist.github.com/username_0/673cbfe68f6c94afdee6ff5c7f0fe9a8

##### Command line used for generation

java -jar openapi-generator-cli-5.1.0.jar generate -i ./openapi-spec.json -c ./config.json -g csharp-netcore

You can find openapi-spec.json here : 
https://gist.github.com/username_0/673cbfe68f6c94afdee6ff5c7f0fe9a8
You can find config.json here : 
https://gist.github.com/username_0/48efb0951e4d21f682948138bcd6eb52

##### Steps to reproduce

download both openapi-spec.json and config.json, put them in the same directory as the openapi-generator-cli-5.1.0.jar and run the command line java -jar openapi-generator-cli-5.1.0.jar generate -i ./openapi-spec.json -c ./config.json -g csharp-netcore

You will get the following error : 
Exception in thread "main" java.lang.StackOverflowError
	at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:740)

The culprit is the schema JToken referencing itself which creates a cyclic reference

##### Related issues/PRs

##### Suggest a fix/enhancement

WIth the swagger generator, I end up with a Dictionary<string, JToken> for that schema
Openapi Generator stackoverflow exception for csharp-netcore
issue
created
wing328
username_1
```
  "components": {
    "schemas": {
      "JToken": {
        "type": "array",
        "items": {
          "$ref": "#/components/schemas/JToken"
        }
      }
    }
  }
```
`JToken` is an array of itself, which is causing the issue.

What does the JSON payload look like?
comment
created
Kink77
username_0
It's basically a [JObject from Newtonsoft.JSON](https://www.newtonsoft.com/json/help/html/T_Newtonsoft_Json_Linq_JObject.htm)

When I try to generate a client with swagger codegen, it gives me a dictionary of <string, JToken>. Open Api Generator seems to do an endless loop and cause a stackoverflow.

I managed to generate a client by fiddling with the openapi spec. Here's the [fixed openapi-spec](https://gist.github.com/username_0/c4352f4b02102937f256fafe4eb552a0) I used to make it work. 

So I'm not too sure how to go about having a property that is a JObject translated to an openapi spec and back to a JObject in the client.
comment
created
JesperG
username_2
I also ran into this issue because we use JToken in an API. It reached the same endless loop until stack overflowed.
Thank you for your insight as it allowed me to manually modify the .json file (change the TJoken type to object instead of an array of itself) in order to make the generator not failing.
I did not need the endpoints which are using the JToken, so I did not look further into how to use this, sorry.
This is to confirm that there is an issue.
comment