datamodel-code-generator icon indicating copy to clipboard operation
datamodel-code-generator copied to clipboard

Support for protobuf / gRPC

Open chaitan94 opened this issue 5 years ago • 1 comments
trafficstars

Feature request / Problem description. Just like how OpenAPI models are currently supported, probably protobuf can be a great addition. Having this, for example, would especially help in building tools similar to FastAPI, but for gRPC based services.

Solution Adding support for a new InputFileType for protobuf.

Although at a technical level I am not sure how hard this is, or if there are any complications (say in terms of compatibility) which would make this simply impossible.

Alternatives Protobuf itself provides some functionality to generate python code. But the generated code does not really give any benefits in terms of typing. Perhaps, by using pydantic we could change that for the better.

chaitan94 avatar Aug 21 '20 10:08 chaitan94

@chaitan94 Thank you for your great suggestion.

There are two ways to add additional input types.

  1. implement a new parser for the schema. example
  2. convert another schema to json schema before calling json schema parser.

Sorry, I don't know the details of protobf/gRPC. I need another library to support it. Or, PR welcome.

koxudaxi avatar Aug 21 '20 16:08 koxudaxi