From 1052ebaced5585b72e1a2a1bac81f0b7d4fa5d5f Mon Sep 17 00:00:00 2001 From: Jan Jongboom Date: Mon, 21 Oct 2019 17:14:48 +0530 Subject: [PATCH] typescript-jquery: Update to work with Typescript strict mode (#3969) * typescript-jquery: Work in Typescript strict mode * re-generate samples --- bin/windows/typescript-jquery-with-npm.bat | 2 +- .../resources/typescript-jquery/api.mustache | 4 +- .../typescript-jquery/configuration.mustache | 8 ++-- .../default/.openapi-generator-ignore | 6 +-- .../typescript-jquery/default/api/PetApi.ts | 4 +- .../typescript-jquery/default/api/StoreApi.ts | 4 +- .../typescript-jquery/default/api/UserApi.ts | 4 +- .../default/configuration.ts | 8 ++-- .../typescript-jquery/default/model/Amount.ts | 26 ------------ .../default/model/Currency.ts | 19 --------- .../typescript-jquery/npm/api/PetApi.ts | 4 +- .../typescript-jquery/npm/api/StoreApi.ts | 4 +- .../typescript-jquery/npm/api/UserApi.ts | 4 +- .../typescript-jquery/npm/configuration.ts | 8 ++-- .../default/model/inlineObject.ts | 42 ------------------- .../default/model/inlineObject1.ts | 42 ------------------- 16 files changed, 30 insertions(+), 159 deletions(-) delete mode 100644 samples/client/petstore/typescript-jquery/default/model/Amount.ts delete mode 100644 samples/client/petstore/typescript-jquery/default/model/Currency.ts delete mode 100644 samples/client/petstore/typescript-node/default/model/inlineObject.ts delete mode 100644 samples/client/petstore/typescript-node/default/model/inlineObject1.ts diff --git a/bin/windows/typescript-jquery-with-npm.bat b/bin/windows/typescript-jquery-with-npm.bat index 7f6a206e8bb..a72a03b5419 100644 --- a/bin/windows/typescript-jquery-with-npm.bat +++ b/bin/windows/typescript-jquery-with-npm.bat @@ -5,6 +5,6 @@ If Not Exist %executable% ( ) REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -c bin\typescript-petstore-npm.json -g typescript-jquery -o samples\client\petstore\typescript-jquery\npm +set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -c bin\typescript-jquery-petstore-npm.json -g typescript-jquery -o samples\client\petstore\typescript-jquery\npm java %JAVA_OPTS% -jar %executable% %ags% diff --git a/modules/openapi-generator/src/main/resources/typescript-jquery/api.mustache b/modules/openapi-generator/src/main/resources/typescript-jquery/api.mustache index 182f2f09b37..f27bfde09e4 100644 --- a/modules/openapi-generator/src/main/resources/typescript-jquery/api.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-jquery/api.mustache @@ -22,7 +22,7 @@ import { Configuration } from '../configuration'; export class {{classname}} { protected basePath = '{{{basePath}}}'; public defaultHeaders: Array = []; - public defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings = null; + public defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings = undefined; public configuration: Configuration = new Configuration(); constructor(basePath?: string, configuration?: Configuration, defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings) { @@ -37,7 +37,7 @@ export class {{classname}} { } } - private extendObj(objA: T2, objB: T2): T1|T2 { + private extendObj(objA: T2, objB: T2): T1|T2 { for (let key in objB) { if (objB.hasOwnProperty(key)) { objA[key] = objB[key]; diff --git a/modules/openapi-generator/src/main/resources/typescript-jquery/configuration.mustache b/modules/openapi-generator/src/main/resources/typescript-jquery/configuration.mustache index a566a180e4e..658e6ad5f61 100644 --- a/modules/openapi-generator/src/main/resources/typescript-jquery/configuration.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-jquery/configuration.mustache @@ -1,6 +1,6 @@ export class Configuration { - apiKey: string; - username: string; - password: string; - accessToken: string | (() => string); + apiKey: string | undefined; + username: string | undefined; + password: string | undefined; + accessToken: string | (() => string) | undefined; } \ No newline at end of file diff --git a/samples/client/petstore/typescript-jquery/default/.openapi-generator-ignore b/samples/client/petstore/typescript-jquery/default/.openapi-generator-ignore index c5fa491b4c5..7484ee590a3 100644 --- a/samples/client/petstore/typescript-jquery/default/.openapi-generator-ignore +++ b/samples/client/petstore/typescript-jquery/default/.openapi-generator-ignore @@ -1,11 +1,11 @@ -# Swagger Codegen Ignore -# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator # Use this file to prevent files from being overwritten by the generator. # The patterns follow closely to .gitignore or .dockerignore. # As an example, the C# client generator defines ApiClient.cs. -# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line: +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: #ApiClient.cs # You can match any string of characters against a directory, file or extension with a single asterisk (*): diff --git a/samples/client/petstore/typescript-jquery/default/api/PetApi.ts b/samples/client/petstore/typescript-jquery/default/api/PetApi.ts index 7da20e6acdb..4985ab13074 100644 --- a/samples/client/petstore/typescript-jquery/default/api/PetApi.ts +++ b/samples/client/petstore/typescript-jquery/default/api/PetApi.ts @@ -22,7 +22,7 @@ import { Configuration } from '../configuration'; export class PetApi { protected basePath = 'http://petstore.swagger.io/v2'; public defaultHeaders: Array = []; - public defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings = null; + public defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings = undefined; public configuration: Configuration = new Configuration(); constructor(basePath?: string, configuration?: Configuration, defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings) { @@ -37,7 +37,7 @@ export class PetApi { } } - private extendObj(objA: T2, objB: T2): T1|T2 { + private extendObj(objA: T2, objB: T2): T1|T2 { for (let key in objB) { if (objB.hasOwnProperty(key)) { objA[key] = objB[key]; diff --git a/samples/client/petstore/typescript-jquery/default/api/StoreApi.ts b/samples/client/petstore/typescript-jquery/default/api/StoreApi.ts index d1c0a00432a..cf2b58ec9d9 100644 --- a/samples/client/petstore/typescript-jquery/default/api/StoreApi.ts +++ b/samples/client/petstore/typescript-jquery/default/api/StoreApi.ts @@ -22,7 +22,7 @@ import { Configuration } from '../configuration'; export class StoreApi { protected basePath = 'http://petstore.swagger.io/v2'; public defaultHeaders: Array = []; - public defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings = null; + public defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings = undefined; public configuration: Configuration = new Configuration(); constructor(basePath?: string, configuration?: Configuration, defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings) { @@ -37,7 +37,7 @@ export class StoreApi { } } - private extendObj(objA: T2, objB: T2): T1|T2 { + private extendObj(objA: T2, objB: T2): T1|T2 { for (let key in objB) { if (objB.hasOwnProperty(key)) { objA[key] = objB[key]; diff --git a/samples/client/petstore/typescript-jquery/default/api/UserApi.ts b/samples/client/petstore/typescript-jquery/default/api/UserApi.ts index bbe42be94b4..c2469d6ef19 100644 --- a/samples/client/petstore/typescript-jquery/default/api/UserApi.ts +++ b/samples/client/petstore/typescript-jquery/default/api/UserApi.ts @@ -22,7 +22,7 @@ import { Configuration } from '../configuration'; export class UserApi { protected basePath = 'http://petstore.swagger.io/v2'; public defaultHeaders: Array = []; - public defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings = null; + public defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings = undefined; public configuration: Configuration = new Configuration(); constructor(basePath?: string, configuration?: Configuration, defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings) { @@ -37,7 +37,7 @@ export class UserApi { } } - private extendObj(objA: T2, objB: T2): T1|T2 { + private extendObj(objA: T2, objB: T2): T1|T2 { for (let key in objB) { if (objB.hasOwnProperty(key)) { objA[key] = objB[key]; diff --git a/samples/client/petstore/typescript-jquery/default/configuration.ts b/samples/client/petstore/typescript-jquery/default/configuration.ts index a566a180e4e..658e6ad5f61 100644 --- a/samples/client/petstore/typescript-jquery/default/configuration.ts +++ b/samples/client/petstore/typescript-jquery/default/configuration.ts @@ -1,6 +1,6 @@ export class Configuration { - apiKey: string; - username: string; - password: string; - accessToken: string | (() => string); + apiKey: string | undefined; + username: string | undefined; + password: string | undefined; + accessToken: string | (() => string) | undefined; } \ No newline at end of file diff --git a/samples/client/petstore/typescript-jquery/default/model/Amount.ts b/samples/client/petstore/typescript-jquery/default/model/Amount.ts deleted file mode 100644 index 5916e491d1c..00000000000 --- a/samples/client/petstore/typescript-jquery/default/model/Amount.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. - * - * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - -import * as models from './models'; - -/** - * some description - */ -export interface Amount { - /** - * some description - */ - value: number; - - currency: models.Currency; - -} diff --git a/samples/client/petstore/typescript-jquery/default/model/Currency.ts b/samples/client/petstore/typescript-jquery/default/model/Currency.ts deleted file mode 100644 index a5f758cb6c3..00000000000 --- a/samples/client/petstore/typescript-jquery/default/model/Currency.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. - * - * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - -import * as models from './models'; - -/** - * some description - */ -export interface Currency { -} diff --git a/samples/client/petstore/typescript-jquery/npm/api/PetApi.ts b/samples/client/petstore/typescript-jquery/npm/api/PetApi.ts index 7da20e6acdb..4985ab13074 100644 --- a/samples/client/petstore/typescript-jquery/npm/api/PetApi.ts +++ b/samples/client/petstore/typescript-jquery/npm/api/PetApi.ts @@ -22,7 +22,7 @@ import { Configuration } from '../configuration'; export class PetApi { protected basePath = 'http://petstore.swagger.io/v2'; public defaultHeaders: Array = []; - public defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings = null; + public defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings = undefined; public configuration: Configuration = new Configuration(); constructor(basePath?: string, configuration?: Configuration, defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings) { @@ -37,7 +37,7 @@ export class PetApi { } } - private extendObj(objA: T2, objB: T2): T1|T2 { + private extendObj(objA: T2, objB: T2): T1|T2 { for (let key in objB) { if (objB.hasOwnProperty(key)) { objA[key] = objB[key]; diff --git a/samples/client/petstore/typescript-jquery/npm/api/StoreApi.ts b/samples/client/petstore/typescript-jquery/npm/api/StoreApi.ts index d1c0a00432a..cf2b58ec9d9 100644 --- a/samples/client/petstore/typescript-jquery/npm/api/StoreApi.ts +++ b/samples/client/petstore/typescript-jquery/npm/api/StoreApi.ts @@ -22,7 +22,7 @@ import { Configuration } from '../configuration'; export class StoreApi { protected basePath = 'http://petstore.swagger.io/v2'; public defaultHeaders: Array = []; - public defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings = null; + public defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings = undefined; public configuration: Configuration = new Configuration(); constructor(basePath?: string, configuration?: Configuration, defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings) { @@ -37,7 +37,7 @@ export class StoreApi { } } - private extendObj(objA: T2, objB: T2): T1|T2 { + private extendObj(objA: T2, objB: T2): T1|T2 { for (let key in objB) { if (objB.hasOwnProperty(key)) { objA[key] = objB[key]; diff --git a/samples/client/petstore/typescript-jquery/npm/api/UserApi.ts b/samples/client/petstore/typescript-jquery/npm/api/UserApi.ts index bbe42be94b4..c2469d6ef19 100644 --- a/samples/client/petstore/typescript-jquery/npm/api/UserApi.ts +++ b/samples/client/petstore/typescript-jquery/npm/api/UserApi.ts @@ -22,7 +22,7 @@ import { Configuration } from '../configuration'; export class UserApi { protected basePath = 'http://petstore.swagger.io/v2'; public defaultHeaders: Array = []; - public defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings = null; + public defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings = undefined; public configuration: Configuration = new Configuration(); constructor(basePath?: string, configuration?: Configuration, defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings) { @@ -37,7 +37,7 @@ export class UserApi { } } - private extendObj(objA: T2, objB: T2): T1|T2 { + private extendObj(objA: T2, objB: T2): T1|T2 { for (let key in objB) { if (objB.hasOwnProperty(key)) { objA[key] = objB[key]; diff --git a/samples/client/petstore/typescript-jquery/npm/configuration.ts b/samples/client/petstore/typescript-jquery/npm/configuration.ts index a566a180e4e..658e6ad5f61 100644 --- a/samples/client/petstore/typescript-jquery/npm/configuration.ts +++ b/samples/client/petstore/typescript-jquery/npm/configuration.ts @@ -1,6 +1,6 @@ export class Configuration { - apiKey: string; - username: string; - password: string; - accessToken: string | (() => string); + apiKey: string | undefined; + username: string | undefined; + password: string | undefined; + accessToken: string | (() => string) | undefined; } \ No newline at end of file diff --git a/samples/client/petstore/typescript-node/default/model/inlineObject.ts b/samples/client/petstore/typescript-node/default/model/inlineObject.ts deleted file mode 100644 index b9396dae34f..00000000000 --- a/samples/client/petstore/typescript-node/default/model/inlineObject.ts +++ /dev/null @@ -1,42 +0,0 @@ -/** - * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -export class InlineObject { - /** - * Updated name of the pet - */ - 'name'?: string; - /** - * Updated status of the pet - */ - 'status'?: string; - - static discriminator: string | undefined = undefined; - - static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ - { - "name": "name", - "baseName": "name", - "type": "string" - }, - { - "name": "status", - "baseName": "status", - "type": "string" - } ]; - - static getAttributeTypeMap() { - return InlineObject.attributeTypeMap; - } -} - diff --git a/samples/client/petstore/typescript-node/default/model/inlineObject1.ts b/samples/client/petstore/typescript-node/default/model/inlineObject1.ts deleted file mode 100644 index a9c57cdab63..00000000000 --- a/samples/client/petstore/typescript-node/default/model/inlineObject1.ts +++ /dev/null @@ -1,42 +0,0 @@ -/** - * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -export class InlineObject1 { - /** - * Additional data to pass to server - */ - 'additionalMetadata'?: string; - /** - * file to upload - */ - 'file'?: Buffer; - - static discriminator: string | undefined = undefined; - - static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ - { - "name": "additionalMetadata", - "baseName": "additionalMetadata", - "type": "string" - }, - { - "name": "file", - "baseName": "file", - "type": "Buffer" - } ]; - - static getAttributeTypeMap() { - return InlineObject1.attributeTypeMap; - } -} -