Repository navigation
fix: parse form name "-" as skipped field - #2090
Merged
Merged
Conversation
isqua
commented
Oct 29, 2025
Comment on lines
+518
to
+521
| name := strings.TrimSpace(strings.Split(ps.tag.Get(formTag), ",")[0]) | ||
| if name != "-" { | ||
| return name | ||
| } |
Author
There was a problem hiding this comment.
Here we consider form:"-" as a field with no name, so we return empty string in the end.
Comment on lines
+526
to
534
| func (ps *tagBaseFieldParserV3) JsonName() string { | ||
| if ps.field.Tag != nil { | ||
| name := strings.TrimSpace(strings.Split(ps.tag.Get(jsonTag), ",")[0]) | ||
| if name != "-" { | ||
| return name | ||
| } | ||
| } | ||
| return "" | ||
| } |
Author
There was a problem hiding this comment.
For the sake of consistency, I also extracted the same method for JSON field names.
Comment on lines
+136
to
+139
| type CatchedFishForm struct { | ||
| Count uint `form:"count"` | ||
| Fish *Fish `form:"-"` | ||
| } |
Author
There was a problem hiding this comment.
So if you apply this changes of testdata/v3/simple/api/api.go and testdata/v3/simple/web/handler.go to the branch v2 and try to generate docs
swag init --v3.1
It'll panic. In this branch it works.
isqua
force-pushed
the
empty-form-field
branch
from
October 29, 2025 21:57
9a724b1 to
3788c63
Compare
sdghchj
approved these changes
Nov 5, 2025
abrar71
added a commit
to abrar71/swag
that referenced
this pull request
Dec 24, 2025
fix: parse form name "-" as skipped field (swaggo#2090)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe the PR
Given following struct with
form:"-"annotation:The tool had panic:
Relation issue
#1639