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

AlternateTypeRule is not working with @JsonIgnoreProperties annotation #1155

Open
italobb opened this issue Jan 24, 2016 · 1 comment
Open

Comments

@italobb
Copy link

italobb commented Jan 24, 2016

I'm trying to hide some properties from my classes combining the AlternateTypeRule and @JsonIgnoreProperties (from Jackson), but the result is not as expected. The workaround is to use @JsonIgnore at property level. I'm suspecting that the type level annotations are being ignored, because I tested @JsonIgnoreType and didn't work.

Example

It was expected that the rule below should hide the password property, but it is not happening.

class User { 
    String name;
    String password;
}

@JsonIgnoreProperties(value = { "password" })
class UserJson extends User {} 

// This rule doesn't hide the password property
AlternateTypeRule rule = alternate(User.class, UserJson.class); 

Workaround

Using an annotation at property level... it works!

class UserJson extends User {
    @JsonIgnore String password;
}
@dilipkrish
Copy link
Member

@italobb @JsonIgnoreProperties isn't supported for a few of reasons the main reason being that currently the models are a union of serializable and de-serializable properties (depending on how the model is being used). To be specific when a model is used for request and response, the properties are a union of the two.

Given that there is no way to separate the request and response models currently, its not super useful supporting this until we solve #807.

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

No branches or pull requests

2 participants