equinix-labs / metal-go

[Deprecated] Golang client for Equinix Metal
https://deploy.equinix.com/labs/equinix-sdk-go/
MIT License
3 stars 2 forks source link

Throw an error when required properties are missing #159

Closed ctreatma closed 11 months ago

ctreatma commented 1 year ago

When a property is marked as required, the Go generator will generate that property as the target data type (e.g., int32 or Device) rather than as a pointer to the target data type (e.g., *int32 or *Device). When a required property is missing in an API response, a generated model will use the zero value for that property's data type (e.g., 0 for an int32 property, a Device with zero values for all properties for a Device property). Since missing required properties are effectively ignored, any schema disambiguation that depends on required properties will not work, and metal-go will see schema validation errors in unexpected places.

Instead, the Go SDK should throw an error if a required property is missing in an API response so that the SDK can correctly identify schemas and so that users can be aware of and address any errors caused by incorrect SDK usage.

ctreatma commented 1 year ago

~There's been some work on validating required fields in #132~

Required field validation for generated Go clients has moved to https://github.com/OpenAPITools/openapi-generator/pull/16863

ctreatma commented 11 months ago

Support for required field validation was added in #172.