-
Notifications
You must be signed in to change notification settings - Fork 159
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
(feature): Add Protobuf mapper types #4210
Conversation
@@ -55,6 +56,7 @@ types: | |||
variables: list<variables.VariableDeclaration> | |||
serviceTypeReferenceInfo: ServiceTypeReferenceInfo | |||
readmeConfig: optional<ReadmeConfig> | |||
sourceConfig: optional<SourceConfig> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the reality is that the source
can be multiple OpenAPI specs, FernDefinitions or Proto files. Thoughts on making this:
sources:
type: list<ApiDefinitionSource>
docs: The raw API definitions that produced the IR
ApiDefinitionSource:
union:
proto: ProtoSource
openapi: OpenAPISource # can skip for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The C# generator can just handle processing a single (the first) ProtoSource
for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also would be great if each source had a unique ApiDefinitionSourceId
(so that in the future we can mark each type / endpoint with a particular source)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice call - the ProtoSourceConfig
as-is handles the multiple .proto
files (via the root directory URL reference), but it doesn't include mixing and matching between Fern / OpenAPI / Proto.
I wonder if it's worth still wrapping sources
in an object so it's easy to extend later. Thoughts on this mild adjustment?
SourceConfig:
properties:
sources:
docs: The raw API definitions that produced the IR.
type: list<ApiDefinitionSource>
ApiDefinitionSource:
union:
proto: ProtoSource
openapi: {}
* grpc: | ||
* service-name: UserService | ||
*/ | ||
TRANSPORT: "x-fern-transport" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't see any logic that actually pushes thes extensions into the fern definition. is that intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, nothing implemented just yet - just spec'ing out the interface for now. I'll incorporate this when they're used in a follow-up.
Overview
This adds support for gRPC/Protobuf types in IRv53. With this, generators can support mapping Fern-generated types to/from their Protobuf equivalent representation defined in the user's
.proto
file. This includes updating the IR, YAML definition schema, generator configuration, and OpenAPI extensions.Example
Consider the following Protobuf service definition:
We now expose a few new configuration options to annotate the Fern definition with the context necessary to map to and from the
message
types defined inproto/user/v1/user.proto
. In combination, we have a Fern definition that looks like the following:Behind the scenes, this is equivalent to a Fern definition that looks like the following: