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

Did not work well with path param syntax #32

Open
RyoJerryYu opened this issue Dec 14, 2024 · 0 comments · May be fixed by #33
Open

Did not work well with path param syntax #32

RyoJerryYu opened this issue Dec 14, 2024 · 0 comments · May be fixed by #33

Comments

@RyoJerryYu
Copy link

RyoJerryYu commented Dec 14, 2024

In AIP-127 , Google introduces a {foo=bar/*} syntax for populating a variable to the URI, that the extracted value would with a bar/ prefix. gRPC-Gateway golang server works well with this syntax.

However, this plugin seems did not support this syntax well.

For example, I have a proto file containing this:

https://github.com/usememos/memos/blob/9612c302c4e897057967112be37f1d4adc0c061c/proto/api/v1/user_service.proto#L25-L29

  // GetUser gets a user by name.
  rpc GetUser(GetUserRequest) returns (User) {
    option (google.api.http) = {get: "/api/v1/{name=users/*}"};
    option (google.api.method_signature) = "name";
  }

And with this plugin, the generated code becomes:

  static GetUser(this:void, req: GetUserRequest, initReq?: fm.InitReq): Promise<User> {
    return fm.fetchRequest<User>(`/api/v1/${req.name=users/*}?${fm.renderURLSearchParams(req, ["name=users/*"])}`, {...initReq, method: "GET"});
  }

Which should be a syntax error near ${req.name=users/*} .

@RyoJerryYu RyoJerryYu changed the title Did not work well with Did not work well with path param syntax Dec 14, 2024
@RyoJerryYu RyoJerryYu linked a pull request Dec 15, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant