Skip to content

Determine if all built-in collections should omit empty #5262

@shawkins

Description

@shawkins

Some collections are not marked as omitempty in their go classes: https://github.com/openshift/api/blob/master/apps/v1/types.go#L63

The java generator will not mark those fields for JsonInclude non_empty.

However our builders are opinionated about treating an empty and null collections the same (in some places), and users will end up with empty collections in their serialized forms without realizing it. This is problematic for merge patches which treat the presense of an empty collection as a full replacement for the existing.

Originally posted by @shawkins in #5222 (comment)

We have two options to evaluate:

  1. Just to be consistent make all collections default to non-empty (can be done in either the generator or the jsonschema2pojo logic). This will of course open users up to Patch with empty collections #4606

  2. Try to modify the builder logic to differentaite between empty and null based upon the JsonInclude annotation - this seems like a tall order, and probably not viable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions