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
{{ message }}
Repository navigation
Upgrade to go 1.18 for generics parsing support #1162
For what its worth, swapping out the any alias with interface{} gets around the error. This only works if you control the libraries which likely isn't possible in all cases.
It seems to work with my own packages that use any judiciously. I don't have a good working knowledge of swag so I don't know if this sort of change is worth a PR.
@rdlaitila I hope you don't mind that I publishes your changes as a PR in #1168.
It's not released yet, so in the meantime you can do the following to install the Go 1.18 compatible version of Swaggo: Edit: It's now released and available since v1.8.1:
I had the same issue, and it seems parsing of the actual code was fixed with v1.8.1. The // @success 200 {object} model.Response[SomeType] annotation still fails when attempting to specify a generic struct as a response object. Is the syntax for describing a generic struct response documented anywhere? :-)
Reacted by Valentin Padurean (Ogg), Yusril Maulidan Raji, SMVirus, Oscar, Hasindu Lanka, shiwyang and Franco Alex
@hcsaustrup Deserves a separate issue IMO. The PR was only fixing the fact that swaggo would fail to parse Go 1.18 code to begin with and did not understand the new any keyword.
To parse generic types in the swaggo comments would be a different story, I presume, and would involve a bit more technical details.
Activity
rdlaitila commentedon Mar 16, 2022
related to #1104 (comment) I tried compiling swag with 1.18 and it passes my prior error but is unable to find the new alias
any:ubogdan commentedon Mar 16, 2022
I see building swag against go 1.18 is not enough.
rdlaitila commentedon Mar 17, 2022
For what its worth, swapping out the
anyalias withinterface{}gets around the error. This only works if you control the libraries which likely isn't possible in all cases.rdlaitila commentedon Mar 17, 2022
@ubogdan i've put togther an adhoc fix for myself here https://github.com/rdlaitila/swag/commit/6d3d4c96d30bfc34d588a560c8944b470e0c40b6 in addition to bumping to 1.18
It seems to work with my own packages that use
anyjudiciously. I don't have a good working knowledge of swag so I don't know if this sort of change is worth a PR.al4669 commentedon Mar 17, 2022
I've also noticed it fails when you have any type constraint declarations in your code:
applejag commentedon Mar 30, 2022
@rdlaitila I hope you don't mind that I publishes your changes as a PR in #1168.
It's not released yet, so in the meantime you can do the following to install the Go 1.18 compatible version of Swaggo:Edit: It's now released and available since v1.8.1:
rdlaitila commentedon Mar 30, 2022
@jilleJr no problem. I was not sure those changes were even structurally or logically sound for swag so I was hesitant. TY!
hcsaustrup commentedon Apr 4, 2022
I had the same issue, and it seems parsing of the actual code was fixed with v1.8.1. The
// @success 200 {object} model.Response[SomeType]annotation still fails when attempting to specify a generic struct as a response object. Is the syntax for describing a generic struct response documented anywhere? :-)applejag commentedon Apr 6, 2022
@hcsaustrup Deserves a separate issue IMO. The PR was only fixing the fact that swaggo would fail to parse Go 1.18 code to begin with and did not understand the new
anykeyword.To parse generic types in the swaggo comments would be a different story, I presume, and would involve a bit more technical details.