diff --git a/.github/workflows/samples-typescript-encode-decode.yaml b/.github/workflows/samples-typescript-encode-decode.yaml new file mode 100644 index 000000000000..d8ba1cc00fa3 --- /dev/null +++ b/.github/workflows/samples-typescript-encode-decode.yaml @@ -0,0 +1,37 @@ +name: TypeScript Client (Encoding / Decoding Test) + +on: + pull_request: + paths: + - samples/client/others/typescript/encode-decode/** + - .github/workflows/samples-typescript-encode-decode.yaml +jobs: + build: + name: Test TypeScript Encoding / Decoding + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + sample: + # clients + - samples/client/others/typescript/encode-decode/test + node-version: + - 16 + - 18 + - 20 + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + + - name: Install + working-directory: ${{ matrix.sample }} + run: | + npm run preinstall + npm i + + - name: Test + working-directory: ${{ matrix.sample }} + run: npm test diff --git a/.github/workflows/samples-typescript-node-encode-decode.yaml b/.github/workflows/samples-typescript-node-encode-decode.yaml new file mode 100644 index 000000000000..e60e99ad71f9 --- /dev/null +++ b/.github/workflows/samples-typescript-node-encode-decode.yaml @@ -0,0 +1,37 @@ +name: TypeScript Node Client (Encoding / Decoding Test) + +on: + pull_request: + paths: + - samples/client/others/typescript-node/encode-decode/** + - .github/workflows/samples-typescript-node-encode-decode.yaml +jobs: + build: + name: Test TypeScript Node Encoding / Decoding + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + sample: + # clients + - samples/client/others/typescript-node/encode-decode/test + node-version: + - 16 + - 18 + - 20 + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + + - name: Install + working-directory: ${{ matrix.sample }} + run: | + npm run preinstall + npm i + + - name: Test + working-directory: ${{ matrix.sample }} + run: npm test diff --git a/bin/configs/typescript-encode-decode.yaml b/bin/configs/typescript-encode-decode.yaml new file mode 100644 index 000000000000..fb75a581b4c6 --- /dev/null +++ b/bin/configs/typescript-encode-decode.yaml @@ -0,0 +1,11 @@ +generatorName: typescript +outputDir: samples/client/others/typescript/encode-decode/build +inputSpec: modules/openapi-generator/src/test/resources/3_1/encode-decode.yaml +templateDir: modules/openapi-generator/src/main/resources/typescript +additionalProperties: + artifactId: encode-decode-typescript + hideGenerationTimestamp: "true" + npmVersion: 1.0.0 + npmName: '@openapitools/typescript-encode-decode' + nullSafeAdditionalProps: true + platform: node diff --git a/bin/configs/typescript-node-encode-decode.yaml b/bin/configs/typescript-node-encode-decode.yaml new file mode 100644 index 000000000000..c40c53311d11 --- /dev/null +++ b/bin/configs/typescript-node-encode-decode.yaml @@ -0,0 +1,10 @@ +generatorName: typescript-node +outputDir: samples/client/others/typescript-node/encode-decode/build +inputSpec: modules/openapi-generator/src/test/resources/3_1/encode-decode.yaml +templateDir: modules/openapi-generator/src/main/resources/typescript-node +additionalProperties: + artifactId: encode-decode-typescript-node + hideGenerationTimestamp: "true" + npmVersion: 1.0.0 + npmName: '@openapitools/typescript-node-encode-decode' + nullSafeAdditionalProps: true diff --git a/modules/openapi-generator/src/main/resources/typescript-angular/tsconfig.mustache b/modules/openapi-generator/src/main/resources/typescript-angular/tsconfig.mustache index dd4391c668ac..98114ac5a51a 100644 --- a/modules/openapi-generator/src/main/resources/typescript-angular/tsconfig.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-angular/tsconfig.mustache @@ -3,7 +3,6 @@ "emitDecoratorMetadata": true, "experimentalDecorators": true, "noImplicitAny": false, - "suppressImplicitAnyIndexErrors": true, "target": "{{#supportsES6}}es6{{/supportsES6}}{{^supportsES6}}es5{{/supportsES6}}", "module": "{{#supportsES6}}es6{{/supportsES6}}{{^supportsES6}}commonjs{{/supportsES6}}", "moduleResolution": "node", diff --git a/modules/openapi-generator/src/main/resources/typescript-inversify/tsconfig.mustache b/modules/openapi-generator/src/main/resources/typescript-inversify/tsconfig.mustache index dd4391c668ac..98114ac5a51a 100644 --- a/modules/openapi-generator/src/main/resources/typescript-inversify/tsconfig.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-inversify/tsconfig.mustache @@ -3,7 +3,6 @@ "emitDecoratorMetadata": true, "experimentalDecorators": true, "noImplicitAny": false, - "suppressImplicitAnyIndexErrors": true, "target": "{{#supportsES6}}es6{{/supportsES6}}{{^supportsES6}}es5{{/supportsES6}}", "module": "{{#supportsES6}}es6{{/supportsES6}}{{^supportsES6}}commonjs{{/supportsES6}}", "moduleResolution": "node", diff --git a/modules/openapi-generator/src/main/resources/typescript-jquery/tsconfig.mustache b/modules/openapi-generator/src/main/resources/typescript-jquery/tsconfig.mustache index f255a8814fc0..41ef7d260aa7 100644 --- a/modules/openapi-generator/src/main/resources/typescript-jquery/tsconfig.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-jquery/tsconfig.mustache @@ -2,7 +2,6 @@ "compilerOptions": { "module": "commonjs", "noImplicitAny": false, - "suppressImplicitAnyIndexErrors": true, "target": "{{#supportsES6}}ES6{{/supportsES6}}{{^supportsES6}}ES5{{/supportsES6}}", "moduleResolution": "node", "removeComments": true, diff --git a/modules/openapi-generator/src/main/resources/typescript-node/models.mustache b/modules/openapi-generator/src/main/resources/typescript-node/models.mustache index e803dfeb6647..96b3fb2b826b 100644 --- a/modules/openapi-generator/src/main/resources/typescript-node/models.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-node/models.mustache @@ -68,6 +68,23 @@ let typeMap: {[index: string]: any} = { {{/models}} } +// Check if a string starts with another string without using es6 features +function startsWith(str: string, match: string): boolean { + return str.substring(0, match.length) === match; +} + +// Check if a string ends with another string without using es6 features +function endsWith(str: string, match: string): boolean { + return str.length >= match.length && str.substring(str.length - match.length) === match; +} + +const nullableSuffix = " | null"; +const optionalSuffix = " | undefined"; +const arrayPrefix = "Array<"; +const arraySuffix = ">"; +const mapPrefix = "{ [key: string]: "; +const mapSuffix = "; }"; + export class ObjectSerializer { public static findCorrectType(data: any, expectedType: string) { if (data == undefined) { @@ -104,20 +121,35 @@ export class ObjectSerializer { } } - public static serialize(data: any, type: string) { + public static serialize(data: any, type: string): any { if (data == undefined) { return data; } else if (primitives.indexOf(type.toLowerCase()) !== -1) { return data; - } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 - let subType: string = type.replace("Array<", ""); // Array => Type> - subType = subType.substring(0, subType.length - 1); // Type> => Type + } else if (endsWith(type, nullableSuffix)) { + let subType: string = type.slice(0, -nullableSuffix.length); // Type | null => Type + return ObjectSerializer.serialize(data, subType); + } else if (endsWith(type, optionalSuffix)) { + let subType: string = type.slice(0, -optionalSuffix.length); // Type | undefined => Type + return ObjectSerializer.serialize(data, subType); + } else if (startsWith(type, arrayPrefix)) { + let subType: string = type.slice(arrayPrefix.length, -arraySuffix.length); // Array => Type let transformedData: any[] = []; for (let index = 0; index < data.length; index++) { let datum = data[index]; transformedData.push(ObjectSerializer.serialize(datum, subType)); } return transformedData; + } else if (startsWith(type, mapPrefix)) { + let subType: string = type.slice(mapPrefix.length, -mapSuffix.length); // { [key: string]: Type; } => Type + let transformedData: { [key: string]: any } = {}; + for (let key in data) { + transformedData[key] = ObjectSerializer.serialize( + data[key], + subType, + ); + } + return transformedData; } else if (type === "Date") { return data.toISOString(); } else { @@ -142,22 +174,37 @@ export class ObjectSerializer { } } - public static deserialize(data: any, type: string) { + public static deserialize(data: any, type: string): any { // polymorphism may change the actual type. type = ObjectSerializer.findCorrectType(data, type); if (data == undefined) { return data; } else if (primitives.indexOf(type.toLowerCase()) !== -1) { return data; - } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 - let subType: string = type.replace("Array<", ""); // Array => Type> - subType = subType.substring(0, subType.length - 1); // Type> => Type + } else if (endsWith(type, nullableSuffix)) { + let subType: string = type.slice(0, -nullableSuffix.length); // Type | null => Type + return ObjectSerializer.deserialize(data, subType); + } else if (endsWith(type, optionalSuffix)) { + let subType: string = type.slice(0, -optionalSuffix.length); // Type | undefined => Type + return ObjectSerializer.deserialize(data, subType); + } else if (startsWith(type, arrayPrefix)) { + let subType: string = type.slice(arrayPrefix.length, -arraySuffix.length); // Array => Type let transformedData: any[] = []; for (let index = 0; index < data.length; index++) { let datum = data[index]; transformedData.push(ObjectSerializer.deserialize(datum, subType)); } return transformedData; + } else if (startsWith(type, mapPrefix)) { + let subType: string = type.slice(mapPrefix.length, -mapSuffix.length); // { [key: string]: Type; } => Type + let transformedData: { [key: string]: any } = {}; + for (let key in data) { + transformedData[key] = ObjectSerializer.deserialize( + data[key], + subType, + ); + } + return transformedData; } else if (type === "Date") { return new Date(data); } else { diff --git a/modules/openapi-generator/src/main/resources/typescript-node/tsconfig.mustache b/modules/openapi-generator/src/main/resources/typescript-node/tsconfig.mustache index de78697d22a3..81217cba20cb 100644 --- a/modules/openapi-generator/src/main/resources/typescript-node/tsconfig.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-node/tsconfig.mustache @@ -2,7 +2,6 @@ "compilerOptions": { "module": "commonjs", "noImplicitAny": false, - "suppressImplicitAnyIndexErrors": true, "target": "{{#supportsES6}}ES6{{/supportsES6}}{{^supportsES6}}ES5{{/supportsES6}}", "allowSyntheticDefaultImports": true, "esModuleInterop": true, diff --git a/modules/openapi-generator/src/main/resources/typescript/model/ObjectSerializer.mustache b/modules/openapi-generator/src/main/resources/typescript/model/ObjectSerializer.mustache index f08a7af94f38..791335e78ed3 100644 --- a/modules/openapi-generator/src/main/resources/typescript/model/ObjectSerializer.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/model/ObjectSerializer.mustache @@ -101,6 +101,13 @@ const supportedMimeTypePredicatesWithPriority: MimeTypePredicate[] = [ isFormUrlencodedMimeType, ]; +const nullableSuffix = " | null"; +const optionalSuffix = " | undefined"; +const arrayPrefix = "Array<"; +const arraySuffix = ">"; +const mapPrefix = "{ [key: string]: "; +const mapSuffix = "; }"; + export class ObjectSerializer { public static findCorrectType(data: any, expectedType: string) { if (data == undefined) { @@ -140,19 +147,35 @@ export class ObjectSerializer { } } - public static serialize(data: any, type: string, format: string) { + public static serialize(data: any, type: string, format: string): any { if (data == undefined) { return data; } else if (primitives.indexOf(type.toLowerCase()) !== -1) { return data; - } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 - let subType: string = type.replace("Array<", ""); // Array => Type> - subType = subType.substring(0, subType.length - 1); // Type> => Type + } else if (type.endsWith(nullableSuffix)) { + let subType: string = type.slice(0, -nullableSuffix.length); // Type | null => Type + return ObjectSerializer.serialize(data, subType, format); + } else if (type.endsWith(optionalSuffix)) { + let subType: string = type.slice(0, -optionalSuffix.length); // Type | undefined => Type + return ObjectSerializer.serialize(data, subType, format); + } else if (type.startsWith(arrayPrefix)) { + let subType: string = type.slice(arrayPrefix.length, -arraySuffix.length); // Array => Type let transformedData: any[] = []; for (let date of data) { transformedData.push(ObjectSerializer.serialize(date, subType, format)); } return transformedData; + } else if (type.startsWith(mapPrefix)) { + let subType: string = type.slice(mapPrefix.length, -mapSuffix.length); // { [key: string]: Type; } => Type + let transformedData: { [key: string]: any } = {}; + for (let key in data) { + transformedData[key] = ObjectSerializer.serialize( + data[key], + subType, + format, + ); + } + return transformedData; } else if (type === "Date") { if (format == "date") { let month = data.getMonth()+1 @@ -185,21 +208,37 @@ export class ObjectSerializer { } } - public static deserialize(data: any, type: string, format: string) { + public static deserialize(data: any, type: string, format: string): any { // polymorphism may change the actual type. type = ObjectSerializer.findCorrectType(data, type); if (data == undefined) { return data; } else if (primitives.indexOf(type.toLowerCase()) !== -1) { return data; - } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 - let subType: string = type.replace("Array<", ""); // Array => Type> - subType = subType.substring(0, subType.length - 1); // Type> => Type + } else if (type.endsWith(nullableSuffix)) { + let subType: string = type.slice(0, -nullableSuffix.length); // Type | null => Type + return ObjectSerializer.deserialize(data, subType, format); + } else if (type.endsWith(optionalSuffix)) { + let subType: string = type.slice(0, -optionalSuffix.length); // Type | undefined => Type + return ObjectSerializer.deserialize(data, subType, format); + } else if (type.startsWith(arrayPrefix)) { + let subType: string = type.slice(arrayPrefix.length, -arraySuffix.length); // Array => Type let transformedData: any[] = []; for (let date of data) { transformedData.push(ObjectSerializer.deserialize(date, subType, format)); } return transformedData; + } else if (type.startsWith(mapPrefix)) { + let subType: string = type.slice(mapPrefix.length, -mapSuffix.length); // { [key: string]: Type; } => Type + let transformedData: { [key: string]: any } = {}; + for (let key in data) { + transformedData[key] = ObjectSerializer.deserialize( + data[key], + subType, + format, + ); + } + return transformedData; } else if (type === "Date") { return new Date(data); } else { diff --git a/modules/openapi-generator/src/test/resources/3_1/encode-decode.yaml b/modules/openapi-generator/src/test/resources/3_1/encode-decode.yaml new file mode 100644 index 000000000000..fe5b176d9e14 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_1/encode-decode.yaml @@ -0,0 +1,401 @@ +openapi: 3.1.0 +info: + title: 'Encoding / Decoding Test' + description: 'A spec to ensure encoding and decoding of types (both primitive and compound) works as expected' + version: latest +paths: + /test/decode/primitive/boolean: + get: + responses: + '200': + description: 'Decodes a boolean' + content: + application/json: + schema: + type: boolean + /test/decode/primitive/integer: + get: + responses: + '200': + description: 'Decodes an integer' + content: + application/json: + schema: + type: integer + /test/decode/primitive/number: + get: + responses: + '200': + description: 'Decodes a number' + content: + application/json: + schema: + type: number + /test/decode/primitive/string: + get: + responses: + '200': + description: 'Decodes a string' + content: + application/json: + schema: + type: string + /test/decode/nullable: + get: + responses: + '200': + description: 'Decodes a nullable type' + content: + application/json: + schema: + type: [string, 'null'] + /test/decode/array-of: + get: + responses: + '200': + description: 'Decodes an array of primitive types' + content: + application/json: + schema: + type: array + items: + type: string + /test/decode/array-of/nullable: + get: + responses: + '200': + description: 'Decodes an array of nullable types' + content: + application/json: + schema: + type: array + items: + type: [string, 'null'] + /test/decode/nullable-array: + get: + responses: + '200': + description: 'Decodes a nullable array' + content: + application/json: + schema: + type: [array, 'null'] + items: + type: string + /test/decode/array-of-arrays: + get: + responses: + '200': + description: 'Decodes an array of arrays' + content: + application/json: + schema: + type: array + items: + type: array + items: + type: string + /test/decode/object: + get: + responses: + '200': + description: 'Decodes an object' + content: + application/json: + schema: + $ref: '#/components/schemas/ComplexObject' + /test/decode/map-of/primitive: + get: + responses: + '200': + description: 'Decodes a map of primitive types' + content: + application/json: + schema: + type: object + additionalProperties: + type: string + /test/decode/map-of/objects: + get: + responses: + '200': + description: 'Decodes a map of objects' + content: + application/json: + schema: + type: object + additionalProperties: + $ref: '#/components/schemas/ComplexObject' + /test/decode/map-of/maps-of/objects: + get: + responses: + '200': + description: 'Decodes a map of maps of objects' + content: + application/json: + schema: + type: object + additionalProperties: + type: object + additionalProperties: + $ref: '#/components/schemas/ComplexObject' + /test/decode/array-of/maps-of/objects: + get: + responses: + '200': + description: 'Decodes an array of maps of complex objects' + content: + application/json: + schema: + type: array + items: + type: object + additionalProperties: + $ref: '#/components/schemas/ComplexObject' + /test/decode/array-of/nullable-objects: + get: + responses: + '200': + description: 'Decodes an array of nullable objects' + content: + application/json: + schema: + type: array + items: + oneOf: + - $ref: '#/components/schemas/ComplexObject' + - type: 'null' + /test/decode/composite-objects: + get: + responses: + '200': + description: 'Decodes a composite object' + content: + application/json: + schema: + $ref: '#/components/schemas/CompositeObject' + /test/encode/primitive/boolean: + post: + requestBody: + required: true + content: + application/json: + schema: + type: boolean + responses: + '200': + description: 'Encodes a boolean' + /test/encode/primitive/integer: + post: + requestBody: + required: true + content: + application/json: + schema: + type: integer + responses: + '200': + description: 'Encodes an integer' + /test/encode/primitive/number: + post: + requestBody: + required: true + content: + application/json: + schema: + type: number + responses: + '200': + description: 'Encodes a number' + /test/encode/primitive/string: + post: + requestBody: + required: true + content: + application/json: + schema: + type: string + responses: + '200': + description: 'Encodes a string' + /test/encode/nullable: + post: + requestBody: + required: false + content: + application/json: + schema: + type: [string, 'null'] + responses: + '200': + description: 'Encodes a nullable type' + /test/encode/array-of: + post: + requestBody: + required: true + content: + application/json: + schema: + type: array + items: + type: string + responses: + '200': + description: 'Encodes an array of primitive types' + /test/encode/array-of/nullable: + post: + requestBody: + required: true + content: + application/json: + schema: + type: array + items: + type: [string, 'null'] + responses: + '200': + description: 'Encodes an array of nullable types' + /test/encode/nullable-array: + post: + requestBody: + required: false + content: + application/json: + schema: + type: [array, 'null'] + items: + type: string + responses: + '200': + description: 'Encodes a nullable array' + /test/encode/array-of-arrays: + post: + requestBody: + required: true + content: + application/json: + schema: + type: array + items: + type: array + items: + type: string + responses: + '200': + description: 'Encodes an array of arrays' + /test/encode/object: + post: + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/ComplexObject' + responses: + '200': + description: 'Encodes an object' + /test/encode/map-of/primitive: + post: + requestBody: + required: true + content: + application/json: + schema: + type: object + additionalProperties: + type: string + responses: + '200': + description: 'Encodes a map of primitive types' + /test/encode/map-of/objects: + post: + requestBody: + required: true + content: + application/json: + schema: + type: object + additionalProperties: + $ref: '#/components/schemas/ComplexObject' + responses: + '200': + description: 'Encodes a map of objects' + /test/encode/map-of/maps-of/objects: + post: + requestBody: + required: true + content: + application/json: + schema: + type: object + additionalProperties: + type: object + additionalProperties: + $ref: '#/components/schemas/ComplexObject' + responses: + '200': + description: 'Encodes a map of maps of objects' + /test/encode/array-of/maps-of/objects: + post: + requestBody: + required: true + content: + application/json: + schema: + type: array + items: + type: object + additionalProperties: + $ref: '#/components/schemas/ComplexObject' + responses: + '200': + description: 'Encodes an array of maps of complex objects' + /test/encode/array-of/nullable-objects: + post: + requestBody: + required: true + content: + application/json: + schema: + type: array + items: + oneOf: + - $ref: '#/components/schemas/ComplexObject' + - type: 'null' + responses: + '200': + description: 'Encodes an array of nullable objects' + /test/encode/composite-objects: + post: + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/CompositeObject' + responses: + '200': + description: 'Encodes a composite object' +components: + schemas: + ComplexObject: + type: object + required: + - required_property + - required_nullable_property + properties: + required_property: + type: string + required_nullable_property: + type: [string, 'null'] + optional_property: + type: string + optional_nullable_property: + type: [string, 'null'] + CompositeObject: + type: object + properties: + optional_nullable_inner_object: + oneOf: + - $ref: '#/components/schemas/ComplexObject' + - type: 'null' diff --git a/modules/openapi-generator/src/test/resources/integrationtests/typescript/additional-properties-expected/tsconfig.json b/modules/openapi-generator/src/test/resources/integrationtests/typescript/additional-properties-expected/tsconfig.json index c01ebe255d4c..89cdedb1cb7f 100644 --- a/modules/openapi-generator/src/test/resources/integrationtests/typescript/additional-properties-expected/tsconfig.json +++ b/modules/openapi-generator/src/test/resources/integrationtests/typescript/additional-properties-expected/tsconfig.json @@ -3,7 +3,6 @@ "emitDecoratorMetadata": true, "experimentalDecorators": true, "noImplicitAny": false, - "suppressImplicitAnyIndexErrors": true, "target": "es5", "module": "commonjs", "moduleResolution": "node", diff --git a/modules/openapi-generator/src/test/resources/integrationtests/typescript/array-and-object-expected/tsconfig.json b/modules/openapi-generator/src/test/resources/integrationtests/typescript/array-and-object-expected/tsconfig.json index c01ebe255d4c..89cdedb1cb7f 100644 --- a/modules/openapi-generator/src/test/resources/integrationtests/typescript/array-and-object-expected/tsconfig.json +++ b/modules/openapi-generator/src/test/resources/integrationtests/typescript/array-and-object-expected/tsconfig.json @@ -3,7 +3,6 @@ "emitDecoratorMetadata": true, "experimentalDecorators": true, "noImplicitAny": false, - "suppressImplicitAnyIndexErrors": true, "target": "es5", "module": "commonjs", "moduleResolution": "node", diff --git a/modules/openapi-generator/src/test/resources/integrationtests/typescript/custom-path-params-expected/tsconfig.json b/modules/openapi-generator/src/test/resources/integrationtests/typescript/custom-path-params-expected/tsconfig.json index c01ebe255d4c..89cdedb1cb7f 100644 --- a/modules/openapi-generator/src/test/resources/integrationtests/typescript/custom-path-params-expected/tsconfig.json +++ b/modules/openapi-generator/src/test/resources/integrationtests/typescript/custom-path-params-expected/tsconfig.json @@ -3,7 +3,6 @@ "emitDecoratorMetadata": true, "experimentalDecorators": true, "noImplicitAny": false, - "suppressImplicitAnyIndexErrors": true, "target": "es5", "module": "commonjs", "moduleResolution": "node", diff --git a/modules/openapi-generator/src/test/resources/integrationtests/typescript/node-es5-expected/tsconfig.json b/modules/openapi-generator/src/test/resources/integrationtests/typescript/node-es5-expected/tsconfig.json index 9a007e9f866b..b07d5d7eaa2e 100644 --- a/modules/openapi-generator/src/test/resources/integrationtests/typescript/node-es5-expected/tsconfig.json +++ b/modules/openapi-generator/src/test/resources/integrationtests/typescript/node-es5-expected/tsconfig.json @@ -2,7 +2,6 @@ "compilerOptions": { "module": "commonjs", "noImplicitAny": false, - "suppressImplicitAnyIndexErrors": true, "target": "ES5", "moduleResolution": "node", "removeComments": true, diff --git a/modules/openapi-generator/src/test/resources/integrationtests/typescript/objectsWithEnums-expected/tsconfig.json b/modules/openapi-generator/src/test/resources/integrationtests/typescript/objectsWithEnums-expected/tsconfig.json index ba2570a4bee6..bed9df7fbbbd 100644 --- a/modules/openapi-generator/src/test/resources/integrationtests/typescript/objectsWithEnums-expected/tsconfig.json +++ b/modules/openapi-generator/src/test/resources/integrationtests/typescript/objectsWithEnums-expected/tsconfig.json @@ -2,7 +2,6 @@ "compilerOptions": { "module": "commonjs", "noImplicitAny": false, - "suppressImplicitAnyIndexErrors": true, "target": "ES5", "strict": true, "moduleResolution": "node", diff --git a/modules/openapi-generator/src/test/resources/integrationtests/typescript/petstore-expected/tsconfig.json b/modules/openapi-generator/src/test/resources/integrationtests/typescript/petstore-expected/tsconfig.json index c01ebe255d4c..89cdedb1cb7f 100644 --- a/modules/openapi-generator/src/test/resources/integrationtests/typescript/petstore-expected/tsconfig.json +++ b/modules/openapi-generator/src/test/resources/integrationtests/typescript/petstore-expected/tsconfig.json @@ -3,7 +3,6 @@ "emitDecoratorMetadata": true, "experimentalDecorators": true, "noImplicitAny": false, - "suppressImplicitAnyIndexErrors": true, "target": "es5", "module": "commonjs", "moduleResolution": "node", diff --git a/samples/client/others/typescript-node/encode-decode/build/.gitignore b/samples/client/others/typescript-node/encode-decode/build/.gitignore new file mode 100644 index 000000000000..149b57654723 --- /dev/null +++ b/samples/client/others/typescript-node/encode-decode/build/.gitignore @@ -0,0 +1,4 @@ +wwwroot/*.js +node_modules +typings +dist diff --git a/samples/client/others/typescript-node/encode-decode/build/.openapi-generator-ignore b/samples/client/others/typescript-node/encode-decode/build/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/client/others/typescript-node/encode-decode/build/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# 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 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 (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/client/others/typescript-node/encode-decode/build/.openapi-generator/FILES b/samples/client/others/typescript-node/encode-decode/build/.openapi-generator/FILES new file mode 100644 index 000000000000..02a42341beff --- /dev/null +++ b/samples/client/others/typescript-node/encode-decode/build/.openapi-generator/FILES @@ -0,0 +1,10 @@ +.gitignore +api.ts +api/apis.ts +api/defaultApi.ts +git_push.sh +model/complexObject.ts +model/compositeObject.ts +model/models.ts +package.json +tsconfig.json diff --git a/samples/client/others/typescript-node/encode-decode/build/.openapi-generator/VERSION b/samples/client/others/typescript-node/encode-decode/build/.openapi-generator/VERSION new file mode 100644 index 000000000000..17f2442ff3bc --- /dev/null +++ b/samples/client/others/typescript-node/encode-decode/build/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.9.0-SNAPSHOT diff --git a/samples/client/others/typescript-node/encode-decode/build/api.ts b/samples/client/others/typescript-node/encode-decode/build/api.ts new file mode 100644 index 000000000000..b1119f15c47f --- /dev/null +++ b/samples/client/others/typescript-node/encode-decode/build/api.ts @@ -0,0 +1,3 @@ +// This is the entrypoint for the package +export * from './api/apis'; +export * from './model/models'; diff --git a/samples/client/others/typescript-node/encode-decode/build/api/apis.ts b/samples/client/others/typescript-node/encode-decode/build/api/apis.ts new file mode 100644 index 000000000000..93aa6621e32e --- /dev/null +++ b/samples/client/others/typescript-node/encode-decode/build/api/apis.ts @@ -0,0 +1,14 @@ +export * from './defaultApi'; +import { DefaultApi } from './defaultApi'; +import * as http from 'http'; + +export class HttpError extends Error { + constructor (public response: http.IncomingMessage, public body: any, public statusCode?: number) { + super('HTTP request failed'); + this.name = 'HttpError'; + } +} + +export { RequestFile } from '../model/models'; + +export const APIS = [DefaultApi]; diff --git a/samples/client/others/typescript-node/encode-decode/build/api/defaultApi.ts b/samples/client/others/typescript-node/encode-decode/build/api/defaultApi.ts new file mode 100644 index 000000000000..f86121d45b40 --- /dev/null +++ b/samples/client/others/typescript-node/encode-decode/build/api/defaultApi.ts @@ -0,0 +1,2016 @@ +/** + * Encoding / Decoding Test + * A spec to ensure encoding and decoding of types (both primitive and compound) works as expected + * + * The version of the OpenAPI document: latest + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +import localVarRequest from 'request'; +import http from 'http'; + +/* tslint:disable:no-unused-locals */ +import { ComplexObject } from '../model/complexObject'; +import { CompositeObject } from '../model/compositeObject'; + +import { ObjectSerializer, Authentication, VoidAuth, Interceptor } from '../model/models'; + +import { HttpError, RequestFile } from './apis'; + +let defaultBasePath = 'http://localhost'; + +// =============================================== +// This file is autogenerated - Please do not edit +// =============================================== + +export enum DefaultApiApiKeys { +} + +export class DefaultApi { + protected _basePath = defaultBasePath; + protected _defaultHeaders : any = {}; + protected _useQuerystring : boolean = false; + + protected authentications = { + 'default': new VoidAuth(), + } + + protected interceptors: Interceptor[] = []; + + constructor(basePath?: string); + constructor(basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } + + set useQuerystring(value: boolean) { + this._useQuerystring = value; + } + + set basePath(basePath: string) { + this._basePath = basePath; + } + + set defaultHeaders(defaultHeaders: any) { + this._defaultHeaders = defaultHeaders; + } + + get defaultHeaders() { + return this._defaultHeaders; + } + + get basePath() { + return this._basePath; + } + + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + + public setApiKey(key: DefaultApiApiKeys, value: string) { + (this.authentications as any)[DefaultApiApiKeys[key]].apiKey = value; + } + + public addInterceptor(interceptor: Interceptor) { + this.interceptors.push(interceptor); + } + + /** + * + */ + public async testDecodeArrayOfArraysGet (options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Array>; }> { + const localVarPath = this.basePath + '/test/decode/array-of-arrays'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); + const produces = ['application/json']; + // give precedence to 'application/json' + if (produces.indexOf('application/json') >= 0) { + localVarHeaderParams.Accept = 'application/json'; + } else { + localVarHeaderParams.Accept = produces.join(','); + } + let localVarFormParams: any = {}; + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + let authenticationPromise = Promise.resolve(); + authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); + + let interceptorPromise = authenticationPromise; + for (const interceptor of this.interceptors) { + interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); + } + + return interceptorPromise.then(() => { + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.IncomingMessage; body: Array>; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + body = ObjectSerializer.deserialize(body, "Array>"); + resolve({ response: response, body: body }); + } else { + reject(new HttpError(response, body, response.statusCode)); + } + } + }); + }); + }); + } + /** + * + */ + public async testDecodeArrayOfGet (options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Array; }> { + const localVarPath = this.basePath + '/test/decode/array-of'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); + const produces = ['application/json']; + // give precedence to 'application/json' + if (produces.indexOf('application/json') >= 0) { + localVarHeaderParams.Accept = 'application/json'; + } else { + localVarHeaderParams.Accept = produces.join(','); + } + let localVarFormParams: any = {}; + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + let authenticationPromise = Promise.resolve(); + authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); + + let interceptorPromise = authenticationPromise; + for (const interceptor of this.interceptors) { + interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); + } + + return interceptorPromise.then(() => { + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.IncomingMessage; body: Array; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + body = ObjectSerializer.deserialize(body, "Array"); + resolve({ response: response, body: body }); + } else { + reject(new HttpError(response, body, response.statusCode)); + } + } + }); + }); + }); + } + /** + * + */ + public async testDecodeArrayOfMapsOfObjectsGet (options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Array<{ [key: string]: ComplexObject | undefined; }>; }> { + const localVarPath = this.basePath + '/test/decode/array-of/maps-of/objects'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); + const produces = ['application/json']; + // give precedence to 'application/json' + if (produces.indexOf('application/json') >= 0) { + localVarHeaderParams.Accept = 'application/json'; + } else { + localVarHeaderParams.Accept = produces.join(','); + } + let localVarFormParams: any = {}; + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + let authenticationPromise = Promise.resolve(); + authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); + + let interceptorPromise = authenticationPromise; + for (const interceptor of this.interceptors) { + interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); + } + + return interceptorPromise.then(() => { + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.IncomingMessage; body: Array<{ [key: string]: ComplexObject | undefined; }>; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + body = ObjectSerializer.deserialize(body, "Array<{ [key: string]: ComplexObject | undefined; }>"); + resolve({ response: response, body: body }); + } else { + reject(new HttpError(response, body, response.statusCode)); + } + } + }); + }); + }); + } + /** + * + */ + public async testDecodeArrayOfNullableGet (options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Array; }> { + const localVarPath = this.basePath + '/test/decode/array-of/nullable'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); + const produces = ['application/json']; + // give precedence to 'application/json' + if (produces.indexOf('application/json') >= 0) { + localVarHeaderParams.Accept = 'application/json'; + } else { + localVarHeaderParams.Accept = produces.join(','); + } + let localVarFormParams: any = {}; + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + let authenticationPromise = Promise.resolve(); + authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); + + let interceptorPromise = authenticationPromise; + for (const interceptor of this.interceptors) { + interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); + } + + return interceptorPromise.then(() => { + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.IncomingMessage; body: Array; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + body = ObjectSerializer.deserialize(body, "Array"); + resolve({ response: response, body: body }); + } else { + reject(new HttpError(response, body, response.statusCode)); + } + } + }); + }); + }); + } + /** + * + */ + public async testDecodeArrayOfNullableObjectsGet (options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Array; }> { + const localVarPath = this.basePath + '/test/decode/array-of/nullable-objects'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); + const produces = ['application/json']; + // give precedence to 'application/json' + if (produces.indexOf('application/json') >= 0) { + localVarHeaderParams.Accept = 'application/json'; + } else { + localVarHeaderParams.Accept = produces.join(','); + } + let localVarFormParams: any = {}; + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + let authenticationPromise = Promise.resolve(); + authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); + + let interceptorPromise = authenticationPromise; + for (const interceptor of this.interceptors) { + interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); + } + + return interceptorPromise.then(() => { + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.IncomingMessage; body: Array; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + body = ObjectSerializer.deserialize(body, "Array"); + resolve({ response: response, body: body }); + } else { + reject(new HttpError(response, body, response.statusCode)); + } + } + }); + }); + }); + } + /** + * + */ + public async testDecodeCompositeObjectsGet (options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: CompositeObject; }> { + const localVarPath = this.basePath + '/test/decode/composite-objects'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); + const produces = ['application/json']; + // give precedence to 'application/json' + if (produces.indexOf('application/json') >= 0) { + localVarHeaderParams.Accept = 'application/json'; + } else { + localVarHeaderParams.Accept = produces.join(','); + } + let localVarFormParams: any = {}; + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + let authenticationPromise = Promise.resolve(); + authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); + + let interceptorPromise = authenticationPromise; + for (const interceptor of this.interceptors) { + interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); + } + + return interceptorPromise.then(() => { + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.IncomingMessage; body: CompositeObject; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + body = ObjectSerializer.deserialize(body, "CompositeObject"); + resolve({ response: response, body: body }); + } else { + reject(new HttpError(response, body, response.statusCode)); + } + } + }); + }); + }); + } + /** + * + */ + public async testDecodeMapOfMapsOfObjectsGet (options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: { [key: string]: { [key: string]: ComplexObject | undefined; } | undefined; }; }> { + const localVarPath = this.basePath + '/test/decode/map-of/maps-of/objects'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); + const produces = ['application/json']; + // give precedence to 'application/json' + if (produces.indexOf('application/json') >= 0) { + localVarHeaderParams.Accept = 'application/json'; + } else { + localVarHeaderParams.Accept = produces.join(','); + } + let localVarFormParams: any = {}; + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + let authenticationPromise = Promise.resolve(); + authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); + + let interceptorPromise = authenticationPromise; + for (const interceptor of this.interceptors) { + interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); + } + + return interceptorPromise.then(() => { + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.IncomingMessage; body: { [key: string]: { [key: string]: ComplexObject | undefined; } | undefined; }; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + body = ObjectSerializer.deserialize(body, "{ [key: string]: { [key: string]: ComplexObject | undefined; } | undefined; }"); + resolve({ response: response, body: body }); + } else { + reject(new HttpError(response, body, response.statusCode)); + } + } + }); + }); + }); + } + /** + * + */ + public async testDecodeMapOfObjectsGet (options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: { [key: string]: ComplexObject | undefined | null; }; }> { + const localVarPath = this.basePath + '/test/decode/map-of/objects'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); + const produces = ['application/json']; + // give precedence to 'application/json' + if (produces.indexOf('application/json') >= 0) { + localVarHeaderParams.Accept = 'application/json'; + } else { + localVarHeaderParams.Accept = produces.join(','); + } + let localVarFormParams: any = {}; + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + let authenticationPromise = Promise.resolve(); + authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); + + let interceptorPromise = authenticationPromise; + for (const interceptor of this.interceptors) { + interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); + } + + return interceptorPromise.then(() => { + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.IncomingMessage; body: { [key: string]: ComplexObject | undefined | null; }; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + body = ObjectSerializer.deserialize(body, "{ [key: string]: ComplexObject | undefined | null; }"); + resolve({ response: response, body: body }); + } else { + reject(new HttpError(response, body, response.statusCode)); + } + } + }); + }); + }); + } + /** + * + */ + public async testDecodeMapOfPrimitiveGet (options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: { [key: string]: string | undefined; }; }> { + const localVarPath = this.basePath + '/test/decode/map-of/primitive'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); + const produces = ['application/json']; + // give precedence to 'application/json' + if (produces.indexOf('application/json') >= 0) { + localVarHeaderParams.Accept = 'application/json'; + } else { + localVarHeaderParams.Accept = produces.join(','); + } + let localVarFormParams: any = {}; + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + let authenticationPromise = Promise.resolve(); + authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); + + let interceptorPromise = authenticationPromise; + for (const interceptor of this.interceptors) { + interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); + } + + return interceptorPromise.then(() => { + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.IncomingMessage; body: { [key: string]: string | undefined; }; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + body = ObjectSerializer.deserialize(body, "{ [key: string]: string | undefined; }"); + resolve({ response: response, body: body }); + } else { + reject(new HttpError(response, body, response.statusCode)); + } + } + }); + }); + }); + } + /** + * + */ + public async testDecodeNullableArrayGet (options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Array; }> { + const localVarPath = this.basePath + '/test/decode/nullable-array'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); + const produces = ['application/json']; + // give precedence to 'application/json' + if (produces.indexOf('application/json') >= 0) { + localVarHeaderParams.Accept = 'application/json'; + } else { + localVarHeaderParams.Accept = produces.join(','); + } + let localVarFormParams: any = {}; + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + let authenticationPromise = Promise.resolve(); + authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); + + let interceptorPromise = authenticationPromise; + for (const interceptor of this.interceptors) { + interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); + } + + return interceptorPromise.then(() => { + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.IncomingMessage; body: Array; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + body = ObjectSerializer.deserialize(body, "Array"); + resolve({ response: response, body: body }); + } else { + reject(new HttpError(response, body, response.statusCode)); + } + } + }); + }); + }); + } + /** + * + */ + public async testDecodeNullableGet (options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: string; }> { + const localVarPath = this.basePath + '/test/decode/nullable'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); + const produces = ['application/json']; + // give precedence to 'application/json' + if (produces.indexOf('application/json') >= 0) { + localVarHeaderParams.Accept = 'application/json'; + } else { + localVarHeaderParams.Accept = produces.join(','); + } + let localVarFormParams: any = {}; + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + let authenticationPromise = Promise.resolve(); + authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); + + let interceptorPromise = authenticationPromise; + for (const interceptor of this.interceptors) { + interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); + } + + return interceptorPromise.then(() => { + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.IncomingMessage; body: string; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + body = ObjectSerializer.deserialize(body, "string"); + resolve({ response: response, body: body }); + } else { + reject(new HttpError(response, body, response.statusCode)); + } + } + }); + }); + }); + } + /** + * + */ + public async testDecodeObjectGet (options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: ComplexObject; }> { + const localVarPath = this.basePath + '/test/decode/object'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); + const produces = ['application/json']; + // give precedence to 'application/json' + if (produces.indexOf('application/json') >= 0) { + localVarHeaderParams.Accept = 'application/json'; + } else { + localVarHeaderParams.Accept = produces.join(','); + } + let localVarFormParams: any = {}; + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + let authenticationPromise = Promise.resolve(); + authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); + + let interceptorPromise = authenticationPromise; + for (const interceptor of this.interceptors) { + interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); + } + + return interceptorPromise.then(() => { + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.IncomingMessage; body: ComplexObject; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + body = ObjectSerializer.deserialize(body, "ComplexObject"); + resolve({ response: response, body: body }); + } else { + reject(new HttpError(response, body, response.statusCode)); + } + } + }); + }); + }); + } + /** + * + */ + public async testDecodePrimitiveBooleanGet (options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: boolean; }> { + const localVarPath = this.basePath + '/test/decode/primitive/boolean'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); + const produces = ['application/json']; + // give precedence to 'application/json' + if (produces.indexOf('application/json') >= 0) { + localVarHeaderParams.Accept = 'application/json'; + } else { + localVarHeaderParams.Accept = produces.join(','); + } + let localVarFormParams: any = {}; + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + let authenticationPromise = Promise.resolve(); + authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); + + let interceptorPromise = authenticationPromise; + for (const interceptor of this.interceptors) { + interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); + } + + return interceptorPromise.then(() => { + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.IncomingMessage; body: boolean; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + body = ObjectSerializer.deserialize(body, "boolean"); + resolve({ response: response, body: body }); + } else { + reject(new HttpError(response, body, response.statusCode)); + } + } + }); + }); + }); + } + /** + * + */ + public async testDecodePrimitiveIntegerGet (options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: number; }> { + const localVarPath = this.basePath + '/test/decode/primitive/integer'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); + const produces = ['application/json']; + // give precedence to 'application/json' + if (produces.indexOf('application/json') >= 0) { + localVarHeaderParams.Accept = 'application/json'; + } else { + localVarHeaderParams.Accept = produces.join(','); + } + let localVarFormParams: any = {}; + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + let authenticationPromise = Promise.resolve(); + authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); + + let interceptorPromise = authenticationPromise; + for (const interceptor of this.interceptors) { + interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); + } + + return interceptorPromise.then(() => { + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.IncomingMessage; body: number; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + body = ObjectSerializer.deserialize(body, "number"); + resolve({ response: response, body: body }); + } else { + reject(new HttpError(response, body, response.statusCode)); + } + } + }); + }); + }); + } + /** + * + */ + public async testDecodePrimitiveNumberGet (options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: number; }> { + const localVarPath = this.basePath + '/test/decode/primitive/number'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); + const produces = ['application/json']; + // give precedence to 'application/json' + if (produces.indexOf('application/json') >= 0) { + localVarHeaderParams.Accept = 'application/json'; + } else { + localVarHeaderParams.Accept = produces.join(','); + } + let localVarFormParams: any = {}; + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + let authenticationPromise = Promise.resolve(); + authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); + + let interceptorPromise = authenticationPromise; + for (const interceptor of this.interceptors) { + interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); + } + + return interceptorPromise.then(() => { + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.IncomingMessage; body: number; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + body = ObjectSerializer.deserialize(body, "number"); + resolve({ response: response, body: body }); + } else { + reject(new HttpError(response, body, response.statusCode)); + } + } + }); + }); + }); + } + /** + * + */ + public async testDecodePrimitiveStringGet (options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: string; }> { + const localVarPath = this.basePath + '/test/decode/primitive/string'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); + const produces = ['application/json']; + // give precedence to 'application/json' + if (produces.indexOf('application/json') >= 0) { + localVarHeaderParams.Accept = 'application/json'; + } else { + localVarHeaderParams.Accept = produces.join(','); + } + let localVarFormParams: any = {}; + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + let authenticationPromise = Promise.resolve(); + authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); + + let interceptorPromise = authenticationPromise; + for (const interceptor of this.interceptors) { + interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); + } + + return interceptorPromise.then(() => { + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.IncomingMessage; body: string; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + body = ObjectSerializer.deserialize(body, "string"); + resolve({ response: response, body: body }); + } else { + reject(new HttpError(response, body, response.statusCode)); + } + } + }); + }); + }); + } + /** + * + * @param requestBody + */ + public async testEncodeArrayOfArraysPost (requestBody: Array>, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> { + const localVarPath = this.basePath + '/test/encode/array-of-arrays'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'requestBody' is not null or undefined + if (requestBody === null || requestBody === undefined) { + throw new Error('Required parameter requestBody was null or undefined when calling testEncodeArrayOfArraysPost.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'POST', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(requestBody, "Array>") + }; + + let authenticationPromise = Promise.resolve(); + authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); + + let interceptorPromise = authenticationPromise; + for (const interceptor of this.interceptors) { + interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); + } + + return interceptorPromise.then(() => { + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.IncomingMessage; body?: any; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject(new HttpError(response, body, response.statusCode)); + } + } + }); + }); + }); + } + /** + * + * @param complexObject + */ + public async testEncodeArrayOfMapsOfObjectsPost (complexObject: Array<{ [key: string]: ComplexObject | undefined; }>, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> { + const localVarPath = this.basePath + '/test/encode/array-of/maps-of/objects'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'complexObject' is not null or undefined + if (complexObject === null || complexObject === undefined) { + throw new Error('Required parameter complexObject was null or undefined when calling testEncodeArrayOfMapsOfObjectsPost.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'POST', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(complexObject, "Array<{ [key: string]: ComplexObject | undefined; }>") + }; + + let authenticationPromise = Promise.resolve(); + authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); + + let interceptorPromise = authenticationPromise; + for (const interceptor of this.interceptors) { + interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); + } + + return interceptorPromise.then(() => { + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.IncomingMessage; body?: any; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject(new HttpError(response, body, response.statusCode)); + } + } + }); + }); + }); + } + /** + * + * @param complexObject + */ + public async testEncodeArrayOfNullableObjectsPost (complexObject: Array, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> { + const localVarPath = this.basePath + '/test/encode/array-of/nullable-objects'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'complexObject' is not null or undefined + if (complexObject === null || complexObject === undefined) { + throw new Error('Required parameter complexObject was null or undefined when calling testEncodeArrayOfNullableObjectsPost.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'POST', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(complexObject, "Array") + }; + + let authenticationPromise = Promise.resolve(); + authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); + + let interceptorPromise = authenticationPromise; + for (const interceptor of this.interceptors) { + interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); + } + + return interceptorPromise.then(() => { + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.IncomingMessage; body?: any; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject(new HttpError(response, body, response.statusCode)); + } + } + }); + }); + }); + } + /** + * + * @param requestBody + */ + public async testEncodeArrayOfNullablePost (requestBody: Array, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> { + const localVarPath = this.basePath + '/test/encode/array-of/nullable'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'requestBody' is not null or undefined + if (requestBody === null || requestBody === undefined) { + throw new Error('Required parameter requestBody was null or undefined when calling testEncodeArrayOfNullablePost.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'POST', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(requestBody, "Array") + }; + + let authenticationPromise = Promise.resolve(); + authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); + + let interceptorPromise = authenticationPromise; + for (const interceptor of this.interceptors) { + interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); + } + + return interceptorPromise.then(() => { + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.IncomingMessage; body?: any; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject(new HttpError(response, body, response.statusCode)); + } + } + }); + }); + }); + } + /** + * + * @param requestBody + */ + public async testEncodeArrayOfPost (requestBody: Array, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> { + const localVarPath = this.basePath + '/test/encode/array-of'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'requestBody' is not null or undefined + if (requestBody === null || requestBody === undefined) { + throw new Error('Required parameter requestBody was null or undefined when calling testEncodeArrayOfPost.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'POST', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(requestBody, "Array") + }; + + let authenticationPromise = Promise.resolve(); + authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); + + let interceptorPromise = authenticationPromise; + for (const interceptor of this.interceptors) { + interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); + } + + return interceptorPromise.then(() => { + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.IncomingMessage; body?: any; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject(new HttpError(response, body, response.statusCode)); + } + } + }); + }); + }); + } + /** + * + * @param compositeObject + */ + public async testEncodeCompositeObjectsPost (compositeObject: CompositeObject, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> { + const localVarPath = this.basePath + '/test/encode/composite-objects'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'compositeObject' is not null or undefined + if (compositeObject === null || compositeObject === undefined) { + throw new Error('Required parameter compositeObject was null or undefined when calling testEncodeCompositeObjectsPost.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'POST', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(compositeObject, "CompositeObject") + }; + + let authenticationPromise = Promise.resolve(); + authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); + + let interceptorPromise = authenticationPromise; + for (const interceptor of this.interceptors) { + interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); + } + + return interceptorPromise.then(() => { + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.IncomingMessage; body?: any; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject(new HttpError(response, body, response.statusCode)); + } + } + }); + }); + }); + } + /** + * + * @param requestBody + */ + public async testEncodeMapOfMapsOfObjectsPost (requestBody: { [key: string]: { [key: string]: ComplexObject | undefined; } | undefined; }, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> { + const localVarPath = this.basePath + '/test/encode/map-of/maps-of/objects'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'requestBody' is not null or undefined + if (requestBody === null || requestBody === undefined) { + throw new Error('Required parameter requestBody was null or undefined when calling testEncodeMapOfMapsOfObjectsPost.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'POST', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(requestBody, "{ [key: string]: { [key: string]: ComplexObject | undefined; } | undefined; }") + }; + + let authenticationPromise = Promise.resolve(); + authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); + + let interceptorPromise = authenticationPromise; + for (const interceptor of this.interceptors) { + interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); + } + + return interceptorPromise.then(() => { + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.IncomingMessage; body?: any; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject(new HttpError(response, body, response.statusCode)); + } + } + }); + }); + }); + } + /** + * + * @param requestBody + */ + public async testEncodeMapOfObjectsPost (requestBody: { [key: string]: ComplexObject | undefined | null; }, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> { + const localVarPath = this.basePath + '/test/encode/map-of/objects'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'requestBody' is not null or undefined + if (requestBody === null || requestBody === undefined) { + throw new Error('Required parameter requestBody was null or undefined when calling testEncodeMapOfObjectsPost.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'POST', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(requestBody, "{ [key: string]: ComplexObject | undefined | null; }") + }; + + let authenticationPromise = Promise.resolve(); + authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); + + let interceptorPromise = authenticationPromise; + for (const interceptor of this.interceptors) { + interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); + } + + return interceptorPromise.then(() => { + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.IncomingMessage; body?: any; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject(new HttpError(response, body, response.statusCode)); + } + } + }); + }); + }); + } + /** + * + * @param requestBody + */ + public async testEncodeMapOfPrimitivePost (requestBody: { [key: string]: string | undefined; }, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> { + const localVarPath = this.basePath + '/test/encode/map-of/primitive'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'requestBody' is not null or undefined + if (requestBody === null || requestBody === undefined) { + throw new Error('Required parameter requestBody was null or undefined when calling testEncodeMapOfPrimitivePost.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'POST', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(requestBody, "{ [key: string]: string | undefined; }") + }; + + let authenticationPromise = Promise.resolve(); + authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); + + let interceptorPromise = authenticationPromise; + for (const interceptor of this.interceptors) { + interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); + } + + return interceptorPromise.then(() => { + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.IncomingMessage; body?: any; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject(new HttpError(response, body, response.statusCode)); + } + } + }); + }); + }); + } + /** + * + * @param requestBody + */ + public async testEncodeNullableArrayPost (requestBody?: Array, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> { + const localVarPath = this.basePath + '/test/encode/nullable-array'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); + let localVarFormParams: any = {}; + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'POST', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(requestBody, "Array") + }; + + let authenticationPromise = Promise.resolve(); + authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); + + let interceptorPromise = authenticationPromise; + for (const interceptor of this.interceptors) { + interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); + } + + return interceptorPromise.then(() => { + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.IncomingMessage; body?: any; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject(new HttpError(response, body, response.statusCode)); + } + } + }); + }); + }); + } + /** + * + * @param body + */ + public async testEncodeNullablePost (body?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> { + const localVarPath = this.basePath + '/test/encode/nullable'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); + let localVarFormParams: any = {}; + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'POST', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(body, "string") + }; + + let authenticationPromise = Promise.resolve(); + authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); + + let interceptorPromise = authenticationPromise; + for (const interceptor of this.interceptors) { + interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); + } + + return interceptorPromise.then(() => { + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.IncomingMessage; body?: any; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject(new HttpError(response, body, response.statusCode)); + } + } + }); + }); + }); + } + /** + * + * @param complexObject + */ + public async testEncodeObjectPost (complexObject: ComplexObject, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> { + const localVarPath = this.basePath + '/test/encode/object'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'complexObject' is not null or undefined + if (complexObject === null || complexObject === undefined) { + throw new Error('Required parameter complexObject was null or undefined when calling testEncodeObjectPost.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'POST', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(complexObject, "ComplexObject") + }; + + let authenticationPromise = Promise.resolve(); + authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); + + let interceptorPromise = authenticationPromise; + for (const interceptor of this.interceptors) { + interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); + } + + return interceptorPromise.then(() => { + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.IncomingMessage; body?: any; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject(new HttpError(response, body, response.statusCode)); + } + } + }); + }); + }); + } + /** + * + * @param body + */ + public async testEncodePrimitiveBooleanPost (body: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> { + const localVarPath = this.basePath + '/test/encode/primitive/boolean'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new Error('Required parameter body was null or undefined when calling testEncodePrimitiveBooleanPost.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'POST', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(body, "boolean") + }; + + let authenticationPromise = Promise.resolve(); + authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); + + let interceptorPromise = authenticationPromise; + for (const interceptor of this.interceptors) { + interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); + } + + return interceptorPromise.then(() => { + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.IncomingMessage; body?: any; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject(new HttpError(response, body, response.statusCode)); + } + } + }); + }); + }); + } + /** + * + * @param body + */ + public async testEncodePrimitiveIntegerPost (body: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> { + const localVarPath = this.basePath + '/test/encode/primitive/integer'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new Error('Required parameter body was null or undefined when calling testEncodePrimitiveIntegerPost.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'POST', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(body, "number") + }; + + let authenticationPromise = Promise.resolve(); + authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); + + let interceptorPromise = authenticationPromise; + for (const interceptor of this.interceptors) { + interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); + } + + return interceptorPromise.then(() => { + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.IncomingMessage; body?: any; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject(new HttpError(response, body, response.statusCode)); + } + } + }); + }); + }); + } + /** + * + * @param body + */ + public async testEncodePrimitiveNumberPost (body: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> { + const localVarPath = this.basePath + '/test/encode/primitive/number'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new Error('Required parameter body was null or undefined when calling testEncodePrimitiveNumberPost.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'POST', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(body, "number") + }; + + let authenticationPromise = Promise.resolve(); + authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); + + let interceptorPromise = authenticationPromise; + for (const interceptor of this.interceptors) { + interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); + } + + return interceptorPromise.then(() => { + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.IncomingMessage; body?: any; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject(new HttpError(response, body, response.statusCode)); + } + } + }); + }); + }); + } + /** + * + * @param body + */ + public async testEncodePrimitiveStringPost (body: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> { + const localVarPath = this.basePath + '/test/encode/primitive/string'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new Error('Required parameter body was null or undefined when calling testEncodePrimitiveStringPost.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'POST', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(body, "string") + }; + + let authenticationPromise = Promise.resolve(); + authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); + + let interceptorPromise = authenticationPromise; + for (const interceptor of this.interceptors) { + interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); + } + + return interceptorPromise.then(() => { + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.IncomingMessage; body?: any; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject(new HttpError(response, body, response.statusCode)); + } + } + }); + }); + }); + } +} diff --git a/samples/client/others/typescript-node/encode-decode/build/git_push.sh b/samples/client/others/typescript-node/encode-decode/build/git_push.sh new file mode 100644 index 000000000000..f53a75d4fabe --- /dev/null +++ b/samples/client/others/typescript-node/encode-decode/build/git_push.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=$(git remote) +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' diff --git a/samples/client/others/typescript-node/encode-decode/build/model/complexObject.ts b/samples/client/others/typescript-node/encode-decode/build/model/complexObject.ts new file mode 100644 index 000000000000..ad7ad04d07bd --- /dev/null +++ b/samples/client/others/typescript-node/encode-decode/build/model/complexObject.ts @@ -0,0 +1,49 @@ +/** + * Encoding / Decoding Test + * A spec to ensure encoding and decoding of types (both primitive and compound) works as expected + * + * The version of the OpenAPI document: latest + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { RequestFile } from './models'; + +export class ComplexObject { + 'requiredProperty': string; + 'requiredNullableProperty': string | null; + 'optionalProperty'?: string; + 'optionalNullableProperty'?: string | null; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "requiredProperty", + "baseName": "required_property", + "type": "string" + }, + { + "name": "requiredNullableProperty", + "baseName": "required_nullable_property", + "type": "string" + }, + { + "name": "optionalProperty", + "baseName": "optional_property", + "type": "string" + }, + { + "name": "optionalNullableProperty", + "baseName": "optional_nullable_property", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return ComplexObject.attributeTypeMap; + } +} + diff --git a/samples/client/others/typescript-node/encode-decode/build/model/compositeObject.ts b/samples/client/others/typescript-node/encode-decode/build/model/compositeObject.ts new file mode 100644 index 000000000000..eff19afe9a24 --- /dev/null +++ b/samples/client/others/typescript-node/encode-decode/build/model/compositeObject.ts @@ -0,0 +1,32 @@ +/** + * Encoding / Decoding Test + * A spec to ensure encoding and decoding of types (both primitive and compound) works as expected + * + * The version of the OpenAPI document: latest + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { RequestFile } from './models'; +import { ComplexObject } from './complexObject'; + +export class CompositeObject { + 'optionalNullableInnerObject'?: ComplexObject | null; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "optionalNullableInnerObject", + "baseName": "optional_nullable_inner_object", + "type": "ComplexObject" + } ]; + + static getAttributeTypeMap() { + return CompositeObject.attributeTypeMap; + } +} + diff --git a/samples/client/others/typescript-node/encode-decode/build/model/models.ts b/samples/client/others/typescript-node/encode-decode/build/model/models.ts new file mode 100644 index 000000000000..362945f18a31 --- /dev/null +++ b/samples/client/others/typescript-node/encode-decode/build/model/models.ts @@ -0,0 +1,272 @@ +import localVarRequest from 'request'; + +export * from './complexObject'; +export * from './compositeObject'; + +import * as fs from 'fs'; + +export interface RequestDetailedFile { + value: Buffer; + options?: { + filename?: string; + contentType?: string; + } +} + +export type RequestFile = string | Buffer | fs.ReadStream | RequestDetailedFile; + + +import { ComplexObject } from './complexObject'; +import { CompositeObject } from './compositeObject'; + +/* tslint:disable:no-unused-variable */ +let primitives = [ + "string", + "boolean", + "double", + "integer", + "long", + "float", + "number", + "any" + ]; + +let enumsMap: {[index: string]: any} = { +} + +let typeMap: {[index: string]: any} = { + "ComplexObject": ComplexObject, + "CompositeObject": CompositeObject, +} + +// Check if a string starts with another string without using es6 features +function startsWith(str: string, match: string): boolean { + return str.substring(0, match.length) === match; +} + +// Check if a string ends with another string without using es6 features +function endsWith(str: string, match: string): boolean { + return str.length >= match.length && str.substring(str.length - match.length) === match; +} + +const nullableSuffix = " | null"; +const optionalSuffix = " | undefined"; +const arrayPrefix = "Array<"; +const arraySuffix = ">"; +const mapPrefix = "{ [key: string]: "; +const mapSuffix = "; }"; + +export class ObjectSerializer { + public static findCorrectType(data: any, expectedType: string) { + if (data == undefined) { + return expectedType; + } else if (primitives.indexOf(expectedType.toLowerCase()) !== -1) { + return expectedType; + } else if (expectedType === "Date") { + return expectedType; + } else { + if (enumsMap[expectedType]) { + return expectedType; + } + + if (!typeMap[expectedType]) { + return expectedType; // w/e we don't know the type + } + + // Check the discriminator + let discriminatorProperty = typeMap[expectedType].discriminator; + if (discriminatorProperty == null) { + return expectedType; // the type does not have a discriminator. use it. + } else { + if (data[discriminatorProperty]) { + var discriminatorType = data[discriminatorProperty]; + if(typeMap[discriminatorType]){ + return discriminatorType; // use the type given in the discriminator + } else { + return expectedType; // discriminator did not map to a type + } + } else { + return expectedType; // discriminator was not present (or an empty string) + } + } + } + } + + public static serialize(data: any, type: string): any { + if (data == undefined) { + return data; + } else if (primitives.indexOf(type.toLowerCase()) !== -1) { + return data; + } else if (endsWith(type, nullableSuffix)) { + let subType: string = type.slice(0, -nullableSuffix.length); // Type | null => Type + return ObjectSerializer.serialize(data, subType); + } else if (endsWith(type, optionalSuffix)) { + let subType: string = type.slice(0, -optionalSuffix.length); // Type | undefined => Type + return ObjectSerializer.serialize(data, subType); + } else if (startsWith(type, arrayPrefix)) { + let subType: string = type.slice(arrayPrefix.length, -arraySuffix.length); // Array => Type + let transformedData: any[] = []; + for (let index = 0; index < data.length; index++) { + let datum = data[index]; + transformedData.push(ObjectSerializer.serialize(datum, subType)); + } + return transformedData; + } else if (startsWith(type, mapPrefix)) { + let subType: string = type.slice(mapPrefix.length, -mapSuffix.length); // { [key: string]: Type; } => Type + let transformedData: { [key: string]: any } = {}; + for (let key in data) { + transformedData[key] = ObjectSerializer.serialize( + data[key], + subType, + ); + } + return transformedData; + } else if (type === "Date") { + return data.toISOString(); + } else { + if (enumsMap[type]) { + return data; + } + if (!typeMap[type]) { // in case we dont know the type + return data; + } + + // Get the actual type of this object + type = this.findCorrectType(data, type); + + // get the map for the correct type. + let attributeTypes = typeMap[type].getAttributeTypeMap(); + let instance: {[index: string]: any} = {}; + for (let index = 0; index < attributeTypes.length; index++) { + let attributeType = attributeTypes[index]; + instance[attributeType.baseName] = ObjectSerializer.serialize(data[attributeType.name], attributeType.type); + } + return instance; + } + } + + public static deserialize(data: any, type: string): any { + // polymorphism may change the actual type. + type = ObjectSerializer.findCorrectType(data, type); + if (data == undefined) { + return data; + } else if (primitives.indexOf(type.toLowerCase()) !== -1) { + return data; + } else if (endsWith(type, nullableSuffix)) { + let subType: string = type.slice(0, -nullableSuffix.length); // Type | null => Type + return ObjectSerializer.deserialize(data, subType); + } else if (endsWith(type, optionalSuffix)) { + let subType: string = type.slice(0, -optionalSuffix.length); // Type | undefined => Type + return ObjectSerializer.deserialize(data, subType); + } else if (startsWith(type, arrayPrefix)) { + let subType: string = type.slice(arrayPrefix.length, -arraySuffix.length); // Array => Type + let transformedData: any[] = []; + for (let index = 0; index < data.length; index++) { + let datum = data[index]; + transformedData.push(ObjectSerializer.deserialize(datum, subType)); + } + return transformedData; + } else if (startsWith(type, mapPrefix)) { + let subType: string = type.slice(mapPrefix.length, -mapSuffix.length); // { [key: string]: Type; } => Type + let transformedData: { [key: string]: any } = {}; + for (let key in data) { + transformedData[key] = ObjectSerializer.deserialize( + data[key], + subType, + ); + } + return transformedData; + } else if (type === "Date") { + return new Date(data); + } else { + if (enumsMap[type]) {// is Enum + return data; + } + + if (!typeMap[type]) { // dont know the type + return data; + } + let instance = new typeMap[type](); + let attributeTypes = typeMap[type].getAttributeTypeMap(); + for (let index = 0; index < attributeTypes.length; index++) { + let attributeType = attributeTypes[index]; + instance[attributeType.name] = ObjectSerializer.deserialize(data[attributeType.baseName], attributeType.type); + } + return instance; + } + } +} + +export interface Authentication { + /** + * Apply authentication settings to header and query params. + */ + applyToRequest(requestOptions: localVarRequest.Options): Promise | void; +} + +export class HttpBasicAuth implements Authentication { + public username: string = ''; + public password: string = ''; + + applyToRequest(requestOptions: localVarRequest.Options): void { + requestOptions.auth = { + username: this.username, password: this.password + } + } +} + +export class HttpBearerAuth implements Authentication { + public accessToken: string | (() => string) = ''; + + applyToRequest(requestOptions: localVarRequest.Options): void { + if (requestOptions && requestOptions.headers) { + const accessToken = typeof this.accessToken === 'function' + ? this.accessToken() + : this.accessToken; + requestOptions.headers["Authorization"] = "Bearer " + accessToken; + } + } +} + +export class ApiKeyAuth implements Authentication { + public apiKey: string = ''; + + constructor(private location: string, private paramName: string) { + } + + applyToRequest(requestOptions: localVarRequest.Options): void { + if (this.location == "query") { + (requestOptions.qs)[this.paramName] = this.apiKey; + } else if (this.location == "header" && requestOptions && requestOptions.headers) { + requestOptions.headers[this.paramName] = this.apiKey; + } else if (this.location == 'cookie' && requestOptions && requestOptions.headers) { + if (requestOptions.headers['Cookie']) { + requestOptions.headers['Cookie'] += '; ' + this.paramName + '=' + encodeURIComponent(this.apiKey); + } + else { + requestOptions.headers['Cookie'] = this.paramName + '=' + encodeURIComponent(this.apiKey); + } + } + } +} + +export class OAuth implements Authentication { + public accessToken: string = ''; + + applyToRequest(requestOptions: localVarRequest.Options): void { + if (requestOptions && requestOptions.headers) { + requestOptions.headers["Authorization"] = "Bearer " + this.accessToken; + } + } +} + +export class VoidAuth implements Authentication { + public username: string = ''; + public password: string = ''; + + applyToRequest(_: localVarRequest.Options): void { + // Do nothing + } +} + +export type Interceptor = (requestOptions: localVarRequest.Options) => (Promise | void); diff --git a/samples/client/others/typescript-node/encode-decode/build/package.json b/samples/client/others/typescript-node/encode-decode/build/package.json new file mode 100644 index 000000000000..8f1535e62e99 --- /dev/null +++ b/samples/client/others/typescript-node/encode-decode/build/package.json @@ -0,0 +1,28 @@ +{ + "name": "@openapitools/typescript-node-encode-decode", + "version": "1.0.0", + "description": "NodeJS client for @openapitools/typescript-node-encode-decode", + "repository": { + "type": "git", + "url": "https://github.com/GIT_USER_ID/GIT_REPO_ID.git" + }, + "main": "dist/api.js", + "types": "dist/api.d.ts", + "scripts": { + "clean": "rm -Rf node_modules/ *.js", + "build": "tsc", + "test": "npm run build && node dist/client.js" + }, + "author": "OpenAPI-Generator Contributors", + "license": "Unlicense", + "dependencies": { + "bluebird": "^3.7.2", + "request": "^2.88.2" + }, + "devDependencies": { + "@types/bluebird": "^3.5.33", + "@types/node": "^12", + "@types/request": "^2.48.8", + "typescript": "^4.0 || ^5.0" + } +} diff --git a/samples/client/others/typescript-node/encode-decode/build/tsconfig.json b/samples/client/others/typescript-node/encode-decode/build/tsconfig.json new file mode 100644 index 000000000000..ea9078675b77 --- /dev/null +++ b/samples/client/others/typescript-node/encode-decode/build/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "noImplicitAny": false, + "target": "ES5", + "allowSyntheticDefaultImports": true, + "esModuleInterop": true, + "strict": true, + "moduleResolution": "node", + "removeComments": true, + "sourceMap": true, + "noLib": false, + "declaration": true, + "lib": ["dom", "es6", "es5", "dom.iterable", "scripthost"], + "outDir": "dist", + "typeRoots": [ + "node_modules/@types" + ] + }, + "exclude": [ + "dist", + "node_modules" + ] +} diff --git a/samples/client/others/typescript-node/encode-decode/test/.gitignore b/samples/client/others/typescript-node/encode-decode/test/.gitignore new file mode 100644 index 000000000000..de4d1f007dd1 --- /dev/null +++ b/samples/client/others/typescript-node/encode-decode/test/.gitignore @@ -0,0 +1,2 @@ +dist +node_modules diff --git a/samples/client/others/typescript-node/encode-decode/test/package-lock.json b/samples/client/others/typescript-node/encode-decode/test/package-lock.json new file mode 100644 index 000000000000..55c2a3c9d591 --- /dev/null +++ b/samples/client/others/typescript-node/encode-decode/test/package-lock.json @@ -0,0 +1,1231 @@ +{ + "name": "typescript-node-encode-decode-test", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "typescript-node-encode-decode-test", + "version": "1.0.0", + "hasInstallScript": true, + "license": "ISC", + "dependencies": { + "@openapitools/typescript-node-encode-decode": "file:../build", + "@types/chai": "^4.3.0", + "@types/mocha": "^10.0.0", + "@types/node": "^16.6.2", + "chai": "^4.3.0", + "mocha": "^10.2.0", + "nock": "^13.5.4", + "ts-node": "^10.9.0", + "typescript": "^5.2.2" + } + }, + "../build": { + "name": "@openapitools/typescript-node-encode-decode", + "version": "1.0.0", + "license": "Unlicense", + "dependencies": { + "bluebird": "^3.7.2", + "request": "^2.88.2" + }, + "devDependencies": { + "@types/bluebird": "^3.5.33", + "@types/node": "^12", + "@types/request": "^2.48.8", + "typescript": "^4.0 || ^5.0" + } + }, + "node_modules/@cspotcode/source-map-support": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "dependencies": { + "@jridgewell/trace-mapping": "0.3.9" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz", + "integrity": "sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.4.15", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", + "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, + "node_modules/@openapitools/typescript-node-encode-decode": { + "resolved": "../build", + "link": true + }, + "node_modules/@tsconfig/node10": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz", + "integrity": "sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==" + }, + "node_modules/@tsconfig/node12": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", + "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==" + }, + "node_modules/@tsconfig/node14": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", + "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==" + }, + "node_modules/@tsconfig/node16": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", + "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==" + }, + "node_modules/@types/chai": { + "version": "4.3.9", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.9.tgz", + "integrity": "sha512-69TtiDzu0bcmKQv3yg1Zx409/Kd7r0b5F1PfpYJfSHzLGtB53547V4u+9iqKYsTu/O2ai6KTb0TInNpvuQ3qmg==" + }, + "node_modules/@types/mocha": { + "version": "10.0.3", + "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-10.0.3.tgz", + "integrity": "sha512-RsOPImTriV/OE4A9qKjMtk2MnXiuLLbcO3nCXK+kvq4nr0iMfFgpjaX3MPLb6f7+EL1FGSelYvuJMV6REH+ZPQ==" + }, + "node_modules/@types/node": { + "version": "16.18.59", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.18.59.tgz", + "integrity": "sha512-PJ1w2cNeKUEdey4LiPra0ZuxZFOGvetswE8qHRriV/sUkL5Al4tTmPV9D2+Y/TPIxTHHgxTfRjZVKWhPw/ORhQ==" + }, + "node_modules/ansi-colors": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", + "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", + "engines": { + "node": ">=6" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==" + }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" + }, + "node_modules/assertion-error": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", + "engines": { + "node": "*" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + }, + "node_modules/binary-extensions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", + "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", + "engines": { + "node": ">=8" + } + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dependencies": { + "fill-range": "^7.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/browser-stdout": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==" + }, + "node_modules/camelcase": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", + "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/chai": { + "version": "4.3.10", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.10.tgz", + "integrity": "sha512-0UXG04VuVbruMUYbJ6JctvH0YnC/4q3/AkT18q4NaITo91CUm0liMS9VqzT9vZhVQ/1eqPanMWjBM+Juhfb/9g==", + "dependencies": { + "assertion-error": "^1.1.0", + "check-error": "^1.0.3", + "deep-eql": "^4.1.3", + "get-func-name": "^2.0.2", + "loupe": "^2.3.6", + "pathval": "^1.1.1", + "type-detect": "^4.0.8" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/chalk/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/check-error": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.3.tgz", + "integrity": "sha512-iKEoDYaRmd1mxM90a2OEfWhjsjPpYPuQ+lMYsoxB126+t8fw7ySEO48nmDg5COTjxDI65/Y2OWpeEHk3ZOe8zg==", + "dependencies": { + "get-func-name": "^2.0.2" + }, + "engines": { + "node": "*" + } + }, + "node_modules/chokidar": { + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", + "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", + "funding": [ + { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + ], + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/cliui": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", + "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^7.0.0" + } + }, + "node_modules/cliui/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/cliui/node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "engines": { + "node": ">=8" + } + }, + "node_modules/cliui/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/cliui/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" + }, + "node_modules/create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==" + }, + "node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/debug/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "node_modules/decamelize": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", + "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/deep-eql": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.3.tgz", + "integrity": "sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==", + "dependencies": { + "type-detect": "^4.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/diff": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", + "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==", + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" + }, + "node_modules/escalade": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", + "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", + "engines": { + "node": ">=6" + } + }, + "node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/flat": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", + "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==", + "bin": { + "flat": "cli.js" + } + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/get-func-name": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.2.tgz", + "integrity": "sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ==", + "engines": { + "node": "*" + } + }, + "node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/he": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", + "bin": { + "he": "bin/he" + } + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/is-plain-obj": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", + "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", + "engines": { + "node": ">=8" + } + }, + "node_modules/is-unicode-supported": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", + "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==", + "license": "ISC" + }, + "node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/log-symbols": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", + "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", + "dependencies": { + "chalk": "^4.1.0", + "is-unicode-supported": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/loupe": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.7.tgz", + "integrity": "sha512-zSMINGVYkdpYSOBmLi0D1Uo7JU9nVdQKrHxC8eYlV+9YKK9WePqAlL7lSlorG/U2Fw1w0hTBmaa/jrQ3UbPHtA==", + "dependencies": { + "get-func-name": "^2.0.1" + } + }, + "node_modules/make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==" + }, + "node_modules/mocha": { + "version": "10.2.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.2.0.tgz", + "integrity": "sha512-IDY7fl/BecMwFHzoqF2sg/SHHANeBoMMXFlS9r0OXKDssYE1M5O43wUY/9BVPeIvfH2zmEbBfseqN9gBQZzXkg==", + "dependencies": { + "ansi-colors": "4.1.1", + "browser-stdout": "1.3.1", + "chokidar": "3.5.3", + "debug": "4.3.4", + "diff": "5.0.0", + "escape-string-regexp": "4.0.0", + "find-up": "5.0.0", + "glob": "7.2.0", + "he": "1.2.0", + "js-yaml": "4.1.0", + "log-symbols": "4.1.0", + "minimatch": "5.0.1", + "ms": "2.1.3", + "nanoid": "3.3.3", + "serialize-javascript": "6.0.0", + "strip-json-comments": "3.1.1", + "supports-color": "8.1.1", + "workerpool": "6.2.1", + "yargs": "16.2.0", + "yargs-parser": "20.2.4", + "yargs-unparser": "2.0.0" + }, + "bin": { + "_mocha": "bin/_mocha", + "mocha": "bin/mocha.js" + }, + "engines": { + "node": ">= 14.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mochajs" + } + }, + "node_modules/mocha/node_modules/glob": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", + "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/mocha/node_modules/glob/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/mocha/node_modules/minimatch": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", + "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/mocha/node_modules/minimatch/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "node_modules/nanoid": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.3.tgz", + "integrity": "sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w==", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/nock": { + "version": "13.5.4", + "resolved": "https://registry.npmjs.org/nock/-/nock-13.5.4.tgz", + "integrity": "sha512-yAyTfdeNJGGBFxWdzSKCBYxs5FxLbCg5X5Q4ets974hcQzG1+qCxvIyOo4j2Ry6MUlhWVMX4OoYDefAIIwupjw==", + "license": "MIT", + "dependencies": { + "debug": "^4.1.0", + "json-stringify-safe": "^5.0.1", + "propagate": "^2.0.0" + }, + "engines": { + "node": ">= 10.13" + } + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "engines": { + "node": ">=8" + } + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/pathval": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", + "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==", + "engines": { + "node": "*" + } + }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/propagate": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/propagate/-/propagate-2.0.1.tgz", + "integrity": "sha512-vGrhOavPSTz4QVNuBNdcNXePNdNMaO1xj9yBeH1ScQPjk/rhg9sSlCXPhMkFuaNNW/syTvYqsnbIJxMBfRbbag==", + "license": "MIT", + "engines": { + "node": ">= 8" + } + }, + "node_modules/randombytes": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", + "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", + "dependencies": { + "safe-buffer": "^5.1.0" + } + }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/serialize-javascript": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", + "integrity": "sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==", + "dependencies": { + "randombytes": "^2.1.0" + } + }, + "node_modules/strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/ts-node": { + "version": "10.9.1", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", + "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", + "dependencies": { + "@cspotcode/source-map-support": "^0.8.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "v8-compile-cache-lib": "^3.0.1", + "yn": "3.1.1" + }, + "bin": { + "ts-node": "dist/bin.js", + "ts-node-cwd": "dist/bin-cwd.js", + "ts-node-esm": "dist/bin-esm.js", + "ts-node-script": "dist/bin-script.js", + "ts-node-transpile-only": "dist/bin-transpile.js", + "ts-script": "dist/bin-script-deprecated.js" + }, + "peerDependencies": { + "@swc/core": ">=1.2.50", + "@swc/wasm": ">=1.2.50", + "@types/node": "*", + "typescript": ">=2.7" + }, + "peerDependenciesMeta": { + "@swc/core": { + "optional": true + }, + "@swc/wasm": { + "optional": true + } + } + }, + "node_modules/ts-node/node_modules/acorn": { + "version": "8.11.2", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.2.tgz", + "integrity": "sha512-nc0Axzp/0FILLEVsm4fNwLCwMttvhEI263QtVPQcbpfZZ3ts0hLsZGOpE6czNlid7CJ9MlyH8reXkpsf3YUY4w==", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/ts-node/node_modules/acorn-walk": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.0.tgz", + "integrity": "sha512-FS7hV565M5l1R08MXqo8odwMTB02C2UqzB17RVgu9EyuYFBqJZ3/ZY97sQD5FewVu1UyDFc1yztUDrAwT0EypA==", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/ts-node/node_modules/diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "engines": { + "node": ">=4" + } + }, + "node_modules/typescript": { + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", + "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/v8-compile-cache-lib": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==" + }, + "node_modules/workerpool": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.1.tgz", + "integrity": "sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==" + }, + "node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrap-ansi/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi/node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" + }, + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs": { + "version": "16.2.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", + "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", + "dependencies": { + "cliui": "^7.0.2", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.0", + "y18n": "^5.0.5", + "yargs-parser": "^20.2.2" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs-parser": { + "version": "20.2.4", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz", + "integrity": "sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==", + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs-unparser": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz", + "integrity": "sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==", + "dependencies": { + "camelcase": "^6.0.0", + "decamelize": "^4.0.0", + "flat": "^5.0.2", + "is-plain-obj": "^2.1.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/yargs/node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "engines": { + "node": ">=8" + } + }, + "node_modules/yargs/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/yargs/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "engines": { + "node": ">=6" + } + }, + "node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + } + } +} diff --git a/samples/client/others/typescript-node/encode-decode/test/package.json b/samples/client/others/typescript-node/encode-decode/test/package.json new file mode 100644 index 000000000000..3ff44fdd7005 --- /dev/null +++ b/samples/client/others/typescript-node/encode-decode/test/package.json @@ -0,0 +1,26 @@ +{ + "private": true, + "dependencies": { + "@openapitools/typescript-node-encode-decode": "file:../build", + "@types/chai": "^4.3.0", + "@types/mocha": "^10.0.0", + "@types/node": "^16.6.2", + "chai": "^4.3.0", + "nock": "^13.5.4", + "mocha": "^10.2.0", + "ts-node": "^10.9.0", + "typescript": "^5.2.2" + }, + "scripts": { + "preinstall": "npm --prefix ../build install && npm --prefix ../build run build", + "test": "mocha test/*.spec.ts --require ts-node/register --timeout 10000" + }, + "name": "typescript-node-encode-decode-test", + "version": "1.0.0", + "directories": { + "test": "test" + }, + "author": "", + "license": "ISC", + "description": "" +} diff --git a/samples/client/others/typescript-node/encode-decode/test/test/api.spec.ts b/samples/client/others/typescript-node/encode-decode/test/test/api.spec.ts new file mode 100644 index 000000000000..9e3c80f8621b --- /dev/null +++ b/samples/client/others/typescript-node/encode-decode/test/test/api.spec.ts @@ -0,0 +1,425 @@ +import { + DefaultApi, +} from '@openapitools/typescript-node-encode-decode'; +import { expect } from 'chai'; +import { BASE_URL, encodeMock } from './server'; + +const api = new DefaultApi(BASE_URL); + +describe('deserialization', () => { + it('deserializes primitive booleans', async () => { + const { body: response } = await api.testDecodePrimitiveBooleanGet(); + expect(response).to.be.true; + }); + + it('deserializes primitive integers', async () => { + const { body: response } = await api.testDecodePrimitiveIntegerGet(); + expect(response).to.equal(42); + }); + + it('deserializes primitive numbers', async () => { + const { body: response } = await api.testDecodePrimitiveNumberGet(); + expect(response).to.equal(42.42); + }); + + it('deserializes primitive strings', async () => { + const { body: response } = await api.testDecodePrimitiveStringGet(); + expect(response).to.equal('some string value'); + }); + + it('deserializes nullable strings', async () => { + const { body: response } = await api.testDecodeNullableGet(); + expect(response).to.equal(null); + }); + + it('deserializes arrays of strings', async () => { + const { body: response } = await api.testDecodeArrayOfGet(); + expect(response).to.deep.equal(["first", "second", "third"]); + }); + + it('deserializes arrays of nullable strings', async () => { + const { body: response } = await api.testDecodeArrayOfNullableGet(); + expect(response).to.deep.equal(["first", null, "third"]); + }); + + it('deserializes nullable arrays', async () => { + const { body: response } = await api.testDecodeNullableArrayGet(); + expect(response).to.equal(null); + }); + + it('deserializes arrays of arrays', async () => { + const { body: response } = await api.testDecodeArrayOfArraysGet(); + expect(response).to.deep.equal([["first", "second"], ["third"]]); + }); + + it('deserializes objects', async () => { + const { body: response } = await api.testDecodeObjectGet(); + expect(response).to.deep.equal({ + requiredProperty: "required", + optionalProperty: undefined, + requiredNullableProperty: null, + optionalNullableProperty: null, + }); + }); + + it('deserializes maps of primitives', async () => { + const { body: response } = await api.testDecodeMapOfPrimitiveGet(); + expect(response).to.deep.equal({ + key1: "value1", + key2: "value2", + }); + }); + + it('deserializes maps of objects', async () => { + const { body: response } = await api.testDecodeMapOfObjectsGet(); + expect(response).to.deep.equal({ + barebones: { + requiredProperty: "first", + requiredNullableProperty: null, + optionalProperty: undefined, + optionalNullableProperty: undefined, + }, + nulls: { + requiredProperty: "second", + requiredNullableProperty: null, + optionalProperty: undefined, + optionalNullableProperty: null, + }, + values: { + requiredProperty: "third", + requiredNullableProperty: "foo", + optionalProperty: "bar", + optionalNullableProperty: "baz", + } + }); + }); + + it('deserializes maps of maps of objects', async () => { + const { body: response } = await api.testDecodeMapOfMapsOfObjectsGet(); + expect(response).to.deep.equal({ + key1: { + key1: { + requiredProperty: "first", + requiredNullableProperty: null, + optionalProperty: undefined, + optionalNullableProperty: undefined, + }, + key2: { + requiredProperty: "second", + requiredNullableProperty: null, + optionalProperty: undefined, + optionalNullableProperty: null, + }, + }, + key2: { + key3: { + requiredProperty: "third", + requiredNullableProperty: "foo", + optionalProperty: "bar", + optionalNullableProperty: "baz", + } + } + }); + }); + + it('deserializes arrays of maps of objects', async () => { + const { body: response } = await api.testDecodeArrayOfMapsOfObjectsGet(); + expect(response).to.deep.equal([ + { + key1: { + requiredProperty: "first", + requiredNullableProperty: null, + optionalProperty: undefined, + optionalNullableProperty: undefined, + }, + key2: { + requiredProperty: "second", + requiredNullableProperty: null, + optionalProperty: undefined, + optionalNullableProperty: null, + }, + }, + { + key3: { + requiredProperty: "third", + requiredNullableProperty: "foo", + optionalProperty: "bar", + optionalNullableProperty: "baz", + } + } + ]); + }); + + it('deserializes arrays of nullable objects', async () => { + const { body: response } = await api.testDecodeArrayOfNullableObjectsGet(); + expect(response).to.deep.equal([ + { + requiredProperty: "first", + requiredNullableProperty: null, + optionalProperty: undefined, + optionalNullableProperty: undefined, + }, + null, + { + requiredProperty: "third", + requiredNullableProperty: "foo", + optionalProperty: "bar", + optionalNullableProperty: "baz", + } + ]); + }); + + it('deserializes composite objects', async () => { + const { body: response } = await api.testDecodeCompositeObjectsGet(); + expect(response).to.deep.equal({ + optionalNullableInnerObject: { + requiredProperty: "required", + requiredNullableProperty: null, + optionalProperty: undefined, + optionalNullableProperty: undefined, + }, + }); + }); +}); + +describe("serialization", () => { + it("serializes primitive booleans", async () => { + await api.testEncodePrimitiveBooleanPost(true); + expect(encodeMock.lastRequestBody).to.equal(true); + }); + + it("serializes primitive integers", async () => { + await api.testEncodePrimitiveIntegerPost(42); + expect(encodeMock.lastRequestBody).to.equal(42); + }); + + it("serializes primitive numbers", async () => { + await api.testEncodePrimitiveNumberPost(42.42); + expect(encodeMock.lastRequestBody).to.equal(42.42); + }); + + it("serializes primitive strings", async () => { + await api.testEncodePrimitiveStringPost("some string value"); + expect(encodeMock.lastRequestBody).to.equal("some string value"); + }); + + it("serializes nullable strings", async () => { + await api.testEncodeNullablePost(null); + expect(encodeMock.lastRequestBody).to.equal(null); + }); + + it("serializes arrays of strings", async () => { + await api.testEncodeArrayOfPost(["first", "second", "third"]); + expect(encodeMock.lastRequestBody).to.deep.equal(["first", "second", "third"]); + }); + + it("serializes arrays of nullable strings", async () => { + await api.testEncodeArrayOfNullablePost(["first", null, "third"]); + expect(encodeMock.lastRequestBody).to.deep.equal(["first", null, "third"]); + }); + + it("serializes nullable arrays", async () => { + await api.testEncodeNullableArrayPost(null); + expect(encodeMock.lastRequestBody).to.equal(null); + }); + + it("serializes arrays of arrays", async () => { + await api.testEncodeArrayOfArraysPost([["first", "second"], ["third"]]); + expect(encodeMock.lastRequestBody).to.deep.equal([["first", "second"], ["third"]]); + }); + + it("serializes objects", async () => { + await api.testEncodeObjectPost({ + requiredProperty: "required", + requiredNullableProperty: null, + optionalNullableProperty: null, + }); + expect(encodeMock.lastRequestBody).to.deep.equal({ + required_property: "required", + required_nullable_property: null, + optional_nullable_property: null, + }); + }); + + it("serializes maps of primitives", async () => { + await api.testEncodeMapOfPrimitivePost({ + key1: "value1", + key2: "value2", + }); + expect(encodeMock.lastRequestBody).to.deep.equal({ + key1: "value1", + key2: "value2", + }); + }); + + it("serializes maps of objects", async () => { + await api.testEncodeMapOfObjectsPost({ + barebones: { + requiredProperty: "first", + requiredNullableProperty: null, + }, + nulls: { + requiredProperty: "second", + requiredNullableProperty: null, + optionalNullableProperty: null, + }, + values: { + requiredProperty: "third", + requiredNullableProperty: "foo", + optionalProperty: "bar", + optionalNullableProperty: "baz", + } + }); + expect(encodeMock.lastRequestBody).to.deep.equal({ + barebones: { + required_property: "first", + required_nullable_property: null, + }, + nulls: { + required_property: "second", + required_nullable_property: null, + optional_nullable_property: null, + }, + values: { + required_property: "third", + required_nullable_property: "foo", + optional_property: "bar", + optional_nullable_property: "baz", + } + }); + }); + + it("serializes maps of maps of objects", async () => { + await api.testEncodeMapOfMapsOfObjectsPost({ + key1: { + key1: { + requiredProperty: "first", + requiredNullableProperty: null, + }, + key2: { + requiredProperty: "second", + requiredNullableProperty: null, + optionalNullableProperty: null, + }, + }, + key2: { + key3: { + requiredProperty: "third", + requiredNullableProperty: "foo", + optionalProperty: "bar", + optionalNullableProperty: "baz", + } + } + }); + expect(encodeMock.lastRequestBody).to.deep.equal({ + key1: { + key1: { + required_property: "first", + required_nullable_property: null, + }, + key2: { + required_property: "second", + required_nullable_property: null, + optional_nullable_property: null, + }, + }, + key2: { + key3: { + required_property: "third", + required_nullable_property: "foo", + optional_property: "bar", + optional_nullable_property: "baz", + } + } + }); + }); + + it("serializes arrays of maps of objects", async () => { + await api.testEncodeArrayOfMapsOfObjectsPost([ + { + key1: { + requiredProperty: "first", + requiredNullableProperty: null, + }, + key2: { + requiredProperty: "second", + requiredNullableProperty: null, + optionalNullableProperty: null, + }, + }, + { + key3: { + requiredProperty: "third", + requiredNullableProperty: "foo", + optionalProperty: "bar", + optionalNullableProperty: "baz", + } + } + ]); + expect(encodeMock.lastRequestBody).to.deep.equal([ + { + key1: { + required_property: "first", + required_nullable_property: null, + }, + key2: { + required_property: "second", + required_nullable_property: null, + optional_nullable_property: null, + }, + }, + { + key3: { + required_property: "third", + required_nullable_property: "foo", + optional_property: "bar", + optional_nullable_property: "baz", + } + } + ]); + }); + + it("serializes arrays of nullable objects", async () => { + await api.testEncodeArrayOfNullableObjectsPost([ + { + requiredProperty: "first", + requiredNullableProperty: null, + }, + null, + { + requiredProperty: "third", + requiredNullableProperty: "foo", + optionalProperty: "bar", + optionalNullableProperty: "baz", + } + ]); + expect(encodeMock.lastRequestBody).to.deep.equal([ + { + required_property: "first", + required_nullable_property: null, + }, + null, + { + required_property: "third", + required_nullable_property: "foo", + optional_property: "bar", + optional_nullable_property: "baz", + } + ]); + }); + + it("serializes composite objects", async () => { + await api.testEncodeCompositeObjectsPost({ + optionalNullableInnerObject: { + requiredProperty: "required", + requiredNullableProperty: null, + }, + }); + expect(encodeMock.lastRequestBody).to.deep.equal({ + optional_nullable_inner_object: { + required_property: "required", + required_nullable_property: null, + }, + }); + }); +}); diff --git a/samples/client/others/typescript-node/encode-decode/test/test/server.ts b/samples/client/others/typescript-node/encode-decode/test/test/server.ts new file mode 100644 index 000000000000..7adc099b672a --- /dev/null +++ b/samples/client/others/typescript-node/encode-decode/test/test/server.ts @@ -0,0 +1,123 @@ +import * as nock from 'nock'; + +export const BASE_URL = 'http://localhost:1234'; + +// Prevent any unmocked requests from making actual HTTP requests. +nock.disableNetConnect(); + +function mockPath(path: string, value: any) { + const body = JSON.stringify(value); + const headers = { 'content-type': 'application/json' }; + nock(BASE_URL).get(path).reply(200, body, headers).persist(); +} + +mockPath('/test/decode/primitive/boolean', true); +mockPath('/test/decode/primitive/integer', 42); +mockPath('/test/decode/primitive/number', 42.42); +mockPath('/test/decode/primitive/string', 'some string value'); +mockPath('/test/decode/nullable', null); +mockPath('/test/decode/array-of', ["first", "second", "third"]); +mockPath('/test/decode/array-of/nullable', ["first", null, "third"]); +mockPath('/test/decode/nullable-array', null); +mockPath('/test/decode/array-of-arrays', [["first", "second"], ["third"]]); +mockPath('/test/decode/object', { + required_property: "required", + required_nullable_property: null, + optional_nullable_property: null, +}); +mockPath('/test/decode/map-of/primitive', { + key1: "value1", + key2: "value2", +}); +mockPath('/test/decode/map-of/objects', { + barebones: { + required_property: "first", + required_nullable_property: null, + }, + nulls: { + required_property: "second", + required_nullable_property: null, + optional_nullable_property: null, + }, + values: { + required_property: "third", + required_nullable_property: "foo", + optional_property: "bar", + optional_nullable_property: "baz", + } +}); +mockPath('/test/decode/map-of/maps-of/objects', { + key1: { + key1: { + required_property: "first", + required_nullable_property: null, + }, + key2: { + required_property: "second", + required_nullable_property: null, + optional_nullable_property: null, + }, + }, + key2: { + key3: { + required_property: "third", + required_nullable_property: "foo", + optional_property: "bar", + optional_nullable_property: "baz", + } + } +}); +mockPath('/test/decode/array-of/maps-of/objects', [ + { + key1: { + required_property: "first", + required_nullable_property: null, + }, + key2: { + required_property: "second", + required_nullable_property: null, + optional_nullable_property: null, + }, + }, + { + key3: { + required_property: "third", + required_nullable_property: "foo", + optional_property: "bar", + optional_nullable_property: "baz", + } + } +]); +mockPath('/test/decode/composite-objects', { + optional_nullable_inner_object: { + required_property: "required", + required_nullable_property: null, + }, +}); +mockPath('/test/decode/array-of/nullable-objects', [ + { + required_property: "first", + required_nullable_property: null, + }, + null, + { + required_property: "third", + required_nullable_property: "foo", + optional_property: "bar", + optional_nullable_property: "baz", + } +]); + +export const encodeMock = { + lastRequestBody: "", +}; + +nock(BASE_URL) + .filteringPath(/^\/test\/encode\/.*/, '/test/encode') + .post('/test/encode') + .reply(200, (uri: string, requestBody: string) => { + encodeMock.lastRequestBody = requestBody; + return ""; + }) + .persist(); + diff --git a/samples/client/others/typescript-node/encode-decode/test/tsconfig.json b/samples/client/others/typescript-node/encode-decode/test/tsconfig.json new file mode 100644 index 000000000000..e4f8bee09a0b --- /dev/null +++ b/samples/client/others/typescript-node/encode-decode/test/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "moduleResolution": "node", + "module": "CommonJS", + "target": "ES5", + "noImplicitAny": true, + "sourceMap": false, + "outDir": "dist", + "types": [ + "mocha" + ], + "lib": [ + "es6", + "dom" + ] + }, + "exclude": [ + "node_modules" + ] +} diff --git a/samples/client/others/typescript/builds/array-of-lists/models/ObjectSerializer.ts b/samples/client/others/typescript/builds/array-of-lists/models/ObjectSerializer.ts index c05f514de93e..9b7f69f664a8 100644 --- a/samples/client/others/typescript/builds/array-of-lists/models/ObjectSerializer.ts +++ b/samples/client/others/typescript/builds/array-of-lists/models/ObjectSerializer.ts @@ -76,6 +76,13 @@ const supportedMimeTypePredicatesWithPriority: MimeTypePredicate[] = [ isFormUrlencodedMimeType, ]; +const nullableSuffix = " | null"; +const optionalSuffix = " | undefined"; +const arrayPrefix = "Array<"; +const arraySuffix = ">"; +const mapPrefix = "{ [key: string]: "; +const mapSuffix = "; }"; + export class ObjectSerializer { public static findCorrectType(data: any, expectedType: string) { if (data == undefined) { @@ -115,19 +122,35 @@ export class ObjectSerializer { } } - public static serialize(data: any, type: string, format: string) { + public static serialize(data: any, type: string, format: string): any { if (data == undefined) { return data; } else if (primitives.indexOf(type.toLowerCase()) !== -1) { return data; - } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 - let subType: string = type.replace("Array<", ""); // Array => Type> - subType = subType.substring(0, subType.length - 1); // Type> => Type + } else if (type.endsWith(nullableSuffix)) { + let subType: string = type.slice(0, -nullableSuffix.length); // Type | null => Type + return ObjectSerializer.serialize(data, subType, format); + } else if (type.endsWith(optionalSuffix)) { + let subType: string = type.slice(0, -optionalSuffix.length); // Type | undefined => Type + return ObjectSerializer.serialize(data, subType, format); + } else if (type.startsWith(arrayPrefix)) { + let subType: string = type.slice(arrayPrefix.length, -arraySuffix.length); // Array => Type let transformedData: any[] = []; for (let date of data) { transformedData.push(ObjectSerializer.serialize(date, subType, format)); } return transformedData; + } else if (type.startsWith(mapPrefix)) { + let subType: string = type.slice(mapPrefix.length, -mapSuffix.length); // { [key: string]: Type; } => Type + let transformedData: { [key: string]: any } = {}; + for (let key in data) { + transformedData[key] = ObjectSerializer.serialize( + data[key], + subType, + format, + ); + } + return transformedData; } else if (type === "Date") { if (format == "date") { let month = data.getMonth()+1 @@ -160,21 +183,37 @@ export class ObjectSerializer { } } - public static deserialize(data: any, type: string, format: string) { + public static deserialize(data: any, type: string, format: string): any { // polymorphism may change the actual type. type = ObjectSerializer.findCorrectType(data, type); if (data == undefined) { return data; } else if (primitives.indexOf(type.toLowerCase()) !== -1) { return data; - } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 - let subType: string = type.replace("Array<", ""); // Array => Type> - subType = subType.substring(0, subType.length - 1); // Type> => Type + } else if (type.endsWith(nullableSuffix)) { + let subType: string = type.slice(0, -nullableSuffix.length); // Type | null => Type + return ObjectSerializer.deserialize(data, subType, format); + } else if (type.endsWith(optionalSuffix)) { + let subType: string = type.slice(0, -optionalSuffix.length); // Type | undefined => Type + return ObjectSerializer.deserialize(data, subType, format); + } else if (type.startsWith(arrayPrefix)) { + let subType: string = type.slice(arrayPrefix.length, -arraySuffix.length); // Array => Type let transformedData: any[] = []; for (let date of data) { transformedData.push(ObjectSerializer.deserialize(date, subType, format)); } return transformedData; + } else if (type.startsWith(mapPrefix)) { + let subType: string = type.slice(mapPrefix.length, -mapSuffix.length); // { [key: string]: Type; } => Type + let transformedData: { [key: string]: any } = {}; + for (let key in data) { + transformedData[key] = ObjectSerializer.deserialize( + data[key], + subType, + format, + ); + } + return transformedData; } else if (type === "Date") { return new Date(data); } else { diff --git a/samples/client/others/typescript/builds/with-unique-items/models/ObjectSerializer.ts b/samples/client/others/typescript/builds/with-unique-items/models/ObjectSerializer.ts index 8a1b41ec04c3..621e27bd391b 100644 --- a/samples/client/others/typescript/builds/with-unique-items/models/ObjectSerializer.ts +++ b/samples/client/others/typescript/builds/with-unique-items/models/ObjectSerializer.ts @@ -73,6 +73,13 @@ const supportedMimeTypePredicatesWithPriority: MimeTypePredicate[] = [ isFormUrlencodedMimeType, ]; +const nullableSuffix = " | null"; +const optionalSuffix = " | undefined"; +const arrayPrefix = "Array<"; +const arraySuffix = ">"; +const mapPrefix = "{ [key: string]: "; +const mapSuffix = "; }"; + export class ObjectSerializer { public static findCorrectType(data: any, expectedType: string) { if (data == undefined) { @@ -112,19 +119,35 @@ export class ObjectSerializer { } } - public static serialize(data: any, type: string, format: string) { + public static serialize(data: any, type: string, format: string): any { if (data == undefined) { return data; } else if (primitives.indexOf(type.toLowerCase()) !== -1) { return data; - } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 - let subType: string = type.replace("Array<", ""); // Array => Type> - subType = subType.substring(0, subType.length - 1); // Type> => Type + } else if (type.endsWith(nullableSuffix)) { + let subType: string = type.slice(0, -nullableSuffix.length); // Type | null => Type + return ObjectSerializer.serialize(data, subType, format); + } else if (type.endsWith(optionalSuffix)) { + let subType: string = type.slice(0, -optionalSuffix.length); // Type | undefined => Type + return ObjectSerializer.serialize(data, subType, format); + } else if (type.startsWith(arrayPrefix)) { + let subType: string = type.slice(arrayPrefix.length, -arraySuffix.length); // Array => Type let transformedData: any[] = []; for (let date of data) { transformedData.push(ObjectSerializer.serialize(date, subType, format)); } return transformedData; + } else if (type.startsWith(mapPrefix)) { + let subType: string = type.slice(mapPrefix.length, -mapSuffix.length); // { [key: string]: Type; } => Type + let transformedData: { [key: string]: any } = {}; + for (let key in data) { + transformedData[key] = ObjectSerializer.serialize( + data[key], + subType, + format, + ); + } + return transformedData; } else if (type === "Date") { if (format == "date") { let month = data.getMonth()+1 @@ -157,21 +180,37 @@ export class ObjectSerializer { } } - public static deserialize(data: any, type: string, format: string) { + public static deserialize(data: any, type: string, format: string): any { // polymorphism may change the actual type. type = ObjectSerializer.findCorrectType(data, type); if (data == undefined) { return data; } else if (primitives.indexOf(type.toLowerCase()) !== -1) { return data; - } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 - let subType: string = type.replace("Array<", ""); // Array => Type> - subType = subType.substring(0, subType.length - 1); // Type> => Type + } else if (type.endsWith(nullableSuffix)) { + let subType: string = type.slice(0, -nullableSuffix.length); // Type | null => Type + return ObjectSerializer.deserialize(data, subType, format); + } else if (type.endsWith(optionalSuffix)) { + let subType: string = type.slice(0, -optionalSuffix.length); // Type | undefined => Type + return ObjectSerializer.deserialize(data, subType, format); + } else if (type.startsWith(arrayPrefix)) { + let subType: string = type.slice(arrayPrefix.length, -arraySuffix.length); // Array => Type let transformedData: any[] = []; for (let date of data) { transformedData.push(ObjectSerializer.deserialize(date, subType, format)); } return transformedData; + } else if (type.startsWith(mapPrefix)) { + let subType: string = type.slice(mapPrefix.length, -mapSuffix.length); // { [key: string]: Type; } => Type + let transformedData: { [key: string]: any } = {}; + for (let key in data) { + transformedData[key] = ObjectSerializer.deserialize( + data[key], + subType, + format, + ); + } + return transformedData; } else if (type === "Date") { return new Date(data); } else { diff --git a/samples/client/others/typescript/encode-decode/build/.gitignore b/samples/client/others/typescript/encode-decode/build/.gitignore new file mode 100644 index 000000000000..1521c8b7652b --- /dev/null +++ b/samples/client/others/typescript/encode-decode/build/.gitignore @@ -0,0 +1 @@ +dist diff --git a/samples/client/others/typescript/encode-decode/build/.openapi-generator-ignore b/samples/client/others/typescript/encode-decode/build/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/client/others/typescript/encode-decode/build/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# 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 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 (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/client/others/typescript/encode-decode/build/.openapi-generator/FILES b/samples/client/others/typescript/encode-decode/build/.openapi-generator/FILES new file mode 100644 index 000000000000..0e8a14dc8634 --- /dev/null +++ b/samples/client/others/typescript/encode-decode/build/.openapi-generator/FILES @@ -0,0 +1,25 @@ +.gitignore +DefaultApi.md +README.md +apis/DefaultApi.ts +apis/baseapi.ts +apis/exception.ts +auth/auth.ts +configuration.ts +git_push.sh +http/http.ts +http/isomorphic-fetch.ts +index.ts +middleware.ts +models/ComplexObject.ts +models/CompositeObject.ts +models/ObjectSerializer.ts +models/all.ts +package.json +rxjsStub.ts +servers.ts +tsconfig.json +types/ObjectParamAPI.ts +types/ObservableAPI.ts +types/PromiseAPI.ts +util.ts diff --git a/samples/client/others/typescript/encode-decode/build/.openapi-generator/VERSION b/samples/client/others/typescript/encode-decode/build/.openapi-generator/VERSION new file mode 100644 index 000000000000..17f2442ff3bc --- /dev/null +++ b/samples/client/others/typescript/encode-decode/build/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.9.0-SNAPSHOT diff --git a/samples/client/others/typescript/encode-decode/build/DefaultApi.md b/samples/client/others/typescript/encode-decode/build/DefaultApi.md new file mode 100644 index 000000000000..ec3dc463f2c8 --- /dev/null +++ b/samples/client/others/typescript/encode-decode/build/DefaultApi.md @@ -0,0 +1,1697 @@ +# .DefaultApi + +All URIs are relative to *http://localhost* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**testDecodeArrayOfArraysGet**](DefaultApi.md#testDecodeArrayOfArraysGet) | **GET** /test/decode/array-of-arrays | +[**testDecodeArrayOfGet**](DefaultApi.md#testDecodeArrayOfGet) | **GET** /test/decode/array-of | +[**testDecodeArrayOfMapsOfObjectsGet**](DefaultApi.md#testDecodeArrayOfMapsOfObjectsGet) | **GET** /test/decode/array-of/maps-of/objects | +[**testDecodeArrayOfNullableGet**](DefaultApi.md#testDecodeArrayOfNullableGet) | **GET** /test/decode/array-of/nullable | +[**testDecodeArrayOfNullableObjectsGet**](DefaultApi.md#testDecodeArrayOfNullableObjectsGet) | **GET** /test/decode/array-of/nullable-objects | +[**testDecodeCompositeObjectsGet**](DefaultApi.md#testDecodeCompositeObjectsGet) | **GET** /test/decode/composite-objects | +[**testDecodeMapOfMapsOfObjectsGet**](DefaultApi.md#testDecodeMapOfMapsOfObjectsGet) | **GET** /test/decode/map-of/maps-of/objects | +[**testDecodeMapOfObjectsGet**](DefaultApi.md#testDecodeMapOfObjectsGet) | **GET** /test/decode/map-of/objects | +[**testDecodeMapOfPrimitiveGet**](DefaultApi.md#testDecodeMapOfPrimitiveGet) | **GET** /test/decode/map-of/primitive | +[**testDecodeNullableArrayGet**](DefaultApi.md#testDecodeNullableArrayGet) | **GET** /test/decode/nullable-array | +[**testDecodeNullableGet**](DefaultApi.md#testDecodeNullableGet) | **GET** /test/decode/nullable | +[**testDecodeObjectGet**](DefaultApi.md#testDecodeObjectGet) | **GET** /test/decode/object | +[**testDecodePrimitiveBooleanGet**](DefaultApi.md#testDecodePrimitiveBooleanGet) | **GET** /test/decode/primitive/boolean | +[**testDecodePrimitiveIntegerGet**](DefaultApi.md#testDecodePrimitiveIntegerGet) | **GET** /test/decode/primitive/integer | +[**testDecodePrimitiveNumberGet**](DefaultApi.md#testDecodePrimitiveNumberGet) | **GET** /test/decode/primitive/number | +[**testDecodePrimitiveStringGet**](DefaultApi.md#testDecodePrimitiveStringGet) | **GET** /test/decode/primitive/string | +[**testEncodeArrayOfArraysPost**](DefaultApi.md#testEncodeArrayOfArraysPost) | **POST** /test/encode/array-of-arrays | +[**testEncodeArrayOfMapsOfObjectsPost**](DefaultApi.md#testEncodeArrayOfMapsOfObjectsPost) | **POST** /test/encode/array-of/maps-of/objects | +[**testEncodeArrayOfNullableObjectsPost**](DefaultApi.md#testEncodeArrayOfNullableObjectsPost) | **POST** /test/encode/array-of/nullable-objects | +[**testEncodeArrayOfNullablePost**](DefaultApi.md#testEncodeArrayOfNullablePost) | **POST** /test/encode/array-of/nullable | +[**testEncodeArrayOfPost**](DefaultApi.md#testEncodeArrayOfPost) | **POST** /test/encode/array-of | +[**testEncodeCompositeObjectsPost**](DefaultApi.md#testEncodeCompositeObjectsPost) | **POST** /test/encode/composite-objects | +[**testEncodeMapOfMapsOfObjectsPost**](DefaultApi.md#testEncodeMapOfMapsOfObjectsPost) | **POST** /test/encode/map-of/maps-of/objects | +[**testEncodeMapOfObjectsPost**](DefaultApi.md#testEncodeMapOfObjectsPost) | **POST** /test/encode/map-of/objects | +[**testEncodeMapOfPrimitivePost**](DefaultApi.md#testEncodeMapOfPrimitivePost) | **POST** /test/encode/map-of/primitive | +[**testEncodeNullableArrayPost**](DefaultApi.md#testEncodeNullableArrayPost) | **POST** /test/encode/nullable-array | +[**testEncodeNullablePost**](DefaultApi.md#testEncodeNullablePost) | **POST** /test/encode/nullable | +[**testEncodeObjectPost**](DefaultApi.md#testEncodeObjectPost) | **POST** /test/encode/object | +[**testEncodePrimitiveBooleanPost**](DefaultApi.md#testEncodePrimitiveBooleanPost) | **POST** /test/encode/primitive/boolean | +[**testEncodePrimitiveIntegerPost**](DefaultApi.md#testEncodePrimitiveIntegerPost) | **POST** /test/encode/primitive/integer | +[**testEncodePrimitiveNumberPost**](DefaultApi.md#testEncodePrimitiveNumberPost) | **POST** /test/encode/primitive/number | +[**testEncodePrimitiveStringPost**](DefaultApi.md#testEncodePrimitiveStringPost) | **POST** /test/encode/primitive/string | + + +# **testDecodeArrayOfArraysGet** +> Array> testDecodeArrayOfArraysGet() + + +### Example + + +```typescript +import { } from ''; +import * as fs from 'fs'; + +const configuration = .createConfiguration(); +const apiInstance = new .DefaultApi(configuration); + +let body:any = {}; + +apiInstance.testDecodeArrayOfArraysGet(body).then((data:any) => { + console.log('API called successfully. Returned data: ' + data); +}).catch((error:any) => console.error(error)); +``` + + +### Parameters +This endpoint does not need any parameter. + + +### Return type + +**Array>** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Decodes an array of arrays | - | + +[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) + +# **testDecodeArrayOfGet** +> Array testDecodeArrayOfGet() + + +### Example + + +```typescript +import { } from ''; +import * as fs from 'fs'; + +const configuration = .createConfiguration(); +const apiInstance = new .DefaultApi(configuration); + +let body:any = {}; + +apiInstance.testDecodeArrayOfGet(body).then((data:any) => { + console.log('API called successfully. Returned data: ' + data); +}).catch((error:any) => console.error(error)); +``` + + +### Parameters +This endpoint does not need any parameter. + + +### Return type + +**Array** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Decodes an array of primitive types | - | + +[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) + +# **testDecodeArrayOfMapsOfObjectsGet** +> Array<{ [key: string]: ComplexObject; }> testDecodeArrayOfMapsOfObjectsGet() + + +### Example + + +```typescript +import { } from ''; +import * as fs from 'fs'; + +const configuration = .createConfiguration(); +const apiInstance = new .DefaultApi(configuration); + +let body:any = {}; + +apiInstance.testDecodeArrayOfMapsOfObjectsGet(body).then((data:any) => { + console.log('API called successfully. Returned data: ' + data); +}).catch((error:any) => console.error(error)); +``` + + +### Parameters +This endpoint does not need any parameter. + + +### Return type + +**Array<{ [key: string]: ComplexObject; }>** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Decodes an array of maps of complex objects | - | + +[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) + +# **testDecodeArrayOfNullableGet** +> Array testDecodeArrayOfNullableGet() + + +### Example + + +```typescript +import { } from ''; +import * as fs from 'fs'; + +const configuration = .createConfiguration(); +const apiInstance = new .DefaultApi(configuration); + +let body:any = {}; + +apiInstance.testDecodeArrayOfNullableGet(body).then((data:any) => { + console.log('API called successfully. Returned data: ' + data); +}).catch((error:any) => console.error(error)); +``` + + +### Parameters +This endpoint does not need any parameter. + + +### Return type + +**Array** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Decodes an array of nullable types | - | + +[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) + +# **testDecodeArrayOfNullableObjectsGet** +> Array testDecodeArrayOfNullableObjectsGet() + + +### Example + + +```typescript +import { } from ''; +import * as fs from 'fs'; + +const configuration = .createConfiguration(); +const apiInstance = new .DefaultApi(configuration); + +let body:any = {}; + +apiInstance.testDecodeArrayOfNullableObjectsGet(body).then((data:any) => { + console.log('API called successfully. Returned data: ' + data); +}).catch((error:any) => console.error(error)); +``` + + +### Parameters +This endpoint does not need any parameter. + + +### Return type + +**Array** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Decodes an array of nullable objects | - | + +[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) + +# **testDecodeCompositeObjectsGet** +> CompositeObject testDecodeCompositeObjectsGet() + + +### Example + + +```typescript +import { } from ''; +import * as fs from 'fs'; + +const configuration = .createConfiguration(); +const apiInstance = new .DefaultApi(configuration); + +let body:any = {}; + +apiInstance.testDecodeCompositeObjectsGet(body).then((data:any) => { + console.log('API called successfully. Returned data: ' + data); +}).catch((error:any) => console.error(error)); +``` + + +### Parameters +This endpoint does not need any parameter. + + +### Return type + +**CompositeObject** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Decodes a composite object | - | + +[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) + +# **testDecodeMapOfMapsOfObjectsGet** +> { [key: string]: { [key: string]: ComplexObject; }; } testDecodeMapOfMapsOfObjectsGet() + + +### Example + + +```typescript +import { } from ''; +import * as fs from 'fs'; + +const configuration = .createConfiguration(); +const apiInstance = new .DefaultApi(configuration); + +let body:any = {}; + +apiInstance.testDecodeMapOfMapsOfObjectsGet(body).then((data:any) => { + console.log('API called successfully. Returned data: ' + data); +}).catch((error:any) => console.error(error)); +``` + + +### Parameters +This endpoint does not need any parameter. + + +### Return type + +**{ [key: string]: { [key: string]: ComplexObject; }; }** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Decodes a map of maps of objects | - | + +[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) + +# **testDecodeMapOfObjectsGet** +> { [key: string]: ComplexObject | null; } testDecodeMapOfObjectsGet() + + +### Example + + +```typescript +import { } from ''; +import * as fs from 'fs'; + +const configuration = .createConfiguration(); +const apiInstance = new .DefaultApi(configuration); + +let body:any = {}; + +apiInstance.testDecodeMapOfObjectsGet(body).then((data:any) => { + console.log('API called successfully. Returned data: ' + data); +}).catch((error:any) => console.error(error)); +``` + + +### Parameters +This endpoint does not need any parameter. + + +### Return type + +**{ [key: string]: ComplexObject | null; }** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Decodes a map of objects | - | + +[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) + +# **testDecodeMapOfPrimitiveGet** +> { [key: string]: string; } testDecodeMapOfPrimitiveGet() + + +### Example + + +```typescript +import { } from ''; +import * as fs from 'fs'; + +const configuration = .createConfiguration(); +const apiInstance = new .DefaultApi(configuration); + +let body:any = {}; + +apiInstance.testDecodeMapOfPrimitiveGet(body).then((data:any) => { + console.log('API called successfully. Returned data: ' + data); +}).catch((error:any) => console.error(error)); +``` + + +### Parameters +This endpoint does not need any parameter. + + +### Return type + +**{ [key: string]: string; }** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Decodes a map of primitive types | - | + +[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) + +# **testDecodeNullableArrayGet** +> Array testDecodeNullableArrayGet() + + +### Example + + +```typescript +import { } from ''; +import * as fs from 'fs'; + +const configuration = .createConfiguration(); +const apiInstance = new .DefaultApi(configuration); + +let body:any = {}; + +apiInstance.testDecodeNullableArrayGet(body).then((data:any) => { + console.log('API called successfully. Returned data: ' + data); +}).catch((error:any) => console.error(error)); +``` + + +### Parameters +This endpoint does not need any parameter. + + +### Return type + +**Array** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Decodes a nullable array | - | + +[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) + +# **testDecodeNullableGet** +> string testDecodeNullableGet() + + +### Example + + +```typescript +import { } from ''; +import * as fs from 'fs'; + +const configuration = .createConfiguration(); +const apiInstance = new .DefaultApi(configuration); + +let body:any = {}; + +apiInstance.testDecodeNullableGet(body).then((data:any) => { + console.log('API called successfully. Returned data: ' + data); +}).catch((error:any) => console.error(error)); +``` + + +### Parameters +This endpoint does not need any parameter. + + +### Return type + +**string** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Decodes a nullable type | - | + +[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) + +# **testDecodeObjectGet** +> ComplexObject testDecodeObjectGet() + + +### Example + + +```typescript +import { } from ''; +import * as fs from 'fs'; + +const configuration = .createConfiguration(); +const apiInstance = new .DefaultApi(configuration); + +let body:any = {}; + +apiInstance.testDecodeObjectGet(body).then((data:any) => { + console.log('API called successfully. Returned data: ' + data); +}).catch((error:any) => console.error(error)); +``` + + +### Parameters +This endpoint does not need any parameter. + + +### Return type + +**ComplexObject** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Decodes an object | - | + +[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) + +# **testDecodePrimitiveBooleanGet** +> boolean testDecodePrimitiveBooleanGet() + + +### Example + + +```typescript +import { } from ''; +import * as fs from 'fs'; + +const configuration = .createConfiguration(); +const apiInstance = new .DefaultApi(configuration); + +let body:any = {}; + +apiInstance.testDecodePrimitiveBooleanGet(body).then((data:any) => { + console.log('API called successfully. Returned data: ' + data); +}).catch((error:any) => console.error(error)); +``` + + +### Parameters +This endpoint does not need any parameter. + + +### Return type + +**boolean** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Decodes a boolean | - | + +[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) + +# **testDecodePrimitiveIntegerGet** +> number testDecodePrimitiveIntegerGet() + + +### Example + + +```typescript +import { } from ''; +import * as fs from 'fs'; + +const configuration = .createConfiguration(); +const apiInstance = new .DefaultApi(configuration); + +let body:any = {}; + +apiInstance.testDecodePrimitiveIntegerGet(body).then((data:any) => { + console.log('API called successfully. Returned data: ' + data); +}).catch((error:any) => console.error(error)); +``` + + +### Parameters +This endpoint does not need any parameter. + + +### Return type + +**number** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Decodes an integer | - | + +[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) + +# **testDecodePrimitiveNumberGet** +> number testDecodePrimitiveNumberGet() + + +### Example + + +```typescript +import { } from ''; +import * as fs from 'fs'; + +const configuration = .createConfiguration(); +const apiInstance = new .DefaultApi(configuration); + +let body:any = {}; + +apiInstance.testDecodePrimitiveNumberGet(body).then((data:any) => { + console.log('API called successfully. Returned data: ' + data); +}).catch((error:any) => console.error(error)); +``` + + +### Parameters +This endpoint does not need any parameter. + + +### Return type + +**number** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Decodes a number | - | + +[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) + +# **testDecodePrimitiveStringGet** +> string testDecodePrimitiveStringGet() + + +### Example + + +```typescript +import { } from ''; +import * as fs from 'fs'; + +const configuration = .createConfiguration(); +const apiInstance = new .DefaultApi(configuration); + +let body:any = {}; + +apiInstance.testDecodePrimitiveStringGet(body).then((data:any) => { + console.log('API called successfully. Returned data: ' + data); +}).catch((error:any) => console.error(error)); +``` + + +### Parameters +This endpoint does not need any parameter. + + +### Return type + +**string** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Decodes a string | - | + +[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) + +# **testEncodeArrayOfArraysPost** +> void testEncodeArrayOfArraysPost(requestBody) + + +### Example + + +```typescript +import { } from ''; +import * as fs from 'fs'; + +const configuration = .createConfiguration(); +const apiInstance = new .DefaultApi(configuration); + +let body:.DefaultApiTestEncodeArrayOfArraysPostRequest = { + // Array> + requestBody: [ + [ + "string_example", + ], + ], +}; + +apiInstance.testEncodeArrayOfArraysPost(body).then((data:any) => { + console.log('API called successfully. Returned data: ' + data); +}).catch((error:any) => console.error(error)); +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **requestBody** | **Array>**| | + + +### Return type + +**void** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Encodes an array of arrays | - | + +[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) + +# **testEncodeArrayOfMapsOfObjectsPost** +> void testEncodeArrayOfMapsOfObjectsPost(complexObject) + + +### Example + + +```typescript +import { } from ''; +import * as fs from 'fs'; + +const configuration = .createConfiguration(); +const apiInstance = new .DefaultApi(configuration); + +let body:.DefaultApiTestEncodeArrayOfMapsOfObjectsPostRequest = { + // Array<{ [key: string]: ComplexObject; }> + complexObject: [ + { + "key": { + requiredProperty: "requiredProperty_example", + requiredNullableProperty: "requiredNullableProperty_example", + optionalProperty: "optionalProperty_example", + optionalNullableProperty: "optionalNullableProperty_example", + }, + }, + ], +}; + +apiInstance.testEncodeArrayOfMapsOfObjectsPost(body).then((data:any) => { + console.log('API called successfully. Returned data: ' + data); +}).catch((error:any) => console.error(error)); +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **complexObject** | **Array<{ [key: string]: ComplexObject; }>**| | + + +### Return type + +**void** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Encodes an array of maps of complex objects | - | + +[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) + +# **testEncodeArrayOfNullableObjectsPost** +> void testEncodeArrayOfNullableObjectsPost(complexObject) + + +### Example + + +```typescript +import { } from ''; +import * as fs from 'fs'; + +const configuration = .createConfiguration(); +const apiInstance = new .DefaultApi(configuration); + +let body:.DefaultApiTestEncodeArrayOfNullableObjectsPostRequest = { + // Array + complexObject: [ + { + requiredProperty: "requiredProperty_example", + requiredNullableProperty: "requiredNullableProperty_example", + optionalProperty: "optionalProperty_example", + optionalNullableProperty: "optionalNullableProperty_example", + }, + ], +}; + +apiInstance.testEncodeArrayOfNullableObjectsPost(body).then((data:any) => { + console.log('API called successfully. Returned data: ' + data); +}).catch((error:any) => console.error(error)); +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **complexObject** | **Array**| | + + +### Return type + +**void** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Encodes an array of nullable objects | - | + +[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) + +# **testEncodeArrayOfNullablePost** +> void testEncodeArrayOfNullablePost(requestBody) + + +### Example + + +```typescript +import { } from ''; +import * as fs from 'fs'; + +const configuration = .createConfiguration(); +const apiInstance = new .DefaultApi(configuration); + +let body:.DefaultApiTestEncodeArrayOfNullablePostRequest = { + // Array + requestBody: [ + "requestBody_example", + ], +}; + +apiInstance.testEncodeArrayOfNullablePost(body).then((data:any) => { + console.log('API called successfully. Returned data: ' + data); +}).catch((error:any) => console.error(error)); +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **requestBody** | **Array**| | + + +### Return type + +**void** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Encodes an array of nullable types | - | + +[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) + +# **testEncodeArrayOfPost** +> void testEncodeArrayOfPost(requestBody) + + +### Example + + +```typescript +import { } from ''; +import * as fs from 'fs'; + +const configuration = .createConfiguration(); +const apiInstance = new .DefaultApi(configuration); + +let body:.DefaultApiTestEncodeArrayOfPostRequest = { + // Array + requestBody: [ + "requestBody_example", + ], +}; + +apiInstance.testEncodeArrayOfPost(body).then((data:any) => { + console.log('API called successfully. Returned data: ' + data); +}).catch((error:any) => console.error(error)); +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **requestBody** | **Array**| | + + +### Return type + +**void** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Encodes an array of primitive types | - | + +[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) + +# **testEncodeCompositeObjectsPost** +> void testEncodeCompositeObjectsPost(compositeObject) + + +### Example + + +```typescript +import { } from ''; +import * as fs from 'fs'; + +const configuration = .createConfiguration(); +const apiInstance = new .DefaultApi(configuration); + +let body:.DefaultApiTestEncodeCompositeObjectsPostRequest = { + // CompositeObject + compositeObject: { + optionalNullableInnerObject: { + requiredProperty: "requiredProperty_example", + requiredNullableProperty: "requiredNullableProperty_example", + optionalProperty: "optionalProperty_example", + optionalNullableProperty: "optionalNullableProperty_example", + }, + }, +}; + +apiInstance.testEncodeCompositeObjectsPost(body).then((data:any) => { + console.log('API called successfully. Returned data: ' + data); +}).catch((error:any) => console.error(error)); +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **compositeObject** | **CompositeObject**| | + + +### Return type + +**void** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Encodes a composite object | - | + +[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) + +# **testEncodeMapOfMapsOfObjectsPost** +> void testEncodeMapOfMapsOfObjectsPost(requestBody) + + +### Example + + +```typescript +import { } from ''; +import * as fs from 'fs'; + +const configuration = .createConfiguration(); +const apiInstance = new .DefaultApi(configuration); + +let body:.DefaultApiTestEncodeMapOfMapsOfObjectsPostRequest = { + // { [key: string]: { [key: string]: ComplexObject; }; } + requestBody: { + "key": + key: { + requiredProperty: "requiredProperty_example", + requiredNullableProperty: "requiredNullableProperty_example", + optionalProperty: "optionalProperty_example", + optionalNullableProperty: "optionalNullableProperty_example", + }, + , + }, +}; + +apiInstance.testEncodeMapOfMapsOfObjectsPost(body).then((data:any) => { + console.log('API called successfully. Returned data: ' + data); +}).catch((error:any) => console.error(error)); +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **requestBody** | **{ [key: string]: { [key: string]: ComplexObject; }; }**| | + + +### Return type + +**void** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Encodes a map of maps of objects | - | + +[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) + +# **testEncodeMapOfObjectsPost** +> void testEncodeMapOfObjectsPost(requestBody) + + +### Example + + +```typescript +import { } from ''; +import * as fs from 'fs'; + +const configuration = .createConfiguration(); +const apiInstance = new .DefaultApi(configuration); + +let body:.DefaultApiTestEncodeMapOfObjectsPostRequest = { + // { [key: string]: ComplexObject | null; } + requestBody: { + "key": { + requiredProperty: "requiredProperty_example", + requiredNullableProperty: "requiredNullableProperty_example", + optionalProperty: "optionalProperty_example", + optionalNullableProperty: "optionalNullableProperty_example", + }, + }, +}; + +apiInstance.testEncodeMapOfObjectsPost(body).then((data:any) => { + console.log('API called successfully. Returned data: ' + data); +}).catch((error:any) => console.error(error)); +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **requestBody** | **{ [key: string]: ComplexObject | null; }**| | + + +### Return type + +**void** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Encodes a map of objects | - | + +[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) + +# **testEncodeMapOfPrimitivePost** +> void testEncodeMapOfPrimitivePost(requestBody) + + +### Example + + +```typescript +import { } from ''; +import * as fs from 'fs'; + +const configuration = .createConfiguration(); +const apiInstance = new .DefaultApi(configuration); + +let body:.DefaultApiTestEncodeMapOfPrimitivePostRequest = { + // { [key: string]: string; } + requestBody: { + "key": "key_example", + }, +}; + +apiInstance.testEncodeMapOfPrimitivePost(body).then((data:any) => { + console.log('API called successfully. Returned data: ' + data); +}).catch((error:any) => console.error(error)); +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **requestBody** | **{ [key: string]: string; }**| | + + +### Return type + +**void** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Encodes a map of primitive types | - | + +[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) + +# **testEncodeNullableArrayPost** +> void testEncodeNullableArrayPost() + + +### Example + + +```typescript +import { } from ''; +import * as fs from 'fs'; + +const configuration = .createConfiguration(); +const apiInstance = new .DefaultApi(configuration); + +let body:.DefaultApiTestEncodeNullableArrayPostRequest = { + // Array (optional) + requestBody: [ + "requestBody_example", + ], +}; + +apiInstance.testEncodeNullableArrayPost(body).then((data:any) => { + console.log('API called successfully. Returned data: ' + data); +}).catch((error:any) => console.error(error)); +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **requestBody** | **Array**| | + + +### Return type + +**void** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Encodes a nullable array | - | + +[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) + +# **testEncodeNullablePost** +> void testEncodeNullablePost() + + +### Example + + +```typescript +import { } from ''; +import * as fs from 'fs'; + +const configuration = .createConfiguration(); +const apiInstance = new .DefaultApi(configuration); + +let body:.DefaultApiTestEncodeNullablePostRequest = { + // string (optional) + body: "body_example", +}; + +apiInstance.testEncodeNullablePost(body).then((data:any) => { + console.log('API called successfully. Returned data: ' + data); +}).catch((error:any) => console.error(error)); +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | **string**| | + + +### Return type + +**void** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Encodes a nullable type | - | + +[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) + +# **testEncodeObjectPost** +> void testEncodeObjectPost(complexObject) + + +### Example + + +```typescript +import { } from ''; +import * as fs from 'fs'; + +const configuration = .createConfiguration(); +const apiInstance = new .DefaultApi(configuration); + +let body:.DefaultApiTestEncodeObjectPostRequest = { + // ComplexObject + complexObject: { + requiredProperty: "requiredProperty_example", + requiredNullableProperty: "requiredNullableProperty_example", + optionalProperty: "optionalProperty_example", + optionalNullableProperty: "optionalNullableProperty_example", + }, +}; + +apiInstance.testEncodeObjectPost(body).then((data:any) => { + console.log('API called successfully. Returned data: ' + data); +}).catch((error:any) => console.error(error)); +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **complexObject** | **ComplexObject**| | + + +### Return type + +**void** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Encodes an object | - | + +[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) + +# **testEncodePrimitiveBooleanPost** +> void testEncodePrimitiveBooleanPost(body) + + +### Example + + +```typescript +import { } from ''; +import * as fs from 'fs'; + +const configuration = .createConfiguration(); +const apiInstance = new .DefaultApi(configuration); + +let body:.DefaultApiTestEncodePrimitiveBooleanPostRequest = { + // boolean + body: true, +}; + +apiInstance.testEncodePrimitiveBooleanPost(body).then((data:any) => { + console.log('API called successfully. Returned data: ' + data); +}).catch((error:any) => console.error(error)); +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | **boolean**| | + + +### Return type + +**void** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Encodes a boolean | - | + +[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) + +# **testEncodePrimitiveIntegerPost** +> void testEncodePrimitiveIntegerPost(body) + + +### Example + + +```typescript +import { } from ''; +import * as fs from 'fs'; + +const configuration = .createConfiguration(); +const apiInstance = new .DefaultApi(configuration); + +let body:.DefaultApiTestEncodePrimitiveIntegerPostRequest = { + // number + body: 1, +}; + +apiInstance.testEncodePrimitiveIntegerPost(body).then((data:any) => { + console.log('API called successfully. Returned data: ' + data); +}).catch((error:any) => console.error(error)); +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | **number**| | + + +### Return type + +**void** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Encodes an integer | - | + +[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) + +# **testEncodePrimitiveNumberPost** +> void testEncodePrimitiveNumberPost(body) + + +### Example + + +```typescript +import { } from ''; +import * as fs from 'fs'; + +const configuration = .createConfiguration(); +const apiInstance = new .DefaultApi(configuration); + +let body:.DefaultApiTestEncodePrimitiveNumberPostRequest = { + // number + body: 3.14, +}; + +apiInstance.testEncodePrimitiveNumberPost(body).then((data:any) => { + console.log('API called successfully. Returned data: ' + data); +}).catch((error:any) => console.error(error)); +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | **number**| | + + +### Return type + +**void** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Encodes a number | - | + +[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) + +# **testEncodePrimitiveStringPost** +> void testEncodePrimitiveStringPost(body) + + +### Example + + +```typescript +import { } from ''; +import * as fs from 'fs'; + +const configuration = .createConfiguration(); +const apiInstance = new .DefaultApi(configuration); + +let body:.DefaultApiTestEncodePrimitiveStringPostRequest = { + // string + body: "body_example", +}; + +apiInstance.testEncodePrimitiveStringPost(body).then((data:any) => { + console.log('API called successfully. Returned data: ' + data); +}).catch((error:any) => console.error(error)); +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | **string**| | + + +### Return type + +**void** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Encodes a string | - | + +[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) + + diff --git a/samples/client/others/typescript/encode-decode/build/README.md b/samples/client/others/typescript/encode-decode/build/README.md new file mode 100644 index 000000000000..43b6c19087aa --- /dev/null +++ b/samples/client/others/typescript/encode-decode/build/README.md @@ -0,0 +1,80 @@ +## @openapitools/typescript-encode-decode@1.0.0 + +This generator creates TypeScript/JavaScript client that utilizes fetch-api. + +### Building + +To build and compile the typescript sources to javascript use: +``` +npm install +npm run build +``` + +### Publishing + +First build the package then run ```npm publish``` + +### Consuming + +Navigate to the folder of your consuming project and run one of the following commands. + +_published:_ + +``` +npm install @openapitools/typescript-encode-decode@1.0.0 --save +``` + +_unPublished (not recommended):_ + +``` +npm install PATH_TO_GENERATED_PACKAGE --save +``` + +### Usage + +Below code snippet shows exemplary usage of the configuration and the API based +on the typical `PetStore` example used for OpenAPI. + +``` +import * as your_api from 'your_api_package' + +// Covers all auth methods included in your OpenAPI yaml definition +const authConfig: your_api.AuthMethodsConfiguration = { + "api_key": "YOUR_API_KEY" +} + +// Implements a simple middleware to modify requests before (`pre`) they are sent +// and after (`post`) they have been received +class Test implements your_api.Middleware { + pre(context: your_api.RequestContext): Promise { + // Modify context here and return + return Promise.resolve(context); + } + + post(context: your_api.ResponseContext): Promise { + return Promise.resolve(context); + } + +} + +// Create configuration parameter object +const configurationParameters = { + httpApi: new your_api.JQueryHttpLibrary(), // Can also be ignored - default is usually fine + baseServer: your_api.servers[0], // First server is default + authMethods: authConfig, // No auth is default + promiseMiddleware: [new Test()], +} + +// Convert to actual configuration +const config = your_api.createConfiguration(configurationParameters); + +// Use configuration with your_api +const api = new your_api.PetApi(config); +your_api.Pet p = new your_api.Pet(); +p.name = "My new pet"; +p.photoUrls = []; +p.tags = []; +p.status = "available"; +Promise createdPet = api.addPet(p); + +``` diff --git a/samples/client/others/typescript/encode-decode/build/apis/DefaultApi.ts b/samples/client/others/typescript/encode-decode/build/apis/DefaultApi.ts new file mode 100644 index 000000000000..923ff4994486 --- /dev/null +++ b/samples/client/others/typescript/encode-decode/build/apis/DefaultApi.ts @@ -0,0 +1,1871 @@ +// TODO: better import syntax? +import {BaseAPIRequestFactory, RequiredError, COLLECTION_FORMATS} from './baseapi'; +import {Configuration} from '../configuration'; +import {RequestContext, HttpMethod, ResponseContext, HttpFile, HttpInfo} from '../http/http'; +import * as FormData from "form-data"; +import { URLSearchParams } from 'url'; +import {ObjectSerializer} from '../models/ObjectSerializer'; +import {ApiException} from './exception'; +import {canConsumeForm, isCodeInRange} from '../util'; +import {SecurityAuthentication} from '../auth/auth'; + + +import { ComplexObject } from '../models/ComplexObject'; +import { CompositeObject } from '../models/CompositeObject'; + +/** + * no description + */ +export class DefaultApiRequestFactory extends BaseAPIRequestFactory { + + /** + */ + public async testDecodeArrayOfArraysGet(_options?: Configuration): Promise { + let _config = _options || this.configuration; + + // Path Params + const localVarPath = '/test/decode/array-of-arrays'; + + // Make Request Context + const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + + + const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default + if (defaultAuth?.applySecurityAuthentication) { + await defaultAuth?.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + */ + public async testDecodeArrayOfGet(_options?: Configuration): Promise { + let _config = _options || this.configuration; + + // Path Params + const localVarPath = '/test/decode/array-of'; + + // Make Request Context + const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + + + const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default + if (defaultAuth?.applySecurityAuthentication) { + await defaultAuth?.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + */ + public async testDecodeArrayOfMapsOfObjectsGet(_options?: Configuration): Promise { + let _config = _options || this.configuration; + + // Path Params + const localVarPath = '/test/decode/array-of/maps-of/objects'; + + // Make Request Context + const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + + + const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default + if (defaultAuth?.applySecurityAuthentication) { + await defaultAuth?.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + */ + public async testDecodeArrayOfNullableGet(_options?: Configuration): Promise { + let _config = _options || this.configuration; + + // Path Params + const localVarPath = '/test/decode/array-of/nullable'; + + // Make Request Context + const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + + + const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default + if (defaultAuth?.applySecurityAuthentication) { + await defaultAuth?.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + */ + public async testDecodeArrayOfNullableObjectsGet(_options?: Configuration): Promise { + let _config = _options || this.configuration; + + // Path Params + const localVarPath = '/test/decode/array-of/nullable-objects'; + + // Make Request Context + const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + + + const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default + if (defaultAuth?.applySecurityAuthentication) { + await defaultAuth?.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + */ + public async testDecodeCompositeObjectsGet(_options?: Configuration): Promise { + let _config = _options || this.configuration; + + // Path Params + const localVarPath = '/test/decode/composite-objects'; + + // Make Request Context + const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + + + const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default + if (defaultAuth?.applySecurityAuthentication) { + await defaultAuth?.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + */ + public async testDecodeMapOfMapsOfObjectsGet(_options?: Configuration): Promise { + let _config = _options || this.configuration; + + // Path Params + const localVarPath = '/test/decode/map-of/maps-of/objects'; + + // Make Request Context + const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + + + const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default + if (defaultAuth?.applySecurityAuthentication) { + await defaultAuth?.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + */ + public async testDecodeMapOfObjectsGet(_options?: Configuration): Promise { + let _config = _options || this.configuration; + + // Path Params + const localVarPath = '/test/decode/map-of/objects'; + + // Make Request Context + const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + + + const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default + if (defaultAuth?.applySecurityAuthentication) { + await defaultAuth?.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + */ + public async testDecodeMapOfPrimitiveGet(_options?: Configuration): Promise { + let _config = _options || this.configuration; + + // Path Params + const localVarPath = '/test/decode/map-of/primitive'; + + // Make Request Context + const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + + + const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default + if (defaultAuth?.applySecurityAuthentication) { + await defaultAuth?.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + */ + public async testDecodeNullableArrayGet(_options?: Configuration): Promise { + let _config = _options || this.configuration; + + // Path Params + const localVarPath = '/test/decode/nullable-array'; + + // Make Request Context + const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + + + const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default + if (defaultAuth?.applySecurityAuthentication) { + await defaultAuth?.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + */ + public async testDecodeNullableGet(_options?: Configuration): Promise { + let _config = _options || this.configuration; + + // Path Params + const localVarPath = '/test/decode/nullable'; + + // Make Request Context + const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + + + const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default + if (defaultAuth?.applySecurityAuthentication) { + await defaultAuth?.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + */ + public async testDecodeObjectGet(_options?: Configuration): Promise { + let _config = _options || this.configuration; + + // Path Params + const localVarPath = '/test/decode/object'; + + // Make Request Context + const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + + + const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default + if (defaultAuth?.applySecurityAuthentication) { + await defaultAuth?.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + */ + public async testDecodePrimitiveBooleanGet(_options?: Configuration): Promise { + let _config = _options || this.configuration; + + // Path Params + const localVarPath = '/test/decode/primitive/boolean'; + + // Make Request Context + const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + + + const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default + if (defaultAuth?.applySecurityAuthentication) { + await defaultAuth?.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + */ + public async testDecodePrimitiveIntegerGet(_options?: Configuration): Promise { + let _config = _options || this.configuration; + + // Path Params + const localVarPath = '/test/decode/primitive/integer'; + + // Make Request Context + const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + + + const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default + if (defaultAuth?.applySecurityAuthentication) { + await defaultAuth?.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + */ + public async testDecodePrimitiveNumberGet(_options?: Configuration): Promise { + let _config = _options || this.configuration; + + // Path Params + const localVarPath = '/test/decode/primitive/number'; + + // Make Request Context + const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + + + const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default + if (defaultAuth?.applySecurityAuthentication) { + await defaultAuth?.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + */ + public async testDecodePrimitiveStringGet(_options?: Configuration): Promise { + let _config = _options || this.configuration; + + // Path Params + const localVarPath = '/test/decode/primitive/string'; + + // Make Request Context + const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + + + const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default + if (defaultAuth?.applySecurityAuthentication) { + await defaultAuth?.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * @param requestBody + */ + public async testEncodeArrayOfArraysPost(requestBody: Array>, _options?: Configuration): Promise { + let _config = _options || this.configuration; + + // verify required parameter 'requestBody' is not null or undefined + if (requestBody === null || requestBody === undefined) { + throw new RequiredError("DefaultApi", "testEncodeArrayOfArraysPost", "requestBody"); + } + + + // Path Params + const localVarPath = '/test/encode/array-of-arrays'; + + // Make Request Context + const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + + // Body Params + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json" + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(requestBody, "Array>", ""), + contentType + ); + requestContext.setBody(serializedBody); + + + const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default + if (defaultAuth?.applySecurityAuthentication) { + await defaultAuth?.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * @param complexObject + */ + public async testEncodeArrayOfMapsOfObjectsPost(complexObject: Array<{ [key: string]: ComplexObject; }>, _options?: Configuration): Promise { + let _config = _options || this.configuration; + + // verify required parameter 'complexObject' is not null or undefined + if (complexObject === null || complexObject === undefined) { + throw new RequiredError("DefaultApi", "testEncodeArrayOfMapsOfObjectsPost", "complexObject"); + } + + + // Path Params + const localVarPath = '/test/encode/array-of/maps-of/objects'; + + // Make Request Context + const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + + // Body Params + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json" + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(complexObject, "Array<{ [key: string]: ComplexObject; }>", ""), + contentType + ); + requestContext.setBody(serializedBody); + + + const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default + if (defaultAuth?.applySecurityAuthentication) { + await defaultAuth?.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * @param complexObject + */ + public async testEncodeArrayOfNullableObjectsPost(complexObject: Array, _options?: Configuration): Promise { + let _config = _options || this.configuration; + + // verify required parameter 'complexObject' is not null or undefined + if (complexObject === null || complexObject === undefined) { + throw new RequiredError("DefaultApi", "testEncodeArrayOfNullableObjectsPost", "complexObject"); + } + + + // Path Params + const localVarPath = '/test/encode/array-of/nullable-objects'; + + // Make Request Context + const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + + // Body Params + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json" + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(complexObject, "Array", ""), + contentType + ); + requestContext.setBody(serializedBody); + + + const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default + if (defaultAuth?.applySecurityAuthentication) { + await defaultAuth?.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * @param requestBody + */ + public async testEncodeArrayOfNullablePost(requestBody: Array, _options?: Configuration): Promise { + let _config = _options || this.configuration; + + // verify required parameter 'requestBody' is not null or undefined + if (requestBody === null || requestBody === undefined) { + throw new RequiredError("DefaultApi", "testEncodeArrayOfNullablePost", "requestBody"); + } + + + // Path Params + const localVarPath = '/test/encode/array-of/nullable'; + + // Make Request Context + const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + + // Body Params + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json" + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(requestBody, "Array", ""), + contentType + ); + requestContext.setBody(serializedBody); + + + const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default + if (defaultAuth?.applySecurityAuthentication) { + await defaultAuth?.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * @param requestBody + */ + public async testEncodeArrayOfPost(requestBody: Array, _options?: Configuration): Promise { + let _config = _options || this.configuration; + + // verify required parameter 'requestBody' is not null or undefined + if (requestBody === null || requestBody === undefined) { + throw new RequiredError("DefaultApi", "testEncodeArrayOfPost", "requestBody"); + } + + + // Path Params + const localVarPath = '/test/encode/array-of'; + + // Make Request Context + const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + + // Body Params + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json" + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(requestBody, "Array", ""), + contentType + ); + requestContext.setBody(serializedBody); + + + const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default + if (defaultAuth?.applySecurityAuthentication) { + await defaultAuth?.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * @param compositeObject + */ + public async testEncodeCompositeObjectsPost(compositeObject: CompositeObject, _options?: Configuration): Promise { + let _config = _options || this.configuration; + + // verify required parameter 'compositeObject' is not null or undefined + if (compositeObject === null || compositeObject === undefined) { + throw new RequiredError("DefaultApi", "testEncodeCompositeObjectsPost", "compositeObject"); + } + + + // Path Params + const localVarPath = '/test/encode/composite-objects'; + + // Make Request Context + const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + + // Body Params + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json" + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(compositeObject, "CompositeObject", ""), + contentType + ); + requestContext.setBody(serializedBody); + + + const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default + if (defaultAuth?.applySecurityAuthentication) { + await defaultAuth?.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * @param requestBody + */ + public async testEncodeMapOfMapsOfObjectsPost(requestBody: { [key: string]: { [key: string]: ComplexObject; }; }, _options?: Configuration): Promise { + let _config = _options || this.configuration; + + // verify required parameter 'requestBody' is not null or undefined + if (requestBody === null || requestBody === undefined) { + throw new RequiredError("DefaultApi", "testEncodeMapOfMapsOfObjectsPost", "requestBody"); + } + + + // Path Params + const localVarPath = '/test/encode/map-of/maps-of/objects'; + + // Make Request Context + const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + + // Body Params + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json" + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(requestBody, "{ [key: string]: { [key: string]: ComplexObject; }; }", ""), + contentType + ); + requestContext.setBody(serializedBody); + + + const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default + if (defaultAuth?.applySecurityAuthentication) { + await defaultAuth?.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * @param requestBody + */ + public async testEncodeMapOfObjectsPost(requestBody: { [key: string]: ComplexObject | null; }, _options?: Configuration): Promise { + let _config = _options || this.configuration; + + // verify required parameter 'requestBody' is not null or undefined + if (requestBody === null || requestBody === undefined) { + throw new RequiredError("DefaultApi", "testEncodeMapOfObjectsPost", "requestBody"); + } + + + // Path Params + const localVarPath = '/test/encode/map-of/objects'; + + // Make Request Context + const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + + // Body Params + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json" + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(requestBody, "{ [key: string]: ComplexObject | null; }", ""), + contentType + ); + requestContext.setBody(serializedBody); + + + const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default + if (defaultAuth?.applySecurityAuthentication) { + await defaultAuth?.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * @param requestBody + */ + public async testEncodeMapOfPrimitivePost(requestBody: { [key: string]: string; }, _options?: Configuration): Promise { + let _config = _options || this.configuration; + + // verify required parameter 'requestBody' is not null or undefined + if (requestBody === null || requestBody === undefined) { + throw new RequiredError("DefaultApi", "testEncodeMapOfPrimitivePost", "requestBody"); + } + + + // Path Params + const localVarPath = '/test/encode/map-of/primitive'; + + // Make Request Context + const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + + // Body Params + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json" + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(requestBody, "{ [key: string]: string; }", ""), + contentType + ); + requestContext.setBody(serializedBody); + + + const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default + if (defaultAuth?.applySecurityAuthentication) { + await defaultAuth?.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * @param requestBody + */ + public async testEncodeNullableArrayPost(requestBody?: Array, _options?: Configuration): Promise { + let _config = _options || this.configuration; + + + // Path Params + const localVarPath = '/test/encode/nullable-array'; + + // Make Request Context + const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + + // Body Params + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json" + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(requestBody, "Array", ""), + contentType + ); + requestContext.setBody(serializedBody); + + + const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default + if (defaultAuth?.applySecurityAuthentication) { + await defaultAuth?.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * @param body + */ + public async testEncodeNullablePost(body?: string, _options?: Configuration): Promise { + let _config = _options || this.configuration; + + + // Path Params + const localVarPath = '/test/encode/nullable'; + + // Make Request Context + const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + + // Body Params + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json" + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(body, "string", ""), + contentType + ); + requestContext.setBody(serializedBody); + + + const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default + if (defaultAuth?.applySecurityAuthentication) { + await defaultAuth?.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * @param complexObject + */ + public async testEncodeObjectPost(complexObject: ComplexObject, _options?: Configuration): Promise { + let _config = _options || this.configuration; + + // verify required parameter 'complexObject' is not null or undefined + if (complexObject === null || complexObject === undefined) { + throw new RequiredError("DefaultApi", "testEncodeObjectPost", "complexObject"); + } + + + // Path Params + const localVarPath = '/test/encode/object'; + + // Make Request Context + const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + + // Body Params + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json" + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(complexObject, "ComplexObject", ""), + contentType + ); + requestContext.setBody(serializedBody); + + + const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default + if (defaultAuth?.applySecurityAuthentication) { + await defaultAuth?.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * @param body + */ + public async testEncodePrimitiveBooleanPost(body: boolean, _options?: Configuration): Promise { + let _config = _options || this.configuration; + + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError("DefaultApi", "testEncodePrimitiveBooleanPost", "body"); + } + + + // Path Params + const localVarPath = '/test/encode/primitive/boolean'; + + // Make Request Context + const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + + // Body Params + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json" + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(body, "boolean", ""), + contentType + ); + requestContext.setBody(serializedBody); + + + const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default + if (defaultAuth?.applySecurityAuthentication) { + await defaultAuth?.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * @param body + */ + public async testEncodePrimitiveIntegerPost(body: number, _options?: Configuration): Promise { + let _config = _options || this.configuration; + + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError("DefaultApi", "testEncodePrimitiveIntegerPost", "body"); + } + + + // Path Params + const localVarPath = '/test/encode/primitive/integer'; + + // Make Request Context + const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + + // Body Params + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json" + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(body, "number", ""), + contentType + ); + requestContext.setBody(serializedBody); + + + const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default + if (defaultAuth?.applySecurityAuthentication) { + await defaultAuth?.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * @param body + */ + public async testEncodePrimitiveNumberPost(body: number, _options?: Configuration): Promise { + let _config = _options || this.configuration; + + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError("DefaultApi", "testEncodePrimitiveNumberPost", "body"); + } + + + // Path Params + const localVarPath = '/test/encode/primitive/number'; + + // Make Request Context + const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + + // Body Params + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json" + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(body, "number", ""), + contentType + ); + requestContext.setBody(serializedBody); + + + const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default + if (defaultAuth?.applySecurityAuthentication) { + await defaultAuth?.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * @param body + */ + public async testEncodePrimitiveStringPost(body: string, _options?: Configuration): Promise { + let _config = _options || this.configuration; + + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError("DefaultApi", "testEncodePrimitiveStringPost", "body"); + } + + + // Path Params + const localVarPath = '/test/encode/primitive/string'; + + // Make Request Context + const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + + // Body Params + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json" + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(body, "string", ""), + contentType + ); + requestContext.setBody(serializedBody); + + + const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default + if (defaultAuth?.applySecurityAuthentication) { + await defaultAuth?.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + +} + +export class DefaultApiResponseProcessor { + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to testDecodeArrayOfArraysGet + * @throws ApiException if the response code was not in [200, 299] + */ + public async testDecodeArrayOfArraysGetWithHttpInfo(response: ResponseContext): Promise> >> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: Array> = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Array>", "" + ) as Array>; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: Array> = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Array>", "" + ) as Array>; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to testDecodeArrayOfGet + * @throws ApiException if the response code was not in [200, 299] + */ + public async testDecodeArrayOfGetWithHttpInfo(response: ResponseContext): Promise >> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: Array = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Array", "" + ) as Array; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: Array = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Array", "" + ) as Array; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to testDecodeArrayOfMapsOfObjectsGet + * @throws ApiException if the response code was not in [200, 299] + */ + public async testDecodeArrayOfMapsOfObjectsGetWithHttpInfo(response: ResponseContext): Promise >> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: Array<{ [key: string]: ComplexObject; }> = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Array<{ [key: string]: ComplexObject; }>", "" + ) as Array<{ [key: string]: ComplexObject; }>; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: Array<{ [key: string]: ComplexObject; }> = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Array<{ [key: string]: ComplexObject; }>", "" + ) as Array<{ [key: string]: ComplexObject; }>; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to testDecodeArrayOfNullableGet + * @throws ApiException if the response code was not in [200, 299] + */ + public async testDecodeArrayOfNullableGetWithHttpInfo(response: ResponseContext): Promise >> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: Array = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Array", "" + ) as Array; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: Array = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Array", "" + ) as Array; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to testDecodeArrayOfNullableObjectsGet + * @throws ApiException if the response code was not in [200, 299] + */ + public async testDecodeArrayOfNullableObjectsGetWithHttpInfo(response: ResponseContext): Promise >> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: Array = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Array", "" + ) as Array; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: Array = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Array", "" + ) as Array; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to testDecodeCompositeObjectsGet + * @throws ApiException if the response code was not in [200, 299] + */ + public async testDecodeCompositeObjectsGetWithHttpInfo(response: ResponseContext): Promise> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: CompositeObject = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "CompositeObject", "" + ) as CompositeObject; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: CompositeObject = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "CompositeObject", "" + ) as CompositeObject; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to testDecodeMapOfMapsOfObjectsGet + * @throws ApiException if the response code was not in [200, 299] + */ + public async testDecodeMapOfMapsOfObjectsGetWithHttpInfo(response: ResponseContext): Promise> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: { [key: string]: { [key: string]: ComplexObject; }; } = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "{ [key: string]: { [key: string]: ComplexObject; }; }", "" + ) as { [key: string]: { [key: string]: ComplexObject; }; }; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: { [key: string]: { [key: string]: ComplexObject; }; } = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "{ [key: string]: { [key: string]: ComplexObject; }; }", "" + ) as { [key: string]: { [key: string]: ComplexObject; }; }; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to testDecodeMapOfObjectsGet + * @throws ApiException if the response code was not in [200, 299] + */ + public async testDecodeMapOfObjectsGetWithHttpInfo(response: ResponseContext): Promise> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: { [key: string]: ComplexObject | null; } = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "{ [key: string]: ComplexObject | null; }", "" + ) as { [key: string]: ComplexObject | null; }; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: { [key: string]: ComplexObject | null; } = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "{ [key: string]: ComplexObject | null; }", "" + ) as { [key: string]: ComplexObject | null; }; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to testDecodeMapOfPrimitiveGet + * @throws ApiException if the response code was not in [200, 299] + */ + public async testDecodeMapOfPrimitiveGetWithHttpInfo(response: ResponseContext): Promise> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: { [key: string]: string; } = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "{ [key: string]: string; }", "" + ) as { [key: string]: string; }; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: { [key: string]: string; } = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "{ [key: string]: string; }", "" + ) as { [key: string]: string; }; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to testDecodeNullableArrayGet + * @throws ApiException if the response code was not in [200, 299] + */ + public async testDecodeNullableArrayGetWithHttpInfo(response: ResponseContext): Promise >> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: Array = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Array", "" + ) as Array; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: Array = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Array", "" + ) as Array; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to testDecodeNullableGet + * @throws ApiException if the response code was not in [200, 299] + */ + public async testDecodeNullableGetWithHttpInfo(response: ResponseContext): Promise> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: string = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "string", "" + ) as string; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: string = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "string", "" + ) as string; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to testDecodeObjectGet + * @throws ApiException if the response code was not in [200, 299] + */ + public async testDecodeObjectGetWithHttpInfo(response: ResponseContext): Promise> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: ComplexObject = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "ComplexObject", "" + ) as ComplexObject; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: ComplexObject = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "ComplexObject", "" + ) as ComplexObject; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to testDecodePrimitiveBooleanGet + * @throws ApiException if the response code was not in [200, 299] + */ + public async testDecodePrimitiveBooleanGetWithHttpInfo(response: ResponseContext): Promise> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: boolean = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "boolean", "" + ) as boolean; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: boolean = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "boolean", "" + ) as boolean; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to testDecodePrimitiveIntegerGet + * @throws ApiException if the response code was not in [200, 299] + */ + public async testDecodePrimitiveIntegerGetWithHttpInfo(response: ResponseContext): Promise> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: number = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "number", "" + ) as number; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: number = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "number", "" + ) as number; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to testDecodePrimitiveNumberGet + * @throws ApiException if the response code was not in [200, 299] + */ + public async testDecodePrimitiveNumberGetWithHttpInfo(response: ResponseContext): Promise> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: number = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "number", "" + ) as number; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: number = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "number", "" + ) as number; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to testDecodePrimitiveStringGet + * @throws ApiException if the response code was not in [200, 299] + */ + public async testDecodePrimitiveStringGetWithHttpInfo(response: ResponseContext): Promise> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: string = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "string", "" + ) as string; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: string = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "string", "" + ) as string; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to testEncodeArrayOfArraysPost + * @throws ApiException if the response code was not in [200, 299] + */ + public async testEncodeArrayOfArraysPostWithHttpInfo(response: ResponseContext): Promise> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + return new HttpInfo(response.httpStatusCode, response.headers, response.body, undefined); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: void = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "void", "" + ) as void; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to testEncodeArrayOfMapsOfObjectsPost + * @throws ApiException if the response code was not in [200, 299] + */ + public async testEncodeArrayOfMapsOfObjectsPostWithHttpInfo(response: ResponseContext): Promise> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + return new HttpInfo(response.httpStatusCode, response.headers, response.body, undefined); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: void = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "void", "" + ) as void; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to testEncodeArrayOfNullableObjectsPost + * @throws ApiException if the response code was not in [200, 299] + */ + public async testEncodeArrayOfNullableObjectsPostWithHttpInfo(response: ResponseContext): Promise> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + return new HttpInfo(response.httpStatusCode, response.headers, response.body, undefined); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: void = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "void", "" + ) as void; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to testEncodeArrayOfNullablePost + * @throws ApiException if the response code was not in [200, 299] + */ + public async testEncodeArrayOfNullablePostWithHttpInfo(response: ResponseContext): Promise> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + return new HttpInfo(response.httpStatusCode, response.headers, response.body, undefined); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: void = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "void", "" + ) as void; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to testEncodeArrayOfPost + * @throws ApiException if the response code was not in [200, 299] + */ + public async testEncodeArrayOfPostWithHttpInfo(response: ResponseContext): Promise> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + return new HttpInfo(response.httpStatusCode, response.headers, response.body, undefined); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: void = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "void", "" + ) as void; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to testEncodeCompositeObjectsPost + * @throws ApiException if the response code was not in [200, 299] + */ + public async testEncodeCompositeObjectsPostWithHttpInfo(response: ResponseContext): Promise> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + return new HttpInfo(response.httpStatusCode, response.headers, response.body, undefined); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: void = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "void", "" + ) as void; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to testEncodeMapOfMapsOfObjectsPost + * @throws ApiException if the response code was not in [200, 299] + */ + public async testEncodeMapOfMapsOfObjectsPostWithHttpInfo(response: ResponseContext): Promise> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + return new HttpInfo(response.httpStatusCode, response.headers, response.body, undefined); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: void = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "void", "" + ) as void; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to testEncodeMapOfObjectsPost + * @throws ApiException if the response code was not in [200, 299] + */ + public async testEncodeMapOfObjectsPostWithHttpInfo(response: ResponseContext): Promise> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + return new HttpInfo(response.httpStatusCode, response.headers, response.body, undefined); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: void = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "void", "" + ) as void; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to testEncodeMapOfPrimitivePost + * @throws ApiException if the response code was not in [200, 299] + */ + public async testEncodeMapOfPrimitivePostWithHttpInfo(response: ResponseContext): Promise> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + return new HttpInfo(response.httpStatusCode, response.headers, response.body, undefined); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: void = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "void", "" + ) as void; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to testEncodeNullableArrayPost + * @throws ApiException if the response code was not in [200, 299] + */ + public async testEncodeNullableArrayPostWithHttpInfo(response: ResponseContext): Promise> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + return new HttpInfo(response.httpStatusCode, response.headers, response.body, undefined); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: void = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "void", "" + ) as void; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to testEncodeNullablePost + * @throws ApiException if the response code was not in [200, 299] + */ + public async testEncodeNullablePostWithHttpInfo(response: ResponseContext): Promise> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + return new HttpInfo(response.httpStatusCode, response.headers, response.body, undefined); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: void = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "void", "" + ) as void; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to testEncodeObjectPost + * @throws ApiException if the response code was not in [200, 299] + */ + public async testEncodeObjectPostWithHttpInfo(response: ResponseContext): Promise> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + return new HttpInfo(response.httpStatusCode, response.headers, response.body, undefined); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: void = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "void", "" + ) as void; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to testEncodePrimitiveBooleanPost + * @throws ApiException if the response code was not in [200, 299] + */ + public async testEncodePrimitiveBooleanPostWithHttpInfo(response: ResponseContext): Promise> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + return new HttpInfo(response.httpStatusCode, response.headers, response.body, undefined); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: void = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "void", "" + ) as void; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to testEncodePrimitiveIntegerPost + * @throws ApiException if the response code was not in [200, 299] + */ + public async testEncodePrimitiveIntegerPostWithHttpInfo(response: ResponseContext): Promise> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + return new HttpInfo(response.httpStatusCode, response.headers, response.body, undefined); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: void = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "void", "" + ) as void; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to testEncodePrimitiveNumberPost + * @throws ApiException if the response code was not in [200, 299] + */ + public async testEncodePrimitiveNumberPostWithHttpInfo(response: ResponseContext): Promise> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + return new HttpInfo(response.httpStatusCode, response.headers, response.body, undefined); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: void = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "void", "" + ) as void; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to testEncodePrimitiveStringPost + * @throws ApiException if the response code was not in [200, 299] + */ + public async testEncodePrimitiveStringPostWithHttpInfo(response: ResponseContext): Promise> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + return new HttpInfo(response.httpStatusCode, response.headers, response.body, undefined); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: void = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "void", "" + ) as void; + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); + } + + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); + } + +} diff --git a/samples/client/others/typescript/encode-decode/build/apis/baseapi.ts b/samples/client/others/typescript/encode-decode/build/apis/baseapi.ts new file mode 100644 index 000000000000..ce1e2dbc47e1 --- /dev/null +++ b/samples/client/others/typescript/encode-decode/build/apis/baseapi.ts @@ -0,0 +1,37 @@ +import { Configuration } from '../configuration' + +/** + * + * @export + */ +export const COLLECTION_FORMATS = { + csv: ",", + ssv: " ", + tsv: "\t", + pipes: "|", +}; + + +/** + * + * @export + * @class BaseAPI + */ +export class BaseAPIRequestFactory { + + constructor(protected configuration: Configuration) { + } +}; + +/** + * + * @export + * @class RequiredError + * @extends {Error} + */ +export class RequiredError extends Error { + name: "RequiredError" = "RequiredError"; + constructor(public api: string, public method: string, public field: string) { + super("Required parameter " + field + " was null or undefined when calling " + api + "." + method + "."); + } +} diff --git a/samples/client/others/typescript/encode-decode/build/apis/exception.ts b/samples/client/others/typescript/encode-decode/build/apis/exception.ts new file mode 100644 index 000000000000..9365d33a8f7e --- /dev/null +++ b/samples/client/others/typescript/encode-decode/build/apis/exception.ts @@ -0,0 +1,15 @@ +/** + * Represents an error caused by an api call i.e. it has attributes for a HTTP status code + * and the returned body object. + * + * Example + * API returns a ErrorMessageObject whenever HTTP status code is not in [200, 299] + * => ApiException(404, someErrorMessageObject) + * + */ +export class ApiException extends Error { + public constructor(public code: number, message: string, public body: T, public headers: { [key: string]: string; }) { + super("HTTP-Code: " + code + "\nMessage: " + message + "\nBody: " + JSON.stringify(body) + "\nHeaders: " + + JSON.stringify(headers)) + } +} diff --git a/samples/client/others/typescript/encode-decode/build/auth/auth.ts b/samples/client/others/typescript/encode-decode/build/auth/auth.ts new file mode 100644 index 000000000000..be50274b9d65 --- /dev/null +++ b/samples/client/others/typescript/encode-decode/build/auth/auth.ts @@ -0,0 +1,51 @@ +import { RequestContext } from "../http/http"; + +/** + * Interface authentication schemes. + */ +export interface SecurityAuthentication { + /* + * @return returns the name of the security authentication as specified in OAI + */ + getName(): string; + + /** + * Applies the authentication scheme to the request context + * + * @params context the request context which should use this authentication scheme + */ + applySecurityAuthentication(context: RequestContext): void | Promise; +} + +export interface TokenProvider { + getToken(): Promise | string; +} + + +export type AuthMethods = { + "default"?: SecurityAuthentication, +} + +export type ApiKeyConfiguration = string; +export type HttpBasicConfiguration = { "username": string, "password": string }; +export type HttpBearerConfiguration = { tokenProvider: TokenProvider }; +export type OAuth2Configuration = { accessToken: string }; + +export type AuthMethodsConfiguration = { + "default"?: SecurityAuthentication, +} + +/** + * Creates the authentication methods from a swagger description. + * + */ +export function configureAuthMethods(config: AuthMethodsConfiguration | undefined): AuthMethods { + let authMethods: AuthMethods = {} + + if (!config) { + return authMethods; + } + authMethods["default"] = config["default"] + + return authMethods; +} \ No newline at end of file diff --git a/samples/client/others/typescript/encode-decode/build/configuration.ts b/samples/client/others/typescript/encode-decode/build/configuration.ts new file mode 100644 index 000000000000..7acb56e66477 --- /dev/null +++ b/samples/client/others/typescript/encode-decode/build/configuration.ts @@ -0,0 +1,82 @@ +import { HttpLibrary } from "./http/http"; +import { Middleware, PromiseMiddleware, PromiseMiddlewareWrapper } from "./middleware"; +import { IsomorphicFetchHttpLibrary as DefaultHttpLibrary } from "./http/isomorphic-fetch"; +import { BaseServerConfiguration, server1 } from "./servers"; +import { configureAuthMethods, AuthMethods, AuthMethodsConfiguration } from "./auth/auth"; + +export interface Configuration { + readonly baseServer: BaseServerConfiguration; + readonly httpApi: HttpLibrary; + readonly middleware: Middleware[]; + readonly authMethods: AuthMethods; +} + + +/** + * Interface with which a configuration object can be configured. + */ +export interface ConfigurationParameters { + /** + * Default server to use - a list of available servers (according to the + * OpenAPI yaml definition) is included in the `servers` const in `./servers`. You can also + * create your own server with the `ServerConfiguration` class from the same + * file. + */ + baseServer?: BaseServerConfiguration; + /** + * HTTP library to use e.g. IsomorphicFetch. This can usually be skipped as + * all generators come with a default library. + * If available, additional libraries can be imported from `./http/*` + */ + httpApi?: HttpLibrary; + + /** + * The middlewares which will be applied to requests and responses. You can + * add any number of middleware components to modify requests before they + * are sent or before they are deserialized by implementing the `Middleware` + * interface defined in `./middleware` + */ + middleware?: Middleware[]; + /** + * Configures middleware functions that return promises instead of + * Observables (which are used by `middleware`). Otherwise allows for the + * same functionality as `middleware`, i.e., modifying requests before they + * are sent and before they are deserialized. + */ + promiseMiddleware?: PromiseMiddleware[]; + /** + * Configuration for the available authentication methods (e.g., api keys) + * according to the OpenAPI yaml definition. For the definition, please refer to + * `./auth/auth` + */ + authMethods?: AuthMethodsConfiguration +} + +/** + * Provide your `ConfigurationParameters` to this function to get a `Configuration` + * object that can be used to configure your APIs (in the constructor or + * for each request individually). + * + * If a property is not included in conf, a default is used: + * - baseServer: server1 + * - httpApi: IsomorphicFetchHttpLibrary + * - middleware: [] + * - promiseMiddleware: [] + * - authMethods: {} + * + * @param conf partial configuration + */ +export function createConfiguration(conf: ConfigurationParameters = {}): Configuration { + const configuration: Configuration = { + baseServer: conf.baseServer !== undefined ? conf.baseServer : server1, + httpApi: conf.httpApi || new DefaultHttpLibrary(), + middleware: conf.middleware || [], + authMethods: configureAuthMethods(conf.authMethods) + }; + if (conf.promiseMiddleware) { + conf.promiseMiddleware.forEach( + m => configuration.middleware.push(new PromiseMiddlewareWrapper(m)) + ); + } + return configuration; +} \ No newline at end of file diff --git a/samples/client/others/typescript/encode-decode/build/git_push.sh b/samples/client/others/typescript/encode-decode/build/git_push.sh new file mode 100644 index 000000000000..b253029754ed --- /dev/null +++ b/samples/client/others/typescript/encode-decode/build/git_push.sh @@ -0,0 +1,51 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=$(git remote) +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' diff --git a/samples/client/others/typescript/encode-decode/build/http/http.ts b/samples/client/others/typescript/encode-decode/build/http/http.ts new file mode 100644 index 000000000000..38fad4135e05 --- /dev/null +++ b/samples/client/others/typescript/encode-decode/build/http/http.ts @@ -0,0 +1,251 @@ +// TODO: evaluate if we can easily get rid of this library +import * as FormData from "form-data"; +import { URL, URLSearchParams } from 'url'; +import * as http from 'http'; +import * as https from 'https'; +import { Observable, from } from '../rxjsStub'; + +export * from './isomorphic-fetch'; + +/** + * Represents an HTTP method. + */ +export enum HttpMethod { + GET = "GET", + HEAD = "HEAD", + POST = "POST", + PUT = "PUT", + DELETE = "DELETE", + CONNECT = "CONNECT", + OPTIONS = "OPTIONS", + TRACE = "TRACE", + PATCH = "PATCH" +} + +/** + * Represents an HTTP file which will be transferred from or to a server. + */ +export type HttpFile = { + data: Buffer, + name: string +}; + +export class HttpException extends Error { + public constructor(msg: string) { + super(msg); + } +} + +/** + * Represents the body of an outgoing HTTP request. + */ +export type RequestBody = undefined | string | FormData | URLSearchParams; + +function ensureAbsoluteUrl(url: string) { + if (url.startsWith("http://") || url.startsWith("https://")) { + return url; + } + throw new Error("You need to define an absolute base url for the server."); +} + +/** + * Represents an HTTP request context + */ +export class RequestContext { + private headers: { [key: string]: string } = {}; + private body: RequestBody = undefined; + private url: URL; + private agent: http.Agent | https.Agent | undefined = undefined; + + /** + * Creates the request context using a http method and request resource url + * + * @param url url of the requested resource + * @param httpMethod http method + */ + public constructor(url: string, private httpMethod: HttpMethod) { + this.url = new URL(ensureAbsoluteUrl(url)); + } + + /* + * Returns the url set in the constructor including the query string + * + */ + public getUrl(): string { + return this.url.toString().endsWith("/") ? + this.url.toString().slice(0, -1) + : this.url.toString(); + } + + /** + * Replaces the url set in the constructor with this url. + * + */ + public setUrl(url: string) { + this.url = new URL(ensureAbsoluteUrl(url)); + } + + /** + * Sets the body of the http request either as a string or FormData + * + * Note that setting a body on a HTTP GET, HEAD, DELETE, CONNECT or TRACE + * request is discouraged. + * https://httpwg.org/http-core/draft-ietf-httpbis-semantics-latest.html#rfc.section.7.3.1 + * + * @param body the body of the request + */ + public setBody(body: RequestBody) { + this.body = body; + } + + public getHttpMethod(): HttpMethod { + return this.httpMethod; + } + + public getHeaders(): { [key: string]: string } { + return this.headers; + } + + public getBody(): RequestBody { + return this.body; + } + + public setQueryParam(name: string, value: string) { + this.url.searchParams.set(name, value); + } + + public appendQueryParam(name: string, value: string) { + this.url.searchParams.append(name, value); + } + + /** + * Sets a cookie with the name and value. NO check for duplicate cookies is performed + * + */ + public addCookie(name: string, value: string): void { + if (!this.headers["Cookie"]) { + this.headers["Cookie"] = ""; + } + this.headers["Cookie"] += name + "=" + value + "; "; + } + + public setHeaderParam(key: string, value: string): void { + this.headers[key] = value; + } + + public setAgent(agent: http.Agent | https.Agent) { + this.agent = agent; + } + + public getAgent(): http.Agent | https.Agent | undefined { + return this.agent; + } +} + +export interface ResponseBody { + text(): Promise; + binary(): Promise; +} + +/** + * Helper class to generate a `ResponseBody` from binary data + */ +export class SelfDecodingBody implements ResponseBody { + constructor(private dataSource: Promise) {} + + binary(): Promise { + return this.dataSource; + } + + async text(): Promise { + const data: Buffer = await this.dataSource; + return data.toString(); + } +} + +export class ResponseContext { + public constructor( + public httpStatusCode: number, + public headers: { [key: string]: string }, + public body: ResponseBody + ) {} + + /** + * Parse header value in the form `value; param1="value1"` + * + * E.g. for Content-Type or Content-Disposition + * Parameter names are converted to lower case + * The first parameter is returned with the key `""` + */ + public getParsedHeader(headerName: string): { [parameter: string]: string } { + const result: { [parameter: string]: string } = {}; + if (!this.headers[headerName]) { + return result; + } + + const parameters = this.headers[headerName].split(";"); + for (const parameter of parameters) { + let [key, value] = parameter.split("=", 2); + key = key.toLowerCase().trim(); + if (value === undefined) { + result[""] = key; + } else { + value = value.trim(); + if (value.startsWith('"') && value.endsWith('"')) { + value = value.substring(1, value.length - 1); + } + result[key] = value; + } + } + return result; + } + + public async getBodyAsFile(): Promise { + const data = await this.body.binary(); + const fileName = this.getParsedHeader("content-disposition")["filename"] || ""; + return { data, name: fileName }; + } + + /** + * Use a heuristic to get a body of unknown data structure. + * Return as string if possible, otherwise as binary. + */ + public getBodyAsAny(): Promise { + try { + return this.body.text(); + } catch {} + + try { + return this.body.binary(); + } catch {} + + return Promise.resolve(undefined); + } +} + +export interface HttpLibrary { + send(request: RequestContext): Observable; +} + +export interface PromiseHttpLibrary { + send(request: RequestContext): Promise; +} + +export function wrapHttpLibrary(promiseHttpLibrary: PromiseHttpLibrary): HttpLibrary { + return { + send(request: RequestContext): Observable { + return from(promiseHttpLibrary.send(request)); + } + } +} + +export class HttpInfo extends ResponseContext { + public constructor( + public httpStatusCode: number, + public headers: { [key: string]: string }, + public body: ResponseBody, + public data: T, + ) { + super(httpStatusCode, headers, body); + } +} diff --git a/samples/client/others/typescript/encode-decode/build/http/isomorphic-fetch.ts b/samples/client/others/typescript/encode-decode/build/http/isomorphic-fetch.ts new file mode 100644 index 000000000000..26d267cfc063 --- /dev/null +++ b/samples/client/others/typescript/encode-decode/build/http/isomorphic-fetch.ts @@ -0,0 +1,32 @@ +import {HttpLibrary, RequestContext, ResponseContext} from './http'; +import { from, Observable } from '../rxjsStub'; +import fetch from "node-fetch"; + +export class IsomorphicFetchHttpLibrary implements HttpLibrary { + + public send(request: RequestContext): Observable { + let method = request.getHttpMethod().toString(); + let body = request.getBody(); + + const resultPromise = fetch(request.getUrl(), { + method: method, + body: body as any, + headers: request.getHeaders(), + agent: request.getAgent(), + }).then((resp: any) => { + const headers: { [name: string]: string } = {}; + resp.headers.forEach((value: string, name: string) => { + headers[name] = value; + }); + + const body = { + text: () => resp.text(), + binary: () => resp.buffer() + }; + return new ResponseContext(resp.status, headers, body); + }); + + return from>(resultPromise); + + } +} diff --git a/samples/client/others/typescript/encode-decode/build/index.ts b/samples/client/others/typescript/encode-decode/build/index.ts new file mode 100644 index 000000000000..89069bd11889 --- /dev/null +++ b/samples/client/others/typescript/encode-decode/build/index.ts @@ -0,0 +1,12 @@ +export * from "./http/http"; +export * from "./auth/auth"; +export * from "./models/all"; +export { createConfiguration } from "./configuration" +export { Configuration } from "./configuration" +export * from "./apis/exception"; +export * from "./servers"; +export { RequiredError } from "./apis/baseapi"; + +export { PromiseMiddleware as Middleware } from './middleware'; +export { PromiseDefaultApi as DefaultApi } from './types/PromiseAPI'; + diff --git a/samples/client/others/typescript/encode-decode/build/middleware.ts b/samples/client/others/typescript/encode-decode/build/middleware.ts new file mode 100644 index 000000000000..524f93f016b2 --- /dev/null +++ b/samples/client/others/typescript/encode-decode/build/middleware.ts @@ -0,0 +1,66 @@ +import {RequestContext, ResponseContext} from './http/http'; +import { Observable, from } from './rxjsStub'; + +/** + * Defines the contract for a middleware intercepting requests before + * they are sent (but after the RequestContext was created) + * and before the ResponseContext is unwrapped. + * + */ +export interface Middleware { + /** + * Modifies the request before the request is sent. + * + * @param context RequestContext of a request which is about to be sent to the server + * @returns an observable of the updated request context + * + */ + pre(context: RequestContext): Observable; + /** + * Modifies the returned response before it is deserialized. + * + * @param context ResponseContext of a sent request + * @returns an observable of the modified response context + */ + post(context: ResponseContext): Observable; +} + +export class PromiseMiddlewareWrapper implements Middleware { + + public constructor(private middleware: PromiseMiddleware) { + + } + + pre(context: RequestContext): Observable { + return from(this.middleware.pre(context)); + } + + post(context: ResponseContext): Observable { + return from(this.middleware.post(context)); + } + +} + +/** + * Defines the contract for a middleware intercepting requests before + * they are sent (but after the RequestContext was created) + * and before the ResponseContext is unwrapped. + * + */ +export interface PromiseMiddleware { + /** + * Modifies the request before the request is sent. + * + * @param context RequestContext of a request which is about to be sent to the server + * @returns an observable of the updated request context + * + */ + pre(context: RequestContext): Promise; + /** + * Modifies the returned response before it is deserialized. + * + * @param context ResponseContext of a sent request + * @returns an observable of the modified response context + */ + post(context: ResponseContext): Promise; +} diff --git a/samples/client/others/typescript/encode-decode/build/models/ComplexObject.ts b/samples/client/others/typescript/encode-decode/build/models/ComplexObject.ts new file mode 100644 index 000000000000..f828c97ab7c5 --- /dev/null +++ b/samples/client/others/typescript/encode-decode/build/models/ComplexObject.ts @@ -0,0 +1,57 @@ +/** + * Encoding / Decoding Test + * A spec to ensure encoding and decoding of types (both primitive and compound) works as expected + * + * OpenAPI spec version: latest + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { HttpFile } from '../http/http'; + +export class ComplexObject { + 'requiredProperty': string; + 'requiredNullableProperty': string | null; + 'optionalProperty'?: string; + 'optionalNullableProperty'?: string | null; + + static readonly discriminator: string | undefined = undefined; + + static readonly mapping: {[index: string]: string} | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "requiredProperty", + "baseName": "required_property", + "type": "string", + "format": "" + }, + { + "name": "requiredNullableProperty", + "baseName": "required_nullable_property", + "type": "string", + "format": "" + }, + { + "name": "optionalProperty", + "baseName": "optional_property", + "type": "string", + "format": "" + }, + { + "name": "optionalNullableProperty", + "baseName": "optional_nullable_property", + "type": "string", + "format": "" + } ]; + + static getAttributeTypeMap() { + return ComplexObject.attributeTypeMap; + } + + public constructor() { + } +} diff --git a/samples/client/others/typescript/encode-decode/build/models/CompositeObject.ts b/samples/client/others/typescript/encode-decode/build/models/CompositeObject.ts new file mode 100644 index 000000000000..18aca6114d67 --- /dev/null +++ b/samples/client/others/typescript/encode-decode/build/models/CompositeObject.ts @@ -0,0 +1,37 @@ +/** + * Encoding / Decoding Test + * A spec to ensure encoding and decoding of types (both primitive and compound) works as expected + * + * OpenAPI spec version: latest + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { ComplexObject } from '../models/ComplexObject'; +import { HttpFile } from '../http/http'; + +export class CompositeObject { + 'optionalNullableInnerObject'?: ComplexObject | null; + + static readonly discriminator: string | undefined = undefined; + + static readonly mapping: {[index: string]: string} | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "optionalNullableInnerObject", + "baseName": "optional_nullable_inner_object", + "type": "ComplexObject", + "format": "" + } ]; + + static getAttributeTypeMap() { + return CompositeObject.attributeTypeMap; + } + + public constructor() { + } +} diff --git a/samples/client/others/typescript/encode-decode/build/models/ObjectSerializer.ts b/samples/client/others/typescript/encode-decode/build/models/ObjectSerializer.ts new file mode 100644 index 000000000000..f1265ea6d5ab --- /dev/null +++ b/samples/client/others/typescript/encode-decode/build/models/ObjectSerializer.ts @@ -0,0 +1,311 @@ +export * from '../models/ComplexObject'; +export * from '../models/CompositeObject'; + +import { ComplexObject } from '../models/ComplexObject'; +import { CompositeObject } from '../models/CompositeObject'; + +/* tslint:disable:no-unused-variable */ +let primitives = [ + "string", + "boolean", + "double", + "integer", + "long", + "float", + "number", + "any" + ]; + +let enumsMap: Set = new Set([ +]); + +let typeMap: {[index: string]: any} = { + "ComplexObject": ComplexObject, + "CompositeObject": CompositeObject, +} + +type MimeTypeDescriptor = { + type: string; + subtype: string; + subtypeTokens: string[]; +}; + +/** + * Every mime-type consists of a type, subtype, and optional parameters. + * The subtype can be composite, including information about the content format. + * For example: `application/json-patch+json`, `application/merge-patch+json`. + * + * This helper transforms a string mime-type into an internal representation. + * This simplifies the implementation of predicates that in turn define common rules for parsing or stringifying + * the payload. + */ +const parseMimeType = (mimeType: string): MimeTypeDescriptor => { + const [type, subtype] = mimeType.split('/'); + return { + type, + subtype, + subtypeTokens: subtype.split('+'), + }; +}; + +type MimeTypePredicate = (mimeType: string) => boolean; + +// This factory creates a predicate function that checks a string mime-type against defined rules. +const mimeTypePredicateFactory = (predicate: (descriptor: MimeTypeDescriptor) => boolean): MimeTypePredicate => (mimeType) => predicate(parseMimeType(mimeType)); + +// Use this factory when you need to define a simple predicate based only on type and, if applicable, subtype. +const mimeTypeSimplePredicateFactory = (type: string, subtype?: string): MimeTypePredicate => mimeTypePredicateFactory((descriptor) => { + if (descriptor.type !== type) return false; + if (subtype != null && descriptor.subtype !== subtype) return false; + return true; +}); + +// Creating a set of named predicates that will help us determine how to handle different mime-types +const isTextLikeMimeType = mimeTypeSimplePredicateFactory('text'); +const isJsonMimeType = mimeTypeSimplePredicateFactory('application', 'json'); +const isJsonLikeMimeType = mimeTypePredicateFactory((descriptor) => descriptor.type === 'application' && descriptor.subtypeTokens.some((item) => item === 'json')); +const isOctetStreamMimeType = mimeTypeSimplePredicateFactory('application', 'octet-stream'); +const isFormUrlencodedMimeType = mimeTypeSimplePredicateFactory('application', 'x-www-form-urlencoded'); + +// Defining a list of mime-types in the order of prioritization for handling. +const supportedMimeTypePredicatesWithPriority: MimeTypePredicate[] = [ + isJsonMimeType, + isJsonLikeMimeType, + isTextLikeMimeType, + isOctetStreamMimeType, + isFormUrlencodedMimeType, +]; + +const nullableSuffix = " | null"; +const optionalSuffix = " | undefined"; +const arrayPrefix = "Array<"; +const arraySuffix = ">"; +const mapPrefix = "{ [key: string]: "; +const mapSuffix = "; }"; + +export class ObjectSerializer { + public static findCorrectType(data: any, expectedType: string) { + if (data == undefined) { + return expectedType; + } else if (primitives.indexOf(expectedType.toLowerCase()) !== -1) { + return expectedType; + } else if (expectedType === "Date") { + return expectedType; + } else { + if (enumsMap.has(expectedType)) { + return expectedType; + } + + if (!typeMap[expectedType]) { + return expectedType; // w/e we don't know the type + } + + // Check the discriminator + let discriminatorProperty = typeMap[expectedType].discriminator; + if (discriminatorProperty == null) { + return expectedType; // the type does not have a discriminator. use it. + } else { + if (data[discriminatorProperty]) { + var discriminatorType = data[discriminatorProperty]; + let mapping = typeMap[expectedType].mapping; + if (mapping != undefined && mapping[discriminatorType]) { + return mapping[discriminatorType]; // use the type given in the discriminator + } else if(typeMap[discriminatorType]) { + return discriminatorType; + } else { + return expectedType; // discriminator did not map to a type + } + } else { + return expectedType; // discriminator was not present (or an empty string) + } + } + } + } + + public static serialize(data: any, type: string, format: string): any { + if (data == undefined) { + return data; + } else if (primitives.indexOf(type.toLowerCase()) !== -1) { + return data; + } else if (type.endsWith(nullableSuffix)) { + let subType: string = type.slice(0, -nullableSuffix.length); // Type | null => Type + return ObjectSerializer.serialize(data, subType, format); + } else if (type.endsWith(optionalSuffix)) { + let subType: string = type.slice(0, -optionalSuffix.length); // Type | undefined => Type + return ObjectSerializer.serialize(data, subType, format); + } else if (type.startsWith(arrayPrefix)) { + let subType: string = type.slice(arrayPrefix.length, -arraySuffix.length); // Array => Type + let transformedData: any[] = []; + for (let date of data) { + transformedData.push(ObjectSerializer.serialize(date, subType, format)); + } + return transformedData; + } else if (type.startsWith(mapPrefix)) { + let subType: string = type.slice(mapPrefix.length, -mapSuffix.length); // { [key: string]: Type; } => Type + let transformedData: { [key: string]: any } = {}; + for (let key in data) { + transformedData[key] = ObjectSerializer.serialize( + data[key], + subType, + format, + ); + } + return transformedData; + } else if (type === "Date") { + if (format == "date") { + let month = data.getMonth()+1 + month = month < 10 ? "0" + month.toString() : month.toString() + let day = data.getDate(); + day = day < 10 ? "0" + day.toString() : day.toString(); + + return data.getFullYear() + "-" + month + "-" + day; + } else { + return data.toISOString(); + } + } else { + if (enumsMap.has(type)) { + return data; + } + if (!typeMap[type]) { // in case we dont know the type + return data; + } + + // Get the actual type of this object + type = this.findCorrectType(data, type); + + // get the map for the correct type. + let attributeTypes = typeMap[type].getAttributeTypeMap(); + let instance: {[index: string]: any} = {}; + for (let attributeType of attributeTypes) { + instance[attributeType.baseName] = ObjectSerializer.serialize(data[attributeType.name], attributeType.type, attributeType.format); + } + return instance; + } + } + + public static deserialize(data: any, type: string, format: string): any { + // polymorphism may change the actual type. + type = ObjectSerializer.findCorrectType(data, type); + if (data == undefined) { + return data; + } else if (primitives.indexOf(type.toLowerCase()) !== -1) { + return data; + } else if (type.endsWith(nullableSuffix)) { + let subType: string = type.slice(0, -nullableSuffix.length); // Type | null => Type + return ObjectSerializer.deserialize(data, subType, format); + } else if (type.endsWith(optionalSuffix)) { + let subType: string = type.slice(0, -optionalSuffix.length); // Type | undefined => Type + return ObjectSerializer.deserialize(data, subType, format); + } else if (type.startsWith(arrayPrefix)) { + let subType: string = type.slice(arrayPrefix.length, -arraySuffix.length); // Array => Type + let transformedData: any[] = []; + for (let date of data) { + transformedData.push(ObjectSerializer.deserialize(date, subType, format)); + } + return transformedData; + } else if (type.startsWith(mapPrefix)) { + let subType: string = type.slice(mapPrefix.length, -mapSuffix.length); // { [key: string]: Type; } => Type + let transformedData: { [key: string]: any } = {}; + for (let key in data) { + transformedData[key] = ObjectSerializer.deserialize( + data[key], + subType, + format, + ); + } + return transformedData; + } else if (type === "Date") { + return new Date(data); + } else { + if (enumsMap.has(type)) {// is Enum + return data; + } + + if (!typeMap[type]) { // dont know the type + return data; + } + let instance = new typeMap[type](); + let attributeTypes = typeMap[type].getAttributeTypeMap(); + for (let attributeType of attributeTypes) { + let value = ObjectSerializer.deserialize(data[attributeType.baseName], attributeType.type, attributeType.format); + if (value !== undefined) { + instance[attributeType.name] = value; + } + } + return instance; + } + } + + + /** + * Normalize media type + * + * We currently do not handle any media types attributes, i.e. anything + * after a semicolon. All content is assumed to be UTF-8 compatible. + */ + public static normalizeMediaType(mediaType: string | undefined): string | undefined { + if (mediaType === undefined) { + return undefined; + } + return mediaType.split(";")[0].trim().toLowerCase(); + } + + /** + * From a list of possible media types, choose the one we can handle best. + * + * The order of the given media types does not have any impact on the choice + * made. + */ + public static getPreferredMediaType(mediaTypes: Array): string { + /** According to OAS 3 we should default to json */ + if (mediaTypes.length === 0) { + return "application/json"; + } + + const normalMediaTypes = mediaTypes.map(this.normalizeMediaType); + + for (const predicate of supportedMimeTypePredicatesWithPriority) { + for (const mediaType of normalMediaTypes) { + if (mediaType != null && predicate(mediaType)) { + return mediaType; + } + } + } + + throw new Error("None of the given media types are supported: " + mediaTypes.join(", ")); + } + + /** + * Convert data to a string according the given media type + */ + public static stringify(data: any, mediaType: string): string { + if (isTextLikeMimeType(mediaType)) { + return String(data); + } + + if (isJsonLikeMimeType(mediaType)) { + return JSON.stringify(data); + } + + throw new Error("The mediaType " + mediaType + " is not supported by ObjectSerializer.stringify."); + } + + /** + * Parse data from a string according to the given media type + */ + public static parse(rawData: string, mediaType: string | undefined) { + if (mediaType === undefined) { + throw new Error("Cannot parse content. No Content-Type defined."); + } + + if (isTextLikeMimeType(mediaType)) { + return rawData; + } + + if (isJsonLikeMimeType(mediaType)) { + return JSON.parse(rawData); + } + + throw new Error("The mediaType " + mediaType + " is not supported by ObjectSerializer.parse."); + } +} diff --git a/samples/client/others/typescript/encode-decode/build/models/all.ts b/samples/client/others/typescript/encode-decode/build/models/all.ts new file mode 100644 index 000000000000..bcc447e6f4bf --- /dev/null +++ b/samples/client/others/typescript/encode-decode/build/models/all.ts @@ -0,0 +1,2 @@ +export * from '../models/ComplexObject' +export * from '../models/CompositeObject' diff --git a/samples/client/others/typescript/encode-decode/build/package.json b/samples/client/others/typescript/encode-decode/build/package.json new file mode 100644 index 000000000000..98e27af43f34 --- /dev/null +++ b/samples/client/others/typescript/encode-decode/build/package.json @@ -0,0 +1,45 @@ +{ + "name": "@openapitools/typescript-encode-decode", + "version": "1.0.0", + "description": "OpenAPI client for @openapitools/typescript-encode-decode", + "author": "OpenAPI-Generator Contributors", + "repository": { + "type": "git", + "url": "https://github.com/GIT_USER_ID/GIT_REPO_ID.git" + }, + "keywords": [ + "fetch", + "typescript", + "openapi-client", + "openapi-generator" + ], + "license": "Unlicense", + "main": "./dist/index.js", + "type": "commonjs", + "exports": { + ".": { + "require": "./dist/index.js", + "types": "./dist/index.d.js" + } + }, + "files": [ + "dist" + ], + "typings": "./dist/index.d.ts", + "scripts": { + "build": "tsc", + "prepare": "npm run build" + }, + "dependencies": { + "node-fetch": "^2.6.0", + "@types/node-fetch": "^2.5.7", + "@types/node": "*", + "form-data": "^2.5.0", + "es6-promise": "^4.2.4", + "url-parse": "^1.4.3" + }, + "devDependencies": { + "typescript": "^4.0", + "@types/url-parse": "1.4.4" + } +} diff --git a/samples/client/others/typescript/encode-decode/build/rxjsStub.ts b/samples/client/others/typescript/encode-decode/build/rxjsStub.ts new file mode 100644 index 000000000000..4c73715a2486 --- /dev/null +++ b/samples/client/others/typescript/encode-decode/build/rxjsStub.ts @@ -0,0 +1,27 @@ +export class Observable { + constructor(private promise: Promise) {} + + toPromise() { + return this.promise; + } + + pipe(callback: (value: T) => S | Promise): Observable { + return new Observable(this.promise.then(callback)); + } +} + +export function from(promise: Promise) { + return new Observable(promise); +} + +export function of(value: T) { + return new Observable(Promise.resolve(value)); +} + +export function mergeMap(callback: (value: T) => Observable) { + return (value: T) => callback(value).toPromise(); +} + +export function map(callback: any) { + return callback; +} diff --git a/samples/client/others/typescript/encode-decode/build/servers.ts b/samples/client/others/typescript/encode-decode/build/servers.ts new file mode 100644 index 000000000000..df71beba9b7d --- /dev/null +++ b/samples/client/others/typescript/encode-decode/build/servers.ts @@ -0,0 +1,55 @@ +import { RequestContext, HttpMethod } from "./http/http"; + +export interface BaseServerConfiguration { + makeRequestContext(endpoint: string, httpMethod: HttpMethod): RequestContext; +} + +/** + * + * Represents the configuration of a server including its + * url template and variable configuration based on the url. + * + */ +export class ServerConfiguration implements BaseServerConfiguration { + public constructor(private url: string, private variableConfiguration: T) {} + + /** + * Sets the value of the variables of this server. Variables are included in + * the `url` of this ServerConfiguration in the form `{variableName}` + * + * @param variableConfiguration a partial variable configuration for the + * variables contained in the url + */ + public setVariables(variableConfiguration: Partial) { + Object.assign(this.variableConfiguration, variableConfiguration); + } + + public getConfiguration(): T { + return this.variableConfiguration + } + + private getUrl() { + let replacedUrl = this.url; + for (const key in this.variableConfiguration) { + var re = new RegExp("{" + key + "}","g"); + replacedUrl = replacedUrl.replace(re, this.variableConfiguration[key]); + } + return replacedUrl + } + + /** + * Creates a new request context for this server using the url with variables + * replaced with their respective values and the endpoint of the request appended. + * + * @param endpoint the endpoint to be queried on the server + * @param httpMethod httpMethod to be used + * + */ + public makeRequestContext(endpoint: string, httpMethod: HttpMethod): RequestContext { + return new RequestContext(this.getUrl() + endpoint, httpMethod); + } +} + +export const server1 = new ServerConfiguration<{ }>("", { }) + +export const servers = [server1]; diff --git a/samples/client/others/typescript/encode-decode/build/tsconfig.json b/samples/client/others/typescript/encode-decode/build/tsconfig.json new file mode 100644 index 000000000000..4a8d5cb2f334 --- /dev/null +++ b/samples/client/others/typescript/encode-decode/build/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "strict": true, + /* Basic Options */ + "target": "es5", + "moduleResolution": "node", + "declaration": true, + + /* Additional Checks */ + "noUnusedLocals": false, /* Report errors on unused locals. */ // TODO: reenable (unused imports!) + "noUnusedParameters": false, /* Report errors on unused parameters. */ // TODO: set to true again + "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + + "removeComments": true, + "sourceMap": true, + "outDir": "./dist", + "noLib": false, + "lib": [ "es6" ], + }, + "exclude": [ + "dist", + "node_modules" + ], + "filesGlob": [ + "./**/*.ts", + ] +} diff --git a/samples/client/others/typescript/encode-decode/build/types/ObjectParamAPI.ts b/samples/client/others/typescript/encode-decode/build/types/ObjectParamAPI.ts new file mode 100644 index 000000000000..c307698325b1 --- /dev/null +++ b/samples/client/others/typescript/encode-decode/build/types/ObjectParamAPI.ts @@ -0,0 +1,657 @@ +import { ResponseContext, RequestContext, HttpFile, HttpInfo } from '../http/http'; +import { Configuration} from '../configuration' + +import { ComplexObject } from '../models/ComplexObject'; +import { CompositeObject } from '../models/CompositeObject'; + +import { ObservableDefaultApi } from "./ObservableAPI"; +import { DefaultApiRequestFactory, DefaultApiResponseProcessor} from "../apis/DefaultApi"; + +export interface DefaultApiTestDecodeArrayOfArraysGetRequest { +} + +export interface DefaultApiTestDecodeArrayOfGetRequest { +} + +export interface DefaultApiTestDecodeArrayOfMapsOfObjectsGetRequest { +} + +export interface DefaultApiTestDecodeArrayOfNullableGetRequest { +} + +export interface DefaultApiTestDecodeArrayOfNullableObjectsGetRequest { +} + +export interface DefaultApiTestDecodeCompositeObjectsGetRequest { +} + +export interface DefaultApiTestDecodeMapOfMapsOfObjectsGetRequest { +} + +export interface DefaultApiTestDecodeMapOfObjectsGetRequest { +} + +export interface DefaultApiTestDecodeMapOfPrimitiveGetRequest { +} + +export interface DefaultApiTestDecodeNullableArrayGetRequest { +} + +export interface DefaultApiTestDecodeNullableGetRequest { +} + +export interface DefaultApiTestDecodeObjectGetRequest { +} + +export interface DefaultApiTestDecodePrimitiveBooleanGetRequest { +} + +export interface DefaultApiTestDecodePrimitiveIntegerGetRequest { +} + +export interface DefaultApiTestDecodePrimitiveNumberGetRequest { +} + +export interface DefaultApiTestDecodePrimitiveStringGetRequest { +} + +export interface DefaultApiTestEncodeArrayOfArraysPostRequest { + /** + * + * @type Array<Array<string>> + * @memberof DefaultApitestEncodeArrayOfArraysPost + */ + requestBody: Array> +} + +export interface DefaultApiTestEncodeArrayOfMapsOfObjectsPostRequest { + /** + * + * @type Array<{ [key: string]: ComplexObject; }> + * @memberof DefaultApitestEncodeArrayOfMapsOfObjectsPost + */ + complexObject: Array<{ [key: string]: ComplexObject; }> +} + +export interface DefaultApiTestEncodeArrayOfNullableObjectsPostRequest { + /** + * + * @type Array<ComplexObject> + * @memberof DefaultApitestEncodeArrayOfNullableObjectsPost + */ + complexObject: Array +} + +export interface DefaultApiTestEncodeArrayOfNullablePostRequest { + /** + * + * @type Array<string | null> + * @memberof DefaultApitestEncodeArrayOfNullablePost + */ + requestBody: Array +} + +export interface DefaultApiTestEncodeArrayOfPostRequest { + /** + * + * @type Array<string> + * @memberof DefaultApitestEncodeArrayOfPost + */ + requestBody: Array +} + +export interface DefaultApiTestEncodeCompositeObjectsPostRequest { + /** + * + * @type CompositeObject + * @memberof DefaultApitestEncodeCompositeObjectsPost + */ + compositeObject: CompositeObject +} + +export interface DefaultApiTestEncodeMapOfMapsOfObjectsPostRequest { + /** + * + * @type { [key: string]: { [key: string]: ComplexObject; }; } + * @memberof DefaultApitestEncodeMapOfMapsOfObjectsPost + */ + requestBody: { [key: string]: { [key: string]: ComplexObject; }; } +} + +export interface DefaultApiTestEncodeMapOfObjectsPostRequest { + /** + * + * @type { [key: string]: ComplexObject | null; } + * @memberof DefaultApitestEncodeMapOfObjectsPost + */ + requestBody: { [key: string]: ComplexObject | null; } +} + +export interface DefaultApiTestEncodeMapOfPrimitivePostRequest { + /** + * + * @type { [key: string]: string; } + * @memberof DefaultApitestEncodeMapOfPrimitivePost + */ + requestBody: { [key: string]: string; } +} + +export interface DefaultApiTestEncodeNullableArrayPostRequest { + /** + * + * @type Array<string> + * @memberof DefaultApitestEncodeNullableArrayPost + */ + requestBody?: Array +} + +export interface DefaultApiTestEncodeNullablePostRequest { + /** + * + * @type string + * @memberof DefaultApitestEncodeNullablePost + */ + body?: string +} + +export interface DefaultApiTestEncodeObjectPostRequest { + /** + * + * @type ComplexObject + * @memberof DefaultApitestEncodeObjectPost + */ + complexObject: ComplexObject +} + +export interface DefaultApiTestEncodePrimitiveBooleanPostRequest { + /** + * + * @type boolean + * @memberof DefaultApitestEncodePrimitiveBooleanPost + */ + body: boolean +} + +export interface DefaultApiTestEncodePrimitiveIntegerPostRequest { + /** + * + * @type number + * @memberof DefaultApitestEncodePrimitiveIntegerPost + */ + body: number +} + +export interface DefaultApiTestEncodePrimitiveNumberPostRequest { + /** + * + * @type number + * @memberof DefaultApitestEncodePrimitiveNumberPost + */ + body: number +} + +export interface DefaultApiTestEncodePrimitiveStringPostRequest { + /** + * + * @type string + * @memberof DefaultApitestEncodePrimitiveStringPost + */ + body: string +} + +export class ObjectDefaultApi { + private api: ObservableDefaultApi + + public constructor(configuration: Configuration, requestFactory?: DefaultApiRequestFactory, responseProcessor?: DefaultApiResponseProcessor) { + this.api = new ObservableDefaultApi(configuration, requestFactory, responseProcessor); + } + + /** + * @param param the request object + */ + public testDecodeArrayOfArraysGetWithHttpInfo(param: DefaultApiTestDecodeArrayOfArraysGetRequest = {}, options?: Configuration): Promise>>> { + return this.api.testDecodeArrayOfArraysGetWithHttpInfo( options).toPromise(); + } + + /** + * @param param the request object + */ + public testDecodeArrayOfArraysGet(param: DefaultApiTestDecodeArrayOfArraysGetRequest = {}, options?: Configuration): Promise>> { + return this.api.testDecodeArrayOfArraysGet( options).toPromise(); + } + + /** + * @param param the request object + */ + public testDecodeArrayOfGetWithHttpInfo(param: DefaultApiTestDecodeArrayOfGetRequest = {}, options?: Configuration): Promise>> { + return this.api.testDecodeArrayOfGetWithHttpInfo( options).toPromise(); + } + + /** + * @param param the request object + */ + public testDecodeArrayOfGet(param: DefaultApiTestDecodeArrayOfGetRequest = {}, options?: Configuration): Promise> { + return this.api.testDecodeArrayOfGet( options).toPromise(); + } + + /** + * @param param the request object + */ + public testDecodeArrayOfMapsOfObjectsGetWithHttpInfo(param: DefaultApiTestDecodeArrayOfMapsOfObjectsGetRequest = {}, options?: Configuration): Promise>> { + return this.api.testDecodeArrayOfMapsOfObjectsGetWithHttpInfo( options).toPromise(); + } + + /** + * @param param the request object + */ + public testDecodeArrayOfMapsOfObjectsGet(param: DefaultApiTestDecodeArrayOfMapsOfObjectsGetRequest = {}, options?: Configuration): Promise> { + return this.api.testDecodeArrayOfMapsOfObjectsGet( options).toPromise(); + } + + /** + * @param param the request object + */ + public testDecodeArrayOfNullableGetWithHttpInfo(param: DefaultApiTestDecodeArrayOfNullableGetRequest = {}, options?: Configuration): Promise>> { + return this.api.testDecodeArrayOfNullableGetWithHttpInfo( options).toPromise(); + } + + /** + * @param param the request object + */ + public testDecodeArrayOfNullableGet(param: DefaultApiTestDecodeArrayOfNullableGetRequest = {}, options?: Configuration): Promise> { + return this.api.testDecodeArrayOfNullableGet( options).toPromise(); + } + + /** + * @param param the request object + */ + public testDecodeArrayOfNullableObjectsGetWithHttpInfo(param: DefaultApiTestDecodeArrayOfNullableObjectsGetRequest = {}, options?: Configuration): Promise>> { + return this.api.testDecodeArrayOfNullableObjectsGetWithHttpInfo( options).toPromise(); + } + + /** + * @param param the request object + */ + public testDecodeArrayOfNullableObjectsGet(param: DefaultApiTestDecodeArrayOfNullableObjectsGetRequest = {}, options?: Configuration): Promise> { + return this.api.testDecodeArrayOfNullableObjectsGet( options).toPromise(); + } + + /** + * @param param the request object + */ + public testDecodeCompositeObjectsGetWithHttpInfo(param: DefaultApiTestDecodeCompositeObjectsGetRequest = {}, options?: Configuration): Promise> { + return this.api.testDecodeCompositeObjectsGetWithHttpInfo( options).toPromise(); + } + + /** + * @param param the request object + */ + public testDecodeCompositeObjectsGet(param: DefaultApiTestDecodeCompositeObjectsGetRequest = {}, options?: Configuration): Promise { + return this.api.testDecodeCompositeObjectsGet( options).toPromise(); + } + + /** + * @param param the request object + */ + public testDecodeMapOfMapsOfObjectsGetWithHttpInfo(param: DefaultApiTestDecodeMapOfMapsOfObjectsGetRequest = {}, options?: Configuration): Promise> { + return this.api.testDecodeMapOfMapsOfObjectsGetWithHttpInfo( options).toPromise(); + } + + /** + * @param param the request object + */ + public testDecodeMapOfMapsOfObjectsGet(param: DefaultApiTestDecodeMapOfMapsOfObjectsGetRequest = {}, options?: Configuration): Promise<{ [key: string]: { [key: string]: ComplexObject; }; }> { + return this.api.testDecodeMapOfMapsOfObjectsGet( options).toPromise(); + } + + /** + * @param param the request object + */ + public testDecodeMapOfObjectsGetWithHttpInfo(param: DefaultApiTestDecodeMapOfObjectsGetRequest = {}, options?: Configuration): Promise> { + return this.api.testDecodeMapOfObjectsGetWithHttpInfo( options).toPromise(); + } + + /** + * @param param the request object + */ + public testDecodeMapOfObjectsGet(param: DefaultApiTestDecodeMapOfObjectsGetRequest = {}, options?: Configuration): Promise<{ [key: string]: ComplexObject | null; }> { + return this.api.testDecodeMapOfObjectsGet( options).toPromise(); + } + + /** + * @param param the request object + */ + public testDecodeMapOfPrimitiveGetWithHttpInfo(param: DefaultApiTestDecodeMapOfPrimitiveGetRequest = {}, options?: Configuration): Promise> { + return this.api.testDecodeMapOfPrimitiveGetWithHttpInfo( options).toPromise(); + } + + /** + * @param param the request object + */ + public testDecodeMapOfPrimitiveGet(param: DefaultApiTestDecodeMapOfPrimitiveGetRequest = {}, options?: Configuration): Promise<{ [key: string]: string; }> { + return this.api.testDecodeMapOfPrimitiveGet( options).toPromise(); + } + + /** + * @param param the request object + */ + public testDecodeNullableArrayGetWithHttpInfo(param: DefaultApiTestDecodeNullableArrayGetRequest = {}, options?: Configuration): Promise>> { + return this.api.testDecodeNullableArrayGetWithHttpInfo( options).toPromise(); + } + + /** + * @param param the request object + */ + public testDecodeNullableArrayGet(param: DefaultApiTestDecodeNullableArrayGetRequest = {}, options?: Configuration): Promise> { + return this.api.testDecodeNullableArrayGet( options).toPromise(); + } + + /** + * @param param the request object + */ + public testDecodeNullableGetWithHttpInfo(param: DefaultApiTestDecodeNullableGetRequest = {}, options?: Configuration): Promise> { + return this.api.testDecodeNullableGetWithHttpInfo( options).toPromise(); + } + + /** + * @param param the request object + */ + public testDecodeNullableGet(param: DefaultApiTestDecodeNullableGetRequest = {}, options?: Configuration): Promise { + return this.api.testDecodeNullableGet( options).toPromise(); + } + + /** + * @param param the request object + */ + public testDecodeObjectGetWithHttpInfo(param: DefaultApiTestDecodeObjectGetRequest = {}, options?: Configuration): Promise> { + return this.api.testDecodeObjectGetWithHttpInfo( options).toPromise(); + } + + /** + * @param param the request object + */ + public testDecodeObjectGet(param: DefaultApiTestDecodeObjectGetRequest = {}, options?: Configuration): Promise { + return this.api.testDecodeObjectGet( options).toPromise(); + } + + /** + * @param param the request object + */ + public testDecodePrimitiveBooleanGetWithHttpInfo(param: DefaultApiTestDecodePrimitiveBooleanGetRequest = {}, options?: Configuration): Promise> { + return this.api.testDecodePrimitiveBooleanGetWithHttpInfo( options).toPromise(); + } + + /** + * @param param the request object + */ + public testDecodePrimitiveBooleanGet(param: DefaultApiTestDecodePrimitiveBooleanGetRequest = {}, options?: Configuration): Promise { + return this.api.testDecodePrimitiveBooleanGet( options).toPromise(); + } + + /** + * @param param the request object + */ + public testDecodePrimitiveIntegerGetWithHttpInfo(param: DefaultApiTestDecodePrimitiveIntegerGetRequest = {}, options?: Configuration): Promise> { + return this.api.testDecodePrimitiveIntegerGetWithHttpInfo( options).toPromise(); + } + + /** + * @param param the request object + */ + public testDecodePrimitiveIntegerGet(param: DefaultApiTestDecodePrimitiveIntegerGetRequest = {}, options?: Configuration): Promise { + return this.api.testDecodePrimitiveIntegerGet( options).toPromise(); + } + + /** + * @param param the request object + */ + public testDecodePrimitiveNumberGetWithHttpInfo(param: DefaultApiTestDecodePrimitiveNumberGetRequest = {}, options?: Configuration): Promise> { + return this.api.testDecodePrimitiveNumberGetWithHttpInfo( options).toPromise(); + } + + /** + * @param param the request object + */ + public testDecodePrimitiveNumberGet(param: DefaultApiTestDecodePrimitiveNumberGetRequest = {}, options?: Configuration): Promise { + return this.api.testDecodePrimitiveNumberGet( options).toPromise(); + } + + /** + * @param param the request object + */ + public testDecodePrimitiveStringGetWithHttpInfo(param: DefaultApiTestDecodePrimitiveStringGetRequest = {}, options?: Configuration): Promise> { + return this.api.testDecodePrimitiveStringGetWithHttpInfo( options).toPromise(); + } + + /** + * @param param the request object + */ + public testDecodePrimitiveStringGet(param: DefaultApiTestDecodePrimitiveStringGetRequest = {}, options?: Configuration): Promise { + return this.api.testDecodePrimitiveStringGet( options).toPromise(); + } + + /** + * @param param the request object + */ + public testEncodeArrayOfArraysPostWithHttpInfo(param: DefaultApiTestEncodeArrayOfArraysPostRequest, options?: Configuration): Promise> { + return this.api.testEncodeArrayOfArraysPostWithHttpInfo(param.requestBody, options).toPromise(); + } + + /** + * @param param the request object + */ + public testEncodeArrayOfArraysPost(param: DefaultApiTestEncodeArrayOfArraysPostRequest, options?: Configuration): Promise { + return this.api.testEncodeArrayOfArraysPost(param.requestBody, options).toPromise(); + } + + /** + * @param param the request object + */ + public testEncodeArrayOfMapsOfObjectsPostWithHttpInfo(param: DefaultApiTestEncodeArrayOfMapsOfObjectsPostRequest, options?: Configuration): Promise> { + return this.api.testEncodeArrayOfMapsOfObjectsPostWithHttpInfo(param.complexObject, options).toPromise(); + } + + /** + * @param param the request object + */ + public testEncodeArrayOfMapsOfObjectsPost(param: DefaultApiTestEncodeArrayOfMapsOfObjectsPostRequest, options?: Configuration): Promise { + return this.api.testEncodeArrayOfMapsOfObjectsPost(param.complexObject, options).toPromise(); + } + + /** + * @param param the request object + */ + public testEncodeArrayOfNullableObjectsPostWithHttpInfo(param: DefaultApiTestEncodeArrayOfNullableObjectsPostRequest, options?: Configuration): Promise> { + return this.api.testEncodeArrayOfNullableObjectsPostWithHttpInfo(param.complexObject, options).toPromise(); + } + + /** + * @param param the request object + */ + public testEncodeArrayOfNullableObjectsPost(param: DefaultApiTestEncodeArrayOfNullableObjectsPostRequest, options?: Configuration): Promise { + return this.api.testEncodeArrayOfNullableObjectsPost(param.complexObject, options).toPromise(); + } + + /** + * @param param the request object + */ + public testEncodeArrayOfNullablePostWithHttpInfo(param: DefaultApiTestEncodeArrayOfNullablePostRequest, options?: Configuration): Promise> { + return this.api.testEncodeArrayOfNullablePostWithHttpInfo(param.requestBody, options).toPromise(); + } + + /** + * @param param the request object + */ + public testEncodeArrayOfNullablePost(param: DefaultApiTestEncodeArrayOfNullablePostRequest, options?: Configuration): Promise { + return this.api.testEncodeArrayOfNullablePost(param.requestBody, options).toPromise(); + } + + /** + * @param param the request object + */ + public testEncodeArrayOfPostWithHttpInfo(param: DefaultApiTestEncodeArrayOfPostRequest, options?: Configuration): Promise> { + return this.api.testEncodeArrayOfPostWithHttpInfo(param.requestBody, options).toPromise(); + } + + /** + * @param param the request object + */ + public testEncodeArrayOfPost(param: DefaultApiTestEncodeArrayOfPostRequest, options?: Configuration): Promise { + return this.api.testEncodeArrayOfPost(param.requestBody, options).toPromise(); + } + + /** + * @param param the request object + */ + public testEncodeCompositeObjectsPostWithHttpInfo(param: DefaultApiTestEncodeCompositeObjectsPostRequest, options?: Configuration): Promise> { + return this.api.testEncodeCompositeObjectsPostWithHttpInfo(param.compositeObject, options).toPromise(); + } + + /** + * @param param the request object + */ + public testEncodeCompositeObjectsPost(param: DefaultApiTestEncodeCompositeObjectsPostRequest, options?: Configuration): Promise { + return this.api.testEncodeCompositeObjectsPost(param.compositeObject, options).toPromise(); + } + + /** + * @param param the request object + */ + public testEncodeMapOfMapsOfObjectsPostWithHttpInfo(param: DefaultApiTestEncodeMapOfMapsOfObjectsPostRequest, options?: Configuration): Promise> { + return this.api.testEncodeMapOfMapsOfObjectsPostWithHttpInfo(param.requestBody, options).toPromise(); + } + + /** + * @param param the request object + */ + public testEncodeMapOfMapsOfObjectsPost(param: DefaultApiTestEncodeMapOfMapsOfObjectsPostRequest, options?: Configuration): Promise { + return this.api.testEncodeMapOfMapsOfObjectsPost(param.requestBody, options).toPromise(); + } + + /** + * @param param the request object + */ + public testEncodeMapOfObjectsPostWithHttpInfo(param: DefaultApiTestEncodeMapOfObjectsPostRequest, options?: Configuration): Promise> { + return this.api.testEncodeMapOfObjectsPostWithHttpInfo(param.requestBody, options).toPromise(); + } + + /** + * @param param the request object + */ + public testEncodeMapOfObjectsPost(param: DefaultApiTestEncodeMapOfObjectsPostRequest, options?: Configuration): Promise { + return this.api.testEncodeMapOfObjectsPost(param.requestBody, options).toPromise(); + } + + /** + * @param param the request object + */ + public testEncodeMapOfPrimitivePostWithHttpInfo(param: DefaultApiTestEncodeMapOfPrimitivePostRequest, options?: Configuration): Promise> { + return this.api.testEncodeMapOfPrimitivePostWithHttpInfo(param.requestBody, options).toPromise(); + } + + /** + * @param param the request object + */ + public testEncodeMapOfPrimitivePost(param: DefaultApiTestEncodeMapOfPrimitivePostRequest, options?: Configuration): Promise { + return this.api.testEncodeMapOfPrimitivePost(param.requestBody, options).toPromise(); + } + + /** + * @param param the request object + */ + public testEncodeNullableArrayPostWithHttpInfo(param: DefaultApiTestEncodeNullableArrayPostRequest = {}, options?: Configuration): Promise> { + return this.api.testEncodeNullableArrayPostWithHttpInfo(param.requestBody, options).toPromise(); + } + + /** + * @param param the request object + */ + public testEncodeNullableArrayPost(param: DefaultApiTestEncodeNullableArrayPostRequest = {}, options?: Configuration): Promise { + return this.api.testEncodeNullableArrayPost(param.requestBody, options).toPromise(); + } + + /** + * @param param the request object + */ + public testEncodeNullablePostWithHttpInfo(param: DefaultApiTestEncodeNullablePostRequest = {}, options?: Configuration): Promise> { + return this.api.testEncodeNullablePostWithHttpInfo(param.body, options).toPromise(); + } + + /** + * @param param the request object + */ + public testEncodeNullablePost(param: DefaultApiTestEncodeNullablePostRequest = {}, options?: Configuration): Promise { + return this.api.testEncodeNullablePost(param.body, options).toPromise(); + } + + /** + * @param param the request object + */ + public testEncodeObjectPostWithHttpInfo(param: DefaultApiTestEncodeObjectPostRequest, options?: Configuration): Promise> { + return this.api.testEncodeObjectPostWithHttpInfo(param.complexObject, options).toPromise(); + } + + /** + * @param param the request object + */ + public testEncodeObjectPost(param: DefaultApiTestEncodeObjectPostRequest, options?: Configuration): Promise { + return this.api.testEncodeObjectPost(param.complexObject, options).toPromise(); + } + + /** + * @param param the request object + */ + public testEncodePrimitiveBooleanPostWithHttpInfo(param: DefaultApiTestEncodePrimitiveBooleanPostRequest, options?: Configuration): Promise> { + return this.api.testEncodePrimitiveBooleanPostWithHttpInfo(param.body, options).toPromise(); + } + + /** + * @param param the request object + */ + public testEncodePrimitiveBooleanPost(param: DefaultApiTestEncodePrimitiveBooleanPostRequest, options?: Configuration): Promise { + return this.api.testEncodePrimitiveBooleanPost(param.body, options).toPromise(); + } + + /** + * @param param the request object + */ + public testEncodePrimitiveIntegerPostWithHttpInfo(param: DefaultApiTestEncodePrimitiveIntegerPostRequest, options?: Configuration): Promise> { + return this.api.testEncodePrimitiveIntegerPostWithHttpInfo(param.body, options).toPromise(); + } + + /** + * @param param the request object + */ + public testEncodePrimitiveIntegerPost(param: DefaultApiTestEncodePrimitiveIntegerPostRequest, options?: Configuration): Promise { + return this.api.testEncodePrimitiveIntegerPost(param.body, options).toPromise(); + } + + /** + * @param param the request object + */ + public testEncodePrimitiveNumberPostWithHttpInfo(param: DefaultApiTestEncodePrimitiveNumberPostRequest, options?: Configuration): Promise> { + return this.api.testEncodePrimitiveNumberPostWithHttpInfo(param.body, options).toPromise(); + } + + /** + * @param param the request object + */ + public testEncodePrimitiveNumberPost(param: DefaultApiTestEncodePrimitiveNumberPostRequest, options?: Configuration): Promise { + return this.api.testEncodePrimitiveNumberPost(param.body, options).toPromise(); + } + + /** + * @param param the request object + */ + public testEncodePrimitiveStringPostWithHttpInfo(param: DefaultApiTestEncodePrimitiveStringPostRequest, options?: Configuration): Promise> { + return this.api.testEncodePrimitiveStringPostWithHttpInfo(param.body, options).toPromise(); + } + + /** + * @param param the request object + */ + public testEncodePrimitiveStringPost(param: DefaultApiTestEncodePrimitiveStringPostRequest, options?: Configuration): Promise { + return this.api.testEncodePrimitiveStringPost(param.body, options).toPromise(); + } + +} diff --git a/samples/client/others/typescript/encode-decode/build/types/ObservableAPI.ts b/samples/client/others/typescript/encode-decode/build/types/ObservableAPI.ts new file mode 100644 index 000000000000..3b4bc6b4c733 --- /dev/null +++ b/samples/client/others/typescript/encode-decode/build/types/ObservableAPI.ts @@ -0,0 +1,920 @@ +import { ResponseContext, RequestContext, HttpFile, HttpInfo } from '../http/http'; +import { Configuration} from '../configuration' +import { Observable, of, from } from '../rxjsStub'; +import {mergeMap, map} from '../rxjsStub'; +import { ComplexObject } from '../models/ComplexObject'; +import { CompositeObject } from '../models/CompositeObject'; + +import { DefaultApiRequestFactory, DefaultApiResponseProcessor} from "../apis/DefaultApi"; +export class ObservableDefaultApi { + private requestFactory: DefaultApiRequestFactory; + private responseProcessor: DefaultApiResponseProcessor; + private configuration: Configuration; + + public constructor( + configuration: Configuration, + requestFactory?: DefaultApiRequestFactory, + responseProcessor?: DefaultApiResponseProcessor + ) { + this.configuration = configuration; + this.requestFactory = requestFactory || new DefaultApiRequestFactory(configuration); + this.responseProcessor = responseProcessor || new DefaultApiResponseProcessor(); + } + + /** + */ + public testDecodeArrayOfArraysGetWithHttpInfo(_options?: Configuration): Observable>>> { + const requestContextPromise = this.requestFactory.testDecodeArrayOfArraysGet(_options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (const middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (const middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.testDecodeArrayOfArraysGetWithHttpInfo(rsp))); + })); + } + + /** + */ + public testDecodeArrayOfArraysGet(_options?: Configuration): Observable>> { + return this.testDecodeArrayOfArraysGetWithHttpInfo(_options).pipe(map((apiResponse: HttpInfo>>) => apiResponse.data)); + } + + /** + */ + public testDecodeArrayOfGetWithHttpInfo(_options?: Configuration): Observable>> { + const requestContextPromise = this.requestFactory.testDecodeArrayOfGet(_options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (const middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (const middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.testDecodeArrayOfGetWithHttpInfo(rsp))); + })); + } + + /** + */ + public testDecodeArrayOfGet(_options?: Configuration): Observable> { + return this.testDecodeArrayOfGetWithHttpInfo(_options).pipe(map((apiResponse: HttpInfo>) => apiResponse.data)); + } + + /** + */ + public testDecodeArrayOfMapsOfObjectsGetWithHttpInfo(_options?: Configuration): Observable>> { + const requestContextPromise = this.requestFactory.testDecodeArrayOfMapsOfObjectsGet(_options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (const middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (const middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.testDecodeArrayOfMapsOfObjectsGetWithHttpInfo(rsp))); + })); + } + + /** + */ + public testDecodeArrayOfMapsOfObjectsGet(_options?: Configuration): Observable> { + return this.testDecodeArrayOfMapsOfObjectsGetWithHttpInfo(_options).pipe(map((apiResponse: HttpInfo>) => apiResponse.data)); + } + + /** + */ + public testDecodeArrayOfNullableGetWithHttpInfo(_options?: Configuration): Observable>> { + const requestContextPromise = this.requestFactory.testDecodeArrayOfNullableGet(_options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (const middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (const middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.testDecodeArrayOfNullableGetWithHttpInfo(rsp))); + })); + } + + /** + */ + public testDecodeArrayOfNullableGet(_options?: Configuration): Observable> { + return this.testDecodeArrayOfNullableGetWithHttpInfo(_options).pipe(map((apiResponse: HttpInfo>) => apiResponse.data)); + } + + /** + */ + public testDecodeArrayOfNullableObjectsGetWithHttpInfo(_options?: Configuration): Observable>> { + const requestContextPromise = this.requestFactory.testDecodeArrayOfNullableObjectsGet(_options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (const middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (const middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.testDecodeArrayOfNullableObjectsGetWithHttpInfo(rsp))); + })); + } + + /** + */ + public testDecodeArrayOfNullableObjectsGet(_options?: Configuration): Observable> { + return this.testDecodeArrayOfNullableObjectsGetWithHttpInfo(_options).pipe(map((apiResponse: HttpInfo>) => apiResponse.data)); + } + + /** + */ + public testDecodeCompositeObjectsGetWithHttpInfo(_options?: Configuration): Observable> { + const requestContextPromise = this.requestFactory.testDecodeCompositeObjectsGet(_options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (const middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (const middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.testDecodeCompositeObjectsGetWithHttpInfo(rsp))); + })); + } + + /** + */ + public testDecodeCompositeObjectsGet(_options?: Configuration): Observable { + return this.testDecodeCompositeObjectsGetWithHttpInfo(_options).pipe(map((apiResponse: HttpInfo) => apiResponse.data)); + } + + /** + */ + public testDecodeMapOfMapsOfObjectsGetWithHttpInfo(_options?: Configuration): Observable> { + const requestContextPromise = this.requestFactory.testDecodeMapOfMapsOfObjectsGet(_options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (const middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (const middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.testDecodeMapOfMapsOfObjectsGetWithHttpInfo(rsp))); + })); + } + + /** + */ + public testDecodeMapOfMapsOfObjectsGet(_options?: Configuration): Observable<{ [key: string]: { [key: string]: ComplexObject; }; }> { + return this.testDecodeMapOfMapsOfObjectsGetWithHttpInfo(_options).pipe(map((apiResponse: HttpInfo<{ [key: string]: { [key: string]: ComplexObject; }; }>) => apiResponse.data)); + } + + /** + */ + public testDecodeMapOfObjectsGetWithHttpInfo(_options?: Configuration): Observable> { + const requestContextPromise = this.requestFactory.testDecodeMapOfObjectsGet(_options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (const middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (const middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.testDecodeMapOfObjectsGetWithHttpInfo(rsp))); + })); + } + + /** + */ + public testDecodeMapOfObjectsGet(_options?: Configuration): Observable<{ [key: string]: ComplexObject | null; }> { + return this.testDecodeMapOfObjectsGetWithHttpInfo(_options).pipe(map((apiResponse: HttpInfo<{ [key: string]: ComplexObject | null; }>) => apiResponse.data)); + } + + /** + */ + public testDecodeMapOfPrimitiveGetWithHttpInfo(_options?: Configuration): Observable> { + const requestContextPromise = this.requestFactory.testDecodeMapOfPrimitiveGet(_options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (const middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (const middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.testDecodeMapOfPrimitiveGetWithHttpInfo(rsp))); + })); + } + + /** + */ + public testDecodeMapOfPrimitiveGet(_options?: Configuration): Observable<{ [key: string]: string; }> { + return this.testDecodeMapOfPrimitiveGetWithHttpInfo(_options).pipe(map((apiResponse: HttpInfo<{ [key: string]: string; }>) => apiResponse.data)); + } + + /** + */ + public testDecodeNullableArrayGetWithHttpInfo(_options?: Configuration): Observable>> { + const requestContextPromise = this.requestFactory.testDecodeNullableArrayGet(_options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (const middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (const middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.testDecodeNullableArrayGetWithHttpInfo(rsp))); + })); + } + + /** + */ + public testDecodeNullableArrayGet(_options?: Configuration): Observable> { + return this.testDecodeNullableArrayGetWithHttpInfo(_options).pipe(map((apiResponse: HttpInfo>) => apiResponse.data)); + } + + /** + */ + public testDecodeNullableGetWithHttpInfo(_options?: Configuration): Observable> { + const requestContextPromise = this.requestFactory.testDecodeNullableGet(_options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (const middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (const middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.testDecodeNullableGetWithHttpInfo(rsp))); + })); + } + + /** + */ + public testDecodeNullableGet(_options?: Configuration): Observable { + return this.testDecodeNullableGetWithHttpInfo(_options).pipe(map((apiResponse: HttpInfo) => apiResponse.data)); + } + + /** + */ + public testDecodeObjectGetWithHttpInfo(_options?: Configuration): Observable> { + const requestContextPromise = this.requestFactory.testDecodeObjectGet(_options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (const middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (const middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.testDecodeObjectGetWithHttpInfo(rsp))); + })); + } + + /** + */ + public testDecodeObjectGet(_options?: Configuration): Observable { + return this.testDecodeObjectGetWithHttpInfo(_options).pipe(map((apiResponse: HttpInfo) => apiResponse.data)); + } + + /** + */ + public testDecodePrimitiveBooleanGetWithHttpInfo(_options?: Configuration): Observable> { + const requestContextPromise = this.requestFactory.testDecodePrimitiveBooleanGet(_options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (const middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (const middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.testDecodePrimitiveBooleanGetWithHttpInfo(rsp))); + })); + } + + /** + */ + public testDecodePrimitiveBooleanGet(_options?: Configuration): Observable { + return this.testDecodePrimitiveBooleanGetWithHttpInfo(_options).pipe(map((apiResponse: HttpInfo) => apiResponse.data)); + } + + /** + */ + public testDecodePrimitiveIntegerGetWithHttpInfo(_options?: Configuration): Observable> { + const requestContextPromise = this.requestFactory.testDecodePrimitiveIntegerGet(_options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (const middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (const middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.testDecodePrimitiveIntegerGetWithHttpInfo(rsp))); + })); + } + + /** + */ + public testDecodePrimitiveIntegerGet(_options?: Configuration): Observable { + return this.testDecodePrimitiveIntegerGetWithHttpInfo(_options).pipe(map((apiResponse: HttpInfo) => apiResponse.data)); + } + + /** + */ + public testDecodePrimitiveNumberGetWithHttpInfo(_options?: Configuration): Observable> { + const requestContextPromise = this.requestFactory.testDecodePrimitiveNumberGet(_options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (const middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (const middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.testDecodePrimitiveNumberGetWithHttpInfo(rsp))); + })); + } + + /** + */ + public testDecodePrimitiveNumberGet(_options?: Configuration): Observable { + return this.testDecodePrimitiveNumberGetWithHttpInfo(_options).pipe(map((apiResponse: HttpInfo) => apiResponse.data)); + } + + /** + */ + public testDecodePrimitiveStringGetWithHttpInfo(_options?: Configuration): Observable> { + const requestContextPromise = this.requestFactory.testDecodePrimitiveStringGet(_options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (const middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (const middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.testDecodePrimitiveStringGetWithHttpInfo(rsp))); + })); + } + + /** + */ + public testDecodePrimitiveStringGet(_options?: Configuration): Observable { + return this.testDecodePrimitiveStringGetWithHttpInfo(_options).pipe(map((apiResponse: HttpInfo) => apiResponse.data)); + } + + /** + * @param requestBody + */ + public testEncodeArrayOfArraysPostWithHttpInfo(requestBody: Array>, _options?: Configuration): Observable> { + const requestContextPromise = this.requestFactory.testEncodeArrayOfArraysPost(requestBody, _options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (const middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (const middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.testEncodeArrayOfArraysPostWithHttpInfo(rsp))); + })); + } + + /** + * @param requestBody + */ + public testEncodeArrayOfArraysPost(requestBody: Array>, _options?: Configuration): Observable { + return this.testEncodeArrayOfArraysPostWithHttpInfo(requestBody, _options).pipe(map((apiResponse: HttpInfo) => apiResponse.data)); + } + + /** + * @param complexObject + */ + public testEncodeArrayOfMapsOfObjectsPostWithHttpInfo(complexObject: Array<{ [key: string]: ComplexObject; }>, _options?: Configuration): Observable> { + const requestContextPromise = this.requestFactory.testEncodeArrayOfMapsOfObjectsPost(complexObject, _options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (const middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (const middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.testEncodeArrayOfMapsOfObjectsPostWithHttpInfo(rsp))); + })); + } + + /** + * @param complexObject + */ + public testEncodeArrayOfMapsOfObjectsPost(complexObject: Array<{ [key: string]: ComplexObject; }>, _options?: Configuration): Observable { + return this.testEncodeArrayOfMapsOfObjectsPostWithHttpInfo(complexObject, _options).pipe(map((apiResponse: HttpInfo) => apiResponse.data)); + } + + /** + * @param complexObject + */ + public testEncodeArrayOfNullableObjectsPostWithHttpInfo(complexObject: Array, _options?: Configuration): Observable> { + const requestContextPromise = this.requestFactory.testEncodeArrayOfNullableObjectsPost(complexObject, _options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (const middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (const middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.testEncodeArrayOfNullableObjectsPostWithHttpInfo(rsp))); + })); + } + + /** + * @param complexObject + */ + public testEncodeArrayOfNullableObjectsPost(complexObject: Array, _options?: Configuration): Observable { + return this.testEncodeArrayOfNullableObjectsPostWithHttpInfo(complexObject, _options).pipe(map((apiResponse: HttpInfo) => apiResponse.data)); + } + + /** + * @param requestBody + */ + public testEncodeArrayOfNullablePostWithHttpInfo(requestBody: Array, _options?: Configuration): Observable> { + const requestContextPromise = this.requestFactory.testEncodeArrayOfNullablePost(requestBody, _options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (const middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (const middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.testEncodeArrayOfNullablePostWithHttpInfo(rsp))); + })); + } + + /** + * @param requestBody + */ + public testEncodeArrayOfNullablePost(requestBody: Array, _options?: Configuration): Observable { + return this.testEncodeArrayOfNullablePostWithHttpInfo(requestBody, _options).pipe(map((apiResponse: HttpInfo) => apiResponse.data)); + } + + /** + * @param requestBody + */ + public testEncodeArrayOfPostWithHttpInfo(requestBody: Array, _options?: Configuration): Observable> { + const requestContextPromise = this.requestFactory.testEncodeArrayOfPost(requestBody, _options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (const middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (const middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.testEncodeArrayOfPostWithHttpInfo(rsp))); + })); + } + + /** + * @param requestBody + */ + public testEncodeArrayOfPost(requestBody: Array, _options?: Configuration): Observable { + return this.testEncodeArrayOfPostWithHttpInfo(requestBody, _options).pipe(map((apiResponse: HttpInfo) => apiResponse.data)); + } + + /** + * @param compositeObject + */ + public testEncodeCompositeObjectsPostWithHttpInfo(compositeObject: CompositeObject, _options?: Configuration): Observable> { + const requestContextPromise = this.requestFactory.testEncodeCompositeObjectsPost(compositeObject, _options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (const middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (const middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.testEncodeCompositeObjectsPostWithHttpInfo(rsp))); + })); + } + + /** + * @param compositeObject + */ + public testEncodeCompositeObjectsPost(compositeObject: CompositeObject, _options?: Configuration): Observable { + return this.testEncodeCompositeObjectsPostWithHttpInfo(compositeObject, _options).pipe(map((apiResponse: HttpInfo) => apiResponse.data)); + } + + /** + * @param requestBody + */ + public testEncodeMapOfMapsOfObjectsPostWithHttpInfo(requestBody: { [key: string]: { [key: string]: ComplexObject; }; }, _options?: Configuration): Observable> { + const requestContextPromise = this.requestFactory.testEncodeMapOfMapsOfObjectsPost(requestBody, _options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (const middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (const middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.testEncodeMapOfMapsOfObjectsPostWithHttpInfo(rsp))); + })); + } + + /** + * @param requestBody + */ + public testEncodeMapOfMapsOfObjectsPost(requestBody: { [key: string]: { [key: string]: ComplexObject; }; }, _options?: Configuration): Observable { + return this.testEncodeMapOfMapsOfObjectsPostWithHttpInfo(requestBody, _options).pipe(map((apiResponse: HttpInfo) => apiResponse.data)); + } + + /** + * @param requestBody + */ + public testEncodeMapOfObjectsPostWithHttpInfo(requestBody: { [key: string]: ComplexObject | null; }, _options?: Configuration): Observable> { + const requestContextPromise = this.requestFactory.testEncodeMapOfObjectsPost(requestBody, _options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (const middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (const middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.testEncodeMapOfObjectsPostWithHttpInfo(rsp))); + })); + } + + /** + * @param requestBody + */ + public testEncodeMapOfObjectsPost(requestBody: { [key: string]: ComplexObject | null; }, _options?: Configuration): Observable { + return this.testEncodeMapOfObjectsPostWithHttpInfo(requestBody, _options).pipe(map((apiResponse: HttpInfo) => apiResponse.data)); + } + + /** + * @param requestBody + */ + public testEncodeMapOfPrimitivePostWithHttpInfo(requestBody: { [key: string]: string; }, _options?: Configuration): Observable> { + const requestContextPromise = this.requestFactory.testEncodeMapOfPrimitivePost(requestBody, _options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (const middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (const middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.testEncodeMapOfPrimitivePostWithHttpInfo(rsp))); + })); + } + + /** + * @param requestBody + */ + public testEncodeMapOfPrimitivePost(requestBody: { [key: string]: string; }, _options?: Configuration): Observable { + return this.testEncodeMapOfPrimitivePostWithHttpInfo(requestBody, _options).pipe(map((apiResponse: HttpInfo) => apiResponse.data)); + } + + /** + * @param requestBody + */ + public testEncodeNullableArrayPostWithHttpInfo(requestBody?: Array, _options?: Configuration): Observable> { + const requestContextPromise = this.requestFactory.testEncodeNullableArrayPost(requestBody, _options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (const middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (const middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.testEncodeNullableArrayPostWithHttpInfo(rsp))); + })); + } + + /** + * @param requestBody + */ + public testEncodeNullableArrayPost(requestBody?: Array, _options?: Configuration): Observable { + return this.testEncodeNullableArrayPostWithHttpInfo(requestBody, _options).pipe(map((apiResponse: HttpInfo) => apiResponse.data)); + } + + /** + * @param body + */ + public testEncodeNullablePostWithHttpInfo(body?: string, _options?: Configuration): Observable> { + const requestContextPromise = this.requestFactory.testEncodeNullablePost(body, _options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (const middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (const middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.testEncodeNullablePostWithHttpInfo(rsp))); + })); + } + + /** + * @param body + */ + public testEncodeNullablePost(body?: string, _options?: Configuration): Observable { + return this.testEncodeNullablePostWithHttpInfo(body, _options).pipe(map((apiResponse: HttpInfo) => apiResponse.data)); + } + + /** + * @param complexObject + */ + public testEncodeObjectPostWithHttpInfo(complexObject: ComplexObject, _options?: Configuration): Observable> { + const requestContextPromise = this.requestFactory.testEncodeObjectPost(complexObject, _options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (const middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (const middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.testEncodeObjectPostWithHttpInfo(rsp))); + })); + } + + /** + * @param complexObject + */ + public testEncodeObjectPost(complexObject: ComplexObject, _options?: Configuration): Observable { + return this.testEncodeObjectPostWithHttpInfo(complexObject, _options).pipe(map((apiResponse: HttpInfo) => apiResponse.data)); + } + + /** + * @param body + */ + public testEncodePrimitiveBooleanPostWithHttpInfo(body: boolean, _options?: Configuration): Observable> { + const requestContextPromise = this.requestFactory.testEncodePrimitiveBooleanPost(body, _options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (const middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (const middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.testEncodePrimitiveBooleanPostWithHttpInfo(rsp))); + })); + } + + /** + * @param body + */ + public testEncodePrimitiveBooleanPost(body: boolean, _options?: Configuration): Observable { + return this.testEncodePrimitiveBooleanPostWithHttpInfo(body, _options).pipe(map((apiResponse: HttpInfo) => apiResponse.data)); + } + + /** + * @param body + */ + public testEncodePrimitiveIntegerPostWithHttpInfo(body: number, _options?: Configuration): Observable> { + const requestContextPromise = this.requestFactory.testEncodePrimitiveIntegerPost(body, _options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (const middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (const middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.testEncodePrimitiveIntegerPostWithHttpInfo(rsp))); + })); + } + + /** + * @param body + */ + public testEncodePrimitiveIntegerPost(body: number, _options?: Configuration): Observable { + return this.testEncodePrimitiveIntegerPostWithHttpInfo(body, _options).pipe(map((apiResponse: HttpInfo) => apiResponse.data)); + } + + /** + * @param body + */ + public testEncodePrimitiveNumberPostWithHttpInfo(body: number, _options?: Configuration): Observable> { + const requestContextPromise = this.requestFactory.testEncodePrimitiveNumberPost(body, _options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (const middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (const middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.testEncodePrimitiveNumberPostWithHttpInfo(rsp))); + })); + } + + /** + * @param body + */ + public testEncodePrimitiveNumberPost(body: number, _options?: Configuration): Observable { + return this.testEncodePrimitiveNumberPostWithHttpInfo(body, _options).pipe(map((apiResponse: HttpInfo) => apiResponse.data)); + } + + /** + * @param body + */ + public testEncodePrimitiveStringPostWithHttpInfo(body: string, _options?: Configuration): Observable> { + const requestContextPromise = this.requestFactory.testEncodePrimitiveStringPost(body, _options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (const middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (const middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.testEncodePrimitiveStringPostWithHttpInfo(rsp))); + })); + } + + /** + * @param body + */ + public testEncodePrimitiveStringPost(body: string, _options?: Configuration): Observable { + return this.testEncodePrimitiveStringPostWithHttpInfo(body, _options).pipe(map((apiResponse: HttpInfo) => apiResponse.data)); + } + +} diff --git a/samples/client/others/typescript/encode-decode/build/types/PromiseAPI.ts b/samples/client/others/typescript/encode-decode/build/types/PromiseAPI.ts new file mode 100644 index 000000000000..48207b6c5904 --- /dev/null +++ b/samples/client/others/typescript/encode-decode/build/types/PromiseAPI.ts @@ -0,0 +1,504 @@ +import { ResponseContext, RequestContext, HttpFile, HttpInfo } from '../http/http'; +import { Configuration} from '../configuration' + +import { ComplexObject } from '../models/ComplexObject'; +import { CompositeObject } from '../models/CompositeObject'; +import { ObservableDefaultApi } from './ObservableAPI'; + +import { DefaultApiRequestFactory, DefaultApiResponseProcessor} from "../apis/DefaultApi"; +export class PromiseDefaultApi { + private api: ObservableDefaultApi + + public constructor( + configuration: Configuration, + requestFactory?: DefaultApiRequestFactory, + responseProcessor?: DefaultApiResponseProcessor + ) { + this.api = new ObservableDefaultApi(configuration, requestFactory, responseProcessor); + } + + /** + */ + public testDecodeArrayOfArraysGetWithHttpInfo(_options?: Configuration): Promise>>> { + const result = this.api.testDecodeArrayOfArraysGetWithHttpInfo(_options); + return result.toPromise(); + } + + /** + */ + public testDecodeArrayOfArraysGet(_options?: Configuration): Promise>> { + const result = this.api.testDecodeArrayOfArraysGet(_options); + return result.toPromise(); + } + + /** + */ + public testDecodeArrayOfGetWithHttpInfo(_options?: Configuration): Promise>> { + const result = this.api.testDecodeArrayOfGetWithHttpInfo(_options); + return result.toPromise(); + } + + /** + */ + public testDecodeArrayOfGet(_options?: Configuration): Promise> { + const result = this.api.testDecodeArrayOfGet(_options); + return result.toPromise(); + } + + /** + */ + public testDecodeArrayOfMapsOfObjectsGetWithHttpInfo(_options?: Configuration): Promise>> { + const result = this.api.testDecodeArrayOfMapsOfObjectsGetWithHttpInfo(_options); + return result.toPromise(); + } + + /** + */ + public testDecodeArrayOfMapsOfObjectsGet(_options?: Configuration): Promise> { + const result = this.api.testDecodeArrayOfMapsOfObjectsGet(_options); + return result.toPromise(); + } + + /** + */ + public testDecodeArrayOfNullableGetWithHttpInfo(_options?: Configuration): Promise>> { + const result = this.api.testDecodeArrayOfNullableGetWithHttpInfo(_options); + return result.toPromise(); + } + + /** + */ + public testDecodeArrayOfNullableGet(_options?: Configuration): Promise> { + const result = this.api.testDecodeArrayOfNullableGet(_options); + return result.toPromise(); + } + + /** + */ + public testDecodeArrayOfNullableObjectsGetWithHttpInfo(_options?: Configuration): Promise>> { + const result = this.api.testDecodeArrayOfNullableObjectsGetWithHttpInfo(_options); + return result.toPromise(); + } + + /** + */ + public testDecodeArrayOfNullableObjectsGet(_options?: Configuration): Promise> { + const result = this.api.testDecodeArrayOfNullableObjectsGet(_options); + return result.toPromise(); + } + + /** + */ + public testDecodeCompositeObjectsGetWithHttpInfo(_options?: Configuration): Promise> { + const result = this.api.testDecodeCompositeObjectsGetWithHttpInfo(_options); + return result.toPromise(); + } + + /** + */ + public testDecodeCompositeObjectsGet(_options?: Configuration): Promise { + const result = this.api.testDecodeCompositeObjectsGet(_options); + return result.toPromise(); + } + + /** + */ + public testDecodeMapOfMapsOfObjectsGetWithHttpInfo(_options?: Configuration): Promise> { + const result = this.api.testDecodeMapOfMapsOfObjectsGetWithHttpInfo(_options); + return result.toPromise(); + } + + /** + */ + public testDecodeMapOfMapsOfObjectsGet(_options?: Configuration): Promise<{ [key: string]: { [key: string]: ComplexObject; }; }> { + const result = this.api.testDecodeMapOfMapsOfObjectsGet(_options); + return result.toPromise(); + } + + /** + */ + public testDecodeMapOfObjectsGetWithHttpInfo(_options?: Configuration): Promise> { + const result = this.api.testDecodeMapOfObjectsGetWithHttpInfo(_options); + return result.toPromise(); + } + + /** + */ + public testDecodeMapOfObjectsGet(_options?: Configuration): Promise<{ [key: string]: ComplexObject | null; }> { + const result = this.api.testDecodeMapOfObjectsGet(_options); + return result.toPromise(); + } + + /** + */ + public testDecodeMapOfPrimitiveGetWithHttpInfo(_options?: Configuration): Promise> { + const result = this.api.testDecodeMapOfPrimitiveGetWithHttpInfo(_options); + return result.toPromise(); + } + + /** + */ + public testDecodeMapOfPrimitiveGet(_options?: Configuration): Promise<{ [key: string]: string; }> { + const result = this.api.testDecodeMapOfPrimitiveGet(_options); + return result.toPromise(); + } + + /** + */ + public testDecodeNullableArrayGetWithHttpInfo(_options?: Configuration): Promise>> { + const result = this.api.testDecodeNullableArrayGetWithHttpInfo(_options); + return result.toPromise(); + } + + /** + */ + public testDecodeNullableArrayGet(_options?: Configuration): Promise> { + const result = this.api.testDecodeNullableArrayGet(_options); + return result.toPromise(); + } + + /** + */ + public testDecodeNullableGetWithHttpInfo(_options?: Configuration): Promise> { + const result = this.api.testDecodeNullableGetWithHttpInfo(_options); + return result.toPromise(); + } + + /** + */ + public testDecodeNullableGet(_options?: Configuration): Promise { + const result = this.api.testDecodeNullableGet(_options); + return result.toPromise(); + } + + /** + */ + public testDecodeObjectGetWithHttpInfo(_options?: Configuration): Promise> { + const result = this.api.testDecodeObjectGetWithHttpInfo(_options); + return result.toPromise(); + } + + /** + */ + public testDecodeObjectGet(_options?: Configuration): Promise { + const result = this.api.testDecodeObjectGet(_options); + return result.toPromise(); + } + + /** + */ + public testDecodePrimitiveBooleanGetWithHttpInfo(_options?: Configuration): Promise> { + const result = this.api.testDecodePrimitiveBooleanGetWithHttpInfo(_options); + return result.toPromise(); + } + + /** + */ + public testDecodePrimitiveBooleanGet(_options?: Configuration): Promise { + const result = this.api.testDecodePrimitiveBooleanGet(_options); + return result.toPromise(); + } + + /** + */ + public testDecodePrimitiveIntegerGetWithHttpInfo(_options?: Configuration): Promise> { + const result = this.api.testDecodePrimitiveIntegerGetWithHttpInfo(_options); + return result.toPromise(); + } + + /** + */ + public testDecodePrimitiveIntegerGet(_options?: Configuration): Promise { + const result = this.api.testDecodePrimitiveIntegerGet(_options); + return result.toPromise(); + } + + /** + */ + public testDecodePrimitiveNumberGetWithHttpInfo(_options?: Configuration): Promise> { + const result = this.api.testDecodePrimitiveNumberGetWithHttpInfo(_options); + return result.toPromise(); + } + + /** + */ + public testDecodePrimitiveNumberGet(_options?: Configuration): Promise { + const result = this.api.testDecodePrimitiveNumberGet(_options); + return result.toPromise(); + } + + /** + */ + public testDecodePrimitiveStringGetWithHttpInfo(_options?: Configuration): Promise> { + const result = this.api.testDecodePrimitiveStringGetWithHttpInfo(_options); + return result.toPromise(); + } + + /** + */ + public testDecodePrimitiveStringGet(_options?: Configuration): Promise { + const result = this.api.testDecodePrimitiveStringGet(_options); + return result.toPromise(); + } + + /** + * @param requestBody + */ + public testEncodeArrayOfArraysPostWithHttpInfo(requestBody: Array>, _options?: Configuration): Promise> { + const result = this.api.testEncodeArrayOfArraysPostWithHttpInfo(requestBody, _options); + return result.toPromise(); + } + + /** + * @param requestBody + */ + public testEncodeArrayOfArraysPost(requestBody: Array>, _options?: Configuration): Promise { + const result = this.api.testEncodeArrayOfArraysPost(requestBody, _options); + return result.toPromise(); + } + + /** + * @param complexObject + */ + public testEncodeArrayOfMapsOfObjectsPostWithHttpInfo(complexObject: Array<{ [key: string]: ComplexObject; }>, _options?: Configuration): Promise> { + const result = this.api.testEncodeArrayOfMapsOfObjectsPostWithHttpInfo(complexObject, _options); + return result.toPromise(); + } + + /** + * @param complexObject + */ + public testEncodeArrayOfMapsOfObjectsPost(complexObject: Array<{ [key: string]: ComplexObject; }>, _options?: Configuration): Promise { + const result = this.api.testEncodeArrayOfMapsOfObjectsPost(complexObject, _options); + return result.toPromise(); + } + + /** + * @param complexObject + */ + public testEncodeArrayOfNullableObjectsPostWithHttpInfo(complexObject: Array, _options?: Configuration): Promise> { + const result = this.api.testEncodeArrayOfNullableObjectsPostWithHttpInfo(complexObject, _options); + return result.toPromise(); + } + + /** + * @param complexObject + */ + public testEncodeArrayOfNullableObjectsPost(complexObject: Array, _options?: Configuration): Promise { + const result = this.api.testEncodeArrayOfNullableObjectsPost(complexObject, _options); + return result.toPromise(); + } + + /** + * @param requestBody + */ + public testEncodeArrayOfNullablePostWithHttpInfo(requestBody: Array, _options?: Configuration): Promise> { + const result = this.api.testEncodeArrayOfNullablePostWithHttpInfo(requestBody, _options); + return result.toPromise(); + } + + /** + * @param requestBody + */ + public testEncodeArrayOfNullablePost(requestBody: Array, _options?: Configuration): Promise { + const result = this.api.testEncodeArrayOfNullablePost(requestBody, _options); + return result.toPromise(); + } + + /** + * @param requestBody + */ + public testEncodeArrayOfPostWithHttpInfo(requestBody: Array, _options?: Configuration): Promise> { + const result = this.api.testEncodeArrayOfPostWithHttpInfo(requestBody, _options); + return result.toPromise(); + } + + /** + * @param requestBody + */ + public testEncodeArrayOfPost(requestBody: Array, _options?: Configuration): Promise { + const result = this.api.testEncodeArrayOfPost(requestBody, _options); + return result.toPromise(); + } + + /** + * @param compositeObject + */ + public testEncodeCompositeObjectsPostWithHttpInfo(compositeObject: CompositeObject, _options?: Configuration): Promise> { + const result = this.api.testEncodeCompositeObjectsPostWithHttpInfo(compositeObject, _options); + return result.toPromise(); + } + + /** + * @param compositeObject + */ + public testEncodeCompositeObjectsPost(compositeObject: CompositeObject, _options?: Configuration): Promise { + const result = this.api.testEncodeCompositeObjectsPost(compositeObject, _options); + return result.toPromise(); + } + + /** + * @param requestBody + */ + public testEncodeMapOfMapsOfObjectsPostWithHttpInfo(requestBody: { [key: string]: { [key: string]: ComplexObject; }; }, _options?: Configuration): Promise> { + const result = this.api.testEncodeMapOfMapsOfObjectsPostWithHttpInfo(requestBody, _options); + return result.toPromise(); + } + + /** + * @param requestBody + */ + public testEncodeMapOfMapsOfObjectsPost(requestBody: { [key: string]: { [key: string]: ComplexObject; }; }, _options?: Configuration): Promise { + const result = this.api.testEncodeMapOfMapsOfObjectsPost(requestBody, _options); + return result.toPromise(); + } + + /** + * @param requestBody + */ + public testEncodeMapOfObjectsPostWithHttpInfo(requestBody: { [key: string]: ComplexObject | null; }, _options?: Configuration): Promise> { + const result = this.api.testEncodeMapOfObjectsPostWithHttpInfo(requestBody, _options); + return result.toPromise(); + } + + /** + * @param requestBody + */ + public testEncodeMapOfObjectsPost(requestBody: { [key: string]: ComplexObject | null; }, _options?: Configuration): Promise { + const result = this.api.testEncodeMapOfObjectsPost(requestBody, _options); + return result.toPromise(); + } + + /** + * @param requestBody + */ + public testEncodeMapOfPrimitivePostWithHttpInfo(requestBody: { [key: string]: string; }, _options?: Configuration): Promise> { + const result = this.api.testEncodeMapOfPrimitivePostWithHttpInfo(requestBody, _options); + return result.toPromise(); + } + + /** + * @param requestBody + */ + public testEncodeMapOfPrimitivePost(requestBody: { [key: string]: string; }, _options?: Configuration): Promise { + const result = this.api.testEncodeMapOfPrimitivePost(requestBody, _options); + return result.toPromise(); + } + + /** + * @param requestBody + */ + public testEncodeNullableArrayPostWithHttpInfo(requestBody?: Array, _options?: Configuration): Promise> { + const result = this.api.testEncodeNullableArrayPostWithHttpInfo(requestBody, _options); + return result.toPromise(); + } + + /** + * @param requestBody + */ + public testEncodeNullableArrayPost(requestBody?: Array, _options?: Configuration): Promise { + const result = this.api.testEncodeNullableArrayPost(requestBody, _options); + return result.toPromise(); + } + + /** + * @param body + */ + public testEncodeNullablePostWithHttpInfo(body?: string, _options?: Configuration): Promise> { + const result = this.api.testEncodeNullablePostWithHttpInfo(body, _options); + return result.toPromise(); + } + + /** + * @param body + */ + public testEncodeNullablePost(body?: string, _options?: Configuration): Promise { + const result = this.api.testEncodeNullablePost(body, _options); + return result.toPromise(); + } + + /** + * @param complexObject + */ + public testEncodeObjectPostWithHttpInfo(complexObject: ComplexObject, _options?: Configuration): Promise> { + const result = this.api.testEncodeObjectPostWithHttpInfo(complexObject, _options); + return result.toPromise(); + } + + /** + * @param complexObject + */ + public testEncodeObjectPost(complexObject: ComplexObject, _options?: Configuration): Promise { + const result = this.api.testEncodeObjectPost(complexObject, _options); + return result.toPromise(); + } + + /** + * @param body + */ + public testEncodePrimitiveBooleanPostWithHttpInfo(body: boolean, _options?: Configuration): Promise> { + const result = this.api.testEncodePrimitiveBooleanPostWithHttpInfo(body, _options); + return result.toPromise(); + } + + /** + * @param body + */ + public testEncodePrimitiveBooleanPost(body: boolean, _options?: Configuration): Promise { + const result = this.api.testEncodePrimitiveBooleanPost(body, _options); + return result.toPromise(); + } + + /** + * @param body + */ + public testEncodePrimitiveIntegerPostWithHttpInfo(body: number, _options?: Configuration): Promise> { + const result = this.api.testEncodePrimitiveIntegerPostWithHttpInfo(body, _options); + return result.toPromise(); + } + + /** + * @param body + */ + public testEncodePrimitiveIntegerPost(body: number, _options?: Configuration): Promise { + const result = this.api.testEncodePrimitiveIntegerPost(body, _options); + return result.toPromise(); + } + + /** + * @param body + */ + public testEncodePrimitiveNumberPostWithHttpInfo(body: number, _options?: Configuration): Promise> { + const result = this.api.testEncodePrimitiveNumberPostWithHttpInfo(body, _options); + return result.toPromise(); + } + + /** + * @param body + */ + public testEncodePrimitiveNumberPost(body: number, _options?: Configuration): Promise { + const result = this.api.testEncodePrimitiveNumberPost(body, _options); + return result.toPromise(); + } + + /** + * @param body + */ + public testEncodePrimitiveStringPostWithHttpInfo(body: string, _options?: Configuration): Promise> { + const result = this.api.testEncodePrimitiveStringPostWithHttpInfo(body, _options); + return result.toPromise(); + } + + /** + * @param body + */ + public testEncodePrimitiveStringPost(body: string, _options?: Configuration): Promise { + const result = this.api.testEncodePrimitiveStringPost(body, _options); + return result.toPromise(); + } + + +} + + + diff --git a/samples/client/others/typescript/encode-decode/build/util.ts b/samples/client/others/typescript/encode-decode/build/util.ts new file mode 100644 index 000000000000..96ea3dfdc770 --- /dev/null +++ b/samples/client/others/typescript/encode-decode/build/util.ts @@ -0,0 +1,37 @@ +/** + * Returns if a specific http code is in a given code range + * where the code range is defined as a combination of digits + * and "X" (the letter X) with a length of 3 + * + * @param codeRange string with length 3 consisting of digits and "X" (the letter X) + * @param code the http status code to be checked against the code range + */ +export function isCodeInRange(codeRange: string, code: number): boolean { + // This is how the default value is encoded in OAG + if (codeRange === "0") { + return true; + } + if (codeRange == code.toString()) { + return true; + } else { + const codeString = code.toString(); + if (codeString.length != codeRange.length) { + return false; + } + for (let i = 0; i < codeString.length; i++) { + if (codeRange.charAt(i) != "X" && codeRange.charAt(i) != codeString.charAt(i)) { + return false; + } + } + return true; + } +} + +/** +* Returns if it can consume form +* +* @param consumes array +*/ +export function canConsumeForm(contentTypes: string[]): boolean { + return contentTypes.indexOf('multipart/form-data') !== -1 +} diff --git a/samples/client/others/typescript/encode-decode/test/.gitignore b/samples/client/others/typescript/encode-decode/test/.gitignore new file mode 100644 index 000000000000..de4d1f007dd1 --- /dev/null +++ b/samples/client/others/typescript/encode-decode/test/.gitignore @@ -0,0 +1,2 @@ +dist +node_modules diff --git a/samples/client/others/typescript/encode-decode/test/package-lock.json b/samples/client/others/typescript/encode-decode/test/package-lock.json new file mode 100644 index 000000000000..48f51130272d --- /dev/null +++ b/samples/client/others/typescript/encode-decode/test/package-lock.json @@ -0,0 +1,1203 @@ +{ + "name": "typescript-encode-decode-test", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "typescript-encode-decode-test", + "version": "1.0.0", + "hasInstallScript": true, + "license": "ISC", + "dependencies": { + "@openapitools/typescript-encode-decode": "file:../build", + "@types/chai": "^4.3.0", + "@types/mocha": "^10.0.0", + "@types/node": "^16.6.2", + "chai": "^4.3.0", + "mocha": "^10.2.0", + "ts-node": "^10.9.0", + "typescript": "^5.2.2" + } + }, + "../build": { + "name": "@openapitools/typescript-encode-decode", + "version": "1.0.0", + "license": "Unlicense", + "dependencies": { + "@types/node": "*", + "@types/node-fetch": "^2.5.7", + "es6-promise": "^4.2.4", + "form-data": "^2.5.0", + "node-fetch": "^2.6.0", + "url-parse": "^1.4.3" + }, + "devDependencies": { + "@types/url-parse": "1.4.4", + "typescript": "^4.0" + } + }, + "node_modules/@cspotcode/source-map-support": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "dependencies": { + "@jridgewell/trace-mapping": "0.3.9" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz", + "integrity": "sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.4.15", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", + "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, + "node_modules/@openapitools/typescript-encode-decode": { + "resolved": "../build", + "link": true + }, + "node_modules/@tsconfig/node10": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz", + "integrity": "sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==" + }, + "node_modules/@tsconfig/node12": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", + "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==" + }, + "node_modules/@tsconfig/node14": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", + "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==" + }, + "node_modules/@tsconfig/node16": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", + "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==" + }, + "node_modules/@types/chai": { + "version": "4.3.9", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.9.tgz", + "integrity": "sha512-69TtiDzu0bcmKQv3yg1Zx409/Kd7r0b5F1PfpYJfSHzLGtB53547V4u+9iqKYsTu/O2ai6KTb0TInNpvuQ3qmg==" + }, + "node_modules/@types/mocha": { + "version": "10.0.3", + "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-10.0.3.tgz", + "integrity": "sha512-RsOPImTriV/OE4A9qKjMtk2MnXiuLLbcO3nCXK+kvq4nr0iMfFgpjaX3MPLb6f7+EL1FGSelYvuJMV6REH+ZPQ==" + }, + "node_modules/@types/node": { + "version": "16.18.59", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.18.59.tgz", + "integrity": "sha512-PJ1w2cNeKUEdey4LiPra0ZuxZFOGvetswE8qHRriV/sUkL5Al4tTmPV9D2+Y/TPIxTHHgxTfRjZVKWhPw/ORhQ==" + }, + "node_modules/ansi-colors": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", + "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", + "engines": { + "node": ">=6" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==" + }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" + }, + "node_modules/assertion-error": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", + "engines": { + "node": "*" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + }, + "node_modules/binary-extensions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", + "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", + "engines": { + "node": ">=8" + } + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dependencies": { + "fill-range": "^7.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/browser-stdout": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==" + }, + "node_modules/camelcase": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", + "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/chai": { + "version": "4.3.10", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.10.tgz", + "integrity": "sha512-0UXG04VuVbruMUYbJ6JctvH0YnC/4q3/AkT18q4NaITo91CUm0liMS9VqzT9vZhVQ/1eqPanMWjBM+Juhfb/9g==", + "dependencies": { + "assertion-error": "^1.1.0", + "check-error": "^1.0.3", + "deep-eql": "^4.1.3", + "get-func-name": "^2.0.2", + "loupe": "^2.3.6", + "pathval": "^1.1.1", + "type-detect": "^4.0.8" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/chalk/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/check-error": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.3.tgz", + "integrity": "sha512-iKEoDYaRmd1mxM90a2OEfWhjsjPpYPuQ+lMYsoxB126+t8fw7ySEO48nmDg5COTjxDI65/Y2OWpeEHk3ZOe8zg==", + "dependencies": { + "get-func-name": "^2.0.2" + }, + "engines": { + "node": "*" + } + }, + "node_modules/chokidar": { + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", + "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", + "funding": [ + { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + ], + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/cliui": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", + "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^7.0.0" + } + }, + "node_modules/cliui/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/cliui/node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "engines": { + "node": ">=8" + } + }, + "node_modules/cliui/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/cliui/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" + }, + "node_modules/create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==" + }, + "node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/debug/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "node_modules/decamelize": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", + "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/deep-eql": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.3.tgz", + "integrity": "sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==", + "dependencies": { + "type-detect": "^4.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/diff": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", + "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==", + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" + }, + "node_modules/escalade": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", + "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", + "engines": { + "node": ">=6" + } + }, + "node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/flat": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", + "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==", + "bin": { + "flat": "cli.js" + } + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/get-func-name": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.2.tgz", + "integrity": "sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ==", + "engines": { + "node": "*" + } + }, + "node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/he": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", + "bin": { + "he": "bin/he" + } + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/is-plain-obj": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", + "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", + "engines": { + "node": ">=8" + } + }, + "node_modules/is-unicode-supported": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", + "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/log-symbols": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", + "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", + "dependencies": { + "chalk": "^4.1.0", + "is-unicode-supported": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/loupe": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.7.tgz", + "integrity": "sha512-zSMINGVYkdpYSOBmLi0D1Uo7JU9nVdQKrHxC8eYlV+9YKK9WePqAlL7lSlorG/U2Fw1w0hTBmaa/jrQ3UbPHtA==", + "dependencies": { + "get-func-name": "^2.0.1" + } + }, + "node_modules/make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==" + }, + "node_modules/mocha": { + "version": "10.2.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.2.0.tgz", + "integrity": "sha512-IDY7fl/BecMwFHzoqF2sg/SHHANeBoMMXFlS9r0OXKDssYE1M5O43wUY/9BVPeIvfH2zmEbBfseqN9gBQZzXkg==", + "dependencies": { + "ansi-colors": "4.1.1", + "browser-stdout": "1.3.1", + "chokidar": "3.5.3", + "debug": "4.3.4", + "diff": "5.0.0", + "escape-string-regexp": "4.0.0", + "find-up": "5.0.0", + "glob": "7.2.0", + "he": "1.2.0", + "js-yaml": "4.1.0", + "log-symbols": "4.1.0", + "minimatch": "5.0.1", + "ms": "2.1.3", + "nanoid": "3.3.3", + "serialize-javascript": "6.0.0", + "strip-json-comments": "3.1.1", + "supports-color": "8.1.1", + "workerpool": "6.2.1", + "yargs": "16.2.0", + "yargs-parser": "20.2.4", + "yargs-unparser": "2.0.0" + }, + "bin": { + "_mocha": "bin/_mocha", + "mocha": "bin/mocha.js" + }, + "engines": { + "node": ">= 14.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mochajs" + } + }, + "node_modules/mocha/node_modules/glob": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", + "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/mocha/node_modules/glob/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/mocha/node_modules/minimatch": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", + "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/mocha/node_modules/minimatch/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "node_modules/nanoid": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.3.tgz", + "integrity": "sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w==", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "engines": { + "node": ">=8" + } + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/pathval": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", + "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==", + "engines": { + "node": "*" + } + }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/randombytes": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", + "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", + "dependencies": { + "safe-buffer": "^5.1.0" + } + }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/serialize-javascript": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", + "integrity": "sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==", + "dependencies": { + "randombytes": "^2.1.0" + } + }, + "node_modules/strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/ts-node": { + "version": "10.9.1", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", + "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", + "dependencies": { + "@cspotcode/source-map-support": "^0.8.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "v8-compile-cache-lib": "^3.0.1", + "yn": "3.1.1" + }, + "bin": { + "ts-node": "dist/bin.js", + "ts-node-cwd": "dist/bin-cwd.js", + "ts-node-esm": "dist/bin-esm.js", + "ts-node-script": "dist/bin-script.js", + "ts-node-transpile-only": "dist/bin-transpile.js", + "ts-script": "dist/bin-script-deprecated.js" + }, + "peerDependencies": { + "@swc/core": ">=1.2.50", + "@swc/wasm": ">=1.2.50", + "@types/node": "*", + "typescript": ">=2.7" + }, + "peerDependenciesMeta": { + "@swc/core": { + "optional": true + }, + "@swc/wasm": { + "optional": true + } + } + }, + "node_modules/ts-node/node_modules/acorn": { + "version": "8.11.2", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.2.tgz", + "integrity": "sha512-nc0Axzp/0FILLEVsm4fNwLCwMttvhEI263QtVPQcbpfZZ3ts0hLsZGOpE6czNlid7CJ9MlyH8reXkpsf3YUY4w==", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/ts-node/node_modules/acorn-walk": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.0.tgz", + "integrity": "sha512-FS7hV565M5l1R08MXqo8odwMTB02C2UqzB17RVgu9EyuYFBqJZ3/ZY97sQD5FewVu1UyDFc1yztUDrAwT0EypA==", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/ts-node/node_modules/diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "engines": { + "node": ">=4" + } + }, + "node_modules/typescript": { + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", + "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/v8-compile-cache-lib": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==" + }, + "node_modules/workerpool": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.1.tgz", + "integrity": "sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==" + }, + "node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrap-ansi/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi/node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" + }, + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs": { + "version": "16.2.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", + "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", + "dependencies": { + "cliui": "^7.0.2", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.0", + "y18n": "^5.0.5", + "yargs-parser": "^20.2.2" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs-parser": { + "version": "20.2.4", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz", + "integrity": "sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==", + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs-unparser": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz", + "integrity": "sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==", + "dependencies": { + "camelcase": "^6.0.0", + "decamelize": "^4.0.0", + "flat": "^5.0.2", + "is-plain-obj": "^2.1.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/yargs/node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "engines": { + "node": ">=8" + } + }, + "node_modules/yargs/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/yargs/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "engines": { + "node": ">=6" + } + }, + "node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + } + } +} diff --git a/samples/client/others/typescript/encode-decode/test/package.json b/samples/client/others/typescript/encode-decode/test/package.json new file mode 100644 index 000000000000..805ee1b339d3 --- /dev/null +++ b/samples/client/others/typescript/encode-decode/test/package.json @@ -0,0 +1,25 @@ +{ + "private": true, + "dependencies": { + "@openapitools/typescript-encode-decode": "file:../build", + "@types/chai": "^4.3.0", + "@types/mocha": "^10.0.0", + "@types/node": "^16.6.2", + "chai": "^4.3.0", + "mocha": "^10.2.0", + "ts-node": "^10.9.0", + "typescript": "^5.2.2" + }, + "scripts": { + "preinstall": "npm --prefix ../build install", + "test": "mocha test/*.spec.ts --require ts-node/register --timeout 10000" + }, + "name": "typescript-encode-decode-test", + "version": "1.0.0", + "directories": { + "test": "test" + }, + "author": "", + "license": "ISC", + "description": "" +} diff --git a/samples/client/others/typescript/encode-decode/test/test/api.spec.ts b/samples/client/others/typescript/encode-decode/test/test/api.spec.ts new file mode 100644 index 000000000000..cd75ddd0e667 --- /dev/null +++ b/samples/client/others/typescript/encode-decode/test/test/api.spec.ts @@ -0,0 +1,407 @@ +import { + DefaultApi, +} from '@openapitools/typescript-encode-decode'; +import { expect } from 'chai'; +import { apiConfiguration, mockServer } from './server'; + +const api = new DefaultApi(apiConfiguration); + +describe('deserialization', () => { + it('deserializes primitive booleans', async () => { + const response = await api.testDecodePrimitiveBooleanGet(); + expect(response).to.be.true; + }); + + it('deserializes primitive integers', async () => { + const response = await api.testDecodePrimitiveIntegerGet(); + expect(response).to.equal(42); + }); + + it('deserializes primitive numbers', async () => { + const response = await api.testDecodePrimitiveNumberGet(); + expect(response).to.equal(42.42); + }); + + it('deserializes primitive strings', async () => { + const response = await api.testDecodePrimitiveStringGet(); + expect(response).to.equal('some string value'); + }); + + it('deserializes nullable strings', async () => { + const response = await api.testDecodeNullableGet(); + expect(response).to.equal(null); + }); + + it('deserializes arrays of strings', async () => { + const response = await api.testDecodeArrayOfGet(); + expect(response).to.deep.equal(["first", "second", "third"]); + }); + + it('deserializes arrays of nullable strings', async () => { + const response = await api.testDecodeArrayOfNullableGet(); + expect(response).to.deep.equal(["first", null, "third"]); + }); + + it('deserializes nullable arrays', async () => { + const response = await api.testDecodeNullableArrayGet(); + expect(response).to.equal(null); + }); + + it('deserializes arrays of arrays', async () => { + const response = await api.testDecodeArrayOfArraysGet(); + expect(response).to.deep.equal([["first", "second"], ["third"]]); + }); + + it('deserializes objects', async () => { + const response = await api.testDecodeObjectGet(); + expect(response).to.deep.equal({ + requiredProperty: "required", + requiredNullableProperty: null, + optionalNullableProperty: null, + }); + }); + + it('deserializes maps of primitives', async () => { + const response = await api.testDecodeMapOfPrimitiveGet(); + expect(response).to.deep.equal({ + key1: "value1", + key2: "value2", + }); + }); + + it('deserializes maps of objects', async () => { + const response = await api.testDecodeMapOfObjectsGet(); + expect(response).to.deep.equal({ + barebones: { + requiredProperty: "first", + requiredNullableProperty: null, + }, + nulls: { + requiredProperty: "second", + requiredNullableProperty: null, + optionalNullableProperty: null, + }, + values: { + requiredProperty: "third", + requiredNullableProperty: "foo", + optionalProperty: "bar", + optionalNullableProperty: "baz", + } + }); + }); + + it('deserializes maps of maps of objects', async () => { + const response = await api.testDecodeMapOfMapsOfObjectsGet(); + expect(response).to.deep.equal({ + key1: { + key1: { + requiredProperty: "first", + requiredNullableProperty: null, + }, + key2: { + requiredProperty: "second", + requiredNullableProperty: null, + optionalNullableProperty: null, + }, + }, + key2: { + key3: { + requiredProperty: "third", + requiredNullableProperty: "foo", + optionalProperty: "bar", + optionalNullableProperty: "baz", + } + } + }); + }); + + it('deserializes arrays of maps of objects', async () => { + const response = await api.testDecodeArrayOfMapsOfObjectsGet(); + expect(response).to.deep.equal([ + { + key1: { + requiredProperty: "first", + requiredNullableProperty: null, + }, + key2: { + requiredProperty: "second", + requiredNullableProperty: null, + optionalNullableProperty: null, + }, + }, + { + key3: { + requiredProperty: "third", + requiredNullableProperty: "foo", + optionalProperty: "bar", + optionalNullableProperty: "baz", + } + } + ]); + }); + + it('deserializes arrays of nullable objects', async () => { + const response = await api.testDecodeArrayOfNullableObjectsGet(); + expect(response).to.deep.equal([ + { + requiredProperty: "first", + requiredNullableProperty: null, + }, + null, + { + requiredProperty: "third", + requiredNullableProperty: "foo", + optionalProperty: "bar", + optionalNullableProperty: "baz", + } + ]); + }); + + it('deserializes composite objects', async () => { + const response = await api.testDecodeCompositeObjectsGet(); + expect(response).to.deep.equal({ + optionalNullableInnerObject: { + requiredProperty: "required", + requiredNullableProperty: null, + }, + }); + }); +}); + +describe("serialization", () => { + it("serializes primitive booleans", async () => { + await api.testEncodePrimitiveBooleanPost(true); + expect(mockServer.lastRequestBody).to.equal(true); + }); + + it("serializes primitive integers", async () => { + await api.testEncodePrimitiveIntegerPost(42); + expect(mockServer.lastRequestBody).to.equal(42); + }); + + it("serializes primitive numbers", async () => { + await api.testEncodePrimitiveNumberPost(42.42); + expect(mockServer.lastRequestBody).to.equal(42.42); + }); + + it("serializes primitive strings", async () => { + await api.testEncodePrimitiveStringPost("some string value"); + expect(mockServer.lastRequestBody).to.equal("some string value"); + }); + + it("serializes nullable strings", async () => { + await api.testEncodeNullablePost(null); + expect(mockServer.lastRequestBody).to.equal(null); + }); + + it("serializes arrays of strings", async () => { + await api.testEncodeArrayOfPost(["first", "second", "third"]); + expect(mockServer.lastRequestBody).to.deep.equal(["first", "second", "third"]); + }); + + it("serializes arrays of nullable strings", async () => { + await api.testEncodeArrayOfNullablePost(["first", null, "third"]); + expect(mockServer.lastRequestBody).to.deep.equal(["first", null, "third"]); + }); + + it("serializes nullable arrays", async () => { + await api.testEncodeNullableArrayPost(null); + expect(mockServer.lastRequestBody).to.equal(null); + }); + + it("serializes arrays of arrays", async () => { + await api.testEncodeArrayOfArraysPost([["first", "second"], ["third"]]); + expect(mockServer.lastRequestBody).to.deep.equal([["first", "second"], ["third"]]); + }); + + it("serializes objects", async () => { + await api.testEncodeObjectPost({ + requiredProperty: "required", + requiredNullableProperty: null, + optionalNullableProperty: null, + }); + expect(mockServer.lastRequestBody).to.deep.equal({ + required_property: "required", + required_nullable_property: null, + optional_nullable_property: null, + }); + }); + + it("serializes maps of primitives", async () => { + await api.testEncodeMapOfPrimitivePost({ + key1: "value1", + key2: "value2", + }); + expect(mockServer.lastRequestBody).to.deep.equal({ + key1: "value1", + key2: "value2", + }); + }); + + it("serializes maps of objects", async () => { + await api.testEncodeMapOfObjectsPost({ + barebones: { + requiredProperty: "first", + requiredNullableProperty: null, + }, + nulls: { + requiredProperty: "second", + requiredNullableProperty: null, + optionalNullableProperty: null, + }, + values: { + requiredProperty: "third", + requiredNullableProperty: "foo", + optionalProperty: "bar", + optionalNullableProperty: "baz", + } + }); + expect(mockServer.lastRequestBody).to.deep.equal({ + barebones: { + required_property: "first", + required_nullable_property: null, + }, + nulls: { + required_property: "second", + required_nullable_property: null, + optional_nullable_property: null, + }, + values: { + required_property: "third", + required_nullable_property: "foo", + optional_property: "bar", + optional_nullable_property: "baz", + } + }); + }); + + it("serializes maps of maps of objects", async () => { + await api.testEncodeMapOfMapsOfObjectsPost({ + key1: { + key1: { + requiredProperty: "first", + requiredNullableProperty: null, + }, + key2: { + requiredProperty: "second", + requiredNullableProperty: null, + optionalNullableProperty: null, + }, + }, + key2: { + key3: { + requiredProperty: "third", + requiredNullableProperty: "foo", + optionalProperty: "bar", + optionalNullableProperty: "baz", + } + } + }); + expect(mockServer.lastRequestBody).to.deep.equal({ + key1: { + key1: { + required_property: "first", + required_nullable_property: null, + }, + key2: { + required_property: "second", + required_nullable_property: null, + optional_nullable_property: null, + }, + }, + key2: { + key3: { + required_property: "third", + required_nullable_property: "foo", + optional_property: "bar", + optional_nullable_property: "baz", + } + } + }); + }); + + it("serializes arrays of maps of objects", async () => { + await api.testEncodeArrayOfMapsOfObjectsPost([ + { + key1: { + requiredProperty: "first", + requiredNullableProperty: null, + }, + key2: { + requiredProperty: "second", + requiredNullableProperty: null, + optionalNullableProperty: null, + }, + }, + { + key3: { + requiredProperty: "third", + requiredNullableProperty: "foo", + optionalProperty: "bar", + optionalNullableProperty: "baz", + } + } + ]); + expect(mockServer.lastRequestBody).to.deep.equal([ + { + key1: { + required_property: "first", + required_nullable_property: null, + }, + key2: { + required_property: "second", + required_nullable_property: null, + optional_nullable_property: null, + }, + }, + { + key3: { + required_property: "third", + required_nullable_property: "foo", + optional_property: "bar", + optional_nullable_property: "baz", + } + } + ]); + }); + + it("serializes arrays of nullable objects", async () => { + await api.testEncodeArrayOfNullableObjectsPost([ + { + requiredProperty: "first", + requiredNullableProperty: null, + }, + null, + { + requiredProperty: "third", + requiredNullableProperty: "foo", + } + ]); + expect(mockServer.lastRequestBody).to.deep.equal([ + { + required_property: "first", + required_nullable_property: null, + }, + null, + { + required_property: "third", + required_nullable_property: "foo", + } + ]); + }); + + it("serializes composite objects", async () => { + await api.testEncodeCompositeObjectsPost({ + optionalNullableInnerObject: { + requiredProperty: "required", + requiredNullableProperty: null, + }, + }); + expect(mockServer.lastRequestBody).to.deep.equal({ + optional_nullable_inner_object: { + required_property: "required", + required_nullable_property: null, + }, + }); + }); +}); diff --git a/samples/client/others/typescript/encode-decode/test/test/server.ts b/samples/client/others/typescript/encode-decode/test/test/server.ts new file mode 100644 index 000000000000..a32330da9c19 --- /dev/null +++ b/samples/client/others/typescript/encode-decode/test/test/server.ts @@ -0,0 +1,174 @@ +import { + createConfiguration, + PromiseHttpLibrary, + RequestContext, + ResponseBody, + ResponseContext, + ServerConfiguration, + wrapHttpLibrary, +} from '@openapitools/typescript-encode-decode'; + +const BASE_URL = 'http://localhost:1234'; + +class TestServerStub implements PromiseHttpLibrary { + public lastRequestBody: any = null; + + async send(request: RequestContext): Promise { + const url = request.getUrl(); + if (!url.startsWith(BASE_URL)) { + throw new Error(`unexpected url: ${url}`); + } + + const path = url.substring(BASE_URL.length); + + if (path.startsWith('/test/decode')) { + const value = this.valueForPath(path); + const body: ResponseBody = { + binary: async () => { throw new Error('not implemented') }, + text: async () => JSON.stringify(value), + }; + const headers = { 'content-type': 'application/json' }; + return new ResponseContext(200, headers, body); + } else if (path.startsWith('/test/encode/')) { + const rawBody = request.getBody().toString(); + this.lastRequestBody = JSON.parse(rawBody); + const body: ResponseBody = { + binary: async () => { throw new Error('not implemented') }, + text: async () => "", + }; + return new ResponseContext(200, {}, body); + } else { + throw new Error(`unexpected path: ${path}`); + } + } + + private valueForPath(path: string): any { + if (path.startsWith('/test/encode')) { + return ""; + } + + switch (path) { + case '/test/decode/primitive/boolean': + return true; + case '/test/decode/primitive/integer': + return 42; + case '/test/decode/primitive/number': + return 42.42; + case '/test/decode/primitive/string': + return 'some string value'; + case '/test/decode/nullable': + return null; + case '/test/decode/array-of': + return ["first", "second", "third"]; + case '/test/decode/array-of/nullable': + return ["first", null, "third"]; + case '/test/decode/nullable-array': + return null; + case '/test/decode/array-of-arrays': + return [["first", "second"], ["third"]]; + case '/test/decode/object': + return { + required_property: "required", + required_nullable_property: null, + optional_nullable_property: null, + }; + case '/test/decode/map-of/primitive': + return { + key1: "value1", + key2: "value2", + }; + case '/test/decode/map-of/objects': + return { + barebones: { + required_property: "first", + required_nullable_property: null, + }, + nulls: { + required_property: "second", + required_nullable_property: null, + optional_nullable_property: null, + }, + values: { + required_property: "third", + required_nullable_property: "foo", + optional_property: "bar", + optional_nullable_property: "baz", + } + }; + case '/test/decode/map-of/maps-of/objects': + return { + key1: { + key1: { + required_property: "first", + required_nullable_property: null, + }, + key2: { + required_property: "second", + required_nullable_property: null, + optional_nullable_property: null, + }, + }, + key2: { + key3: { + required_property: "third", + required_nullable_property: "foo", + optional_property: "bar", + optional_nullable_property: "baz", + } + } + }; + case '/test/decode/array-of/maps-of/objects': + return [ + { + key1: { + required_property: "first", + required_nullable_property: null, + }, + key2: { + required_property: "second", + required_nullable_property: null, + optional_nullable_property: null, + }, + }, + { + key3: { + required_property: "third", + required_nullable_property: "foo", + optional_property: "bar", + optional_nullable_property: "baz", + } + } + ]; + case '/test/decode/composite-objects': + return { + optional_nullable_inner_object: { + required_property: "required", + required_nullable_property: null, + }, + }; + case '/test/decode/array-of/nullable-objects': + return [ + { + required_property: "first", + required_nullable_property: null, + }, + null, + { + required_property: "third", + required_nullable_property: "foo", + optional_property: "bar", + optional_nullable_property: "baz", + } + ]; + default: + throw new Error(`unexpected path: ${path}`); + } + } +} + +export const mockServer = new TestServerStub(); + +export const apiConfiguration = createConfiguration({ + baseServer: new ServerConfiguration(BASE_URL, {}), + httpApi: wrapHttpLibrary(mockServer), +}); diff --git a/samples/client/others/typescript/encode-decode/test/tsconfig.json b/samples/client/others/typescript/encode-decode/test/tsconfig.json new file mode 100644 index 000000000000..e4f8bee09a0b --- /dev/null +++ b/samples/client/others/typescript/encode-decode/test/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "moduleResolution": "node", + "module": "CommonJS", + "target": "ES5", + "noImplicitAny": true, + "sourceMap": false, + "outDir": "dist", + "types": [ + "mocha" + ], + "lib": [ + "es6", + "dom" + ] + }, + "exclude": [ + "node_modules" + ] +} diff --git a/samples/client/petstore/typescript-angular-v12-provided-in-root/builds/with-npm/tsconfig.json b/samples/client/petstore/typescript-angular-v12-provided-in-root/builds/with-npm/tsconfig.json index c01ebe255d4c..89cdedb1cb7f 100644 --- a/samples/client/petstore/typescript-angular-v12-provided-in-root/builds/with-npm/tsconfig.json +++ b/samples/client/petstore/typescript-angular-v12-provided-in-root/builds/with-npm/tsconfig.json @@ -3,7 +3,6 @@ "emitDecoratorMetadata": true, "experimentalDecorators": true, "noImplicitAny": false, - "suppressImplicitAnyIndexErrors": true, "target": "es5", "module": "commonjs", "moduleResolution": "node", diff --git a/samples/client/petstore/typescript-angular-v13-provided-in-root/builds/with-npm/tsconfig.json b/samples/client/petstore/typescript-angular-v13-provided-in-root/builds/with-npm/tsconfig.json index fd2abf8a2ad4..85f130ae01ef 100644 --- a/samples/client/petstore/typescript-angular-v13-provided-in-root/builds/with-npm/tsconfig.json +++ b/samples/client/petstore/typescript-angular-v13-provided-in-root/builds/with-npm/tsconfig.json @@ -3,7 +3,6 @@ "emitDecoratorMetadata": true, "experimentalDecorators": true, "noImplicitAny": false, - "suppressImplicitAnyIndexErrors": true, "target": "es6", "module": "es6", "moduleResolution": "node", diff --git a/samples/client/petstore/typescript-angular-v14-provided-in-root/builds/with-npm/tsconfig.json b/samples/client/petstore/typescript-angular-v14-provided-in-root/builds/with-npm/tsconfig.json index fd2abf8a2ad4..85f130ae01ef 100644 --- a/samples/client/petstore/typescript-angular-v14-provided-in-root/builds/with-npm/tsconfig.json +++ b/samples/client/petstore/typescript-angular-v14-provided-in-root/builds/with-npm/tsconfig.json @@ -3,7 +3,6 @@ "emitDecoratorMetadata": true, "experimentalDecorators": true, "noImplicitAny": false, - "suppressImplicitAnyIndexErrors": true, "target": "es6", "module": "es6", "moduleResolution": "node", diff --git a/samples/client/petstore/typescript-jquery/npm/tsconfig.json b/samples/client/petstore/typescript-jquery/npm/tsconfig.json index e15ee4c5762c..6c601c979e42 100644 --- a/samples/client/petstore/typescript-jquery/npm/tsconfig.json +++ b/samples/client/petstore/typescript-jquery/npm/tsconfig.json @@ -2,7 +2,6 @@ "compilerOptions": { "module": "commonjs", "noImplicitAny": false, - "suppressImplicitAnyIndexErrors": true, "target": "ES5", "moduleResolution": "node", "removeComments": true, diff --git a/samples/client/petstore/typescript-node/default/model/models.ts b/samples/client/petstore/typescript-node/default/model/models.ts index 4e9ba21b4e76..7a784c6a9730 100644 --- a/samples/client/petstore/typescript-node/default/model/models.ts +++ b/samples/client/petstore/typescript-node/default/model/models.ts @@ -53,6 +53,23 @@ let typeMap: {[index: string]: any} = { "User": User, } +// Check if a string starts with another string without using es6 features +function startsWith(str: string, match: string): boolean { + return str.substring(0, match.length) === match; +} + +// Check if a string ends with another string without using es6 features +function endsWith(str: string, match: string): boolean { + return str.length >= match.length && str.substring(str.length - match.length) === match; +} + +const nullableSuffix = " | null"; +const optionalSuffix = " | undefined"; +const arrayPrefix = "Array<"; +const arraySuffix = ">"; +const mapPrefix = "{ [key: string]: "; +const mapSuffix = "; }"; + export class ObjectSerializer { public static findCorrectType(data: any, expectedType: string) { if (data == undefined) { @@ -89,20 +106,35 @@ export class ObjectSerializer { } } - public static serialize(data: any, type: string) { + public static serialize(data: any, type: string): any { if (data == undefined) { return data; } else if (primitives.indexOf(type.toLowerCase()) !== -1) { return data; - } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 - let subType: string = type.replace("Array<", ""); // Array => Type> - subType = subType.substring(0, subType.length - 1); // Type> => Type + } else if (endsWith(type, nullableSuffix)) { + let subType: string = type.slice(0, -nullableSuffix.length); // Type | null => Type + return ObjectSerializer.serialize(data, subType); + } else if (endsWith(type, optionalSuffix)) { + let subType: string = type.slice(0, -optionalSuffix.length); // Type | undefined => Type + return ObjectSerializer.serialize(data, subType); + } else if (startsWith(type, arrayPrefix)) { + let subType: string = type.slice(arrayPrefix.length, -arraySuffix.length); // Array => Type let transformedData: any[] = []; for (let index = 0; index < data.length; index++) { let datum = data[index]; transformedData.push(ObjectSerializer.serialize(datum, subType)); } return transformedData; + } else if (startsWith(type, mapPrefix)) { + let subType: string = type.slice(mapPrefix.length, -mapSuffix.length); // { [key: string]: Type; } => Type + let transformedData: { [key: string]: any } = {}; + for (let key in data) { + transformedData[key] = ObjectSerializer.serialize( + data[key], + subType, + ); + } + return transformedData; } else if (type === "Date") { return data.toISOString(); } else { @@ -127,22 +159,37 @@ export class ObjectSerializer { } } - public static deserialize(data: any, type: string) { + public static deserialize(data: any, type: string): any { // polymorphism may change the actual type. type = ObjectSerializer.findCorrectType(data, type); if (data == undefined) { return data; } else if (primitives.indexOf(type.toLowerCase()) !== -1) { return data; - } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 - let subType: string = type.replace("Array<", ""); // Array => Type> - subType = subType.substring(0, subType.length - 1); // Type> => Type + } else if (endsWith(type, nullableSuffix)) { + let subType: string = type.slice(0, -nullableSuffix.length); // Type | null => Type + return ObjectSerializer.deserialize(data, subType); + } else if (endsWith(type, optionalSuffix)) { + let subType: string = type.slice(0, -optionalSuffix.length); // Type | undefined => Type + return ObjectSerializer.deserialize(data, subType); + } else if (startsWith(type, arrayPrefix)) { + let subType: string = type.slice(arrayPrefix.length, -arraySuffix.length); // Array => Type let transformedData: any[] = []; for (let index = 0; index < data.length; index++) { let datum = data[index]; transformedData.push(ObjectSerializer.deserialize(datum, subType)); } return transformedData; + } else if (startsWith(type, mapPrefix)) { + let subType: string = type.slice(mapPrefix.length, -mapSuffix.length); // { [key: string]: Type; } => Type + let transformedData: { [key: string]: any } = {}; + for (let key in data) { + transformedData[key] = ObjectSerializer.deserialize( + data[key], + subType, + ); + } + return transformedData; } else if (type === "Date") { return new Date(data); } else { diff --git a/samples/client/petstore/typescript-node/npm/model/models.ts b/samples/client/petstore/typescript-node/npm/model/models.ts index 4e9ba21b4e76..7a784c6a9730 100644 --- a/samples/client/petstore/typescript-node/npm/model/models.ts +++ b/samples/client/petstore/typescript-node/npm/model/models.ts @@ -53,6 +53,23 @@ let typeMap: {[index: string]: any} = { "User": User, } +// Check if a string starts with another string without using es6 features +function startsWith(str: string, match: string): boolean { + return str.substring(0, match.length) === match; +} + +// Check if a string ends with another string without using es6 features +function endsWith(str: string, match: string): boolean { + return str.length >= match.length && str.substring(str.length - match.length) === match; +} + +const nullableSuffix = " | null"; +const optionalSuffix = " | undefined"; +const arrayPrefix = "Array<"; +const arraySuffix = ">"; +const mapPrefix = "{ [key: string]: "; +const mapSuffix = "; }"; + export class ObjectSerializer { public static findCorrectType(data: any, expectedType: string) { if (data == undefined) { @@ -89,20 +106,35 @@ export class ObjectSerializer { } } - public static serialize(data: any, type: string) { + public static serialize(data: any, type: string): any { if (data == undefined) { return data; } else if (primitives.indexOf(type.toLowerCase()) !== -1) { return data; - } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 - let subType: string = type.replace("Array<", ""); // Array => Type> - subType = subType.substring(0, subType.length - 1); // Type> => Type + } else if (endsWith(type, nullableSuffix)) { + let subType: string = type.slice(0, -nullableSuffix.length); // Type | null => Type + return ObjectSerializer.serialize(data, subType); + } else if (endsWith(type, optionalSuffix)) { + let subType: string = type.slice(0, -optionalSuffix.length); // Type | undefined => Type + return ObjectSerializer.serialize(data, subType); + } else if (startsWith(type, arrayPrefix)) { + let subType: string = type.slice(arrayPrefix.length, -arraySuffix.length); // Array => Type let transformedData: any[] = []; for (let index = 0; index < data.length; index++) { let datum = data[index]; transformedData.push(ObjectSerializer.serialize(datum, subType)); } return transformedData; + } else if (startsWith(type, mapPrefix)) { + let subType: string = type.slice(mapPrefix.length, -mapSuffix.length); // { [key: string]: Type; } => Type + let transformedData: { [key: string]: any } = {}; + for (let key in data) { + transformedData[key] = ObjectSerializer.serialize( + data[key], + subType, + ); + } + return transformedData; } else if (type === "Date") { return data.toISOString(); } else { @@ -127,22 +159,37 @@ export class ObjectSerializer { } } - public static deserialize(data: any, type: string) { + public static deserialize(data: any, type: string): any { // polymorphism may change the actual type. type = ObjectSerializer.findCorrectType(data, type); if (data == undefined) { return data; } else if (primitives.indexOf(type.toLowerCase()) !== -1) { return data; - } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 - let subType: string = type.replace("Array<", ""); // Array => Type> - subType = subType.substring(0, subType.length - 1); // Type> => Type + } else if (endsWith(type, nullableSuffix)) { + let subType: string = type.slice(0, -nullableSuffix.length); // Type | null => Type + return ObjectSerializer.deserialize(data, subType); + } else if (endsWith(type, optionalSuffix)) { + let subType: string = type.slice(0, -optionalSuffix.length); // Type | undefined => Type + return ObjectSerializer.deserialize(data, subType); + } else if (startsWith(type, arrayPrefix)) { + let subType: string = type.slice(arrayPrefix.length, -arraySuffix.length); // Array => Type let transformedData: any[] = []; for (let index = 0; index < data.length; index++) { let datum = data[index]; transformedData.push(ObjectSerializer.deserialize(datum, subType)); } return transformedData; + } else if (startsWith(type, mapPrefix)) { + let subType: string = type.slice(mapPrefix.length, -mapSuffix.length); // { [key: string]: Type; } => Type + let transformedData: { [key: string]: any } = {}; + for (let key in data) { + transformedData[key] = ObjectSerializer.deserialize( + data[key], + subType, + ); + } + return transformedData; } else if (type === "Date") { return new Date(data); } else { diff --git a/samples/client/petstore/typescript-node/npm/tsconfig.json b/samples/client/petstore/typescript-node/npm/tsconfig.json index afce3b7abd4a..ea9078675b77 100644 --- a/samples/client/petstore/typescript-node/npm/tsconfig.json +++ b/samples/client/petstore/typescript-node/npm/tsconfig.json @@ -2,7 +2,6 @@ "compilerOptions": { "module": "commonjs", "noImplicitAny": false, - "suppressImplicitAnyIndexErrors": true, "target": "ES5", "allowSyntheticDefaultImports": true, "esModuleInterop": true, diff --git a/samples/openapi3/client/petstore/typescript/builds/browser/models/ObjectSerializer.ts b/samples/openapi3/client/petstore/typescript/builds/browser/models/ObjectSerializer.ts index ec5282483271..ee77e74cddd2 100644 --- a/samples/openapi3/client/petstore/typescript/builds/browser/models/ObjectSerializer.ts +++ b/samples/openapi3/client/petstore/typescript/builds/browser/models/ObjectSerializer.ts @@ -90,6 +90,13 @@ const supportedMimeTypePredicatesWithPriority: MimeTypePredicate[] = [ isFormUrlencodedMimeType, ]; +const nullableSuffix = " | null"; +const optionalSuffix = " | undefined"; +const arrayPrefix = "Array<"; +const arraySuffix = ">"; +const mapPrefix = "{ [key: string]: "; +const mapSuffix = "; }"; + export class ObjectSerializer { public static findCorrectType(data: any, expectedType: string) { if (data == undefined) { @@ -129,19 +136,35 @@ export class ObjectSerializer { } } - public static serialize(data: any, type: string, format: string) { + public static serialize(data: any, type: string, format: string): any { if (data == undefined) { return data; } else if (primitives.indexOf(type.toLowerCase()) !== -1) { return data; - } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 - let subType: string = type.replace("Array<", ""); // Array => Type> - subType = subType.substring(0, subType.length - 1); // Type> => Type + } else if (type.endsWith(nullableSuffix)) { + let subType: string = type.slice(0, -nullableSuffix.length); // Type | null => Type + return ObjectSerializer.serialize(data, subType, format); + } else if (type.endsWith(optionalSuffix)) { + let subType: string = type.slice(0, -optionalSuffix.length); // Type | undefined => Type + return ObjectSerializer.serialize(data, subType, format); + } else if (type.startsWith(arrayPrefix)) { + let subType: string = type.slice(arrayPrefix.length, -arraySuffix.length); // Array => Type let transformedData: any[] = []; for (let date of data) { transformedData.push(ObjectSerializer.serialize(date, subType, format)); } return transformedData; + } else if (type.startsWith(mapPrefix)) { + let subType: string = type.slice(mapPrefix.length, -mapSuffix.length); // { [key: string]: Type; } => Type + let transformedData: { [key: string]: any } = {}; + for (let key in data) { + transformedData[key] = ObjectSerializer.serialize( + data[key], + subType, + format, + ); + } + return transformedData; } else if (type === "Date") { if (format == "date") { let month = data.getMonth()+1 @@ -174,21 +197,37 @@ export class ObjectSerializer { } } - public static deserialize(data: any, type: string, format: string) { + public static deserialize(data: any, type: string, format: string): any { // polymorphism may change the actual type. type = ObjectSerializer.findCorrectType(data, type); if (data == undefined) { return data; } else if (primitives.indexOf(type.toLowerCase()) !== -1) { return data; - } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 - let subType: string = type.replace("Array<", ""); // Array => Type> - subType = subType.substring(0, subType.length - 1); // Type> => Type + } else if (type.endsWith(nullableSuffix)) { + let subType: string = type.slice(0, -nullableSuffix.length); // Type | null => Type + return ObjectSerializer.deserialize(data, subType, format); + } else if (type.endsWith(optionalSuffix)) { + let subType: string = type.slice(0, -optionalSuffix.length); // Type | undefined => Type + return ObjectSerializer.deserialize(data, subType, format); + } else if (type.startsWith(arrayPrefix)) { + let subType: string = type.slice(arrayPrefix.length, -arraySuffix.length); // Array => Type let transformedData: any[] = []; for (let date of data) { transformedData.push(ObjectSerializer.deserialize(date, subType, format)); } return transformedData; + } else if (type.startsWith(mapPrefix)) { + let subType: string = type.slice(mapPrefix.length, -mapSuffix.length); // { [key: string]: Type; } => Type + let transformedData: { [key: string]: any } = {}; + for (let key in data) { + transformedData[key] = ObjectSerializer.deserialize( + data[key], + subType, + format, + ); + } + return transformedData; } else if (type === "Date") { return new Date(data); } else { diff --git a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/ObjectSerializer.ts b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/ObjectSerializer.ts index dff7067ea8de..8b05a8c481e0 100644 --- a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/ObjectSerializer.ts +++ b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/ObjectSerializer.ts @@ -95,6 +95,13 @@ const supportedMimeTypePredicatesWithPriority: MimeTypePredicate[] = [ isFormUrlencodedMimeType, ]; +const nullableSuffix = " | null"; +const optionalSuffix = " | undefined"; +const arrayPrefix = "Array<"; +const arraySuffix = ">"; +const mapPrefix = "{ [key: string]: "; +const mapSuffix = "; }"; + export class ObjectSerializer { public static findCorrectType(data: any, expectedType: string) { if (data == undefined) { @@ -134,19 +141,35 @@ export class ObjectSerializer { } } - public static serialize(data: any, type: string, format: string) { + public static serialize(data: any, type: string, format: string): any { if (data == undefined) { return data; } else if (primitives.indexOf(type.toLowerCase()) !== -1) { return data; - } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 - let subType: string = type.replace("Array<", ""); // Array => Type> - subType = subType.substring(0, subType.length - 1); // Type> => Type + } else if (type.endsWith(nullableSuffix)) { + let subType: string = type.slice(0, -nullableSuffix.length); // Type | null => Type + return ObjectSerializer.serialize(data, subType, format); + } else if (type.endsWith(optionalSuffix)) { + let subType: string = type.slice(0, -optionalSuffix.length); // Type | undefined => Type + return ObjectSerializer.serialize(data, subType, format); + } else if (type.startsWith(arrayPrefix)) { + let subType: string = type.slice(arrayPrefix.length, -arraySuffix.length); // Array => Type let transformedData: any[] = []; for (let date of data) { transformedData.push(ObjectSerializer.serialize(date, subType, format)); } return transformedData; + } else if (type.startsWith(mapPrefix)) { + let subType: string = type.slice(mapPrefix.length, -mapSuffix.length); // { [key: string]: Type; } => Type + let transformedData: { [key: string]: any } = {}; + for (let key in data) { + transformedData[key] = ObjectSerializer.serialize( + data[key], + subType, + format, + ); + } + return transformedData; } else if (type === "Date") { if (format == "date") { let month = data.getMonth()+1 @@ -179,21 +202,37 @@ export class ObjectSerializer { } } - public static deserialize(data: any, type: string, format: string) { + public static deserialize(data: any, type: string, format: string): any { // polymorphism may change the actual type. type = ObjectSerializer.findCorrectType(data, type); if (data == undefined) { return data; } else if (primitives.indexOf(type.toLowerCase()) !== -1) { return data; - } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 - let subType: string = type.replace("Array<", ""); // Array => Type> - subType = subType.substring(0, subType.length - 1); // Type> => Type + } else if (type.endsWith(nullableSuffix)) { + let subType: string = type.slice(0, -nullableSuffix.length); // Type | null => Type + return ObjectSerializer.deserialize(data, subType, format); + } else if (type.endsWith(optionalSuffix)) { + let subType: string = type.slice(0, -optionalSuffix.length); // Type | undefined => Type + return ObjectSerializer.deserialize(data, subType, format); + } else if (type.startsWith(arrayPrefix)) { + let subType: string = type.slice(arrayPrefix.length, -arraySuffix.length); // Array => Type let transformedData: any[] = []; for (let date of data) { transformedData.push(ObjectSerializer.deserialize(date, subType, format)); } return transformedData; + } else if (type.startsWith(mapPrefix)) { + let subType: string = type.slice(mapPrefix.length, -mapSuffix.length); // { [key: string]: Type; } => Type + let transformedData: { [key: string]: any } = {}; + for (let key in data) { + transformedData[key] = ObjectSerializer.deserialize( + data[key], + subType, + format, + ); + } + return transformedData; } else if (type === "Date") { return new Date(data); } else { diff --git a/samples/openapi3/client/petstore/typescript/builds/default/models/ObjectSerializer.ts b/samples/openapi3/client/petstore/typescript/builds/default/models/ObjectSerializer.ts index ec5282483271..ee77e74cddd2 100644 --- a/samples/openapi3/client/petstore/typescript/builds/default/models/ObjectSerializer.ts +++ b/samples/openapi3/client/petstore/typescript/builds/default/models/ObjectSerializer.ts @@ -90,6 +90,13 @@ const supportedMimeTypePredicatesWithPriority: MimeTypePredicate[] = [ isFormUrlencodedMimeType, ]; +const nullableSuffix = " | null"; +const optionalSuffix = " | undefined"; +const arrayPrefix = "Array<"; +const arraySuffix = ">"; +const mapPrefix = "{ [key: string]: "; +const mapSuffix = "; }"; + export class ObjectSerializer { public static findCorrectType(data: any, expectedType: string) { if (data == undefined) { @@ -129,19 +136,35 @@ export class ObjectSerializer { } } - public static serialize(data: any, type: string, format: string) { + public static serialize(data: any, type: string, format: string): any { if (data == undefined) { return data; } else if (primitives.indexOf(type.toLowerCase()) !== -1) { return data; - } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 - let subType: string = type.replace("Array<", ""); // Array => Type> - subType = subType.substring(0, subType.length - 1); // Type> => Type + } else if (type.endsWith(nullableSuffix)) { + let subType: string = type.slice(0, -nullableSuffix.length); // Type | null => Type + return ObjectSerializer.serialize(data, subType, format); + } else if (type.endsWith(optionalSuffix)) { + let subType: string = type.slice(0, -optionalSuffix.length); // Type | undefined => Type + return ObjectSerializer.serialize(data, subType, format); + } else if (type.startsWith(arrayPrefix)) { + let subType: string = type.slice(arrayPrefix.length, -arraySuffix.length); // Array => Type let transformedData: any[] = []; for (let date of data) { transformedData.push(ObjectSerializer.serialize(date, subType, format)); } return transformedData; + } else if (type.startsWith(mapPrefix)) { + let subType: string = type.slice(mapPrefix.length, -mapSuffix.length); // { [key: string]: Type; } => Type + let transformedData: { [key: string]: any } = {}; + for (let key in data) { + transformedData[key] = ObjectSerializer.serialize( + data[key], + subType, + format, + ); + } + return transformedData; } else if (type === "Date") { if (format == "date") { let month = data.getMonth()+1 @@ -174,21 +197,37 @@ export class ObjectSerializer { } } - public static deserialize(data: any, type: string, format: string) { + public static deserialize(data: any, type: string, format: string): any { // polymorphism may change the actual type. type = ObjectSerializer.findCorrectType(data, type); if (data == undefined) { return data; } else if (primitives.indexOf(type.toLowerCase()) !== -1) { return data; - } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 - let subType: string = type.replace("Array<", ""); // Array => Type> - subType = subType.substring(0, subType.length - 1); // Type> => Type + } else if (type.endsWith(nullableSuffix)) { + let subType: string = type.slice(0, -nullableSuffix.length); // Type | null => Type + return ObjectSerializer.deserialize(data, subType, format); + } else if (type.endsWith(optionalSuffix)) { + let subType: string = type.slice(0, -optionalSuffix.length); // Type | undefined => Type + return ObjectSerializer.deserialize(data, subType, format); + } else if (type.startsWith(arrayPrefix)) { + let subType: string = type.slice(arrayPrefix.length, -arraySuffix.length); // Array => Type let transformedData: any[] = []; for (let date of data) { transformedData.push(ObjectSerializer.deserialize(date, subType, format)); } return transformedData; + } else if (type.startsWith(mapPrefix)) { + let subType: string = type.slice(mapPrefix.length, -mapSuffix.length); // { [key: string]: Type; } => Type + let transformedData: { [key: string]: any } = {}; + for (let key in data) { + transformedData[key] = ObjectSerializer.deserialize( + data[key], + subType, + format, + ); + } + return transformedData; } else if (type === "Date") { return new Date(data); } else { diff --git a/samples/openapi3/client/petstore/typescript/builds/deno/models/ObjectSerializer.ts b/samples/openapi3/client/petstore/typescript/builds/deno/models/ObjectSerializer.ts index 32490364bb7e..6a3ec9d4f812 100644 --- a/samples/openapi3/client/petstore/typescript/builds/deno/models/ObjectSerializer.ts +++ b/samples/openapi3/client/petstore/typescript/builds/deno/models/ObjectSerializer.ts @@ -90,6 +90,13 @@ const supportedMimeTypePredicatesWithPriority: MimeTypePredicate[] = [ isFormUrlencodedMimeType, ]; +const nullableSuffix = " | null"; +const optionalSuffix = " | undefined"; +const arrayPrefix = "Array<"; +const arraySuffix = ">"; +const mapPrefix = "{ [key: string]: "; +const mapSuffix = "; }"; + export class ObjectSerializer { public static findCorrectType(data: any, expectedType: string) { if (data == undefined) { @@ -129,19 +136,35 @@ export class ObjectSerializer { } } - public static serialize(data: any, type: string, format: string) { + public static serialize(data: any, type: string, format: string): any { if (data == undefined) { return data; } else if (primitives.indexOf(type.toLowerCase()) !== -1) { return data; - } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 - let subType: string = type.replace("Array<", ""); // Array => Type> - subType = subType.substring(0, subType.length - 1); // Type> => Type + } else if (type.endsWith(nullableSuffix)) { + let subType: string = type.slice(0, -nullableSuffix.length); // Type | null => Type + return ObjectSerializer.serialize(data, subType, format); + } else if (type.endsWith(optionalSuffix)) { + let subType: string = type.slice(0, -optionalSuffix.length); // Type | undefined => Type + return ObjectSerializer.serialize(data, subType, format); + } else if (type.startsWith(arrayPrefix)) { + let subType: string = type.slice(arrayPrefix.length, -arraySuffix.length); // Array => Type let transformedData: any[] = []; for (let date of data) { transformedData.push(ObjectSerializer.serialize(date, subType, format)); } return transformedData; + } else if (type.startsWith(mapPrefix)) { + let subType: string = type.slice(mapPrefix.length, -mapSuffix.length); // { [key: string]: Type; } => Type + let transformedData: { [key: string]: any } = {}; + for (let key in data) { + transformedData[key] = ObjectSerializer.serialize( + data[key], + subType, + format, + ); + } + return transformedData; } else if (type === "Date") { if (format == "date") { let month = data.getMonth()+1 @@ -174,21 +197,37 @@ export class ObjectSerializer { } } - public static deserialize(data: any, type: string, format: string) { + public static deserialize(data: any, type: string, format: string): any { // polymorphism may change the actual type. type = ObjectSerializer.findCorrectType(data, type); if (data == undefined) { return data; } else if (primitives.indexOf(type.toLowerCase()) !== -1) { return data; - } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 - let subType: string = type.replace("Array<", ""); // Array => Type> - subType = subType.substring(0, subType.length - 1); // Type> => Type + } else if (type.endsWith(nullableSuffix)) { + let subType: string = type.slice(0, -nullableSuffix.length); // Type | null => Type + return ObjectSerializer.deserialize(data, subType, format); + } else if (type.endsWith(optionalSuffix)) { + let subType: string = type.slice(0, -optionalSuffix.length); // Type | undefined => Type + return ObjectSerializer.deserialize(data, subType, format); + } else if (type.startsWith(arrayPrefix)) { + let subType: string = type.slice(arrayPrefix.length, -arraySuffix.length); // Array => Type let transformedData: any[] = []; for (let date of data) { transformedData.push(ObjectSerializer.deserialize(date, subType, format)); } return transformedData; + } else if (type.startsWith(mapPrefix)) { + let subType: string = type.slice(mapPrefix.length, -mapSuffix.length); // { [key: string]: Type; } => Type + let transformedData: { [key: string]: any } = {}; + for (let key in data) { + transformedData[key] = ObjectSerializer.deserialize( + data[key], + subType, + format, + ); + } + return transformedData; } else if (type === "Date") { return new Date(data); } else { diff --git a/samples/openapi3/client/petstore/typescript/builds/deno_object_params/models/ObjectSerializer.ts b/samples/openapi3/client/petstore/typescript/builds/deno_object_params/models/ObjectSerializer.ts index 32490364bb7e..6a3ec9d4f812 100644 --- a/samples/openapi3/client/petstore/typescript/builds/deno_object_params/models/ObjectSerializer.ts +++ b/samples/openapi3/client/petstore/typescript/builds/deno_object_params/models/ObjectSerializer.ts @@ -90,6 +90,13 @@ const supportedMimeTypePredicatesWithPriority: MimeTypePredicate[] = [ isFormUrlencodedMimeType, ]; +const nullableSuffix = " | null"; +const optionalSuffix = " | undefined"; +const arrayPrefix = "Array<"; +const arraySuffix = ">"; +const mapPrefix = "{ [key: string]: "; +const mapSuffix = "; }"; + export class ObjectSerializer { public static findCorrectType(data: any, expectedType: string) { if (data == undefined) { @@ -129,19 +136,35 @@ export class ObjectSerializer { } } - public static serialize(data: any, type: string, format: string) { + public static serialize(data: any, type: string, format: string): any { if (data == undefined) { return data; } else if (primitives.indexOf(type.toLowerCase()) !== -1) { return data; - } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 - let subType: string = type.replace("Array<", ""); // Array => Type> - subType = subType.substring(0, subType.length - 1); // Type> => Type + } else if (type.endsWith(nullableSuffix)) { + let subType: string = type.slice(0, -nullableSuffix.length); // Type | null => Type + return ObjectSerializer.serialize(data, subType, format); + } else if (type.endsWith(optionalSuffix)) { + let subType: string = type.slice(0, -optionalSuffix.length); // Type | undefined => Type + return ObjectSerializer.serialize(data, subType, format); + } else if (type.startsWith(arrayPrefix)) { + let subType: string = type.slice(arrayPrefix.length, -arraySuffix.length); // Array => Type let transformedData: any[] = []; for (let date of data) { transformedData.push(ObjectSerializer.serialize(date, subType, format)); } return transformedData; + } else if (type.startsWith(mapPrefix)) { + let subType: string = type.slice(mapPrefix.length, -mapSuffix.length); // { [key: string]: Type; } => Type + let transformedData: { [key: string]: any } = {}; + for (let key in data) { + transformedData[key] = ObjectSerializer.serialize( + data[key], + subType, + format, + ); + } + return transformedData; } else if (type === "Date") { if (format == "date") { let month = data.getMonth()+1 @@ -174,21 +197,37 @@ export class ObjectSerializer { } } - public static deserialize(data: any, type: string, format: string) { + public static deserialize(data: any, type: string, format: string): any { // polymorphism may change the actual type. type = ObjectSerializer.findCorrectType(data, type); if (data == undefined) { return data; } else if (primitives.indexOf(type.toLowerCase()) !== -1) { return data; - } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 - let subType: string = type.replace("Array<", ""); // Array => Type> - subType = subType.substring(0, subType.length - 1); // Type> => Type + } else if (type.endsWith(nullableSuffix)) { + let subType: string = type.slice(0, -nullableSuffix.length); // Type | null => Type + return ObjectSerializer.deserialize(data, subType, format); + } else if (type.endsWith(optionalSuffix)) { + let subType: string = type.slice(0, -optionalSuffix.length); // Type | undefined => Type + return ObjectSerializer.deserialize(data, subType, format); + } else if (type.startsWith(arrayPrefix)) { + let subType: string = type.slice(arrayPrefix.length, -arraySuffix.length); // Array => Type let transformedData: any[] = []; for (let date of data) { transformedData.push(ObjectSerializer.deserialize(date, subType, format)); } return transformedData; + } else if (type.startsWith(mapPrefix)) { + let subType: string = type.slice(mapPrefix.length, -mapSuffix.length); // { [key: string]: Type; } => Type + let transformedData: { [key: string]: any } = {}; + for (let key in data) { + transformedData[key] = ObjectSerializer.deserialize( + data[key], + subType, + format, + ); + } + return transformedData; } else if (type === "Date") { return new Date(data); } else { diff --git a/samples/openapi3/client/petstore/typescript/builds/explode-query/models/ObjectSerializer.ts b/samples/openapi3/client/petstore/typescript/builds/explode-query/models/ObjectSerializer.ts index d4a5ed1010ad..229b5710f470 100644 --- a/samples/openapi3/client/petstore/typescript/builds/explode-query/models/ObjectSerializer.ts +++ b/samples/openapi3/client/petstore/typescript/builds/explode-query/models/ObjectSerializer.ts @@ -220,6 +220,13 @@ const supportedMimeTypePredicatesWithPriority: MimeTypePredicate[] = [ isFormUrlencodedMimeType, ]; +const nullableSuffix = " | null"; +const optionalSuffix = " | undefined"; +const arrayPrefix = "Array<"; +const arraySuffix = ">"; +const mapPrefix = "{ [key: string]: "; +const mapSuffix = "; }"; + export class ObjectSerializer { public static findCorrectType(data: any, expectedType: string) { if (data == undefined) { @@ -259,19 +266,35 @@ export class ObjectSerializer { } } - public static serialize(data: any, type: string, format: string) { + public static serialize(data: any, type: string, format: string): any { if (data == undefined) { return data; } else if (primitives.indexOf(type.toLowerCase()) !== -1) { return data; - } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 - let subType: string = type.replace("Array<", ""); // Array => Type> - subType = subType.substring(0, subType.length - 1); // Type> => Type + } else if (type.endsWith(nullableSuffix)) { + let subType: string = type.slice(0, -nullableSuffix.length); // Type | null => Type + return ObjectSerializer.serialize(data, subType, format); + } else if (type.endsWith(optionalSuffix)) { + let subType: string = type.slice(0, -optionalSuffix.length); // Type | undefined => Type + return ObjectSerializer.serialize(data, subType, format); + } else if (type.startsWith(arrayPrefix)) { + let subType: string = type.slice(arrayPrefix.length, -arraySuffix.length); // Array => Type let transformedData: any[] = []; for (let date of data) { transformedData.push(ObjectSerializer.serialize(date, subType, format)); } return transformedData; + } else if (type.startsWith(mapPrefix)) { + let subType: string = type.slice(mapPrefix.length, -mapSuffix.length); // { [key: string]: Type; } => Type + let transformedData: { [key: string]: any } = {}; + for (let key in data) { + transformedData[key] = ObjectSerializer.serialize( + data[key], + subType, + format, + ); + } + return transformedData; } else if (type === "Date") { if (format == "date") { let month = data.getMonth()+1 @@ -304,21 +327,37 @@ export class ObjectSerializer { } } - public static deserialize(data: any, type: string, format: string) { + public static deserialize(data: any, type: string, format: string): any { // polymorphism may change the actual type. type = ObjectSerializer.findCorrectType(data, type); if (data == undefined) { return data; } else if (primitives.indexOf(type.toLowerCase()) !== -1) { return data; - } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 - let subType: string = type.replace("Array<", ""); // Array => Type> - subType = subType.substring(0, subType.length - 1); // Type> => Type + } else if (type.endsWith(nullableSuffix)) { + let subType: string = type.slice(0, -nullableSuffix.length); // Type | null => Type + return ObjectSerializer.deserialize(data, subType, format); + } else if (type.endsWith(optionalSuffix)) { + let subType: string = type.slice(0, -optionalSuffix.length); // Type | undefined => Type + return ObjectSerializer.deserialize(data, subType, format); + } else if (type.startsWith(arrayPrefix)) { + let subType: string = type.slice(arrayPrefix.length, -arraySuffix.length); // Array => Type let transformedData: any[] = []; for (let date of data) { transformedData.push(ObjectSerializer.deserialize(date, subType, format)); } return transformedData; + } else if (type.startsWith(mapPrefix)) { + let subType: string = type.slice(mapPrefix.length, -mapSuffix.length); // { [key: string]: Type; } => Type + let transformedData: { [key: string]: any } = {}; + for (let key in data) { + transformedData[key] = ObjectSerializer.deserialize( + data[key], + subType, + format, + ); + } + return transformedData; } else if (type === "Date") { return new Date(data); } else { diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/models/ObjectSerializer.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/models/ObjectSerializer.ts index ec5282483271..ee77e74cddd2 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/models/ObjectSerializer.ts +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/models/ObjectSerializer.ts @@ -90,6 +90,13 @@ const supportedMimeTypePredicatesWithPriority: MimeTypePredicate[] = [ isFormUrlencodedMimeType, ]; +const nullableSuffix = " | null"; +const optionalSuffix = " | undefined"; +const arrayPrefix = "Array<"; +const arraySuffix = ">"; +const mapPrefix = "{ [key: string]: "; +const mapSuffix = "; }"; + export class ObjectSerializer { public static findCorrectType(data: any, expectedType: string) { if (data == undefined) { @@ -129,19 +136,35 @@ export class ObjectSerializer { } } - public static serialize(data: any, type: string, format: string) { + public static serialize(data: any, type: string, format: string): any { if (data == undefined) { return data; } else if (primitives.indexOf(type.toLowerCase()) !== -1) { return data; - } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 - let subType: string = type.replace("Array<", ""); // Array => Type> - subType = subType.substring(0, subType.length - 1); // Type> => Type + } else if (type.endsWith(nullableSuffix)) { + let subType: string = type.slice(0, -nullableSuffix.length); // Type | null => Type + return ObjectSerializer.serialize(data, subType, format); + } else if (type.endsWith(optionalSuffix)) { + let subType: string = type.slice(0, -optionalSuffix.length); // Type | undefined => Type + return ObjectSerializer.serialize(data, subType, format); + } else if (type.startsWith(arrayPrefix)) { + let subType: string = type.slice(arrayPrefix.length, -arraySuffix.length); // Array => Type let transformedData: any[] = []; for (let date of data) { transformedData.push(ObjectSerializer.serialize(date, subType, format)); } return transformedData; + } else if (type.startsWith(mapPrefix)) { + let subType: string = type.slice(mapPrefix.length, -mapSuffix.length); // { [key: string]: Type; } => Type + let transformedData: { [key: string]: any } = {}; + for (let key in data) { + transformedData[key] = ObjectSerializer.serialize( + data[key], + subType, + format, + ); + } + return transformedData; } else if (type === "Date") { if (format == "date") { let month = data.getMonth()+1 @@ -174,21 +197,37 @@ export class ObjectSerializer { } } - public static deserialize(data: any, type: string, format: string) { + public static deserialize(data: any, type: string, format: string): any { // polymorphism may change the actual type. type = ObjectSerializer.findCorrectType(data, type); if (data == undefined) { return data; } else if (primitives.indexOf(type.toLowerCase()) !== -1) { return data; - } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 - let subType: string = type.replace("Array<", ""); // Array => Type> - subType = subType.substring(0, subType.length - 1); // Type> => Type + } else if (type.endsWith(nullableSuffix)) { + let subType: string = type.slice(0, -nullableSuffix.length); // Type | null => Type + return ObjectSerializer.deserialize(data, subType, format); + } else if (type.endsWith(optionalSuffix)) { + let subType: string = type.slice(0, -optionalSuffix.length); // Type | undefined => Type + return ObjectSerializer.deserialize(data, subType, format); + } else if (type.startsWith(arrayPrefix)) { + let subType: string = type.slice(arrayPrefix.length, -arraySuffix.length); // Array => Type let transformedData: any[] = []; for (let date of data) { transformedData.push(ObjectSerializer.deserialize(date, subType, format)); } return transformedData; + } else if (type.startsWith(mapPrefix)) { + let subType: string = type.slice(mapPrefix.length, -mapSuffix.length); // { [key: string]: Type; } => Type + let transformedData: { [key: string]: any } = {}; + for (let key in data) { + transformedData[key] = ObjectSerializer.deserialize( + data[key], + subType, + format, + ); + } + return transformedData; } else if (type === "Date") { return new Date(data); } else { diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/models/ObjectSerializer.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/models/ObjectSerializer.ts index ec5282483271..ee77e74cddd2 100644 --- a/samples/openapi3/client/petstore/typescript/builds/jquery/models/ObjectSerializer.ts +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/models/ObjectSerializer.ts @@ -90,6 +90,13 @@ const supportedMimeTypePredicatesWithPriority: MimeTypePredicate[] = [ isFormUrlencodedMimeType, ]; +const nullableSuffix = " | null"; +const optionalSuffix = " | undefined"; +const arrayPrefix = "Array<"; +const arraySuffix = ">"; +const mapPrefix = "{ [key: string]: "; +const mapSuffix = "; }"; + export class ObjectSerializer { public static findCorrectType(data: any, expectedType: string) { if (data == undefined) { @@ -129,19 +136,35 @@ export class ObjectSerializer { } } - public static serialize(data: any, type: string, format: string) { + public static serialize(data: any, type: string, format: string): any { if (data == undefined) { return data; } else if (primitives.indexOf(type.toLowerCase()) !== -1) { return data; - } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 - let subType: string = type.replace("Array<", ""); // Array => Type> - subType = subType.substring(0, subType.length - 1); // Type> => Type + } else if (type.endsWith(nullableSuffix)) { + let subType: string = type.slice(0, -nullableSuffix.length); // Type | null => Type + return ObjectSerializer.serialize(data, subType, format); + } else if (type.endsWith(optionalSuffix)) { + let subType: string = type.slice(0, -optionalSuffix.length); // Type | undefined => Type + return ObjectSerializer.serialize(data, subType, format); + } else if (type.startsWith(arrayPrefix)) { + let subType: string = type.slice(arrayPrefix.length, -arraySuffix.length); // Array => Type let transformedData: any[] = []; for (let date of data) { transformedData.push(ObjectSerializer.serialize(date, subType, format)); } return transformedData; + } else if (type.startsWith(mapPrefix)) { + let subType: string = type.slice(mapPrefix.length, -mapSuffix.length); // { [key: string]: Type; } => Type + let transformedData: { [key: string]: any } = {}; + for (let key in data) { + transformedData[key] = ObjectSerializer.serialize( + data[key], + subType, + format, + ); + } + return transformedData; } else if (type === "Date") { if (format == "date") { let month = data.getMonth()+1 @@ -174,21 +197,37 @@ export class ObjectSerializer { } } - public static deserialize(data: any, type: string, format: string) { + public static deserialize(data: any, type: string, format: string): any { // polymorphism may change the actual type. type = ObjectSerializer.findCorrectType(data, type); if (data == undefined) { return data; } else if (primitives.indexOf(type.toLowerCase()) !== -1) { return data; - } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 - let subType: string = type.replace("Array<", ""); // Array => Type> - subType = subType.substring(0, subType.length - 1); // Type> => Type + } else if (type.endsWith(nullableSuffix)) { + let subType: string = type.slice(0, -nullableSuffix.length); // Type | null => Type + return ObjectSerializer.deserialize(data, subType, format); + } else if (type.endsWith(optionalSuffix)) { + let subType: string = type.slice(0, -optionalSuffix.length); // Type | undefined => Type + return ObjectSerializer.deserialize(data, subType, format); + } else if (type.startsWith(arrayPrefix)) { + let subType: string = type.slice(arrayPrefix.length, -arraySuffix.length); // Array => Type let transformedData: any[] = []; for (let date of data) { transformedData.push(ObjectSerializer.deserialize(date, subType, format)); } return transformedData; + } else if (type.startsWith(mapPrefix)) { + let subType: string = type.slice(mapPrefix.length, -mapSuffix.length); // { [key: string]: Type; } => Type + let transformedData: { [key: string]: any } = {}; + for (let key in data) { + transformedData[key] = ObjectSerializer.deserialize( + data[key], + subType, + format, + ); + } + return transformedData; } else if (type === "Date") { return new Date(data); } else { diff --git a/samples/openapi3/client/petstore/typescript/builds/nullable-enum/models/ObjectSerializer.ts b/samples/openapi3/client/petstore/typescript/builds/nullable-enum/models/ObjectSerializer.ts index 463933cf57f3..2a45b7048843 100644 --- a/samples/openapi3/client/petstore/typescript/builds/nullable-enum/models/ObjectSerializer.ts +++ b/samples/openapi3/client/petstore/typescript/builds/nullable-enum/models/ObjectSerializer.ts @@ -74,6 +74,13 @@ const supportedMimeTypePredicatesWithPriority: MimeTypePredicate[] = [ isFormUrlencodedMimeType, ]; +const nullableSuffix = " | null"; +const optionalSuffix = " | undefined"; +const arrayPrefix = "Array<"; +const arraySuffix = ">"; +const mapPrefix = "{ [key: string]: "; +const mapSuffix = "; }"; + export class ObjectSerializer { public static findCorrectType(data: any, expectedType: string) { if (data == undefined) { @@ -113,19 +120,35 @@ export class ObjectSerializer { } } - public static serialize(data: any, type: string, format: string) { + public static serialize(data: any, type: string, format: string): any { if (data == undefined) { return data; } else if (primitives.indexOf(type.toLowerCase()) !== -1) { return data; - } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 - let subType: string = type.replace("Array<", ""); // Array => Type> - subType = subType.substring(0, subType.length - 1); // Type> => Type + } else if (type.endsWith(nullableSuffix)) { + let subType: string = type.slice(0, -nullableSuffix.length); // Type | null => Type + return ObjectSerializer.serialize(data, subType, format); + } else if (type.endsWith(optionalSuffix)) { + let subType: string = type.slice(0, -optionalSuffix.length); // Type | undefined => Type + return ObjectSerializer.serialize(data, subType, format); + } else if (type.startsWith(arrayPrefix)) { + let subType: string = type.slice(arrayPrefix.length, -arraySuffix.length); // Array => Type let transformedData: any[] = []; for (let date of data) { transformedData.push(ObjectSerializer.serialize(date, subType, format)); } return transformedData; + } else if (type.startsWith(mapPrefix)) { + let subType: string = type.slice(mapPrefix.length, -mapSuffix.length); // { [key: string]: Type; } => Type + let transformedData: { [key: string]: any } = {}; + for (let key in data) { + transformedData[key] = ObjectSerializer.serialize( + data[key], + subType, + format, + ); + } + return transformedData; } else if (type === "Date") { if (format == "date") { let month = data.getMonth()+1 @@ -158,21 +181,37 @@ export class ObjectSerializer { } } - public static deserialize(data: any, type: string, format: string) { + public static deserialize(data: any, type: string, format: string): any { // polymorphism may change the actual type. type = ObjectSerializer.findCorrectType(data, type); if (data == undefined) { return data; } else if (primitives.indexOf(type.toLowerCase()) !== -1) { return data; - } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 - let subType: string = type.replace("Array<", ""); // Array => Type> - subType = subType.substring(0, subType.length - 1); // Type> => Type + } else if (type.endsWith(nullableSuffix)) { + let subType: string = type.slice(0, -nullableSuffix.length); // Type | null => Type + return ObjectSerializer.deserialize(data, subType, format); + } else if (type.endsWith(optionalSuffix)) { + let subType: string = type.slice(0, -optionalSuffix.length); // Type | undefined => Type + return ObjectSerializer.deserialize(data, subType, format); + } else if (type.startsWith(arrayPrefix)) { + let subType: string = type.slice(arrayPrefix.length, -arraySuffix.length); // Array => Type let transformedData: any[] = []; for (let date of data) { transformedData.push(ObjectSerializer.deserialize(date, subType, format)); } return transformedData; + } else if (type.startsWith(mapPrefix)) { + let subType: string = type.slice(mapPrefix.length, -mapSuffix.length); // { [key: string]: Type; } => Type + let transformedData: { [key: string]: any } = {}; + for (let key in data) { + transformedData[key] = ObjectSerializer.deserialize( + data[key], + subType, + format, + ); + } + return transformedData; } else if (type === "Date") { return new Date(data); } else { diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/models/ObjectSerializer.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/models/ObjectSerializer.ts index ec5282483271..ee77e74cddd2 100644 --- a/samples/openapi3/client/petstore/typescript/builds/object_params/models/ObjectSerializer.ts +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/models/ObjectSerializer.ts @@ -90,6 +90,13 @@ const supportedMimeTypePredicatesWithPriority: MimeTypePredicate[] = [ isFormUrlencodedMimeType, ]; +const nullableSuffix = " | null"; +const optionalSuffix = " | undefined"; +const arrayPrefix = "Array<"; +const arraySuffix = ">"; +const mapPrefix = "{ [key: string]: "; +const mapSuffix = "; }"; + export class ObjectSerializer { public static findCorrectType(data: any, expectedType: string) { if (data == undefined) { @@ -129,19 +136,35 @@ export class ObjectSerializer { } } - public static serialize(data: any, type: string, format: string) { + public static serialize(data: any, type: string, format: string): any { if (data == undefined) { return data; } else if (primitives.indexOf(type.toLowerCase()) !== -1) { return data; - } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 - let subType: string = type.replace("Array<", ""); // Array => Type> - subType = subType.substring(0, subType.length - 1); // Type> => Type + } else if (type.endsWith(nullableSuffix)) { + let subType: string = type.slice(0, -nullableSuffix.length); // Type | null => Type + return ObjectSerializer.serialize(data, subType, format); + } else if (type.endsWith(optionalSuffix)) { + let subType: string = type.slice(0, -optionalSuffix.length); // Type | undefined => Type + return ObjectSerializer.serialize(data, subType, format); + } else if (type.startsWith(arrayPrefix)) { + let subType: string = type.slice(arrayPrefix.length, -arraySuffix.length); // Array => Type let transformedData: any[] = []; for (let date of data) { transformedData.push(ObjectSerializer.serialize(date, subType, format)); } return transformedData; + } else if (type.startsWith(mapPrefix)) { + let subType: string = type.slice(mapPrefix.length, -mapSuffix.length); // { [key: string]: Type; } => Type + let transformedData: { [key: string]: any } = {}; + for (let key in data) { + transformedData[key] = ObjectSerializer.serialize( + data[key], + subType, + format, + ); + } + return transformedData; } else if (type === "Date") { if (format == "date") { let month = data.getMonth()+1 @@ -174,21 +197,37 @@ export class ObjectSerializer { } } - public static deserialize(data: any, type: string, format: string) { + public static deserialize(data: any, type: string, format: string): any { // polymorphism may change the actual type. type = ObjectSerializer.findCorrectType(data, type); if (data == undefined) { return data; } else if (primitives.indexOf(type.toLowerCase()) !== -1) { return data; - } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 - let subType: string = type.replace("Array<", ""); // Array => Type> - subType = subType.substring(0, subType.length - 1); // Type> => Type + } else if (type.endsWith(nullableSuffix)) { + let subType: string = type.slice(0, -nullableSuffix.length); // Type | null => Type + return ObjectSerializer.deserialize(data, subType, format); + } else if (type.endsWith(optionalSuffix)) { + let subType: string = type.slice(0, -optionalSuffix.length); // Type | undefined => Type + return ObjectSerializer.deserialize(data, subType, format); + } else if (type.startsWith(arrayPrefix)) { + let subType: string = type.slice(arrayPrefix.length, -arraySuffix.length); // Array => Type let transformedData: any[] = []; for (let date of data) { transformedData.push(ObjectSerializer.deserialize(date, subType, format)); } return transformedData; + } else if (type.startsWith(mapPrefix)) { + let subType: string = type.slice(mapPrefix.length, -mapSuffix.length); // { [key: string]: Type; } => Type + let transformedData: { [key: string]: any } = {}; + for (let key in data) { + transformedData[key] = ObjectSerializer.deserialize( + data[key], + subType, + format, + ); + } + return transformedData; } else if (type === "Date") { return new Date(data); } else {