-
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
Struct fields supported for header and path param types #1740
Struct fields supported for header and path param types #1740
Conversation
Looking at rebasing this and fixing the conflicts - I'm not sure if the change introduced in #1706 @sdghchj what do you think about this? Should all the fields trim "[]"? I'm not so sure. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1740 +/- ##
==========================================
+ Coverage 83.25% 83.32% +0.06%
==========================================
Files 16 16
Lines 3811 3815 +4
==========================================
+ Hits 3173 3179 +6
+ Misses 542 541 -1
+ Partials 96 95 -1 ☔ View full report in Codecov by Sentry. |
[] is trivial, make nonsense.
trim them.
…------------------ Original ------------------
From: Joe Shaw ***@***.***>
Date: Thu,Jan 18,2024 7:48 PM
To: swaggo/swag ***@***.***>
Cc: sdghchj ***@***.***>, Mention ***@***.***>
Subject: Re: [swaggo/swag] Struct fields supported for header and path paramtypes (PR #1740)
Looking at rebasing this and fixing the conflicts - I'm not sure if the change introduced in #1706 return strings.TrimRight(strings.TrimSpace(strings.Split(ps.tag.Get(formTag), ",")[0]), "[]") is in fact backwards compatible - what about API definitions where people want to include the [] characters at the end of their parameter names? While not common, it could cause unwanted doc changes.
@sdghchj what do you think about this? Should all the fields trim "[]"? I'm not so sure.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Add initial struct test for header names and validation.
wip: fix merge
42d478d
to
c7eb9f5
Compare
Fair enough - rebased and updated. |
Describe the PR
Supports "object" (i.e. struct model) data types for
header
andpath
parameter types via@Param
operation comment in the same way thatquery
andformData
already work - basic structs are supported to represent multiple paramters at once.This allows struct models, e.g. for a number of related headers, to be used directly rather than duplicating all the
@Param
comments for every field in those structs.This works similarly to existing
formData
andquery
types and largely reuses all the same operation parsing logic.In addition this supports using struct tags
header:"name"
anduri:"name"
forheader
andpath
params respectively. This follows the Gin specific tag naming conventions.Relation issues
A few issues with similar feature requests: