Generated clients fail to invoke `New...Request` with `value is a nil pointer` when using `prefer-skip-optional-pointer-with-omitzero`
Also, if you generate clients with this:
prefer-skip-optional-pointer: true prefer-skip-optional-pointer-with-omitzero: trueand add this to a parameter like this:
- name: parentTag in: header description: Version string of parent model, if any model x-go-type-skip-optional-pointer: false required: false schema: type: string example: parentTagClient call will fail with
value is a nil pointererror. If you removex-go-type-skip-optional-pointerfrom the field, the client adds the parameters to the query even if they are zero-values, resulting in a 400 on the server side.
Originally posted by @juan-carvajal in #2044
@juan-carvajal to confirm, what's the intent behind the x-go-type-skip-optional-pointer: false on the header parameter?
Just trying to confirm, as it'll generate:
// ParentTag Version string of parent model, if any model
ParentTag *string `json:"parentTag,omitempty"`
Hmm, I think that this may be a case of incorrect location for the extension.
@juan-carvajal, with the following patch:
diff --git internal/test/issues/2074/api.yaml internal/test/issues/2074/api.yaml
index 458bb99..8287fd5 100644
--- internal/test/issues/2074/api.yaml
+++ internal/test/issues/2074/api.yaml
@@ -17,11 +17,11 @@ paths:
- name: parentTag
in: header
description: Version string of parent model, if any model
- x-go-type-skip-optional-pointer: false
required: false
schema:
type: string
example: parentTag
+ x-go-type-skip-optional-pointer: false
I see that this gets generated correctly - check out #2075 for an example
Let me know if this is what you were looking for!
Hi @jamietanna ! Will take a look, thanks for looking into it.