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
// []stringAsNotification200Errors is a convenience function that returns []string wrapped in Notification200Errorsfunc []stringAsNotification200Errors(v*[]string) Notification200Errors {
returnNotification200Errors{ []string: v}
}
notice the function name []stringAsNotification200Errors leads to an error also.
Digging into the source code a bit, it looks like the problem occurs in model_oneof.mustache:
// {{classname}} - {{#description}}{{{description}}}{{/description}}{{^description}}struct for {{{classname}}}{{/description}}
type {{classname}} struct { {{#oneOf}}
{{{.}}} *{{{.}}}
{{/oneOf}}
}
{{#oneOf}}
// {{{.}}}As{{classname}} is a convenience function that returns {{{.}}} wrapped in {{classname}}
func {{{.}}}As{{classname}}(v *{{{.}}}) {{classname}} { return {{classname}}{ {{{.}}}: v}
}
{{/oneOf}}
In particular, this portion: {{{.}}} *{{{.}}} which results in the name and the type being the same. With my first model (InvalidIdentifierError) there is no issue since the model is it's own object with own definition. But in the second case (NoSubscribersError) the model is an array so I think it's not creating its own type.
The correct result would be something like:
typeNotification200Errorsstruct {
InvalidIdentifierError*InvalidIdentifierErrorNoSubscribersError*[]string// <-- no error
}
Note, as of 3/9/22 I don't know what changed, but I have been unable to reproduce the above build where we get the:
rgomezp
changed the title
[BUG] Go generator import error
[BUG] Go generator results in missing objects
Mar 9, 2022
rgomezp
changed the title
[BUG] Go generator results in missing objects
[BUG] Go generator results in missing objects when using oneOf interfaces - leads to import error
Mar 9, 2022
@rgomezp thanks for sponsoring the fix. Basically the goal is to support non-model type (e.g. primitive type or array or primitive type) in the oneOf member in the Go client.
Bug Report Checklist
Description
Similar to #6161 , the Go generator has a bug where "oneOf" spec definitions are resulting in missing objects that lead to errors.
We are willing to sponsor work on this issue to the tune of $100.
openapi-generator version
Using version
5.2.0
OpenAPI declaration file content or url
Thanks @wing328
Generation Details
openapi-generator-cli generate -g go -i /parent/api.json -o /parent/build/go -c /parent/codegen/go.yml --git-user-id OneSignal --git-repo-id onesignal-go
go.yml:
Steps to reproduce
Related issues/PRs
#6161
Suggest a fix
Currently, building results in the following struct:
and the following functions:
notice the function name
[]stringAsNotification200Errors
leads to an error also.Digging into the source code a bit, it looks like the problem occurs in
model_oneof.mustache
:In particular, this portion:
{{{.}}} *{{{.}}}
which results in the name and the type being the same. With my first model (InvalidIdentifierError
) there is no issue since the model is it's own object with own definition. But in the second case (NoSubscribersError
) the model is an array so I think it's not creating its own type.The correct result would be something like:
Note, as of 3/9/22 I don't know what changed, but I have been unable to reproduce the above build where we get the:
I am back to getting the original issue where the
Notification200Errors
doesn't get generated -- an issue regardless.The text was updated successfully, but these errors were encountered: