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(protoc-gen-go-http): buildMethodDesc for two and more message field #1979

Merged
merged 1 commit into from
May 16, 2022

Conversation

nikitaksv
Copy link
Contributor

@nikitaksv nikitaksv commented May 14, 2022

Description (what this PR does / why we need it):
Generator cannot parse multiple message fields and i fixed it ;)

I have RPC method:

  rpc UpsertLevel (UpsertLevelRequest) returns (UpsertLevelResponse) {
    option (google.api.http) = {
      post: "/v1/organization/{level.organization_id}/levels"
      body: "level"
      response_body: "level"
      additional_bindings: {
        put: "/v1/organizations/{level.organization_id}/levels/{level.id}"
        body: "level"
        response_body: "level"
      }
    };
  }

and message:

message UpsertLevelRequest {
  message Level {
    string id = 1;
    string organization_id = 2;
    // ... and other fields
  }
  Level level = 1;
}

An error occurs during generation: ERROR: The corresponding field 'level.id' declaration in message could not be found in '/v1/organizations/{level.organization_id}/levels/{level.id}'

The error was in the method buildMethodDesc. The "fields" variable overwrote the fields of the child message "message.field".
Now I update the "fields" variable inside the "vars" loop in order to restore the "fields" of the initial message.

@nikitaksv nikitaksv changed the title A bug fix: buildMethodDesc for two and more message field fix(protoc-gen-go-http): buildMethodDesc for two and more message field May 14, 2022
Copy link
Member

@tonybase tonybase left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@codecov-commenter
Copy link

codecov-commenter commented May 15, 2022

Codecov Report

Merging #1979 (c5c9f95) into main (ddc82ce) will increase coverage by 0.11%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main    #1979      +/-   ##
==========================================
+ Coverage   80.71%   80.82%   +0.11%     
==========================================
  Files          82       82              
  Lines        3635     3635              
==========================================
+ Hits         2934     2938       +4     
+ Misses        494      492       -2     
+ Partials      207      205       -2     
Impacted Files Coverage Δ
config/file/file.go 66.66% <0.00%> (+4.76%) ⬆️
config/file/watcher.go 65.62% <0.00%> (+6.25%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ddc82ce...c5c9f95. Read the comment docs.

@tonybase tonybase merged commit ed144f6 into go-kratos:main May 16, 2022
@nikitaksv nikitaksv deleted the fix-gen-go-http branch May 17, 2022 10:46
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 this pull request may close these issues.

None yet

4 participants