Skip to content

Commit

Permalink
fix: mixins override command line processing (#1277)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-fenster committed Sep 27, 2022
1 parent 89c21e0 commit 03bf5a7
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
4 changes: 3 additions & 1 deletion typescript/src/gapic-generator-typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,9 @@ yargs.boolean('rest-numeric-enums');
yargs.alias('rest-numeric-enums', 'rest_numeric_enums');
yargs.describe(
'mixins',
'Override the list of mixins to use. Comma-separated list of API names to mixin, e.g. google.longrunning.Operations. Use "none" to disable all mixins.'
'Override the list of mixins to use. Semicolon-separated list of API names to mixin, e.g. google.longrunning.Operations. Use "none" to disable all mixins.'
);
yargs.string('mixins');
yargs.describe('protoc', 'Path to protoc binary');
yargs.usage('Usage: $0 -I /path/to/googleapis');
yargs.usage(' --output_dir /path/to/output_directory');
Expand All @@ -139,6 +140,7 @@ export interface IArguments {
handwrittenLayer?: boolean;
legacyProtoLoad?: boolean;
restNumericEnums?: boolean;
mixins?: string;
_: string[];
$0: string;
}
Expand Down
5 changes: 3 additions & 2 deletions typescript/src/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export class Generator {
this.serviceYaml.apis = serviceMixins;
}
// override if needed
if (this.mixinsOverride) {
if (this.mixinsOverride !== undefined) {
if (!this.serviceYaml) {
this.serviceYaml = {title: '', apis: [], http: {rules: []}};
}
Expand Down Expand Up @@ -234,7 +234,7 @@ export class Generator {

private readMixins() {
if (this.paramMap['mixins']) {
this.mixinsOverride = this.paramMap['mixins'].split(',');
this.mixinsOverride = this.paramMap['mixins'].split(';');
}
}

Expand Down Expand Up @@ -299,6 +299,7 @@ export class Generator {
handwrittenLayer: this.handwrittenLayer,
legacyProtoLoad: this.legacyProtoLoad,
restNumericEnums: this.restNumericEnums,
mixinsOverridden: this.mixinsOverride !== undefined,
});
return api;
}
Expand Down
1 change: 1 addition & 0 deletions typescript/src/schema/naming.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface Options {
handwrittenLayer?: boolean;
legacyProtoLoad?: boolean;
restNumericEnums?: boolean;
mixinsOverridden?: boolean;
}

export class Naming {
Expand Down
3 changes: 2 additions & 1 deletion typescript/src/schema/proto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,8 @@ function augmentService(parameters: AugmentServiceParameters) {
parameters.options.serviceYaml?.apis.includes(
'google.longrunning.Operations'
) &&
hasLroMethods
// enable LRO mixin if either LRO methods exist, or overridden by an option
(hasLroMethods || parameters.options.mixinsOverridden)
) {
augmentedService.LongRunningOperationsMixin = 1;
}
Expand Down

0 comments on commit 03bf5a7

Please sign in to comment.