Skip to content

Commit c99fcd7

Browse files
committed
typescript-jquery: Work in Typescript strict mode
1 parent ea76a94 commit c99fcd7

File tree

22 files changed

+264
-112
lines changed

22 files changed

+264
-112
lines changed

modules/openapi-generator/src/main/resources/typescript-jquery/api.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { Configuration } from '../configuration';
2222
export class {{classname}} {
2323
protected basePath = '{{{basePath}}}';
2424
public defaultHeaders: Array<string> = [];
25-
public defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings = null;
25+
public defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings = undefined;
2626
public configuration: Configuration = new Configuration();
2727
2828
constructor(basePath?: string, configuration?: Configuration, defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings) {
@@ -37,7 +37,7 @@ export class {{classname}} {
3737
}
3838
}
3939

40-
private extendObj<T1, T2 extends T1>(objA: T2, objB: T2): T1|T2 {
40+
private extendObj<T1 extends object, T2 extends T1>(objA: T2, objB: T2): T1|T2 {
4141
for (let key in objB) {
4242
if (objB.hasOwnProperty(key)) {
4343
objA[key] = objB[key];
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export class Configuration {
2-
apiKey: string;
3-
username: string;
4-
password: string;
5-
accessToken: string | (() => string);
2+
apiKey: string | undefined;
3+
username: string | undefined;
4+
password: string | undefined;
5+
accessToken: string | (() => string) | undefined;
66
}

samples/client/petstore/typescript-jquery/default/api/PetApi.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { Configuration } from '../configuration';
2222
export class PetApi {
2323
protected basePath = 'http://petstore.swagger.io/v2';
2424
public defaultHeaders: Array<string> = [];
25-
public defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings = null;
25+
public defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings = undefined;
2626
public configuration: Configuration = new Configuration();
2727

2828
constructor(basePath?: string, configuration?: Configuration, defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings) {
@@ -37,7 +37,7 @@ export class PetApi {
3737
}
3838
}
3939

40-
private extendObj<T1, T2 extends T1>(objA: T2, objB: T2): T1|T2 {
40+
private extendObj<T1 extends object, T2 extends T1>(objA: T2, objB: T2): T1|T2 {
4141
for (let key in objB) {
4242
if (objB.hasOwnProperty(key)) {
4343
objA[key] = objB[key];

samples/client/petstore/typescript-jquery/default/api/StoreApi.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { Configuration } from '../configuration';
2222
export class StoreApi {
2323
protected basePath = 'http://petstore.swagger.io/v2';
2424
public defaultHeaders: Array<string> = [];
25-
public defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings = null;
25+
public defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings = undefined;
2626
public configuration: Configuration = new Configuration();
2727

2828
constructor(basePath?: string, configuration?: Configuration, defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings) {
@@ -37,7 +37,7 @@ export class StoreApi {
3737
}
3838
}
3939

40-
private extendObj<T1, T2 extends T1>(objA: T2, objB: T2): T1|T2 {
40+
private extendObj<T1 extends object, T2 extends T1>(objA: T2, objB: T2): T1|T2 {
4141
for (let key in objB) {
4242
if (objB.hasOwnProperty(key)) {
4343
objA[key] = objB[key];

samples/client/petstore/typescript-jquery/default/api/UserApi.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { Configuration } from '../configuration';
2222
export class UserApi {
2323
protected basePath = 'http://petstore.swagger.io/v2';
2424
public defaultHeaders: Array<string> = [];
25-
public defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings = null;
25+
public defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings = undefined;
2626
public configuration: Configuration = new Configuration();
2727

2828
constructor(basePath?: string, configuration?: Configuration, defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings) {
@@ -37,7 +37,7 @@ export class UserApi {
3737
}
3838
}
3939

40-
private extendObj<T1, T2 extends T1>(objA: T2, objB: T2): T1|T2 {
40+
private extendObj<T1 extends object, T2 extends T1>(objA: T2, objB: T2): T1|T2 {
4141
for (let key in objB) {
4242
if (objB.hasOwnProperty(key)) {
4343
objA[key] = objB[key];
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export class Configuration {
2-
apiKey: string;
3-
username: string;
4-
password: string;
5-
accessToken: string | (() => string);
2+
apiKey: string | undefined;
3+
username: string | undefined;
4+
password: string | undefined;
5+
accessToken: string | (() => string) | undefined;
66
}

samples/client/petstore/typescript-jquery/npm/api/PetApi.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { Configuration } from '../configuration';
2222
export class PetApi {
2323
protected basePath = 'http://petstore.swagger.io/v2';
2424
public defaultHeaders: Array<string> = [];
25-
public defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings = null;
25+
public defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings = undefined;
2626
public configuration: Configuration = new Configuration();
2727

2828
constructor(basePath?: string, configuration?: Configuration, defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings) {
@@ -37,7 +37,7 @@ export class PetApi {
3737
}
3838
}
3939

40-
private extendObj<T1, T2 extends T1>(objA: T2, objB: T2): T1|T2 {
40+
private extendObj<T1 extends object, T2 extends T1>(objA: T2, objB: T2): T1|T2 {
4141
for (let key in objB) {
4242
if (objB.hasOwnProperty(key)) {
4343
objA[key] = objB[key];

samples/client/petstore/typescript-jquery/npm/api/StoreApi.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { Configuration } from '../configuration';
2222
export class StoreApi {
2323
protected basePath = 'http://petstore.swagger.io/v2';
2424
public defaultHeaders: Array<string> = [];
25-
public defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings = null;
25+
public defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings = undefined;
2626
public configuration: Configuration = new Configuration();
2727

2828
constructor(basePath?: string, configuration?: Configuration, defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings) {
@@ -37,7 +37,7 @@ export class StoreApi {
3737
}
3838
}
3939

40-
private extendObj<T1, T2 extends T1>(objA: T2, objB: T2): T1|T2 {
40+
private extendObj<T1 extends object, T2 extends T1>(objA: T2, objB: T2): T1|T2 {
4141
for (let key in objB) {
4242
if (objB.hasOwnProperty(key)) {
4343
objA[key] = objB[key];

samples/client/petstore/typescript-jquery/npm/api/UserApi.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { Configuration } from '../configuration';
2222
export class UserApi {
2323
protected basePath = 'http://petstore.swagger.io/v2';
2424
public defaultHeaders: Array<string> = [];
25-
public defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings = null;
25+
public defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings = undefined;
2626
public configuration: Configuration = new Configuration();
2727

2828
constructor(basePath?: string, configuration?: Configuration, defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings) {
@@ -37,7 +37,7 @@ export class UserApi {
3737
}
3838
}
3939

40-
private extendObj<T1, T2 extends T1>(objA: T2, objB: T2): T1|T2 {
40+
private extendObj<T1 extends object, T2 extends T1>(objA: T2, objB: T2): T1|T2 {
4141
for (let key in objB) {
4242
if (objB.hasOwnProperty(key)) {
4343
objA[key] = objB[key];
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export class Configuration {
2-
apiKey: string;
3-
username: string;
4-
password: string;
5-
accessToken: string | (() => string);
2+
apiKey: string | undefined;
3+
username: string | undefined;
4+
password: string | undefined;
5+
accessToken: string | (() => string) | undefined;
66
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* OpenAPI Petstore
3+
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
4+
*
5+
* The version of the OpenAPI document: 1.0.0
6+
*
7+
*
8+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9+
* https://openapi-generator.tech
10+
* Do not edit the class manually.
11+
*/
12+
13+
import * as models from './models';
14+
15+
export interface InlineObject1 {
16+
/**
17+
* Additional data to pass to server
18+
*/
19+
additionalMetadata?: string;
20+
21+
/**
22+
* file to upload
23+
*/
24+
file?: any;
25+
26+
}

samples/client/petstore/typescript-node/default/api/petApi.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,17 @@ export class PetApi {
8383
/**
8484
*
8585
* @summary Add a new pet to the store
86-
* @param body Pet object that needs to be added to the store
86+
* @param pet Pet object that needs to be added to the store
8787
*/
88-
public async addPet (body: Pet, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> {
88+
public async addPet (pet: Pet, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> {
8989
const localVarPath = this.basePath + '/pet';
9090
let localVarQueryParameters: any = {};
9191
let localVarHeaderParams: any = (<any>Object).assign({}, this.defaultHeaders);
9292
let localVarFormParams: any = {};
9393

94-
// verify required parameter 'body' is not null or undefined
95-
if (body === null || body === undefined) {
96-
throw new Error('Required parameter body was null or undefined when calling addPet.');
94+
// verify required parameter 'pet' is not null or undefined
95+
if (pet === null || pet === undefined) {
96+
throw new Error('Required parameter pet was null or undefined when calling addPet.');
9797
}
9898

9999
(<any>Object).assign(localVarHeaderParams, options.headers);
@@ -107,7 +107,7 @@ export class PetApi {
107107
uri: localVarPath,
108108
useQuerystring: this._useQuerystring,
109109
json: true,
110-
body: ObjectSerializer.serialize(body, "Pet")
110+
body: ObjectSerializer.serialize(pet, "Pet")
111111
};
112112

113113
let authenticationPromise = Promise.resolve();
@@ -400,17 +400,17 @@ export class PetApi {
400400
/**
401401
*
402402
* @summary Update an existing pet
403-
* @param body Pet object that needs to be added to the store
403+
* @param pet Pet object that needs to be added to the store
404404
*/
405-
public async updatePet (body: Pet, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> {
405+
public async updatePet (pet: Pet, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> {
406406
const localVarPath = this.basePath + '/pet';
407407
let localVarQueryParameters: any = {};
408408
let localVarHeaderParams: any = (<any>Object).assign({}, this.defaultHeaders);
409409
let localVarFormParams: any = {};
410410

411-
// verify required parameter 'body' is not null or undefined
412-
if (body === null || body === undefined) {
413-
throw new Error('Required parameter body was null or undefined when calling updatePet.');
411+
// verify required parameter 'pet' is not null or undefined
412+
if (pet === null || pet === undefined) {
413+
throw new Error('Required parameter pet was null or undefined when calling updatePet.');
414414
}
415415

416416
(<any>Object).assign(localVarHeaderParams, options.headers);
@@ -424,7 +424,7 @@ export class PetApi {
424424
uri: localVarPath,
425425
useQuerystring: this._useQuerystring,
426426
json: true,
427-
body: ObjectSerializer.serialize(body, "Pet")
427+
body: ObjectSerializer.serialize(pet, "Pet")
428428
};
429429

430430
let authenticationPromise = Promise.resolve();

samples/client/petstore/typescript-node/default/api/storeApi.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,9 @@ export class StoreApi {
253253
/**
254254
*
255255
* @summary Place an order for a pet
256-
* @param body order placed for purchasing the pet
256+
* @param order order placed for purchasing the pet
257257
*/
258-
public async placeOrder (body: Order, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Order; }> {
258+
public async placeOrder (order: Order, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Order; }> {
259259
const localVarPath = this.basePath + '/store/order';
260260
let localVarQueryParameters: any = {};
261261
let localVarHeaderParams: any = (<any>Object).assign({}, this.defaultHeaders);
@@ -268,9 +268,9 @@ export class StoreApi {
268268
}
269269
let localVarFormParams: any = {};
270270

271-
// verify required parameter 'body' is not null or undefined
272-
if (body === null || body === undefined) {
273-
throw new Error('Required parameter body was null or undefined when calling placeOrder.');
271+
// verify required parameter 'order' is not null or undefined
272+
if (order === null || order === undefined) {
273+
throw new Error('Required parameter order was null or undefined when calling placeOrder.');
274274
}
275275

276276
(<any>Object).assign(localVarHeaderParams, options.headers);
@@ -284,7 +284,7 @@ export class StoreApi {
284284
uri: localVarPath,
285285
useQuerystring: this._useQuerystring,
286286
json: true,
287-
body: ObjectSerializer.serialize(body, "Order")
287+
body: ObjectSerializer.serialize(order, "Order")
288288
};
289289

290290
let authenticationPromise = Promise.resolve();

0 commit comments

Comments
 (0)