Description of the problem/issue
When trying to upgrade from 2.2.43 to 2.2.44, our build fails with an error message that clearly seems related to the recent modifications on default values (#4838, #5063 ...).
I see this in the generated openapi specification the offending ##default :
components:
schemas:
BoundingBox:
default: "##default"
description: Bounding box
properties:
bottom:
description: Bottom side of the bounding box
example: 1
type: number
...
required:
- bottom
...
Our corresponding Java class is defined as
@Schema(description = "Bounding box")
public record BoundingBox(
...
@JsonProperty("bottom")
@NotNull
@Schema(
description = "Bottom side of the bounding box",
requiredMode = Schema.RequiredMode.REQUIRED,
example = "1.0")
BigDecimal bottom)
implements JsonDto {
...
}
The JsonDto interface is defined as
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder(alphabetic = true)
public interface JsonDto {}
Affected Version
2.2.44
Earliest version the bug appears in (if known):
2.2.44
Steps to Reproduce
I have provided the parts of the code and generated openapi specification that seem relevant
Expected Behavior
The ##default shouldn't be used in the resulting spec (if I understand correctly, the generated openapi specification contains now a default value with ##default, which cannot be interpreted...)
Actual Behavior
Don't mess up the openapi specification with ##default
Logs / Stack Traces
Can't resolve default value: ##default
java.lang.ClassCastException: class com.fasterxml.jackson.databind.node.TextNode cannot be cast to class com.fasterxml.jackson.databind.node.ObjectNode (com.fasterxml.jackson.databind.node.TextNode and com.fasterxml.jackson.databind.node.ObjectNode are in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader$InstrumentingVisitableURLClassLoader @4899739b)
at org.openapitools.codegen.languages.AbstractJavaCodegen.toDefaultValue(AbstractJavaCodegen.java:1459)
at org.openapitools.codegen.DefaultCodegen.fromProperty(DefaultCodegen.java:4307)
at org.openapitools.codegen.DefaultCodegen.fromProperty(DefaultCodegen.java:3971)
at org.openapitools.codegen.DefaultCodegen.addVars(DefaultCodegen.java:6181)
at org.openapitools.codegen.DefaultCodegen.addVars(DefaultCodegen.java:6102)
at org.openapitools.codegen.DefaultCodegen.updateModelForObject(DefaultCodegen.java:2914)
at org.openapitools.codegen.DefaultCodegen.fromModel(DefaultCodegen.java:3142)
at org.openapitools.codegen.languages.AbstractJavaCodegen.fromModel(AbstractJavaCodegen.java:1838)
at org.openapitools.codegen.languages.JavaClientCodegen.fromModel(JavaClientCodegen.java:1076)
at org.openapitools.codegen.DefaultGenerator.processModels(DefaultGenerator.java:1754)
at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:514)
at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:444)
at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:1292)
at org.openapitools.generator.gradle.plugin.tasks.GenerateTask.doWork(GenerateTask.kt:974)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:565)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:125)
...
Additional Context
No other additional context yet
Checklist
Description of the problem/issue
When trying to upgrade from 2.2.43 to 2.2.44, our build fails with an error message that clearly seems related to the recent modifications on default values (#4838, #5063 ...).
I see this in the generated openapi specification the offending
##default:Our corresponding Java class is defined as
The JsonDto interface is defined as
Affected Version
2.2.44
Earliest version the bug appears in (if known):
2.2.44
Steps to Reproduce
I have provided the parts of the code and generated openapi specification that seem relevant
Expected Behavior
The
##defaultshouldn't be used in the resulting spec (if I understand correctly, the generated openapi specification contains now a default value with##default, which cannot be interpreted...)Actual Behavior
Don't mess up the openapi specification with ##default
Logs / Stack Traces
Additional Context
No other additional context yet
Checklist
@nvervelle thanks for reporting this.
The issue has been addressed and the fix has already been merged. It will be available in the next swagger-core release.
Thanks for bringing this up and helping improve the project.