Closed alinagb closed 1 year ago
I think you want this Jackson feature:
DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL
Thanks it's working having the DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL. I was thinking maybe there is a solution having a kind of property directly in the json for ignoring the unknown value
No, I don't think there's any way to express this in a schema. By definition, and enum means 'only these values and no other'.
It should be possible to "customize" EnumRule
behavior by extending/overriding methods in latter and providing instance of it through extended RuleFactory
:
https://github.com/joelittlejohn/jsonschema2pojo/blob/25bfc76091ed8f1deaac91a6d1f479ec4a3db6ee/jsonschema2pojo-maven-plugin/src/main/java/org/jsonschema2pojo/maven/Jsonschema2PojoMojo.java#L300-L308
After a basic enum schema is generated, the enum class has
And in my case it is possible to pass an unkown value, but the code will throw IllegalArgumentException. I'd like it just to be ignored or having a default value.
Is there any possibility to just ignore unknown values or set a default value in the json schema?