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 · 0 comments

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
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

1 participant