Skip to content

Commit 91800ea

Browse files
committed
Fix tests and generate samples
1 parent 908cfab commit 91800ea

102 files changed

Lines changed: 368 additions & 368 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/fetch/TypeScriptFetchClientCodegenTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,10 @@ public void getTypeDeclarationTest() {
187187
parentSchema = new MapSchema().additionalProperties(new Schema().$ref("#/components/schemas/Child"));
188188

189189
ModelUtils.setGenerateAliasAsModel(false);
190-
Assert.assertEquals(codegen.getTypeDeclaration(parentSchema), "{ [key: string]: Array<string>; }");
190+
Assert.assertEquals(codegen.getTypeDeclaration(parentSchema), "Record<string, Array<string>>");
191191

192192
ModelUtils.setGenerateAliasAsModel(true);
193-
Assert.assertEquals(codegen.getTypeDeclaration(parentSchema), "{ [key: string]: Child; }");
193+
Assert.assertEquals(codegen.getTypeDeclaration(parentSchema), "Record<string, Child>");
194194
}
195195

196196
@Test

modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/fetch/TypeScriptFetchModelTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ public void testNullSafeAdditionalProps() {
443443
codegen.additionalProperties().put("nullSafeAdditionalProps", true);
444444
codegen.processOpts();
445445

446-
Assert.assertEquals(codegen.getTypeDeclaration(model), "{ [key: string]: string | undefined; }");
446+
Assert.assertEquals(codegen.getTypeDeclaration(model), "Record<string, string | undefined>");
447447
}
448448

449449
@Test(description = "Don't add null safe additional property indexer by default")
@@ -453,7 +453,7 @@ public void testWithoutNullSafeAdditionalProps() {
453453
final DefaultCodegen codegen = new TypeScriptFetchClientCodegen();
454454
codegen.processOpts();
455455

456-
Assert.assertEquals(codegen.getTypeDeclaration(model), "{ [key: string]: string; }");
456+
Assert.assertEquals(codegen.getTypeDeclaration(model), "Record<string, string>");
457457
}
458458

459459
@Test(description = "Don't generate new schemas for readonly references")

samples/client/others/typescript-node/encode-decode/build/api/defaultApi.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ export class DefaultApi {
212212
/**
213213
*
214214
*/
215-
public async testDecodeArrayOfMapsOfObjectsGet (options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Array<{ [key: string]: ComplexObject | undefined; }>; }> {
215+
public async testDecodeArrayOfMapsOfObjectsGet (options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Array<Record<string, ComplexObject | undefined>>; }> {
216216
const localVarPath = this.basePath + '/test/decode/array-of/maps-of/objects';
217217
let localVarQueryParameters: any = {};
218218
let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders);
@@ -254,13 +254,13 @@ export class DefaultApi {
254254
localVarRequestOptions.form = localVarFormParams;
255255
}
256256
}
257-
return new Promise<{ response: http.IncomingMessage; body: Array<{ [key: string]: ComplexObject | undefined; }>; }>((resolve, reject) => {
257+
return new Promise<{ response: http.IncomingMessage; body: Array<Record<string, ComplexObject | undefined>>; }>((resolve, reject) => {
258258
localVarRequest(localVarRequestOptions, (error, response, body) => {
259259
if (error) {
260260
reject(error);
261261
} else {
262262
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
263-
body = ObjectSerializer.deserialize(body, "Array<{ [key: string]: ComplexObject | undefined; }>");
263+
body = ObjectSerializer.deserialize(body, "Array<Record<string, ComplexObject | undefined>>");
264264
resolve({ response: response, body: body });
265265
} else {
266266
reject(new HttpError(response, body, response.statusCode));
@@ -456,7 +456,7 @@ export class DefaultApi {
456456
/**
457457
*
458458
*/
459-
public async testDecodeMapOfMapsOfObjectsGet (options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: { [key: string]: { [key: string]: ComplexObject | undefined; } | undefined; }; }> {
459+
public async testDecodeMapOfMapsOfObjectsGet (options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Record<string, Record<string, ComplexObject | undefined> | undefined>; }> {
460460
const localVarPath = this.basePath + '/test/decode/map-of/maps-of/objects';
461461
let localVarQueryParameters: any = {};
462462
let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders);
@@ -498,13 +498,13 @@ export class DefaultApi {
498498
localVarRequestOptions.form = localVarFormParams;
499499
}
500500
}
501-
return new Promise<{ response: http.IncomingMessage; body: { [key: string]: { [key: string]: ComplexObject | undefined; } | undefined; }; }>((resolve, reject) => {
501+
return new Promise<{ response: http.IncomingMessage; body: Record<string, Record<string, ComplexObject | undefined> | undefined>; }>((resolve, reject) => {
502502
localVarRequest(localVarRequestOptions, (error, response, body) => {
503503
if (error) {
504504
reject(error);
505505
} else {
506506
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
507-
body = ObjectSerializer.deserialize(body, "{ [key: string]: { [key: string]: ComplexObject | undefined; } | undefined; }");
507+
body = ObjectSerializer.deserialize(body, "Record<string, Record<string, ComplexObject | undefined> | undefined>");
508508
resolve({ response: response, body: body });
509509
} else {
510510
reject(new HttpError(response, body, response.statusCode));
@@ -517,7 +517,7 @@ export class DefaultApi {
517517
/**
518518
*
519519
*/
520-
public async testDecodeMapOfObjectsGet (options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: { [key: string]: ComplexObject | undefined | null; }; }> {
520+
public async testDecodeMapOfObjectsGet (options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Record<string, ComplexObject | undefined | null>; }> {
521521
const localVarPath = this.basePath + '/test/decode/map-of/objects';
522522
let localVarQueryParameters: any = {};
523523
let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders);
@@ -559,13 +559,13 @@ export class DefaultApi {
559559
localVarRequestOptions.form = localVarFormParams;
560560
}
561561
}
562-
return new Promise<{ response: http.IncomingMessage; body: { [key: string]: ComplexObject | undefined | null; }; }>((resolve, reject) => {
562+
return new Promise<{ response: http.IncomingMessage; body: Record<string, ComplexObject | undefined | null>; }>((resolve, reject) => {
563563
localVarRequest(localVarRequestOptions, (error, response, body) => {
564564
if (error) {
565565
reject(error);
566566
} else {
567567
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
568-
body = ObjectSerializer.deserialize(body, "{ [key: string]: ComplexObject | undefined | null; }");
568+
body = ObjectSerializer.deserialize(body, "Record<string, ComplexObject | undefined | null>");
569569
resolve({ response: response, body: body });
570570
} else {
571571
reject(new HttpError(response, body, response.statusCode));
@@ -578,7 +578,7 @@ export class DefaultApi {
578578
/**
579579
*
580580
*/
581-
public async testDecodeMapOfPrimitiveGet (options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: { [key: string]: string | undefined; }; }> {
581+
public async testDecodeMapOfPrimitiveGet (options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Record<string, string | undefined>; }> {
582582
const localVarPath = this.basePath + '/test/decode/map-of/primitive';
583583
let localVarQueryParameters: any = {};
584584
let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders);
@@ -620,13 +620,13 @@ export class DefaultApi {
620620
localVarRequestOptions.form = localVarFormParams;
621621
}
622622
}
623-
return new Promise<{ response: http.IncomingMessage; body: { [key: string]: string | undefined; }; }>((resolve, reject) => {
623+
return new Promise<{ response: http.IncomingMessage; body: Record<string, string | undefined>; }>((resolve, reject) => {
624624
localVarRequest(localVarRequestOptions, (error, response, body) => {
625625
if (error) {
626626
reject(error);
627627
} else {
628628
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
629-
body = ObjectSerializer.deserialize(body, "{ [key: string]: string | undefined; }");
629+
body = ObjectSerializer.deserialize(body, "Record<string, string | undefined>");
630630
resolve({ response: response, body: body });
631631
} else {
632632
reject(new HttpError(response, body, response.statusCode));
@@ -1127,7 +1127,7 @@ export class DefaultApi {
11271127
*
11281128
* @param complexObject
11291129
*/
1130-
public async testEncodeArrayOfMapsOfObjectsPost (complexObject: Array<{ [key: string]: ComplexObject | undefined; }>, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> {
1130+
public async testEncodeArrayOfMapsOfObjectsPost (complexObject: Array<Record<string, ComplexObject | undefined>>, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> {
11311131
const localVarPath = this.basePath + '/test/encode/array-of/maps-of/objects';
11321132
let localVarQueryParameters: any = {};
11331133
let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders);
@@ -1149,7 +1149,7 @@ export class DefaultApi {
11491149
uri: localVarPath,
11501150
useQuerystring: this._useQuerystring,
11511151
json: true,
1152-
body: ObjectSerializer.serialize(complexObject, "Array<{ [key: string]: ComplexObject | undefined; }>")
1152+
body: ObjectSerializer.serialize(complexObject, "Array<Record<string, ComplexObject | undefined>>")
11531153
};
11541154

11551155
let authenticationPromise = Promise.resolve();
@@ -1427,7 +1427,7 @@ export class DefaultApi {
14271427
*
14281428
* @param requestBody
14291429
*/
1430-
public async testEncodeMapOfMapsOfObjectsPost (requestBody: { [key: string]: { [key: string]: ComplexObject | undefined; } | undefined; }, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> {
1430+
public async testEncodeMapOfMapsOfObjectsPost (requestBody: Record<string, Record<string, ComplexObject | undefined> | undefined>, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> {
14311431
const localVarPath = this.basePath + '/test/encode/map-of/maps-of/objects';
14321432
let localVarQueryParameters: any = {};
14331433
let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders);
@@ -1449,7 +1449,7 @@ export class DefaultApi {
14491449
uri: localVarPath,
14501450
useQuerystring: this._useQuerystring,
14511451
json: true,
1452-
body: ObjectSerializer.serialize(requestBody, "{ [key: string]: { [key: string]: ComplexObject | undefined; } | undefined; }")
1452+
body: ObjectSerializer.serialize(requestBody, "Record<string, Record<string, ComplexObject | undefined> | undefined>")
14531453
};
14541454

14551455
let authenticationPromise = Promise.resolve();
@@ -1487,7 +1487,7 @@ export class DefaultApi {
14871487
*
14881488
* @param requestBody
14891489
*/
1490-
public async testEncodeMapOfObjectsPost (requestBody: { [key: string]: ComplexObject | undefined | null; }, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> {
1490+
public async testEncodeMapOfObjectsPost (requestBody: Record<string, ComplexObject | undefined | null>, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> {
14911491
const localVarPath = this.basePath + '/test/encode/map-of/objects';
14921492
let localVarQueryParameters: any = {};
14931493
let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders);
@@ -1509,7 +1509,7 @@ export class DefaultApi {
15091509
uri: localVarPath,
15101510
useQuerystring: this._useQuerystring,
15111511
json: true,
1512-
body: ObjectSerializer.serialize(requestBody, "{ [key: string]: ComplexObject | undefined | null; }")
1512+
body: ObjectSerializer.serialize(requestBody, "Record<string, ComplexObject | undefined | null>")
15131513
};
15141514

15151515
let authenticationPromise = Promise.resolve();
@@ -1547,7 +1547,7 @@ export class DefaultApi {
15471547
*
15481548
* @param requestBody
15491549
*/
1550-
public async testEncodeMapOfPrimitivePost (requestBody: { [key: string]: string | undefined; }, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> {
1550+
public async testEncodeMapOfPrimitivePost (requestBody: Record<string, string | undefined>, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> {
15511551
const localVarPath = this.basePath + '/test/encode/map-of/primitive';
15521552
let localVarQueryParameters: any = {};
15531553
let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders);
@@ -1569,7 +1569,7 @@ export class DefaultApi {
15691569
uri: localVarPath,
15701570
useQuerystring: this._useQuerystring,
15711571
json: true,
1572-
body: ObjectSerializer.serialize(requestBody, "{ [key: string]: string | undefined; }")
1572+
body: ObjectSerializer.serialize(requestBody, "Record<string, string | undefined>")
15731573
};
15741574

15751575
let authenticationPromise = Promise.resolve();

samples/client/petstore/typescript-angular-v16-provided-in-root/builds/default/api/store.service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ export class StoreService extends BaseService {
9696
* @param reportProgress flag to report request and response progress.
9797
* @param options additional options
9898
*/
99-
public getInventory(observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<{ [key: string]: number; }>;
100-
public getInventory(observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpResponse<{ [key: string]: number; }>>;
101-
public getInventory(observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpEvent<{ [key: string]: number; }>>;
99+
public getInventory(observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<Record<string, number>>;
100+
public getInventory(observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpResponse<Record<string, number>>>;
101+
public getInventory(observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpEvent<Record<string, number>>>;
102102
public getInventory(observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<any> {
103103

104104
let localVarHeaders = this.defaultHeaders;
@@ -129,7 +129,7 @@ export class StoreService extends BaseService {
129129

130130
let localVarPath = `/store/inventory`;
131131
const { basePath, withCredentials } = this.configuration;
132-
return this.httpClient.request<{ [key: string]: number; }>('get', `${basePath}${localVarPath}`,
132+
return this.httpClient.request<Record<string, number>>('get', `${basePath}${localVarPath}`,
133133
{
134134
context: localVarHttpContext,
135135
responseType: <any>responseType_,

samples/client/petstore/typescript-angular-v17-provided-in-root/builds/default/api/store.service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ export class StoreService extends BaseService {
9999
* @param reportProgress flag to report request and response progress.
100100
* @param options additional options
101101
*/
102-
public getInventory(observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<{ [key: string]: number; }>;
103-
public getInventory(observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<{ [key: string]: number; }>>;
104-
public getInventory(observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<{ [key: string]: number; }>>;
102+
public getInventory(observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<Record<string, number>>;
103+
public getInventory(observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<Record<string, number>>>;
104+
public getInventory(observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<Record<string, number>>>;
105105
public getInventory(observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
106106

107107
let localVarHeaders = this.defaultHeaders;
@@ -134,7 +134,7 @@ export class StoreService extends BaseService {
134134

135135
let localVarPath = `/store/inventory`;
136136
const { basePath, withCredentials } = this.configuration;
137-
return this.httpClient.request<{ [key: string]: number; }>('get', `${basePath}${localVarPath}`,
137+
return this.httpClient.request<Record<string, number>>('get', `${basePath}${localVarPath}`,
138138
{
139139
context: localVarHttpContext,
140140
responseType: <any>responseType_,

0 commit comments

Comments
 (0)