gapic-generator-typescript icon indicating copy to clipboard operation
gapic-generator-typescript copied to clipboard

Secret Manager doesn't tell me which parameters are required

Open JustinBeckwith opened this issue 4 years ago • 2 comments

Looking at this ol favorite:

const sm = new SecretManagerServiceClient();
const [secrets] = await sm.listSecrets({
  parent: 'projects/el-gato',
});

Looking at the listSecrets method, I see it takes an options bag. Great! I dig deeper:

listSecrets(request: protos.google.cloud.secretmanager.v1.IListSecretsRequest, options?: gax.CallOptions): Promise<[protos.google.cloud.secretmanager.v1.ISecret[], protos.google.cloud.secretmanager.v1.IListSecretsRequest | null, protos.google.cloud.secretmanager.v1.IListSecretsResponse]>;

Ok, fine, what does IListSecretsRequest look like:

/** Properties of a ListSecretsRequest. */
interface IListSecretsRequest {

    /** ListSecretsRequest parent */
    parent?: (string|null);

    /** ListSecretsRequest pageSize */
    pageSize?: (number|null);

    /** ListSecretsRequest pageToken */
    pageToken?: (string|null);
}

This has 2 separate problems:

  1. I have no idea which of these parameters are required. I know that when I ran my code without it, I got an exception for not passing a parent :)

  2. I have no idea what any of these properties mean (I mean I do, but a mortal wouldn't). Aren't there better descriptions somewhere for these properties in the protos?

JustinBeckwith avatar Sep 02 '20 15:09 JustinBeckwith

This one is a valid bugreport / feature request. We do have comments in protos, but apparently protobuf.js ignores the //-style comments (it wants /* */-style comments). I even proposed the hacky way to fix it https://github.com/googleapis/gapic-generator-typescript/pull/150 but we decided it must be fixed in protobuf.js.

I think there might be an option for that, I'll try to figure out.

alexander-fenster avatar Sep 03 '20 00:09 alexander-fenster

re: required fields - we mark required fields in protos (with annotations) but those annotations don't map well into the types generated by pbts. I need to think how to make it better.

alexander-fenster avatar Sep 03 '20 00:09 alexander-fenster