chrusty / protoc-gen-jsonschema

Protobuf to JSON-Schema compiler
Apache License 2.0
496 stars 101 forks source link

How do I generate json schema for grpc service proto ? #125

Closed yashdesai7 closed 2 years ago

yashdesai7 commented 2 years ago

I would like to use this to generate json schema for service proto which looks like below

service GetSomeThingService {
    rpc Get(stream ClientMessage) returns (stream ServiceMessage);
}

How do I do that ?

I tried generating schema but It only generated schema for ClientMessage and ServiceMessage but not for GetSomeThingService

chrusty commented 2 years ago

Hi @yashdesai7, interesting question here. I'm sorry to say that this project was only ever aiming to generate schemas for the payloads themselves. I'm not even sure that JSONSchema would make much sense of an RPC definition! Have a look at this link here - these guys are discussing this very issue.

I know this is not the answer you were looking for, sorry I can't be of more use here. The only thing which may be of use to you is OpenAPI / Swagger, which is specifically designed to define APIs with request and response payloads. For the most part it maps quite well to JSONSchema.