-
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
protoc-gen-swagger: add support for arbitrary extensions #1033
protoc-gen-swagger: add support for arbitrary extensions #1033
Conversation
d3055f2
to
9d5620c
Compare
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.
This seems reasonable to me, thanks for including an example in a_little_bit_of_everything.proto
. I'd like @ivucica's thoughts on this before merging though.
@johanbrandhorst Ultimately, I want extensions on operations, so if @ivucica agrees with the gist of this, I'd add extensions on the other places where they're valid. |
Codecov Report
@@ Coverage Diff @@
## master #1033 +/- ##
==========================================
+ Coverage 53.62% 53.89% +0.26%
==========================================
Files 40 40
Lines 4052 4125 +73
==========================================
+ Hits 2173 2223 +50
+ Misses 1674 1659 -15
- Partials 205 243 +38
Continue to review full report at Codecov.
|
started with tests. added another TODO (ordering!) |
f72b737
to
dda6116
Compare
|
Using google.protobuf.Value isn't the nicest solution here, but with map<string, google.protobuf.Any> extensions = 15; I could not find a way to specify those in a_bit_of_everything.proto that would have passed through protoc. Signed-off-by: Stephan Renatus <srenatus@chef.io>
Signed-off-by: Stephan Renatus <srenatus@chef.io>
Signed-off-by: Stephan Renatus <srenatus@chef.io>
Signed-off-by: Stephan Renatus <srenatus@chef.io>
Signed-off-by: Stephan Renatus <srenatus@chef.io>
791d22a
to
712a868
Compare
with no output, but exit code 1, is a bit mysterious to me 😕 |
I agree with the switch to (Having said this, I think (Having having said this, yes, |
If you'd like me to take another look, please re-notify me when this is ready for review. Thanks! |
Signed-off-by: Stephan Renatus <srenatus@chef.io>
Signed-off-by: Stephan Renatus <srenatus@chef.io>
Signed-off-by: Stephan Renatus <srenatus@chef.io>
Signed-off-by: Stephan Renatus <srenatus@chef.io>
Sooo.... I've added extension points everywhere I thought they belonged. I'm not 100% certain about the stuff I haven't covered, but I'm also not entire sure about what the OpenAPIv2 docs try to tell me. I'd be happy if this went in regardless 😅 Also needs squashing, but I kept that for post-review. |
Fixing the missing pb.go and the bazel rule. |
Signed-off-by: Stephan Renatus <srenatus@chef.io>
Signed-off-by: Stephan Renatus <srenatus@chef.io>
…ment Dropping the `-` would make `x-foobar` and `x-foo-bar` clash. Replacing with `_` doesn't. Signed-off-by: Stephan Renatus <srenatus@chef.io>
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, @ivucica?
There does seem to be an actual test failure:
|
Hrm weirdly, those pass locally 😕 I'm looking into it... |
Ah 💡 found the problem, I think. Fixing incoming. |
Signed-off-by: Stephan Renatus <srenatus@chef.io>
Thanks, any final thoughts @ivucica? |
So, not rushing this, but I've got some time on my hands today, and very little of it in the near future. I'd appreciate another look @ivucica 😉 |
LG |
Thanks for your contribution! |
…tem#1033) * protoc-gen-swagger: add support for arbitrary top-level extensions Using google.protobuf.Value isn't the nicest solution here, but with map<string, google.protobuf.Any> extensions = 15; I could not find a way to specify those in a_bit_of_everything.proto that would have passed through protoc. Signed-off-by: Stephan Renatus <srenatus@chef.io> * protoc-gen-swagger: ensure keys start with 'x-' Signed-off-by: Stephan Renatus <srenatus@chef.io> * protoc-gen-swagger: start with tests Signed-off-by: Stephan Renatus <srenatus@chef.io> * protoc-gen-swagger/genswagger: sort extensions by key, expand test Signed-off-by: Stephan Renatus <srenatus@chef.io> * protoc-gen-swagger/genswagger: add custom Extensions to SecurityScheme Signed-off-by: Stephan Renatus <srenatus@chef.io> * protoc-gen-swagger/genswagger: add custom Extensions to Info Signed-off-by: Stephan Renatus <srenatus@chef.io> * protoc-gen-swagger/genswagger: add custom Extensions to Operation Signed-off-by: Stephan Renatus <srenatus@chef.io> * protoc-gen-swagger/genswagger: add custom Extensions to Response Signed-off-by: Stephan Renatus <srenatus@chef.io> * protoc-gen-swagger/genswagger: add comment and links Signed-off-by: Stephan Renatus <srenatus@chef.io> * update a_bit_of_everything.pb.go Signed-off-by: Stephan Renatus <srenatus@chef.io> * update protoc-gen-swagger/genswagger/BUILD.bazel Signed-off-by: Stephan Renatus <srenatus@chef.io> * update protoc-gen-swagger/genswagger: fix internal struct key replacement Dropping the `-` would make `x-foobar` and `x-foo-bar` clash. Replacing with `_` doesn't. Signed-off-by: Stephan Renatus <srenatus@chef.io> * TestApplyTemplateExtensions: fix test Signed-off-by: Stephan Renatus <srenatus@chef.io>
Using google.protobuf.Value perhaps isn't the nicest solution here, but with
I could not find a way to specify those in
a_bit_of_everything.proto
that would have passed through protoc.
Instead of
I have tried
following the example of this blog post,
but I've ended up with a
protoc
call stuck withfutex(0x2534960, FUTEX_WAIT_PRIVATE, 2, NULL
, see this backtrace: https://gist.github.com/srenatus/ba63e837673a28ba15fcef64cdb6abe0Also, it's not clear how we'd have truely arbitrary messages, i.e. nothing like
google.protobuf.*
, resolved there properly....This is just the first bit -- these extensions go in many places, see https://swagger.io/docs/specification/2-0/swagger-extensions/.
TODO:
map[string]something
)tags-- don't seem to be exposed in a way that allows for adding extensions