Document required fields in messaging-api.yml #34
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue Description
While developing the Go SDK, we identified a compatibility issue related to the handling of optional and required fields. Due to Go's default behavior of assigning zero-values to uninitialized struct fields (e.g., an empty string "" for string fields), we need to be explicit about field requirements in the OpenAPI specification.
Importance of required Fields in OpenAPI for Go
In Go, the omitempty attribute is typically added to optional fields when generating code based on OpenAPI definitions. This ensures that if a field holds a zero-value, it will not be included in the serialized JSON. However, this behavior can lead to issues if the required attribute is not correctly set in the OpenAPI specification. Especially, required fields might get sent with zero-values, potentially breaking the API contract.
To mitigate this, we have updated the OpenAPI specification to include explicit required designations for relevant fields. This should improve the reliability of the generated Go SDK and ensure proper adherence to the API's expected behavior.