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: camel case for multiple capital letters #1149

Merged
merged 1 commit into from
Jun 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ service Naming {
body: "*"
};
}

rpc createABCDESomething(google.protobuf.Empty) returns (google.protobuf.Empty) {
option (google.api.http) = {
post: "/v1beta1/naming:createABCDESomething"
body: "*"
};
}

}

message PaginatedMethodRequest {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **



'use strict';

function main() {
// [START localhost_v1beta1_generated_Naming_createABCDESomething_async]
/**
* TODO(developer): Uncomment these variables before running the sample.
*/

// Imports the Naming library
const {NamingClient} = require('naming').v1beta1;

// Instantiates a client
const namingClient = new NamingClient();

async function callCreateABCDESomething() {
// Construct request
const request = {
};

// Run request
const response = await namingClient.createABCDESomething(request);
console.log(response);
}

callCreateABCDESomething();
// [END localhost_v1beta1_generated_Naming_createABCDESomething_async]
}

process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,41 @@
}
}
}
},
{
"regionTag": "localhost_v1beta1_generated_Naming_createABCDESomething_async",
"title": "Naming createABCDESomething Sample",
"origin": "API_DEFINITION",
"description": "",
"canonical": true,
"file": "naming.create_a_b_c_d_e_something.js",
"language": "JAVASCRIPT",
"segments": [
{
"start": 25,
"end": 45,
"type": "FULL"
}
],
"clientMethod": {
"shortName": "createABCDESomething",
"fullName": "google.naming.v1beta1.Naming.createABCDESomething",
"async": true,
"parameters": [],
"resultType": ".google.protobuf.Empty",
"client": {
"shortName": "NamingClient",
"fullName": "google.naming.v1beta1.NamingClient"
},
"method": {
"shortName": "CreateABCDESomething",
"fullName": "google.naming.v1beta1.Naming.CreateABCDESomething",
"service": {
"shortName": "Naming",
"fullName": "google.naming.v1beta1.Naming"
}
}
}
}
]
}
10 changes: 10 additions & 0 deletions baselines/naming/src/v1beta1/gapic_metadata.json.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@
"getReservedWord"
]
},
"createABCDESomething": {
"methods": [
"createABCDESomething"
]
},
"LongRunning": {
"methods": [
"longRunning"
Expand Down Expand Up @@ -127,6 +132,11 @@
"getReservedWord"
]
},
"createABCDESomething": {
"methods": [
"createABCDESomething"
]
},
"LongRunning": {
"methods": [
"longRunning"
Expand Down
65 changes: 64 additions & 1 deletion baselines/naming/src/v1beta1/naming_client.ts.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ export class NamingClient {
// Iterate over each of the methods that the service provides
// and create an API call method for each.
const namingStubMethods =
['paginatedMethod', 'paginatedMethodStream', 'paginatedMethodAsync', 'longRunning', 'checkLongRunningProgress', 'initialize', 'servicePath', 'apiEndpoint', 'port', 'scopes', 'getProjectId', 'getReservedWord'];
['paginatedMethod', 'paginatedMethodStream', 'paginatedMethodAsync', 'longRunning', 'checkLongRunningProgress', 'initialize', 'servicePath', 'apiEndpoint', 'port', 'scopes', 'getProjectId', 'getReservedWord', 'createAbcdeSomething'];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here is the main change: if you scroll to the right, the last element of this list is createAbcdeSomething. It would've been createABCDESomething without the fix.

for (const methodName of namingStubMethods) {
const callPromise = this.namingStub.then(
stub => (...args: Array<{}>) => {
Expand Down Expand Up @@ -954,6 +954,69 @@ export class NamingClient {
this.initialize1();
return this.innerApiCalls.getReservedWord(request, options, callback);
}
/**
*
* @param {Object} request
* The request object that will be sent.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Promise} - The promise which resolves to an array.
* The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}.
* Please see the
* [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
* for more details and examples.
* @example <caption>include:samples/generated/v1beta1/naming.create_a_b_c_d_e_something.js</caption>
* region_tag:localhost_v1beta1_generated_Naming_createABCDESomething_async
*/
createABCDESomething(
request?: protos.google.protobuf.IEmpty,
options?: CallOptions):
Promise<[
protos.google.protobuf.IEmpty,
protos.google.protobuf.IEmpty|undefined, {}|undefined
]>;
createABCDESomething(
request: protos.google.protobuf.IEmpty,
options: CallOptions,
callback: Callback<
protos.google.protobuf.IEmpty,
protos.google.protobuf.IEmpty|null|undefined,
{}|null|undefined>): void;
createABCDESomething(
request: protos.google.protobuf.IEmpty,
callback: Callback<
protos.google.protobuf.IEmpty,
protos.google.protobuf.IEmpty|null|undefined,
{}|null|undefined>): void;
createABCDESomething(
request?: protos.google.protobuf.IEmpty,
optionsOrCallback?: CallOptions|Callback<
protos.google.protobuf.IEmpty,
protos.google.protobuf.IEmpty|null|undefined,
{}|null|undefined>,
callback?: Callback<
protos.google.protobuf.IEmpty,
protos.google.protobuf.IEmpty|null|undefined,
{}|null|undefined>):
Promise<[
protos.google.protobuf.IEmpty,
protos.google.protobuf.IEmpty|undefined, {}|undefined
]>|void {
request = request || {};
let options: CallOptions;
if (typeof optionsOrCallback === 'function' && callback === undefined) {
callback = optionsOrCallback;
options = {};
}
else {
options = optionsOrCallback as CallOptions;
}
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
this.initialize1();
return this.innerApiCalls.createAbcdeSomething(request, options, callback);
}

/**
* Problem #2: long running method generates extra method check*Progress()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@
"getReservedWord": {
"retry_codes_name": "non_idempotent",
"retry_params_name": "default"
},
"createABCDESomething": {
"retry_codes_name": "non_idempotent",
"retry_params_name": "default"
}
}
}
Expand Down
72 changes: 72 additions & 0 deletions baselines/naming/test/gapic_naming_v1beta1.ts.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,78 @@ describe('v1beta1.NamingClient', () => {
});
});

describe('createABCDESomething', () => {
it('invokes createABCDESomething without error', async () => {
const client = new namingModule.v1beta1.NamingClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
});
client.initialize1();
const request = generateSampleMessage(new protos.google.protobuf.Empty());
const expectedOptions = {otherArgs: {headers: {}}};;
const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty());
client.innerApiCalls.createABCDESomething = stubSimpleCall(expectedResponse);
const [response] = await client.createABCDESomething(request);
assert.deepStrictEqual(response, expectedResponse);
assert((client.innerApiCalls.createABCDESomething as SinonStub)
.getCall(0).calledWith(request, expectedOptions, undefined));
});

it('invokes createABCDESomething without error using callback', async () => {
const client = new namingModule.v1beta1.NamingClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
});
client.initialize1();
const request = generateSampleMessage(new protos.google.protobuf.Empty());
const expectedOptions = {otherArgs: {headers: {}}};;
const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty());
client.innerApiCalls.createABCDESomething = stubSimpleCallWithCallback(expectedResponse);
const promise = new Promise((resolve, reject) => {
client.createABCDESomething(
request,
(err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => {
if (err) {
reject(err);
} else {
resolve(result);
}
});
});
const response = await promise;
assert.deepStrictEqual(response, expectedResponse);
assert((client.innerApiCalls.createABCDESomething as SinonStub)
.getCall(0).calledWith(request, expectedOptions /*, callback defined above */));
});

it('invokes createABCDESomething with error', async () => {
const client = new namingModule.v1beta1.NamingClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
});
client.initialize1();
const request = generateSampleMessage(new protos.google.protobuf.Empty());
const expectedOptions = {otherArgs: {headers: {}}};;
const expectedError = new Error('expected');
client.innerApiCalls.createABCDESomething = stubSimpleCall(undefined, expectedError);
await assert.rejects(client.createABCDESomething(request), expectedError);
assert((client.innerApiCalls.createABCDESomething as SinonStub)
.getCall(0).calledWith(request, expectedOptions, undefined));
});

it('invokes createABCDESomething with closed client', async () => {
const client = new namingModule.v1beta1.NamingClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
});
client.initialize1();
const request = generateSampleMessage(new protos.google.protobuf.Empty());
const expectedError = new Error('The client has already been closed.');
client.close();
await assert.rejects(client.createABCDESomething(request), expectedError);
});
});

describe('longRunning', () => {
it('invokes longRunning without error', async () => {
const client = new namingModule.v1beta1.NamingClient({
Expand Down
10 changes: 5 additions & 5 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@

interface String {
capitalize(): string;
words(): string[];
toCamelCase(): string;
toPascalCase(): string;
toKebabCase(): string;
toSnakeCase(): string;
words(protobufJsStyle?: boolean): string[];
toCamelCase(protobufJsStyle?: boolean): string;
toPascalCase(protobufJsStyle?: boolean): string;
toKebabCase(protobufJsStyle?: boolean): string;
toSnakeCase(protobufJsStyle?: boolean): string;
replaceAll(this: string, search: string, replacement: string): string;
}

Expand Down
Loading