googleapis / googleapis/google-cloud-swift
Improve serialization of fields with default values
- Dominant language
- Swift
- Stars
- 26
- Forks
- 10
- Avg merge
- 12h 56m
- Merged PRs (30d)
- 211
Description
Gemini says:
#### 3. Default Values Are Emitted Instead of Omitted (Spec Gap)
* **Spec Requirement**:
> *"If the field doesn’t support field presence and has the default value (for example any empty repeated field) serializers should omit it from the output. An implementation may provide options to include fields with default values in the output."*
* **Current Implementation**:
Generated code unconditionally encodes singular primitive fields (`singular: 0`, `singular: ""`), empty repeated fields (`repeated: []`), and empty map fields (`map: [:]`). An unpopulated message currently produces:
```json
{"mapKey":{},"mapKeyValue":{},"mapValue":{},"option":null,"repeated":[],"singular":0}
```
whereas ProtoJSON specification specifies `{}` by default.
----
This is a "SHOULD" requirement, we can ignore it for now, though it would be nice to have as a message-size optimization (maybe at a CPU-time tradeoff).
Contributor guide
Research direction
No files or tests are identified. Locate the generated serialization code, inspect how singular primitive, repeated, and map fields are emitted when they hold default or empty values, and compare the behavior with the ProtoJSON requirement; done means an unpopulated message produces {} by default.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- api
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100