Skip to content
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

Swagger example field #847

Closed

Conversation

srenatus
Copy link
Contributor

@srenatus srenatus commented Jan 9, 2019

Picked up and rebased @birdayz's work on making the example field available.

@johanbrandhorst do we have any tests that could be expanded to cover that new field?

(💭 let's see what happens in CI -- locally, the swagger.json got a bit different when running make examples/proto/examplepb/a_bit_of_everything.swagger.json...)

@googlebot
Copy link

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of all the commit author(s), set the cla label to yes (if enabled on your project), and then merge this pull request when appropriate.

@srenatus
Copy link
Contributor Author

srenatus commented Jan 9, 2019

ok, mistake 1: I should have rebuilt the other stuff, too, of course 😅

@johanbrandhorst
Copy link
Collaborator

Ah, yes, the CLA bot will not like the different approvers. Could you, uh, force push a new history with just your commits?

@johanbrandhorst
Copy link
Collaborator

To regenerate files, see https://github.com/grpc-ecosystem/grpc-gateway/blob/master/CONTRIBUTING.md#i-want-to-regenerate-the-files-after-making-changes

@srenatus
Copy link
Contributor Author

srenatus commented Jan 9, 2019

Ah, yes, the CLA bot will not like the different approvers. Could you, uh, force push a new history with just your commits?

Sure, but that'll only work if it's branched off of #799 or that other PR is merged first (and this rebased) -- which one do you prefer? 😉

@johanbrandhorst
Copy link
Collaborator

johanbrandhorst commented Jan 9, 2019

I imagine you could just rebase on master and squash the commits so they become yours? I mean, @birdayz can be mentioned as an author in the commit still.

@srenatus
Copy link
Contributor Author

srenatus commented Jan 9, 2019

OK, will do.

use json.RawMessage for property & object examples

with json.RawMessage, users can supply complete json for swagger objects (i.e.
for a proto Message). If it's correct json, it will be added to the output.json
and rendered correctly by consuming applications (i.e. code generators or
swagger-ui)

Example, in proto:
option (grpc.gateway.protoc_gen_swagger.options.openapiv2_schema) = {
  example: {
    value:
    '{"someKey" : "someValue", "anotherKey" : 5}';
  };
};

Rendered JSON:
"example": {
  "someKey": "someValue",
  "anotherKey": 5
}

If we used string instead of json.RawMessage, the serializer would escape the
quotes and it would be serialized as a string. This is not desirable, because
the output should be in fact JSON key/value pairs.

Also:

* a_bit_of_everything.proto: add 'example' example

Co-authored-by: Johannes Brüderl <[email protected]>
Signed-off-by: Stephan Renatus <[email protected]>
@srenatus srenatus force-pushed the swagger_example_field branch from 5a48d37 to 1e7e5ef Compare January 9, 2019 15:05
@srenatus
Copy link
Contributor Author

srenatus commented Jan 9, 2019

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of all the commit author(s), set the cla label to yes (if enabled on your project), and then merge this pull request when appropriate.

This makes me think that this won't fix itself, though... 🤔 Can you change the label, or should I just open another PR?

@codecov-io
Copy link

Codecov Report

Merging #847 into master will decrease coverage by 0.05%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #847      +/-   ##
==========================================
- Coverage   50.46%   50.41%   -0.06%     
==========================================
  Files          39       39              
  Lines        3761     3765       +4     
==========================================
  Hits         1898     1898              
- Misses       1681     1685       +4     
  Partials      182      182
Impacted Files Coverage Δ
protoc-gen-swagger/genswagger/types.go 19.04% <ø> (ø) ⬆️
protoc-gen-swagger/genswagger/template.go 42.24% <0%> (-0.19%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9ae9465...1e7e5ef. Read the comment docs.

@johanbrandhorst
Copy link
Collaborator

I don't have the permission to change it since I'm not a google administrator 😬. I suppose try and create a new one 😂.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants