Skip to content
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

Type Parameters support? #1104

Closed
hhuseyinpay opened this issue Jan 18, 2022 · 6 comments
Closed

Type Parameters support? #1104

hhuseyinpay opened this issue Jan 18, 2022 · 6 comments
Labels

Comments

@hhuseyinpay
Copy link

Hi, I'm experimenting with generics. I'm getting the following error.

Screen Shot 2022-01-18 at 16 25 22
Screen Shot 2022-01-18 at 16 25 43

@ubogdan
Copy link
Contributor

ubogdan commented Jan 18, 2022

Funny. Go1.18 is not released yet.

@hhuseyinpay
Copy link
Author

"I'm experimenting". It will be released soon so I'm preparing for it :)

@ubogdan
Copy link
Contributor

ubogdan commented Jan 18, 2022

Nice. I don't see what kinda Open API definition may swag generate for a "generic" definition.

From my perspective, this kind of struct will be ignored by swag or will produce an error if it is used in a request/response.

@hhuseyinpay
Copy link
Author

You can check my repository. By using generics, I'm trying to reduce code duplications for simple CRUD APIs, especially for admin panels.

@ubogdan
Copy link
Contributor

ubogdan commented Jan 18, 2022

The error comes obviously from the fact you are using a swag binary that was built with a go version before 1.18 and the go/parser doesn't recognize generics.

Regarding the project. if you are going to use DTO for request/response I believe it will work fine with current implementation.

@hhuseyinpay
Copy link
Author

I've cloned the repository and changed the go version in the go.mod file and compiled it and then it worked as expected. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants