-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
YAML.dump ignores Boolean values #340
Comments
@mbohlool fyi, looks like we should update the version of the generator that we use... |
Test failes because a key with Boolean value is ignored. See kubernetes-client#340.
I just ran into this. I created a test that fails here. I tried to fix but don't know how. Does this commit hash need to be updated to a commit in OpenAPITools/openapi-generator now? |
Test fails because a key with Boolean value is ignored. See kubernetes-client#340.
I think I'm hitting the same problem at V1SecurityContext#privileged field in #531 |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
/remove-lifecycle stale |
A temporary workaround as following (may not work for some scenario)
|
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
/remove-lifecycle stale |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
/lifecycle frozen |
I'm going to close this as I believe that we have advanced the code generator past the commit with the fix for this issue (and this issue is pretty old). We can reopen if it reoccurs. |
Problem:
When performing a YAML.dump on a model object the value of Boolean fields are missing in the output.
For example, when running a YAML.dump on a V1Deployment which has a V1Container where stdin equals true, the value of stdin will not be present in the YAML.dump of the V1Deployment.
Reproduction path:
Load the following yaml into a V1Deployment via Yaml.loadAs:
Then run a Yaml.dump on the V1Deployment, the result equals:
The value of stdin is missing in the dumped yaml, although it is read in correctly in the V1Deployment object.
Probable cause:
In version 2.3.0 of the Swagger codegeneration a bug was introduced in generating non-primitive Boolean getters. They now follow the naming conventions for primitive booleans, which equal is<booleanName> instead of get<booleanName>. However, this naming convention does not hold for Boolean primitives, their getters should be named get<BooleanName>.
(See also http://www.oracle.com/technetwork/articles/javaee/spec-136004.html, paragraph 8.3)
Snakeyaml uses getter methods to determine which fields are readable. It cannot find a correct getter for all Boolean fields, and therefore it will not serialize this field.
This issue is introduced in the Swagger codegeneration via swagger-api/swagger-codegen#4882 and fixed via OpenAPITools/openapi-generator#432.
Note 1:
Yaml.loadAs has no issues, because the setters of Boolean fields are named correctly and therefore it can deserialze Yaml to Java beans.
Note 2:
Luckily the Boolean fields seem to be passed correctly to kubernetes, because here Gson is used for serialization, which does not use getters and setters to serialize Java beans.
The text was updated successfully, but these errors were encountered: