ric1
3 years agoRegular Visitor
Generated Java code (swagger) does not compile
I'm trying to create e Java client defined with swagger. I have generated the source code automatically in three ways.
online https://editor.swagger.io/
java -jar swagger-codegen-cli-3.0.20.jar generate -i https://www.xxxxxx.xxx/xxxxxx/swagger.json -l java
swagger-codegen generate -i https://www.xxxxxx.xxx/xxxxxx/swagger.json -l java
Unfortunately, the generated source code cannot be compiled in all ways. When I execute
mvn clean install
I get many errors of this type:
A.java cannot inherit from final B
I have analyzed the error and found the following pattern many times.
public class A extends B {
....
}
public enum B {
....
}
I know that the swagger provider works with c# and in this language this construct should be allowed.
I see the following in jason
"xxxx.xxxx.xx.B": {
"enum": [
"A",
"B",
"C",
"D"
],
"type": "string"
}
...
"b": {
"allOf": [
{
"$ref": "#/xxxx/xxxx/xxxx.xxxx.xx.B"
}
],
"description": "abc",
"nullable": true
}
I am not allowed to publish the swagger URL.
Is there anything I can do to build a Java client anyway?
online https://editor.swagger.io/
java -jar swagger-codegen-cli-3.0.20.jar generate -i https://www.xxxxxx.xxx/xxxxxx/swagger.json -l java
swagger-codegen generate -i https://www.xxxxxx.xxx/xxxxxx/swagger.json -l java
Unfortunately, the generated source code cannot be compiled in all ways. When I execute
mvn clean install
I get many errors of this type:
A.java cannot inherit from final B
I have analyzed the error and found the following pattern many times.
public class A extends B {
....
}
public enum B {
....
}
I know that the swagger provider works with c# and in this language this construct should be allowed.
I see the following in jason
"xxxx.xxxx.xx.B": {
"enum": [
"A",
"B",
"C",
"D"
],
"type": "string"
}
...
"b": {
"allOf": [
{
"$ref": "#/xxxx/xxxx/xxxx.xxxx.xx.B"
}
],
"description": "abc",
"nullable": true
}
I am not allowed to publish the swagger URL.
Is there anything I can do to build a Java client anyway?