-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
JSONSchemaProps does not support properties of type boolean with default value #2144
Comments
I believe the only reason it works for the array type is that the deserialization is putting the |
Actually, I think this problem extends to more than just boolean. I tried adding a default to an integer field, and saw a similar issue. Even for a string field, it works, but if I re-serialize it as YAML it gets improperly formatted. I.E.
turns into
|
Umm, strange. I remember we fixed something like this in #1565 . |
I think it's due to the underlying go structs in https://github.com/kubernetes/kubernetes/blob/8436dde049fb055e2c58c85f3f1dec5c06c36399/staging/src/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/types_jsonschema.go#L29. I'm guessing this issue will cause improper serialization for all of the fields marked |
let me take a close look into this whenever I get time |
I've been looking further into this by reading the original PR into kubernetes for custom resources support. I think at the very least what we have missing here is a custom deserializer for JSON type. Conveniently, they summarized the JSON handling here: kubernetes/kubernetes#47263 (comment) Note specifically the custom marshal/unmarshal code for this type here: https://github.com/kubernetes/kubernetes/pull/47263/files#diff-3fe7a62396a7708e034adc5c0bbff3fdR121-R134. Currently we are relying upon default jackson de/serialization, which is not handling this well. I actually wonder if we should simply replace JSON with JsonNode. Alternatively, the "proper" way to do this from a jackson perspective would probably be to use JsonSubTypes keyed off the Another alternative would be to annotate the JSON class with |
@rohanKanojia are you amenable to the above JsonNode solution? I was able to get a test case up and it solved for both If you are open to this solution I can try to spend a little more time creating an actual junit test for it. |
Great, Thanks. Feel free to send a PR. I haven't started looking into this. |
I've submitted #2151 for this |
Here is a valid CRD spec:
This is accepted by kubernetes server version 1.15.10. However, this is unparseable via fabric8 CustomResourceDefinition.class:
This fails with the following MismatchedInputException:
If you remove the
default: false
fromhollow
andzoom
, it works. It seems like thedefault: true
inspiky
does work. Note: the true/false values don't matter. It appears that the parsing works within nested arrays of objects, but not nested objects. Not sure why that is.The text was updated successfully, but these errors were encountered: