Description
Using the swagger-codegen-maven-plugin 2.2.2 with tag <modelNameSuffix> and the yml property "discriminator" generates the annotation @JsonSubTypes with classnames without modelNameSuffix which leads to compiler errors. Inheritance works fine though.
The plugin generates:
ProductTO.java and ProductChildTO.java
Java Code:
...
@JsonSubTypes({
@JsonSubTypes.Type(value = ProductChild.class, name = "ProductChild")
// Issue: here it should be ProductChildTO.class (with suffix)
})
public class ProductTO {
...
}
public class ProductChildTO extends ProductTO {
...
}
Swagger-codegen version
swagger-codegen-maven-plugin 2.2.2
Swagger declaration file content or url
JSON in order to implement inheritance:
"definitions": {
"Product": {
"type": "object",
"discriminator": "productDiscriminator",
"properties": {
"productDiscriminator": {
"type": "string",
"required": true
},
"title": {
"type": "string"
}
}
},
"ProductChild": {
"type": "object",
"allOf": [
{
"$ref": "#/definitions/Product"
},
{
"properties": {
"name": {
"type": "string"
}
}
}
]
}
}
<execution>
<id>swagger-generate-rewards</id>
<phase>validate</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/api.json</inputSpec>
<language>spring</language>
<output>${project.build.directory}/tmp/swagger</output>
<configOptions>
<apiPackage>com.mypackage.api</apiPackage>
<modelPackage>com.mypackage.dto</modelPackage>
<invokerPackage>com.mypackage.invoker</invokerPackage>
<dateLibrary>legacy</dateLibrary>
</configOptions>
<modelNameSuffix>TO</modelNameSuffix>
</configuration>
</execution>
Command line used for generation
mvn clean install
Steps to reproduce
See above
Related issues
N/A
Suggest a Fix
@JsonSubTypes.Type(value = ProductChildTO.class, name = "ProductChild")
Description
Using the swagger-codegen-maven-plugin 2.2.2 with tag <modelNameSuffix> and the yml property "discriminator" generates the annotation @JsonSubTypes with classnames without modelNameSuffix which leads to compiler errors. Inheritance works fine though.
The plugin generates:
ProductTO.java and ProductChildTO.java
Java Code:
Swagger-codegen version
swagger-codegen-maven-plugin 2.2.2
Swagger declaration file content or url
JSON in order to implement inheritance:
Command line used for generation
mvn clean install
Steps to reproduce
See above
Related issues
N/A
Suggest a Fix
@JsonSubTypes.Type(value = ProductChildTO.class, name = "ProductChild")