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 using tab (\t) as separator for custom type names #1594

Conversation

nitram509
Copy link
Contributor

@nitram509 nitram509 commented May 29, 2023

Describe the PR

A bug fix.

What happened

  • using swag version v1.8.12
  • did run swag fmt ... and custom type names got reformatted
  • did run swag init ... - Problem: types for custom names not found anymore

Hint: the swag fmt reformats the comment, using a tab (\t) as a separator between @name and the type name.

Expectation

After running swag fmt, the parser still finds all types.

Solution

I did rework the parser using some little regEx to use any kind of whitespace.
An additional test is provided as well.


Relation issue
Issue #1150 seems somewhat related, but I don't care what the fmt command does, rather the problem, the parser can't find custom types.

Additional context

I did run go run github.com/swaggo/swag/cmd/swag@latest fmt yesterday, on a larger code base and afterward all custom type names could not be found anymore. The parser did complain can't finding the type.

@codecov
Copy link

codecov bot commented Jun 7, 2023

Codecov Report

Patch coverage: 71.42% and project coverage change: -0.04 ⚠️

Comparison is base (ea35767) 83.80% compared to head (f2d4697) 83.76%.

❗ Current head f2d4697 differs from pull request most recent head fa1ceeb. Consider uploading reports for the commit fa1ceeb to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1594      +/-   ##
==========================================
- Coverage   83.80%   83.76%   -0.04%     
==========================================
  Files          19       19              
  Lines        3747     3752       +5     
==========================================
+ Hits         3140     3143       +3     
- Misses        520      521       +1     
- Partials       87       88       +1     
Impacted Files Coverage Δ
types.go 93.75% <71.42%> (-6.25%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@sdghchj sdghchj merged commit e73a0d0 into swaggo:master Jun 7, 2023
10 checks passed
@nitram509 nitram509 deleted the fix/fmt-command-breaks-renamed-struct-definitions branch June 7, 2023 07:35
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.

None yet

2 participants