How to avoid generate the same java file with swagger gen

Viewed 49

Let us suppose we have some yaml files like following:

Article.yml

GenericArticleDto:
  type: object
  properties:
    description: 
      type: string
[...]

Order.yml

EnglishArticleDto:
  type: object
  allOf:
    - $ref: '../Article.yml/components/schemas/GenericArticleDto'
[...]

I generate the Java classes from the Order.yml with swagger gen and specify the destination package, let's say 'com.test.order' After this operation I have two classes in com.test.order, EnglishArticleDto.java and GenericArticleDto.java

If I have another yml file with a dto that point to the same object GenericArticleDto

Proposal.yml

CustomerArticleDto:
  type: object
  allOf:
    - $ref: '../Article.yml/components/schemas/GenericArticleDto'

I generate the Java classes from the Proposal.yml and specify the destination package, let's say 'com.test.proposal'. If I run the swagger script I have two classes in com.test.proposal, CustomerArticleDto.java and GenericArticleDto.java

My doubt is: Is there a way with swagger gen to specify to avoid the creation of another Java class for GenericArticleDto and to REUSE the same present under the package com.test.order?

Swagger gen version: 2.2

Thanks a lot!

0 Answers
Related