Forum Discussion

gaman007's avatar
gaman007
Regular Visitor
2 years ago

How to implement Java Interface classes in Open API Template

Output class is generated as 

@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class GetEntitiesResponse {
@JsonProperty("convertedCurrency")
private String convertedCurrency;

@JsonProperty("entities")
@Valid
private List<Entity> entities = null;

@JsonProperty("showEntityAccountsinSingleView")
private Boolean showEntityAccountsinSingleView;
}

 

instead of required Class

public class GetEntitiesAndAccountsResponse implements ServiceCodeOverride, EntityServiceCodeOverride {
   String convertedCurrency;
   List<Entity> entities;
   boolean showEntityAccountsinSingleView;

}

 

build.gradle configuration:

openApiGenerate {
generatorName = "spring"
inputSpec = project.ext.openApiSpecFile.toString()
outputDir = "${generatedModelDir}"
modelPackage = "com.example.dto"
configOptions = [
dateLibrary: "java8", // dateLibrary option is set to java8, which specifies that the java.time classes should be used for date/time handling
useLombok: "true", // Enable Lombok
interfaceImplementation: "true"
]
}
following is openApi Template for the class
"GetEntitiesResponse": {
"x-java-implements": [
"com.example.dto.ServiceCodeOverride",
"com.example.dto.EntityServiceCodeOverride"
],

"type": "object",
"properties": {
"convertedCurrency": {
"type": "string"
},
"entities": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Entity"
}
},
"showEntityAccountsinSingleView": {
"type": "boolean"
}
}
},

How to get the required output class with implementation of interfaces.


 

No RepliesBe the first to reply