Closed quilicicf closed 7 years ago
Sounds reasonable for specific case of empty Object, but would this cause problems for other kinds of invalid schema JSON? Default implementation is used in every case where type identifier is missing.
Perhaps this is not a big problem (any JSON properties found would likely not have counterpart in AnySchema
.
JSON schemas without type being of type any
was my interpretation of the spec. Maybe I'm wrong.
I'll look at the failing tests.
Looks like one cannot deserialize directly in any subtype of JsonSchema anymore, only in JsonSchema itself.
When trying to MAPPER.readValue(str, ObjectSchema.class)
it says
AnySchema is not a subtype of ObjectSchema.
I'm wondering if defaultImpl
should be applied to subclasses of JsonSchema but I don't know Jackson enough to make a clean fix on that issue I'm afraid. Any suggestion ?
@quilicicf Right, you can not ask for ObjectSchema
, and then be handed AnySchema
since latter is not a subtype of former -- you can not cast AnySchema
into ObjectSchema
.
This is... a problematic case, and ideally I think there should be a way to try to handle this. But as things are, I am not sure how that could be achieved.
Ideally, I think, it should be possible to specify defaultImpl
that obeys contract at @JsonTypeInfo
(true here), but also request a subtype, and only fail if there is an actual problem (that is, attempt was made to use invalid defauilt implementation) -- but work if type actually does match.
Problem comes from the fact that code at low level only sees the potential problem, of base type not the one where @JsonTypeInfo
was declared, but one that user specified (ObjectSchema
), and correctly (wrt information it has) determines that two are not compatible.
I'll have to think about this, but it is probably safe to say that fix, if one is found, will not be found on short term.
OK for me. The fix I did works for us because we always deserialize into class JsonSchema
so nothing urgent on our side, we forked the module.
If you find a complete fix, we'd be glad to switch back to the official implementation though.
Thanks for your time.
And as I'm being told, we'd like to get rid of that fork ASAP.
Affects: 2.8.2
Issue
Spec pointer
I'd expect an empty JSON schema to be deserialized as
AnySchema
.How to reproduce
POM file
Java file
Trace