Skip to content

Commit db0586b

Browse files
authored
build: adds codegen config option to rename models (#81)
* build: adds codegen config option to rename models * refactor: update field name usage and model exports
1 parent ad7239f commit db0586b

File tree

7 files changed

+28
-26
lines changed

7 files changed

+28
-26
lines changed

generate.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@ docker run --rm -v "${PWD}:/local" -u $(id -u) openapitools/openapi-generator-cl
1414
-i "/local/$file" \
1515
-g typescript-fetch \
1616
-o /local/src/generated \
17-
--additional-properties=modelPropertyNaming=camelCase
17+
--additional-properties=modelPropertyNaming=camelCase \
18+
--global-property apiTests=false,modelTests=false,apiDocs=false,modelDocs=false \
19+
--model-name-mappings CreateTransactionRegisterRequest=RegisterTransactionArgs

src/classes/Auth/Auth.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class Auth extends PassageBase {
2929
try {
3030
const response = await this.transactionClient.createRegisterTransaction({
3131
appId: this.config.appId,
32-
createTransactionRegisterRequest: args,
32+
registerTransactionArgs: args,
3333
});
3434

3535
return response.transactionId;

src/classes/Auth/types.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import { CreateTransactionRegisterRequest } from '../../generated';
1+
import { RegisterTransactionArgs } from '../../generated';
22

3-
export type RegisterTransactionArgs = CreateTransactionRegisterRequest;
3+
export { RegisterTransactionArgs };

src/generated/.openapi-generator/FILES

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ index.ts
88
models/AppleUserSocialConnection.ts
99
models/AuthenticateVerifyNonceResponse.ts
1010
models/CreateTransactionAuthenticateRequest.ts
11-
models/CreateTransactionRegisterRequest.ts
1211
models/CreateTransactionResponse.ts
1312
models/GithubUserSocialConnection.ts
1413
models/GoogleUserSocialConnection.ts
@@ -24,6 +23,7 @@ models/Model409Error.ts
2423
models/Model500Error.ts
2524
models/Nonce.ts
2625
models/PaginatedLinks.ts
26+
models/RegisterTransactionArgs.ts
2727
models/SocialConnectionType.ts
2828
models/UserEventAction.ts
2929
models/UserEventStatus.ts

src/generated/apis/TransactionsApi.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,18 @@
1616
import * as runtime from '../runtime';
1717
import type {
1818
CreateTransactionAuthenticateRequest,
19-
CreateTransactionRegisterRequest,
2019
CreateTransactionResponse,
2120
Model400Error,
2221
Model401Error,
2322
Model403Error,
2423
Model404Error,
2524
Model409Error,
2625
Model500Error,
26+
RegisterTransactionArgs,
2727
} from '../models/index';
2828
import {
2929
CreateTransactionAuthenticateRequestFromJSON,
3030
CreateTransactionAuthenticateRequestToJSON,
31-
CreateTransactionRegisterRequestFromJSON,
32-
CreateTransactionRegisterRequestToJSON,
3331
CreateTransactionResponseFromJSON,
3432
CreateTransactionResponseToJSON,
3533
Model400ErrorFromJSON,
@@ -44,6 +42,8 @@ import {
4442
Model409ErrorToJSON,
4543
Model500ErrorFromJSON,
4644
Model500ErrorToJSON,
45+
RegisterTransactionArgsFromJSON,
46+
RegisterTransactionArgsToJSON,
4747
} from '../models/index';
4848

4949
export interface CreateAuthenticateTransactionRequest {
@@ -53,7 +53,7 @@ export interface CreateAuthenticateTransactionRequest {
5353

5454
export interface CreateRegisterTransactionRequest {
5555
appId: string;
56-
createTransactionRegisterRequest: CreateTransactionRegisterRequest;
56+
registerTransactionArgs: RegisterTransactionArgs;
5757
}
5858

5959
/**
@@ -123,10 +123,10 @@ export class TransactionsApi extends runtime.BaseAPI {
123123
);
124124
}
125125

126-
if (requestParameters['createTransactionRegisterRequest'] == null) {
126+
if (requestParameters['registerTransactionArgs'] == null) {
127127
throw new runtime.RequiredError(
128-
'createTransactionRegisterRequest',
129-
'Required parameter "createTransactionRegisterRequest" was null or undefined when calling createRegisterTransaction().'
128+
'registerTransactionArgs',
129+
'Required parameter "registerTransactionArgs" was null or undefined when calling createRegisterTransaction().'
130130
);
131131
}
132132

@@ -149,7 +149,7 @@ export class TransactionsApi extends runtime.BaseAPI {
149149
method: 'POST',
150150
headers: headerParameters,
151151
query: queryParameters,
152-
body: CreateTransactionRegisterRequestToJSON(requestParameters['createTransactionRegisterRequest']),
152+
body: RegisterTransactionArgsToJSON(requestParameters['registerTransactionArgs']),
153153
}, initOverrides);
154154

155155
return new runtime.JSONApiResponse(response, (jsonValue) => CreateTransactionResponseFromJSON(jsonValue));

src/generated/models/CreateTransactionRegisterRequest.ts src/generated/models/RegisterTransactionArgs.ts

+12-12
Original file line numberDiff line numberDiff line change
@@ -16,37 +16,37 @@ import { mapValues } from '../runtime';
1616
/**
1717
*
1818
* @export
19-
* @interface CreateTransactionRegisterRequest
19+
* @interface RegisterTransactionArgs
2020
*/
21-
export interface CreateTransactionRegisterRequest {
21+
export interface RegisterTransactionArgs {
2222
/**
2323
* the user's unique identifier
2424
* @type {string}
25-
* @memberof CreateTransactionRegisterRequest
25+
* @memberof RegisterTransactionArgs
2626
*/
2727
externalId: string;
2828
/**
2929
* the immutable display name of the passkey that the user will see
3030
* @type {string}
31-
* @memberof CreateTransactionRegisterRequest
31+
* @memberof RegisterTransactionArgs
3232
*/
3333
passkeyDisplayName: string;
3434
}
3535

3636
/**
37-
* Check if a given object implements the CreateTransactionRegisterRequest interface.
37+
* Check if a given object implements the RegisterTransactionArgs interface.
3838
*/
39-
export function instanceOfCreateTransactionRegisterRequest(value: object): value is CreateTransactionRegisterRequest {
39+
export function instanceOfRegisterTransactionArgs(value: object): value is RegisterTransactionArgs {
4040
if (!('externalId' in value) || value['externalId'] === undefined) return false;
4141
if (!('passkeyDisplayName' in value) || value['passkeyDisplayName'] === undefined) return false;
4242
return true;
4343
}
4444

45-
export function CreateTransactionRegisterRequestFromJSON(json: any): CreateTransactionRegisterRequest {
46-
return CreateTransactionRegisterRequestFromJSONTyped(json, false);
45+
export function RegisterTransactionArgsFromJSON(json: any): RegisterTransactionArgs {
46+
return RegisterTransactionArgsFromJSONTyped(json, false);
4747
}
4848

49-
export function CreateTransactionRegisterRequestFromJSONTyped(json: any, ignoreDiscriminator: boolean): CreateTransactionRegisterRequest {
49+
export function RegisterTransactionArgsFromJSONTyped(json: any, ignoreDiscriminator: boolean): RegisterTransactionArgs {
5050
if (json == null) {
5151
return json;
5252
}
@@ -57,11 +57,11 @@ export function CreateTransactionRegisterRequestFromJSONTyped(json: any, ignoreD
5757
};
5858
}
5959

60-
export function CreateTransactionRegisterRequestToJSON(json: any): CreateTransactionRegisterRequest {
61-
return CreateTransactionRegisterRequestToJSONTyped(json, false);
60+
export function RegisterTransactionArgsToJSON(json: any): RegisterTransactionArgs {
61+
return RegisterTransactionArgsToJSONTyped(json, false);
6262
}
6363

64-
export function CreateTransactionRegisterRequestToJSONTyped(value?: CreateTransactionRegisterRequest | null, ignoreDiscriminator: boolean = false): any {
64+
export function RegisterTransactionArgsToJSONTyped(value?: RegisterTransactionArgs | null, ignoreDiscriminator: boolean = false): any {
6565
if (value == null) {
6666
return value;
6767
}

src/generated/models/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
export * from './AppleUserSocialConnection';
44
export * from './AuthenticateVerifyNonceResponse';
55
export * from './CreateTransactionAuthenticateRequest';
6-
export * from './CreateTransactionRegisterRequest';
76
export * from './CreateTransactionResponse';
87
export * from './GithubUserSocialConnection';
98
export * from './GoogleUserSocialConnection';
@@ -19,6 +18,7 @@ export * from './Model409Error';
1918
export * from './Model500Error';
2019
export * from './Nonce';
2120
export * from './PaginatedLinks';
21+
export * from './RegisterTransactionArgs';
2222
export * from './SocialConnectionType';
2323
export * from './UserEventAction';
2424
export * from './UserEventStatus';

0 commit comments

Comments
 (0)