Skip to content

Conversation

@tokuhirom
Copy link
Contributor

@tokuhirom tokuhirom commented Oct 25, 2023

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.

@tokuhirom tokuhirom enabled auto-merge (squash) October 25, 2023 13:33
@Yang-33 Yang-33 self-requested a review October 26, 2023 23:42
Copy link
Contributor

@Yang-33 Yang-33 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked some endpoints return error if required field is not specified as request body, and this change is correct. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants