-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
go generics cannot find common package object type definition #1237
Comments
@Coderpipi FYI ProblemCategories it's a slice in go terminology. 1.8.3 is the first version supporting basic generics parsing. That being said, it's acceptable to have this kind of issue. |
@ubogdan but after my testing, it also gives errors like this, even though it's not a slice |
i have had the same puzzle , it really really confused me |
I've also been experiencing this issue and have been using this as a workaround: type problemR response.R[models.Problem]
// xx
// @Tags xxx
// @Summary xxx
// @Param xxx
// @Success 200 {object} problemR
// @Router /api/v1/xxx [get]
func Route() {
} Swag doesn't properly parse this but instead gives the warning |
- use ast.SelectorExpr instead if ast.Ident to embed types - tests reworked fixes swaggo#1237
- Generate full type name, if only one generic field exists - Generate refs to generic properties - Tests extended to test override behavior refs swaggo#1237 fixes swaggo#1253
Describe the bug
An error occurred while parsing a data structure that contains generics and the generic object field is another object and both objects are in the same package
ParseComment error in file problem.go :cannot find type definition: ProblemCategory
This is my
response.go
:This is my
problem.go
,it contains a field of type ProblemCategory Array:This is my
problem_category.go
:This is my comment:
Your swag version
1.8.3
Your go version
1.18
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: