Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using @JsonUnwrapped with @Schema(implementation = Something) does not unwrap #4696

Open
Jouramie opened this issue Jun 12, 2024 · 1 comment

Comments

@Jouramie
Copy link

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
@jayChrono
Copy link

Added resolve(t, context, Collections.emptyIterator()) just before the handleUnwrapped(...) call (ModelResolver:710) to properly process @JsonUnwrapped in my project.

image001_resized

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants