Closed ctreatma closed 11 months 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
Support for required field validation was added in #172.
When a property is marked as
required
, the Go generator will generate that property as the target data type (e.g.,int32
orDevice
) 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 anint32
property, aDevice
with zero values for all properties for aDevice
property). Since missing required properties are effectively ignored, any schema disambiguation that depends on required properties will not work, andmetal-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.