joelittlejohn / jsonschema2pojo

Generate Java types from JSON or JSON Schema and annotate those types for data-binding with Jackson, Gson, etc

Home Page:http://www.jsonschema2pojo.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Generating same class that appears few times in the JSON file

rushabh0701 opened this issue · comments

Hello all,

I have a JSON file that has a class called Invoice that appears multiple times and each time the library is generating the class for it. I now have class called Invoice, Invoice__1, Invoice__2, and Invoice__3. Is there a way to avoid generating the same class multiple times?

Thanks for the help!

Hi

Could it be that given issue is duplicate of #1559 ?

I am having a similar (same?) issue when parsing/generating from JSONSchema. I have a reproducer here: https://github.com/InfoSec812/asyncapi-java-parser

The Maven build downloads the files for the AsyncAPI Specification, rewrites the $ref links to be local file references, then generates the code in src/gen/java. I see that a few of the types are generating duplicates.

I'm going to see if I can add a new option to merge duplicate POJOs without impacting the existing behavior. Probably and option like mergeDuplicates or something. Any hints on where to look would be appreciated!