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: Unclear comments' parser behaviour #352

Closed
utrack opened this issue Apr 6, 2017 · 3 comments
Closed

swagger: Unclear comments' parser behaviour #352

utrack opened this issue Apr 6, 2017 · 3 comments

Comments

@utrack
Copy link
Contributor

utrack commented Apr 6, 2017

// SumRequest is a request for Summator service.
message SumRequest {
  // A is the number we're adding to. Can't be zero for the sake of example.
  int64 a = 1;
  // B is the number we're adding.
  int64 b = 2;
}

This proto message is generated to corresponding doc:

...
      "properties": {
        "a": {
          "type": "string",
          "format": "int64",
          "description": "a is the number we're adding to. can't be zero for the sake of example."
...

But if we'll remove the trailing dot in A's comment then description becomes title:

      "properties": {
        "a": {
          "type": "string",
          "format": "int64",
          "title": "A is the number we're adding to. Can't be zero for the sake of example"

and this title is invisible in the model's outline (see the screenshot).

It is intended judging by the code, but this behaviour clearly breaks Swagger UI.

scrot-20170406_103406

@achew22
Copy link
Collaborator

achew22 commented Apr 10, 2017

Huh, this is strange. Especially strange given that it looks like we have code to handle it. I don't have an answer on what's going on here, but want to document what I have looked at

Doesn't look like we are setting the title at all.

~/Projects/grpc-gateway (master)$ grep "Title =" . -rn
./protoc-gen-swagger/genswagger/template.go:638:                usingTitle = true

Could it be that we are copying the struct from proto into the swagger types somewhere? I didn't think we did that and also It seems like the interfaces would be incompatible and disallow that but that's the best theory I have off the top of my head.

@utrack
Copy link
Contributor Author

utrack commented Apr 10, 2017

@achew22 We've got the (weird) code that decides if comment is description or title here.
It sets Title and Description through reflection (prolly I could refactor it?)

@achew22
Copy link
Collaborator

achew22 commented Dec 14, 2017

The parser has been updated a lot since this bug was filed and I think it's likely fixed if you wanna take another look at it.

@achew22 achew22 closed this as completed Dec 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants