swagger-core
swagger-core copied to clipboard
Using @JsonUnwrapped with @Schema(implementation = Something) does not unwrap
Hi, I have an object like
public record Car(String model, @JsonUnwrapped @Schema(implementation=ResourcePath.class) Resource resource, boolean selected) {
}
public abstract class Resource {
}
public abstract class ResourcePath extend Resource {
public String resourcePath;
public String resourceType;
}
Resource is an abstract class, and does not contain all the fields present in ResourcePath. However, Jackson picks up all the fields and still unwrap them with @JsonUnwrapped.
The moment I specify an implementation in @Schema, resource stop being unwrapped in the openapi.yaml.
Expected
Car:
type: object
properties:
model:
type: string
resourceType:
type: string
resourcePath:
type: string
selected:
type: boolean
Result
ResourcePath:
type: object
properties:
resourceType:
type: string
resourcePath:
type: string
Car:
type: object
properties:
model:
type: string
resource:
$ref: "#/components/schemas/ResourcePath"
selected:
type: boolean
Added resolve(t, context, Collections.emptyIterator()) just before the handleUnwrapped(...) call (ModelResolver:710) to properly process @JsonUnwrapped in my project.
I’m experiencing this issue too. I can’t believe it’s been open for so long without any help to resolve it.