joelittlejohn / jsonschema2pojo

Generate Java types from JSON or JSON Schema and annotate those types for data-binding with Jackson, Gson, etc
http://www.jsonschema2pojo.org
Apache License 2.0
6.24k stars 1.66k forks source link

Generating same class that appears few times in the JSON file #1562

Open rushabh0701 opened 1 year ago

rushabh0701 commented 1 year ago

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, Invoice1, Invoice2, and Invoice__3. Is there a way to avoid generating the same class multiple times?

Thanks for the help!

unkish commented 1 year ago

Hi

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

InfoSec812 commented 9 months ago

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.

InfoSec812 commented 8 months ago

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!