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

Support Service doc comments for OpenApi/Swagger generation #4419

Open
seanlaff opened this issue Jun 6, 2024 · 4 comments
Open

Support Service doc comments for OpenApi/Swagger generation #4419

seanlaff opened this issue Jun 6, 2024 · 4 comments

Comments

@seanlaff
Copy link
Contributor

seanlaff commented Jun 6, 2024

For methods we can control the OpenAPI title/description via comments

// Update a book
//
// This method updates a book
 rpc UpdateBook(UpdateBookRequest) returns (Book) { 
   option (google.api.http) = { 
     patch: "/v1/{book.name=publishers/*/books/*}" 
     body: "book" 
   }; 
 } 

However, I can't find any documentation for doing the same at the service level, and I don't see it in ABitOfEverything.proto. I'd like to do

// Book
//
// Methods of interacting with books
service BookService {
}

and have it function as if I did

service BookService {
  option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_tag) = {
    name: "Book"
    description: "Methods of interacting with books"
  }
}
@johanbrandhorst
Copy link
Collaborator

HI, thanks for your issue! I can't tell if this is a straightforward mapping, is a openapiv2_tag analogous to a service? I'd be happy to look at a PR that experiments with this idea to see if it makes sense.

@seanlaff
Copy link
Contributor Author

Yup, that is the distinction the generator currently makes. Of note is that all the methods attached to a service need to point to the renamed openapiv2_tag, and not the original name, else they won't render properly in the swagger UIs. I imagine a first pass at this issue may run into the same issues as described in #3829 (comment)

@ankur-kalita
Copy link

heyy @seanlaff can you please assign this issue to me ?

@johanbrandhorst
Copy link
Collaborator

There's no need for assignments, if you want to work on this, go ahead.

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

No branches or pull requests

3 participants