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
Implement error (and any) like interface #1212
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1212 +/- ##
==========================================
- Coverage 95.02% 94.96% -0.07%
==========================================
Files 12 12
Lines 2515 2524 +9
==========================================
+ Hits 2390 2397 +7
- Misses 68 69 +1
- Partials 57 58 +1
Continue to review full report at Codecov.
|
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.
Good job! Please write unit test to cover new added functionality
if IsInterfaceLike(typeName) { | ||
return &spec.Schema{}, nil | ||
} |
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.
We need to cover this with unit tests.
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.
It should already be covered by TestGen_ErrorAndInterface
and TestIsInterfaceLike
but I can recheck.
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.
I added a test similar to TestGen_ErrorAndInterface based on testdata in the root package.
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.
LGTM
This manage error and any like interface.
Previously, any would result in a primitive type
any
which seem not valid in swagger definition.This basically, set an empty definition like for
interface{}
previously forany
anderror
types.Relation issue
error
as a Primitive Type #1188Additional context
This fix cases when you cannot override with tag
swaggertype
in case the struct is from an external dependency.Previously this case need to redefine the struct locally to override the field type but can be cumbersome in case of deeply nested struct and It is also not possible to override go types with .swaggo file.
I first try to implement like suggested in this comment but after reviewing some cases (like in the testdata test) this feel better and more logical to consider error (and any) like interface. Let me know if it doesn't fit you.