-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[REQ] [Java] Add JsonIgnoreProperties to model #3438
Comments
…alFieldsAnnotation" to turn off this feature
Which client/server are you using? The Line 19 in 411199b
So is the Line 22 in 411199b
I think we need to define if we would like to add support at model level (using the jackson annotation) or at jackson mapper level: Related issue: #3573 (both options mapper and annotation are possible) |
To me the root issue is that you use the same mapper for everything. Why do you have to do so ? It's a design smell IMO since it introduces coupling. If you're shipping the client, can't you just include your own mapper configured as you like ? |
Is this resolved? |
@cbornet it shouldn't be assumed that the same classes are used for everything. One reason for this is for forwards compatibility where backend model classes are enriched with enhancements over time but some software is using an older yet compatible version of the API that does not need access to these properties. |
One option that could be used is to utilise
What happened though is my annotation got translated with escaped equals sign.
|
Building on the post by @brettryan, the following worked okay:
|
Hi @ericnjogu which version are you using? I'm using the latest version 5.3.0 but the |
@ericnjogu that's exactly what I needed, I pimped it a bit to avoid importing JsonIgnoreProperties @iliassk I used |
I have the same issue. When API has new fields, generated model can't parse these fields. As for me, @Fjolnir-Dvorak proposes good solution to add Is it possible to actualize and merge this pull request? |
@Ferioney I will look into it to get it running at least. |
The workaround using the For me this REQ would still make a lot of sense as I do want that definition on model side and not in every using object mapper. |
Is your feature request related to a problem? Please describe.
We have the scenario that we have a service with multiple client APIs and a lot of other interfaces for other systems like databases which are also working with json.
The project is using one single JsonMapper for everything. The problem is: The JsonMapper is not iognoring unknown fields per se.
Describe the solution you'd like
To acommodate this issue we are adding the annotation
to each model each time we need to regenerate the API per hand (to be honest, sed, but even sed can be considered a manual intervention).
Would this addition destroy anything? No, the generator provides its own JsonMapper which does exactly the same, but implicit, not explicit. This addition would (in my opinion) add some beautiful flavour of further documentation to each model making it even possible to use your own mapper without any further configuration or intervention.
There will be a new flag to turn off this new feature, but it will be on by default
Pull Request will follow...
The text was updated successfully, but these errors were encountered: