Skip to content

Commit 62e4abc

Browse files
committed
Discourage usage of nullable on API types
1 parent 2a02172 commit 62e4abc

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

contributors/devel/sig-architecture/api-conventions.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ An introduction to using resources with kubectl can be found in [the object mana
2727
- [Categories](#categories)
2828
- [Idempotency](#idempotency)
2929
- [Optional vs. Required](#optional-vs-required)
30+
- [Nullable](#nullable)
3031
- [Defaulting](#defaulting)
3132
- [Static Defaults](#static-defaults)
3233
- [Admission Controlled Defaults](#admission-controlled-defaults)
@@ -866,6 +867,17 @@ language client, and any other clients that use corresponding types
866867
Therefore, we ask that pointers always be used with optional fields that do not
867868
have a built-in `nil` value.
868869

870+
## Nullable
871+
872+
The `+nullable` comment tag allows the json `null` value to be a valid value
873+
for a field. The `null` value is serialized only when a field is a pointer
874+
in the Go definition, and does not have the `omitempty` json tag.
875+
876+
For example, a map field marked with `+nullable` would accept either `foo: null` or `foo: {}`.
877+
878+
Usage of `+nullable` is discouraged as it introduces several issues:
879+
- It is not compatible with json merge patching.
880+
- It is not compatible with generic protobuf.
869881

870882
## Defaulting
871883

0 commit comments

Comments
 (0)