Skip to content

[Kotlin] google.api.field_behavior from proto file generates unresolved reference and results in compile error #3198

Open
@karthi2007

Description

@karthi2007

Issue: Compile error on generated kotlin code

Proto file
I have a proto file with field_behavior attribute for a parameter.

import "buf/validate/validate.proto";
import "google/api/field_behavior.proto";

message GetABCRequest {
  string item_id = 1 [
    (buf.validate.field).string = {min_len: 1},
    (google.api.field_behavior) = REQUIRED
  ];
}

Generated code:

import com.google.api.FieldBehavior
import com.google.api.FieldBehaviorOption

public class GetABCRequest(
  @FieldBehaviorOption(value = [
    FieldBehavior.REQUIRED
  ])
  @field:WireField(
    tag = 1,
    adapter = "com.squareup.wire.ProtoAdapter#STRING",
    label = WireField.Label.OMIT_IDENTITY,
    jsonName = "itemId",
    schemaIndex = 0,
  )
  public val item_id: String = "",
  unknownFields: ByteString = ByteString.EMPTY,
) : Message<GetABCRequest, Nothing>(ADAPTER, unknownFields) {

"Config":

wire {
...
protoPath {
        srcJar("com.google.api.grpc:proto-google-common-protos:2.45.1")
        srcJar("build.buf:protovalidate:0.4.2")
    }
...
}

dependencies {
   ...
   implementation("com.google.api.grpc:proto-google-common-protos:2.45.1")
   ...
}

Issue:
Unresolved reference 'FieldBehaviorOption'.

import com.google.api.FieldBehaviorOption

There is no FieldBehaviorOption in google library to refer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions