-
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: support all well-known wrapper types #695
protoc-gen-swagger: support all well-known wrapper types #695
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here (e.g. What to do if you already signed the CLAIndividual signers
Corporate signers
|
I signed it! |
CLAs look good, thanks! |
Hi @jriecken! Thanks for your contribution! The idea looks good, unfortunately, it looks like your changes caused an issue with the marshal_jsonpb_test.go:274: strings.Contains("{\"singleNested\":{},\"uuid\":\"6EC2446F-7E89-4127-B3E6-5C05E6BECBA7\",\"nested\":[{\"name\":\"foo\",\"amount\":12345}],\"uint64Value\":\"18446744073709551615\",\"repeatedStringValue\":[],\"oneofString\":\"bar\",\"mapValue\":{\"a\":\"ONE\",\"b\":\"ZERO\"},\"mappedStringValue\":{},\"mappedNestedValue\":{},\"timestampValue\":\"1970-01-01T00:00:00Z\",\"repeatedEnumValue\":[]}", "ONE") = true; want false If I had to guess, I think you might need to add these new types to to the test as well. Other than that, looks good! |
It looks like this was caused by an upstream bugfix in The JSON generated by that {"singleNested":{},"uuid":"6EC2446F-7E89-4127-B3E6-5C05E6BECBA7","nested":[{"name":"foo","amount":12345}],"uint64Value":"18446744073709551615"
,"repeatedStringValue":[],"oneofString":"bar","mapValue":{"a":1,"b":0},"mappedStringValue":{},"mappedNestedValue":{},"timestampValue":"1970-01-01T00:00:00Z","repeatedEnumValue":[
]} and after: {"singleNested":{},"uuid":"6EC2446F-7E89-4127-B3E6-5C05E6BECBA7","nested":[{"name":"foo","amount":12345}],"uint64Value":"18446744073709551615"
,"repeatedStringValue":[],"oneofString":"bar","mapValue":{"a":"ONE","b":"ZERO"},"mappedStringValue":{},"mappedNestedValue":{},"timestampValue":"1970-01-01T00:00:00Z","repeatedEnu
mValue":[]} Note how the I'll update the test to match the fixed behavior from |
One of the browser tests was also assuming integer enum values - fixed it too |
Looks like we still need some regeneration of files. |
One of the travis runs failed because protoc generated a file descriptor The Bazel version of the build also failed (it must somehow be pulling in a different version of I feel like I'm very quickly going down a rabbit hole in |
I was using the latest version of |
I did a little more digging and the Bazel Go rules pin the The non-Bazel build uses |
So it seems we have a mismatch of versions between that pinned by Bazel and that fetched in the normal test runs. Presumably this means we cannot get a successful build unless we change one of the two. I'm not comfortable with making the call here but I would assume we'd be more keen to pin versions to releases, so assuming that, how do we pin the non-Bazel tests? This might well not be fixable until something like #689 is done. |
Release |
#696 should hopefully fix these dependency inconsistencies. Then this PR should be easy to merge. |
There were a few well-known wrapper types missing from the wkSchemas map. In specific UInt32Value, UInt64Value and BytesValue. This change handles them (and maps them to the same swagger types as the non-wrapped values) This also fixes the mapping of Int64Value. The Int64Value handling maps the value to a swagger integer. The documentation for Int64Value indicates that it should be mapped to a JSON string (also the mapping for normal int64 in protoc-gen-swagger maps it to a string, so this was inconsistent.)
f4d2348
to
bf62347
Compare
Codecov Report
@@ Coverage Diff @@
## master #695 +/- ##
==========================================
- Coverage 56.54% 56.43% -0.12%
==========================================
Files 30 30
Lines 3040 3046 +6
==========================================
Hits 1719 1719
- Misses 1152 1158 +6
Partials 169 169
Continue to review full report at Codecov.
|
Done |
Great, this LGTM! |
@johanbrandhorst @jriecken
Right now when I compile using protoc:
I get the error: |
That should absolutely work, I can't see why that is erroring. Could you raise an issue please? |
Created: #808 |
There were a few well-known wrapper types missing from the
wkSchemas
map, in specific:UInt32Value
,UInt64Value
andBytesValue
. This change handles them (and maps them to the same swagger types as the non-wrapped values)This also fixes the mapping of
Int64Value
. TheInt64Value
handling maps the value to a swaggerinteger
. The documentation forInt64Value
indicates that it should be mapped to a JSONstring
(also the mapping for normalint64
inprotoc-gen-swagger
maps it to astring
, so this was inconsistent.)