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

fix make schema name to support generics #41

Merged
merged 2 commits into from
Mar 14, 2024
Merged

fix make schema name to support generics #41

merged 2 commits into from
Mar 14, 2024

Conversation

zc2638
Copy link
Owner

@zc2638 zc2638 commented Mar 14, 2024

When versions greater than 1.18 support generics, makeName will cause a reference exception.

github.com/zc2638/swag/option/option.go

type Test struct {
    Name string `json:"name"`
}

github.com/zc2638/swag/endpoint/endpoint.go

type List[T any] struct {
    Items []T `json:"items"`
}

The above will be parsed by makeName as endpoint.List[github.com/zc2638/swag/option.Test] and option.Test.

Now use the full pkgPath and remove the / special character,
will be parsed as github.com_zc2638_swag_endpoint.List[github.com_zc2638_swag_option.Test] and github.com_zc2638_swag_option.Test.

This will work fine.

Copy link

codecov bot commented Mar 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.74%. Comparing base (a206f70) to head (8034a07).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #41      +/-   ##
==========================================
+ Coverage   90.73%   90.74%   +0.01%     
==========================================
  Files          11       11              
  Lines         820      821       +1     
==========================================
+ Hits          744      745       +1     
  Misses         69       69              
  Partials        7        7              
Flag Coverage Δ
all 90.74% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zc2638 zc2638 merged commit c0db946 into main Mar 14, 2024
4 checks passed
@zc2638 zc2638 deleted the fix/makeName branch March 14, 2024 06:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant