datamodel-code-generator
datamodel-code-generator copied to clipboard
Support for protobuf / gRPC
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 Thank you for your great suggestion.
There are two ways to add additional input types.
- implement a new parser for the schema. example
- 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.