yoheimuta / go-protoparser

Yet another Go package which parses a Protocol Buffer file (proto2+proto3)
MIT License
166 stars 20 forks source link

found "{" but expected [constant] with nested stuctsx #88

Closed mjudeikis closed 1 month ago

mjudeikis commented 1 month ago

Related to: https://github.com/yoheimuta/protolint/issues/21

There are still cases where it fails to parse annotations: file: parsing proto file: found "{" but expected [constant] when it nested with multiple layers:

Works:

  // Deprecated: use /management/v1/organization
  rpc CreateOrganization(CreateOrganizationRequest) returns (CreateOrganizationResponse) {
    option (google.api.http) = {
      post: "/management/v1/organizations"
      body: "organization"
      response_body: "organization"
    };
    option (foo.rbac.v1beta1.authz) = {
      category: "iam"
      action: "write"
    };
  }

Fails (see added additional_bindings:

  // Deprecated: use /management/v1/organization
  rpc CreateOrganization(CreateOrganizationRequest) returns (CreateOrganizationResponse) {
    option (google.api.http) = {
      post: "/management/v1/organizations"
      additional_bindings: [{ post: "/v1/organizations" }]
      body: "organization"
      response_body: "organization"
    };
    option (foo.rbac.v1beta1.authz) = {
      category: "iam"
      action: "write"
    };
  }

In addition it can be {} and [{}] too