Open miguelsorianod opened 3 years ago
openapi-generator-cli 4.3.1
Tried newer stable version 5.0.1 instead as the Go client generator has been refactored in the 5.x release.
Hi,
I've tried 5.0.1
but I think I still can't get the desired behavior.
The use case we want is: On OpenAPI side we want to specify that a user needs to send a mandatory attribute, and it cannot send it as null, and in Go code side we need to be able to detect whether the user has specified the attribute or not. This is, a mandatory, non-nullable value.
If in OpenAPI model (using 5.0.1) I set 'required' to true and 'nullable' to false then it is always generated as int32
. That doesn't allow us to check whether the user has set the value to its zero value or has not set it at all.
Description
Hi,
With the openapi-generator Go code generator, it seems it is not possible to generate a Go struct attribute that is a pointer to a type and at the same time contains the
omitempty
json struct tag when therequired
OpenAPI attribute is set.We have the following use case where it seems this would be needed:
We want to define a property that is required and that the user should set and should set it to a non-null value. From our code we need to be able to differentiate between the user not having set the value and having set it to its zero-value.
When digging deeper:
optional
when it shouldn't be optional, we want the user to provide a non-null value alwaysopenapi-generator version
openapi-generator-cli 4.3.1
Thank you