Skip to content
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

fix: Fix generating wrong web-rpc implementation for wrapper-type method arg #978

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified integration/grpc-web/example.bin
Binary file not shown.
3 changes: 2 additions & 1 deletion integration/grpc-web/example.proto
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
syntax = "proto3";

import "google/protobuf/wrappers.proto";
package rpx;

service DashState {
Expand Down Expand Up @@ -40,6 +40,7 @@ service DashAPICreds {
rpc Create(DashAPICredsCreateReq) returns (DashCred);
rpc Update(DashAPICredsUpdateReq) returns (DashCred);
rpc Delete(DashAPICredsDeleteReq) returns (DashCred);
rpc Uppercase(google.protobuf.StringValue) returns (google.protobuf.StringValue);
}

message DashCred {
Expand Down
30 changes: 30 additions & 0 deletions integration/grpc-web/example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { BrowserHeaders } from "browser-headers";
import * as _m0 from "protobufjs/minimal";
import { Observable } from "rxjs";
import { share } from "rxjs/operators";
import { StringValue } from "./google/protobuf/wrappers";

export const protobufPackage = "rpx";

Expand Down Expand Up @@ -826,6 +827,7 @@ export interface DashAPICreds {
Create(request: DeepPartial<DashAPICredsCreateReq>, metadata?: grpc.Metadata): Promise<DashCred>;
Update(request: DeepPartial<DashAPICredsUpdateReq>, metadata?: grpc.Metadata): Promise<DashCred>;
Delete(request: DeepPartial<DashAPICredsDeleteReq>, metadata?: grpc.Metadata): Promise<DashCred>;
Uppercase(request: DeepPartial<StringValue>, metadata?: grpc.Metadata): Promise<StringValue>;
}

export class DashAPICredsClientImpl implements DashAPICreds {
Expand All @@ -836,6 +838,7 @@ export class DashAPICredsClientImpl implements DashAPICreds {
this.Create = this.Create.bind(this);
this.Update = this.Update.bind(this);
this.Delete = this.Delete.bind(this);
this.Uppercase = this.Uppercase.bind(this);
}

Create(request: DeepPartial<DashAPICredsCreateReq>, metadata?: grpc.Metadata): Promise<DashCred> {
Expand All @@ -849,6 +852,10 @@ export class DashAPICredsClientImpl implements DashAPICreds {
Delete(request: DeepPartial<DashAPICredsDeleteReq>, metadata?: grpc.Metadata): Promise<DashCred> {
return this.rpc.unary(DashAPICredsDeleteDesc, DashAPICredsDeleteReq.fromPartial(request), metadata);
}

Uppercase(request: DeepPartial<StringValue>, metadata?: grpc.Metadata): Promise<StringValue> {
return this.rpc.unary(DashAPICredsUppercaseDesc, StringValue.fromPartial(request), metadata);
}
}

export const DashAPICredsDesc = { serviceName: "rpx.DashAPICreds" };
Expand Down Expand Up @@ -922,6 +929,29 @@ export const DashAPICredsDeleteDesc: UnaryMethodDefinitionish = {
} as any,
};

export const DashAPICredsUppercaseDesc: UnaryMethodDefinitionish = {
methodName: "Uppercase",
service: DashAPICredsDesc,
requestStream: false,
responseStream: false,
requestType: {
serializeBinary() {
return StringValue.encode(this).finish();
},
} as any,
responseType: {
deserializeBinary(data: Uint8Array) {
const value = StringValue.decode(data);
return {
...value,
toObject() {
return value;
},
};
},
} as any,
};

interface UnaryMethodDefinitionishR extends grpc.UnaryMethodDefinition<any, any> {
requestStream: any;
responseStream: any;
Expand Down
Loading
Loading