How to approach simultaneous description and generation of an HTTP and gRPC and however many operations contracts? #8324
Unanswered
artsiommiksiuk
asked this question in
Q&A
Replies: 1 comment
-
Hm. Look at this, my example is not actually fully equivalent for the get, because common implementation declaring two possibilities, entity found and entity not found, which I'm basically ommiting in gRPC case. @rpc
op createEntity(@field(0) id: string): grpcOk & { id: number };
@rpc
op get(@field(0) id: string): (grpcOk & Entity) | grpcNotFound; Assuming there are some equivalent ok and notFound structures to mix in, though structurally different, still is not clear how to then proceed? Filter out by decorators, like with json-schema? Then merged definition might be @post
@rpc
op createEntity(@field(0) @path id: string): OkResponse & grpcOk & { id: number };
@get
@rpc
op get(@field(0) @path id: string): (OkResponse & grpcOk & Entity) | (NotFoundResponse & grpcNotFound); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
If I were to emmit and implement simultaneously functionally equivalent contracts in HTTP and gRPC how would I declare and emit them in a non conflicting way?
E.g, simplest protocol independent definition of some operation.
For Http case definition will look like this:
For gRPC case it might look like:
It is clear that two definitions are not compatible and I don't know clear ways of separating them for two emitters, except having two different definitions, which kinda sucks, as I was thinking that typespec can achieve common ground and declare once and emit to multiple targets.
So, how would one achieve that with TypeSpec?
Beta Was this translation helpful? Give feedback.
All reactions