Cannot handle generic type by v0.16.3 #1790
Unanswered
babyfish-ct
asked this question in
Q&A
Replies: 1 comment
-
I also encountered this issue. // @success 201 {object} helper.BaseResponse[dto.TokenDetail] "User authenticated successfully" type BaseResponse[TData any] struct { |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi
A type is defined as follows:
Add the following comments for the HTTP method in the Controller:
After executing the relevant commands, the OpenAPI was correctly generated, although the result was not what I expected.
To get the expected result, I added a generic to the Response struct:
Then I modified the comments in the HTTP function of the Controller:
After executing the relevant commands and regenerating the OpenAPI, an error occurred: "cannot find type definition".
I searched it in documentation, it clearly states that it supports Go generics: https://github.com/swaggo/swag/tree/master?tab=readme-ov-file#how-to-use-generics
Finally, when searching for other issues, several issues occurred during the period when Go added generics, and the problems were caused by the users using versions of the frameworks that were too old. However, my version is the latest v1.16.3, which is far beyond the required version for this feature, yet the problem still persists.
Has anyone encountered this issue before?
Beta Was this translation helpful? Give feedback.
All reactions