-
Notifications
You must be signed in to change notification settings - Fork 54
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
feat: support providing examples for pointer fields #56
Conversation
Codecov Report
@@ Coverage Diff @@
## master #56 +/- ##
==========================================
+ Coverage 95.33% 95.88% +0.55%
==========================================
Files 7 7
Lines 900 924 +24
==========================================
+ Hits 858 886 +28
+ Misses 27 22 -5
- Partials 15 16 +1
Continue to review full report at Codecov.
|
2a0bec3
to
27813d4
Compare
@nikicc However, I noticed that it was lacking support for pointer-chain fields, such as Please, don't hesitate to comment and/or give a feddback on my changes. |
@wI2L great, will check. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wI2L other than the coverage complaining, LGTM 👍
I am looking into it to add more tests cases. |
@wI2L as far as I'm concerned, this can go in. Do you have something else you want to add or can we merge? |
The issue
Currently, the
example
tag will not work for fields that are pointers to other types. For example, for this struct:the
valA
will be present in the generated spec, whilevalB
will not.Reasoning
As having pointers to other types is the simplest solution to get
null
values in the JSON responses for missing data (instead of the Go defaults for the corresponding type), I think theexample
tag should also work for pointers.Proposed solution
When parsing the
example
tag values, if we get a pointer, try to parse the value that pointer points to.