You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
type SearchResponse struct {
Data *[]struct {
// Embedded struct due to allOf(#/components/schemas/CommonParent)
someparentstruct
// Embedded fields due to inline allOf schema
Uri *string `json:"uri,omitempty"`
} `json:"data,omitempty"`
Total *int32 `json:"total,omitempty"`
}
above *[]struct should be []*struct
Reacted by Oleg Tsarev, Alexei Dudko, Kamil Wilk and Jackson Tong
I'm. not sure what the semantics are meant to be regarding type: array and if/how you can mark individual items as able to be null. possibly by having nullable: true somewhere, I'm not sure if/how this library handled this.
// SearchResponse defines model for SearchResponse.typeSearchResponsestruct {
Data []map[string]interface{} `json:"data"`Total*int32`json:"total,omitempty"`
}
And suggests that this library is not using the nullable: true field when determining if references to an object can be nil or not. That might be a feature or bugfix that could be added for correctness
Have the same issue. I need to be able to generate the array of pointers to primitives of objets. OpenAPI v3 specification allows to do this by using nullable: true. However it is not implemented in this codegen and I also did not find the evidence of this feature in the source code.
Hi Folks, I just submitted a pull request that should resolve at least some of these issues. I hit the same issue when trying to return a db row which was a column of nullable fields... #490
Activity
pseudo-su commentedon Mar 20, 2020
This is the closest I got to replicating you use case.
If you make the data field
requiredit will remote the pointer from the Data fieldI'm. not sure what the semantics are meant to be regarding
type: arrayand if/how you can mark individual items as able to be null. possibly by havingnullable: truesomewhere, I'm not sure if/how this library handled this.pseudo-su commentedon Mar 20, 2020
A quick test using this:
Generates:
And suggests that this library is not using the
nullable: truefield when determining if references to an object can be nil or not. That might be a feature or bugfix that could be added for correctnesspseudo-su commentedon Mar 20, 2020
Looks like there's some weirdness around the OpenAPI spec and
nullableOAI/OpenAPI-Specification#1368 (comment)I might be wrong but it looks like the correct spec required in order to generate the code you would (
[]*struct{}) would look something like thisHowever this currently generated a signature of
[]struct{}becausenullable: truedoesn't seem to be handled.dududko commentedon Apr 20, 2020
Have the same issue. I need to be able to generate the array of pointers to primitives of objets. OpenAPI v3 specification allows to do this by using
nullable: true. However it is not implemented in this codegen and I also did not find the evidence of this feature in the source code.Is it possible to add this feature ?
dududko commentedon Apr 20, 2020
Here is the example of api definition.
expected output
wjase commentedon Nov 26, 2021
Hi Folks, I just submitted a pull request that should resolve at least some of these issues. I hit the same issue when trying to return a db row which was a column of nullable fields...
#490
wjase commentedon Mar 12, 2022