-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Allow explicit empty security definition to overwrite existing definitions #666
Allow explicit empty security definition to overwrite existing definitions #666
Conversation
I wonder why the https://travis-ci.org/grpc-ecosystem/grpc-gateway/builds/390065893 build fails in |
The test failure looks to be because some of example files are out-of-date. c.f. golang/protobuf@05f48f4#diff-8c603013608023320d5242916c4ea03bR1571 Would you mind running |
@yugui
|
The error has been fixed at d1985fc . The https://travis-ci.org/grpc-ecosystem/grpc-gateway/jobs/390576866 job for |
@co3k thanks for your contribution, can you rebase this so CI runs again? |
d1985fc
to
4f318d7
Compare
@tmc Thanks for your response but the https://travis-ci.org/grpc-ecosystem/grpc-gateway/jobs/394549559#L554-L557 test is failed that is due to timed out in go get phase. I cannot rebase it again because the upstream is not updated yet. How should I do next? |
I have re-triggered the job. |
@@ -105,7 +105,7 @@ type swaggerOperationObject struct { | |||
Tags []string `json:"tags,omitempty"` | |||
Deprecated bool `json:"deprecated,omitempty"` | |||
|
|||
Security []swaggerSecurityRequirementObject `json:"security,omitempty"` | |||
Security *[]swaggerSecurityRequirementObject `json:"security,omitempty"` |
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.
Is this required? Can't we just have an empty slice?
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.
Required. The omitempty
tag removes an empty slice. However we don't want to print null
value in every JSON response so we can't remove this omitempty
tag.
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.
OK
} else { | ||
newSecurity = operationObject.Security | ||
if operationObject.Security != nil { | ||
newSecurity = *operationObject.Security | ||
} |
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.
Can we not just set newSecurity = nil
when operationObject.Security == 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.
I think we really need empty slice in this case.
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.
OK
As with the other PR, could you please squash the commits? Thank you. |
@@ -274,6 +274,8 @@ service ABitOfEverythingService { | |||
url: "https://github.com/grpc-ecosystem/grpc-gateway"; | |||
description: "Find out more about GetQuery"; | |||
} | |||
security: { | |||
} |
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.
The indendation of this line seems off, are you using spaces instead of tabs?
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.
Sorry, I've fixed it in a78ff38 (I'll squash this commit later)
Could you also please reword this title, description and commit message to clearly state the intent please? Something along the lines of: Allow explicit empty security definition to overwrite existing definitions. |
…tions. It enables to clear default security configuration in operationObject.Security (to make public api). protoc-gen-swagger doesn't allow empty array (and it causes segfault) in operationObject.Security but it is really needed resetting security requirement configuration by Swagger.
a78ff38
to
dcd2104
Compare
Codecov Report
@@ Coverage Diff @@
## master #666 +/- ##
==========================================
- Coverage 56.49% 56.42% -0.08%
==========================================
Files 30 30
Lines 3004 3006 +2
==========================================
- Hits 1697 1696 -1
- Misses 1144 1146 +2
- Partials 163 164 +1
Continue to review full report at Codecov.
|
@johanbrandhorst Thanks for your advice! I've squashed commits and changed the title of this pull request and the first commit to follow your suggestion. |
Thank you for your contribution! |
It enables to clear default security configuration in operationObject.Security (to make public api).
protoc-gen-swagger doesn't allow empty array (and it causes segfault) in operationObject.Security but it is really needed resetting security requirement configuration by Swagger.