OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
[ ] [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
the java generator on openapi-generator-maven-plugin 7.0.1 doesn't compile with an openapi which contain an oneOf instructions with descriptor of string type, but the implementations have enum for descriptor
The interfaces and implementation are generated, but the compilation is failed due to wrong implementation of getter method. Interface has discriminator of type String, while implementations have discriminator of enum type
The compilation error (name of the classes are changed due to requirements from the company):
getAtType() in .<implementation class name 1> cannot implement getAtType() in .
Interface class:
@JsonIgnoreProperties(
value = "@type", // ignore manually set @type, it will be automatically generated by Jackson during serialization
allowSetters = true // allows the @type to be set during deserialization
)
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "@type", visible = true)
@JsonSubTypes({
@JsonSubTypes.Type(value =<first class>.class, name = "<first class name>"),
@JsonSubTypes.Type(value =<second class>.class, name = "<second class name>"),
})
public interface<interface name> extends Serializable {
public String getAtType();
}
Implementation classes:
@JsonPropertyOrder({
})
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2023-09-26T12:17:27.817531+03:00[Europe/Athens]")
public class <first class> implements Serializable, <interface name> {
private static final long serialVersionUID = 1L;
//other code
/**
* When sub-classing, this defines the sub-class entity name
*/
public enum AtTypeEnum {
<first class name>("<first class name>");
private String value;
AtTypeEnum(String value) {
this.value = value;
}
@JsonValue
public String getValue() {
return value;
}
@Override
public String toString() {
return String.valueOf(value);
}
@JsonCreator
public static AtTypeEnum fromValue(String value) {
for (AtTypeEnum b : AtTypeEnum.values()) {
if (b.value.equals(value)) {
return b;
}
}
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
}
//other code
Bug Report Checklist
Description
the java generator on openapi-generator-maven-plugin 7.0.1 doesn't compile with an openapi which contain an oneOf instructions with descriptor of string type, but the implementations have enum for descriptor
The interfaces and implementation are generated, but the compilation is failed due to wrong implementation of getter method. Interface has discriminator of type String, while implementations have discriminator of enum type
The compilation error (name of the classes are changed due to requirements from the company): getAtType() in.<implementation class name 1> cannot implement getAtType() in .
Interface class:
Implementation classes:
openapi-generator version
version: 7.0.1
OpenAPI declaration file content or url
Yaml file provided partly due to security reasons
Generation Details
pom file: `