Forum Discussion

shd's avatar
shd
Frequent Visitor
2 years ago

Retain original package structure in swagger document

Hi Team,

I am not sure if this has been discussed before as I was not able to find any similar question. 

I am trying to retain the original package structure of the import ed Java class in my dtos. 

 

A basic example to demonstrate what i am trying to achieve. 

 

1: DTO class

 

 

package com.company.abc.test;

import com.company.xyz.test.ClassB;
import com.company.xyz.test.ClassC;

public class ClassA {

ClassB b = new ClassB();
ClassC c = new ClassC();

// getter
// setter
}

 

 


2: Swagger json/yaml
The swagger doc file is created from above is test-swagger.json using swagger-maven-plugin (openapitools.swagger)


3. Generate DTO classes from test-swagger.json
The clients are now generating the classes from test-swagger.json. In this example we want the generated class ClassB and ClassC to retain their original package name ie com.company.xyz.test.ClassB and com.company.xyz.test.ClassC.
But unfortunately all the classes, generated in this step, are in the same base destination folder - ClassA, ClassB, ClassC.

 

What i understand is that we have to have the right package structure retained in the test-swagger.json itself. Is there a way to achieve this ? What is the parameter that retains the original package structure ?

 

 

 

No RepliesBe the first to reply