Closed rohnigam closed 3 months ago
Found one workaround for this.
Both JsonIgnore
on the method getSomethingAboutA
and JsonIgnoreProperties
on the class like @JsonIgnoreProperties({"somethingAboutA"})
work.
But, I still feel these are workarounds, and somethingAboutA
should not have been picked in the first place.
This seems to work as expected: getSomethingAboutA()
is a valid getter and Jackson does consider there to be a property. This is by design; by default public getters/setters with Bean-compatible name and signature are auto-detected.
Similarly public fields are detected.
You can, however, change configurations so that only explicitly annotated accessors are considered.
For classes that is via @JsonAutoDetect
, although there is ObjectMapper
configuration setting for changing baseline as well.
What you want basically is to set detection level for getters (and probably setters, fields too) to Visibility.NONE
, in which case only explicitly annotated properties are detected.
@cowtowncoder This works. Thanks 👍
Glad it works @rohnigam!
For me jsonschemagenerator is not creating any instance. Giving me some exceptions. I am using Jackson 2.14.2 version
Can anyone help?
It Says CLASSNOTFOUND Exception
@rishabhvarshney2 Do not tag on unrelated things into existing issues. Instead file a new issue with enough details to explain the issue you see -- preferably using a recent version.
I have a class like below:
This will go on to generate the following json schema
For brevity I have excluded the details of A, B and C in both java classes and json schema generated.
Bug:
somethingAboutA is not actually a property and should not be generated.
Is there any workaround for this ? Or maybe I am missing some other configuration ?
My observation is that this is only happening when a method starts with get,
so may be, it is being interpreted as an attribute.
I am using the latest version of this library.
This is the schema generation code: