From 725cdbbee25d154c37b8688e620b9940a5bf2dbc Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 24 Aug 2020 05:34:47 +0000 Subject: [PATCH 1/4] Bump rollup from 2.23.1 to 2.26.5 Bumps [rollup](https://github.com/rollup/rollup) from 2.23.1 to 2.26.5. - [Release notes](https://github.com/rollup/rollup/releases) - [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md) - [Commits](https://github.com/rollup/rollup/compare/v2.23.1...v2.26.5) Signed-off-by: dependabot-preview[bot] --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 80d1b18c..4dccbd52 100644 --- a/package.json +++ b/package.json @@ -87,7 +87,7 @@ "jest": "26.4.2", "jest-cli": "26.4.2", "prettier": "2.0.5", - "rollup": "2.23.1", + "rollup": "2.26.5", "rollup-plugin-terser": "7.0.0", "rollup-plugin-typescript2": "0.27.2", "typescript": "4.0.2" diff --git a/yarn.lock b/yarn.lock index 14b52b75..d6d42ece 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4354,10 +4354,10 @@ rollup-plugin-typescript2@0.27.2: resolve "1.17.0" tslib "2.0.1" -rollup@2.23.1: - version "2.23.1" - resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.23.1.tgz#d458d28386dc7660c2e8a4978bea6f9494046c20" - integrity sha512-Heyl885+lyN/giQwxA8AYT2GY3U+gOlTqVLrMQYno8Z1X9lAOpfXPiKiZCyPc25e9BLJM3Zlh957dpTlO4pa8A== +rollup@2.26.5: + version "2.26.5" + resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.26.5.tgz#5562ec36fcba3eed65cfd630bd78e037ad0e0307" + integrity sha512-rCyFG3ZtQdnn9YwfuAVH0l/Om34BdO5lwCA0W6Hq+bNB21dVEBbCRxhaHOmu1G7OBFDWytbzAC104u7rxHwGjA== optionalDependencies: fsevents "~2.1.2" From 320f9a4e6ff60b7f2bc7ce30385e8bcddd6fbd1e Mon Sep 17 00:00:00 2001 From: Ferdi Koomen Date: Fri, 28 Aug 2020 21:18:30 +0200 Subject: [PATCH 2/4] - Added support for latest rmdir --- package.json | 14 +- rollup.config.js | 10 +- src/utils/fileSystem.ts | 2 +- test/__snapshots__/index.spec.js.snap | 5223 ------------------------- yarn.lock | 178 +- 5 files changed, 102 insertions(+), 5325 deletions(-) delete mode 100644 test/__snapshots__/index.spec.js.snap diff --git a/package.json b/package.json index 4dccbd52..cedf16ad 100644 --- a/package.json +++ b/package.json @@ -57,8 +57,8 @@ "codecov": "codecov --token=66c30c23-8954-4892-bef9-fbaed0a2e42b" }, "dependencies": { - "camelcase": "5.3.1", - "commander": "6.0.0", + "camelcase": "6.0.0", + "commander": "6.1.0", "handlebars": "4.7.6", "js-yaml": "3.14.0", "mkdirp": "1.0.4", @@ -74,10 +74,10 @@ "@types/jest": "26.0.10", "@types/js-yaml": "3.12.5", "@types/mkdirp": "1.0.1", - "@types/node": "14.6.0", + "@types/node": "14.6.1", "@types/rimraf": "3.0.0", - "@typescript-eslint/eslint-plugin": "3.9.1", - "@typescript-eslint/parser": "3.9.1", + "@typescript-eslint/eslint-plugin": "3.10.1", + "@typescript-eslint/parser": "3.10.1", "codecov": "3.7.2", "eslint": "7.7.0", "eslint-config-prettier": "6.11.0", @@ -86,8 +86,8 @@ "glob": "7.1.6", "jest": "26.4.2", "jest-cli": "26.4.2", - "prettier": "2.0.5", - "rollup": "2.26.5", + "prettier": "2.1.1", + "rollup": "2.26.7", "rollup-plugin-terser": "7.0.0", "rollup-plugin-typescript2": "0.27.2", "typescript": "4.0.2" diff --git a/rollup.config.js b/rollup.config.js index d6050c46..a8743a13 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -66,10 +66,10 @@ export default { }), nodeResolve(), commonjs(), - terser({ - output: { - comments: false, - }, - }), + // terser({ + // output: { + // comments: false, + // }, + // }), ], }; diff --git a/src/utils/fileSystem.ts b/src/utils/fileSystem.ts index 6c792a84..7c1b685c 100644 --- a/src/utils/fileSystem.ts +++ b/src/utils/fileSystem.ts @@ -1,5 +1,5 @@ import * as fs from 'fs'; -import * as mkdirp from 'mkdirp'; +import mkdirp from 'mkdirp'; import rimraf from 'rimraf'; import * as util from 'util'; diff --git a/test/__snapshots__/index.spec.js.snap b/test/__snapshots__/index.spec.js.snap deleted file mode 100644 index 4c212bd1..00000000 --- a/test/__snapshots__/index.spec.js.snap +++ /dev/null @@ -1,5223 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`v2 should generate: ./test/result/v2/core/ApiError.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { isSuccess } from './isSuccess'; -import { Result } from './Result'; - -export class ApiError extends Error { - - public readonly url: string; - public readonly status: number; - public readonly statusText: string; - public readonly body: any; - - constructor(result: Readonly, message: string) { - super(message); - - this.url = result.url; - this.status = result.status; - this.statusText = result.statusText; - this.body = result.body; - } -} - -export namespace ApiError { - export enum Message { - BAD_REQUEST = 'Bad Request', - UNAUTHORIZED = 'Unauthorized', - FORBIDDEN = 'Forbidden', - NOT_FOUND = 'Not Found', - INTERNAL_SERVER_ERROR = 'Internal Server Error', - BAD_GATEWAY = 'Bad Gateway', - SERVICE_UNAVAILABLE = 'Service Unavailable', - GENERIC_ERROR = 'Generic Error', - } -} - -/** - * Catch common errors (based on status code). - * @param result - */ -export function catchGenericError(result: Result): void { - switch (result.status) { - case 400: throw new ApiError(result, ApiError.Message.BAD_REQUEST); - case 401: throw new ApiError(result, ApiError.Message.UNAUTHORIZED); - case 403: throw new ApiError(result, ApiError.Message.FORBIDDEN); - case 404: throw new ApiError(result, ApiError.Message.NOT_FOUND); - case 500: throw new ApiError(result, ApiError.Message.INTERNAL_SERVER_ERROR); - case 502: throw new ApiError(result, ApiError.Message.BAD_GATEWAY); - case 503: throw new ApiError(result, ApiError.Message.SERVICE_UNAVAILABLE); - } - - if (!isSuccess(result.status)) { - throw new ApiError(result, ApiError.Message.GENERIC_ERROR); - } -} -" -`; - -exports[`v2 should generate: ./test/result/v2/core/OpenAPI.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -interface Config { - BASE: string; - VERSION: string; - CLIENT: 'fetch' | 'xhr'; - WITH_CREDENTIALS: boolean; - TOKEN: string; -} - -export const OpenAPI: Config = { - BASE: 'http://localhost:8080/api', - VERSION: '9.0', - CLIENT: 'fetch', - WITH_CREDENTIALS: false, - TOKEN: '', -};" -`; - -exports[`v2 should generate: ./test/result/v2/core/RequestOptions.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export interface RequestOptions { - method: 'get' | 'put' | 'post' | 'delete' | 'options' | 'head' | 'patch'; - path: string; - cookies?: { [key: string]: any }; - headers?: { [key: string]: any }; - query?: { [key: string]: any }; - formData?: { [key: string]: any }; - body?: any; - responseHeader?: string; -} -" -`; - -exports[`v2 should generate: ./test/result/v2/core/Result.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export interface Result { - url: string; - ok: boolean; - status: number; - statusText: string; - body: any; -} -" -`; - -exports[`v2 should generate: ./test/result/v2/core/getFormData.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -/** - * Get FormData from object. This method is needed to upload - * multipart form data to the REST API. - * @param params Key value based object. - */ -export function getFormData(params: { [key: string]: any }): FormData { - const formData = new FormData(); - for (const key in params) { - if (typeof params[key] !== 'undefined') { - const value: any = params[key]; - if (value !== undefined && value !== null) { - formData.append(key, value); - } - } - } - return formData; -} -" -`; - -exports[`v2 should generate: ./test/result/v2/core/getQueryString.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -/** - * Get query string from query parameters object. This method also - * supports multi-value items by creating a key for each item. - * @param params Key value based object. - */ -export function getQueryString(params: { [key: string]: any }): string { - const qs: string[] = []; - for (const key in params) { - if (typeof params[key] !== 'undefined') { - const value: any = params[key]; - if (value !== undefined && value !== null) { - if (Array.isArray(value)) { - value.forEach(value => { - qs.push(\`\${encodeURIComponent(key)}=\${encodeURIComponent(String(value))}\`); - }); - } else { - qs.push(\`\${encodeURIComponent(key)}=\${encodeURIComponent(String(value))}\`); - } - } - } - } - if (qs.length > 0) { - return \`?\${qs.join('&')}\`; - } - return ''; -} -" -`; - -exports[`v2 should generate: ./test/result/v2/core/isSuccess.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -/** - * Check success response code. - * @param status Status code - */ -export function isSuccess(status: number): boolean { - return status >= 200 && status < 300; -} -" -`; - -exports[`v2 should generate: ./test/result/v2/core/request.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { getFormData } from './getFormData'; -import { getQueryString } from './getQueryString'; -import { OpenAPI } from './OpenAPI'; -import { RequestOptions } from './RequestOptions'; -import { requestUsingFetch } from './requestUsingFetch'; -import { requestUsingXHR } from './requestUsingXHR'; -import { Result } from './Result'; - -/** - * Create the request. - * @param options Request method options. - * @returns Result object (see above) - */ -export async function request(options: Readonly): Promise { - - // Escape path (RFC3986) and create the request URL - let path = options.path.replace(/[:]/g, '_'); - let url = \`\${OpenAPI.BASE}\${path}\`; - - // Create request headers - const headers = new Headers({ - ...options.headers, - Accept: 'application/json', - }); - - // Create request settings - const request: RequestInit = { - headers, - method: options.method, - }; - - // If we specified to send requests with credentials, then we - // set the request credentials options to include. This is only - // needed if you make cross-origin calls. - if (OpenAPI.WITH_CREDENTIALS) { - request.credentials = 'include'; - } - - // If we have a bearer token then we set the authentication header. - if (OpenAPI.TOKEN !== null && OpenAPI.TOKEN !== '') { - headers.append('Authorization', \`Bearer \${OpenAPI.TOKEN}\`); - } - - // Add the query parameters (if defined). - if (options.query) { - url += getQueryString(options.query); - } - - // Append formData as body - if (options.formData) { - request.body = getFormData(options.formData); - } else if (options.body) { - - // If this is blob data, then pass it directly to the body and set content type. - // Otherwise we just convert request data to JSON string (needed for fetch api) - if (options.body instanceof Blob) { - request.body = options.body; - if (options.body.type) { - headers.append('Content-Type', options.body.type); - } - } else { - request.body = JSON.stringify(options.body); - headers.append('Content-Type', 'application/json'); - } - } - - try { - switch (OpenAPI.CLIENT) { - case 'xhr': - return await requestUsingXHR(url, request, options.responseHeader); - default: - return await requestUsingFetch(url, request, options.responseHeader); - } - } catch (error) { - return { - url, - ok: false, - status: 0, - statusText: '', - body: error, - }; - } -} -" -`; - -exports[`v2 should generate: ./test/result/v2/core/requestUsingFetch.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { Result } from './Result'; - -/** - * Try to parse the content for any response status code. - * We check the \\"Content-Type\\" header to see if we need to parse the - * content as json or as plain text. - * @param response Response object from fetch - */ -async function parseBody(response: Response): Promise { - try { - const contentType = response.headers.get('Content-Type'); - if (contentType) { - switch (contentType.toLowerCase()) { - case 'application/json': - case 'application/json; charset=utf-8': - return await response.json(); - - default: - return await response.text(); - } - } - } catch (e) { - console.error(e); - } - return null; -} - -/** - * Fetch the response header (if specified) - * @param response Response object from fetch - * @param responseHeader The name of the header to fetch - */ -function parseHeader(response: Response, responseHeader?: string): string | null { - if (responseHeader) { - const content = response.headers.get(responseHeader); - if (typeof content === 'string') { - return content; - } - } - return null; -} - -/** - * Request content using the new Fetch API. This is the default API that is used and - * is create for all JSON, XML and text objects. However it is limited to UTF-8. - * This is a problem for some of the Docs content, since that requires UTF-16! - * @param url The url to request. - * @param request The request object, containing method, headers, body, etc. - * @param responseHeader The header we want to parse. - */ -export async function requestUsingFetch(url: string, request: Readonly, responseHeader?: string): Promise { - - // Fetch response using fetch API. - const response = await fetch(url, request); - - // Get content of response header or response body - const contentHeader = parseHeader(response, responseHeader); - const contentBody = await parseBody(response); - - // Create result object. - return { - url, - ok: response.ok, - status: response.status, - statusText: response.statusText, - body: contentHeader || contentBody, - }; -} -" -`; - -exports[`v2 should generate: ./test/result/v2/core/requestUsingXHR.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { isSuccess } from './isSuccess'; -import { Result } from './Result'; - -/** - * Try to parse the content for any response status code. - * We check the \\"Content-Type\\" header to see if we need to parse the - * content as json or as plain text. - * @param xhr XHR request object - */ -function parseBody(xhr: XMLHttpRequest): any { - try { - const contentType = xhr.getResponseHeader('Content-Type'); - if (contentType) { - switch (contentType.toLowerCase()) { - case 'application/json': - case 'application/json; charset=utf-8': - return JSON.parse(xhr.responseText); - - default: - return xhr.responseText; - } - } - } catch (e) { - console.error(e); - } - return null; -} - -/** - * Fetch the response header (if specified) - * @param xhr XHR request object - * @param responseHeader The name of the header to fetch - */ -function parseHeader(xhr: XMLHttpRequest, responseHeader?: string): string | null { - if (responseHeader) { - const content = xhr.getResponseHeader(responseHeader); - if (typeof content === 'string') { - return content; - } - } - return null; -} - -/** - * Request content using the new legacy XMLHttpRequest API. This method is useful - * when we want to request UTF-16 content, since it natively supports loading UTF-16. - * We could do the same with the Fetch API, but then we will need to convert the - * content using JavaScript... And that is very very slow. - * @param url The url to request. - * @param request The request object, containing method, headers, body, etc. - * @param responseHeader The header we want to parse. - */ -export async function requestUsingXHR(url: string, request: Readonly, responseHeader?: string): Promise { - return new Promise(resolve => { - const xhr = new XMLHttpRequest(); - - // Open the request, remember to do this before adding any headers, - // because the request needs to be initialized! - xhr.open(request.method!, url, true); - - // When request credentials are set to include then this is - // the same behaviour as withCredentials = true in XHR: - // https://developer.mozilla.org/en-US/docs/Web/API/Request/credentials - xhr.withCredentials = request.credentials === 'include'; - - // Add the headers (required when dealing with JSON) - const headers = request.headers as Headers; - headers.forEach((value: string, key: string): void => { - xhr.setRequestHeader(key, value); - }); - - // Register the readystate handler, this will fire when the request is done. - xhr.onreadystatechange = () => { - if (xhr.readyState === XMLHttpRequest.DONE) { - - // Get content of response header or response body - const contentHeader = parseHeader(xhr, responseHeader); - const contentBody = parseBody(xhr); - - // Create result object. - const result: Result = { - url, - ok: isSuccess(xhr.status), - status: xhr.status, - statusText: xhr.statusText, - body: contentHeader || contentBody, - }; - - // Done! - resolve(result); - } - }; - - // Start the request! - xhr.send(request.body); - }); -} -" -`; - -exports[`v2 should generate: ./test/result/v2/index.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export { ApiError } from './core/ApiError'; -export { isSuccess } from './core/isSuccess'; -export { OpenAPI } from './core/OpenAPI'; - -export type { ArrayWithArray } from './models/ArrayWithArray'; -export type { ArrayWithBooleans } from './models/ArrayWithBooleans'; -export type { ArrayWithNumbers } from './models/ArrayWithNumbers'; -export type { ArrayWithProperties } from './models/ArrayWithProperties'; -export type { ArrayWithReferences } from './models/ArrayWithReferences'; -export type { ArrayWithStrings } from './models/ArrayWithStrings'; -export type { DictionaryWithArray } from './models/DictionaryWithArray'; -export type { DictionaryWithDictionary } from './models/DictionaryWithDictionary'; -export type { DictionaryWithProperties } from './models/DictionaryWithProperties'; -export type { DictionaryWithReference } from './models/DictionaryWithReference'; -export type { DictionaryWithString } from './models/DictionaryWithString'; -export { EnumFromDescription } from './models/EnumFromDescription'; -export { EnumWithExtensions } from './models/EnumWithExtensions'; -export { EnumWithNumbers } from './models/EnumWithNumbers'; -export { EnumWithStrings } from './models/EnumWithStrings'; -export type { ModelLink } from './models/ModelLink'; -export type { ModelThatExtends } from './models/ModelThatExtends'; -export type { ModelThatExtendsExtends } from './models/ModelThatExtendsExtends'; -export type { ModelWithArray } from './models/ModelWithArray'; -export type { ModelWithBoolean } from './models/ModelWithBoolean'; -export type { ModelWithCircularReference } from './models/ModelWithCircularReference'; -export type { ModelWithDictionary } from './models/ModelWithDictionary'; -export type { ModelWithDuplicateImports } from './models/ModelWithDuplicateImports'; -export type { ModelWithDuplicateProperties } from './models/ModelWithDuplicateProperties'; -export { ModelWithEnum } from './models/ModelWithEnum'; -export { ModelWithEnumFromDescription } from './models/ModelWithEnumFromDescription'; -export type { ModelWithInteger } from './models/ModelWithInteger'; -export type { ModelWithLink } from './models/ModelWithLink'; -export type { ModelWithNestedEnums } from './models/ModelWithNestedEnums'; -export type { ModelWithNestedProperties } from './models/ModelWithNestedProperties'; -export type { ModelWithOrderedProperties } from './models/ModelWithOrderedProperties'; -export type { ModelWithPattern } from './models/ModelWithPattern'; -export type { ModelWithProperties } from './models/ModelWithProperties'; -export type { ModelWithReference } from './models/ModelWithReference'; -export type { ModelWithString } from './models/ModelWithString'; -export type { MultilineComment } from './models/MultilineComment'; -export type { SimpleBoolean } from './models/SimpleBoolean'; -export type { SimpleFile } from './models/SimpleFile'; -export type { SimpleInteger } from './models/SimpleInteger'; -export type { SimpleReference } from './models/SimpleReference'; -export type { SimpleString } from './models/SimpleString'; - -export { $ArrayWithArray } from './schemas/$ArrayWithArray'; -export { $ArrayWithBooleans } from './schemas/$ArrayWithBooleans'; -export { $ArrayWithNumbers } from './schemas/$ArrayWithNumbers'; -export { $ArrayWithProperties } from './schemas/$ArrayWithProperties'; -export { $ArrayWithReferences } from './schemas/$ArrayWithReferences'; -export { $ArrayWithStrings } from './schemas/$ArrayWithStrings'; -export { $DictionaryWithArray } from './schemas/$DictionaryWithArray'; -export { $DictionaryWithDictionary } from './schemas/$DictionaryWithDictionary'; -export { $DictionaryWithProperties } from './schemas/$DictionaryWithProperties'; -export { $DictionaryWithReference } from './schemas/$DictionaryWithReference'; -export { $DictionaryWithString } from './schemas/$DictionaryWithString'; -export { $EnumFromDescription } from './schemas/$EnumFromDescription'; -export { $EnumWithExtensions } from './schemas/$EnumWithExtensions'; -export { $EnumWithNumbers } from './schemas/$EnumWithNumbers'; -export { $EnumWithStrings } from './schemas/$EnumWithStrings'; -export { $ModelLink } from './schemas/$ModelLink'; -export { $ModelThatExtends } from './schemas/$ModelThatExtends'; -export { $ModelThatExtendsExtends } from './schemas/$ModelThatExtendsExtends'; -export { $ModelWithArray } from './schemas/$ModelWithArray'; -export { $ModelWithBoolean } from './schemas/$ModelWithBoolean'; -export { $ModelWithCircularReference } from './schemas/$ModelWithCircularReference'; -export { $ModelWithDictionary } from './schemas/$ModelWithDictionary'; -export { $ModelWithDuplicateImports } from './schemas/$ModelWithDuplicateImports'; -export { $ModelWithDuplicateProperties } from './schemas/$ModelWithDuplicateProperties'; -export { $ModelWithEnum } from './schemas/$ModelWithEnum'; -export { $ModelWithEnumFromDescription } from './schemas/$ModelWithEnumFromDescription'; -export { $ModelWithInteger } from './schemas/$ModelWithInteger'; -export { $ModelWithLink } from './schemas/$ModelWithLink'; -export { $ModelWithNestedEnums } from './schemas/$ModelWithNestedEnums'; -export { $ModelWithNestedProperties } from './schemas/$ModelWithNestedProperties'; -export { $ModelWithOrderedProperties } from './schemas/$ModelWithOrderedProperties'; -export { $ModelWithPattern } from './schemas/$ModelWithPattern'; -export { $ModelWithProperties } from './schemas/$ModelWithProperties'; -export { $ModelWithReference } from './schemas/$ModelWithReference'; -export { $ModelWithString } from './schemas/$ModelWithString'; -export { $MultilineComment } from './schemas/$MultilineComment'; -export { $SimpleBoolean } from './schemas/$SimpleBoolean'; -export { $SimpleFile } from './schemas/$SimpleFile'; -export { $SimpleInteger } from './schemas/$SimpleInteger'; -export { $SimpleReference } from './schemas/$SimpleReference'; -export { $SimpleString } from './schemas/$SimpleString'; - -export { ComplexService } from './services/ComplexService'; -export { DefaultsService } from './services/DefaultsService'; -export { DuplicateService } from './services/DuplicateService'; -export { HeaderService } from './services/HeaderService'; -export { ParametersService } from './services/ParametersService'; -export { ResponseService } from './services/ResponseService'; -export { SimpleService } from './services/SimpleService'; -export { TypesService } from './services/TypesService'; -" -`; - -exports[`v2 should generate: ./test/result/v2/models/ArrayWithArray.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { ModelWithString } from './ModelWithString'; - -/** - * This is a simple array containing an array - */ -export type ArrayWithArray = Array>;" -`; - -exports[`v2 should generate: ./test/result/v2/models/ArrayWithBooleans.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - - -/** - * This is a simple array with booleans - */ -export type ArrayWithBooleans = Array;" -`; - -exports[`v2 should generate: ./test/result/v2/models/ArrayWithNumbers.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - - -/** - * This is a simple array with numbers - */ -export type ArrayWithNumbers = Array;" -`; - -exports[`v2 should generate: ./test/result/v2/models/ArrayWithProperties.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - - -/** - * This is a simple array with properties - */ -export type ArrayWithProperties = Array<{ - foo?: string, - bar?: string, -}>;" -`; - -exports[`v2 should generate: ./test/result/v2/models/ArrayWithReferences.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { ModelWithString } from './ModelWithString'; - -/** - * This is a simple array with references - */ -export type ArrayWithReferences = Array;" -`; - -exports[`v2 should generate: ./test/result/v2/models/ArrayWithStrings.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - - -/** - * This is a simple array with strings - */ -export type ArrayWithStrings = Array;" -`; - -exports[`v2 should generate: ./test/result/v2/models/Dictionary.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export type Dictionary = { - [key: string]: T; -} -" -`; - -exports[`v2 should generate: ./test/result/v2/models/DictionaryWithArray.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { Dictionary } from './Dictionary'; -import { ModelWithString } from './ModelWithString'; - -/** - * This is a complex dictionary - */ -export type DictionaryWithArray = Dictionary>;" -`; - -exports[`v2 should generate: ./test/result/v2/models/DictionaryWithDictionary.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { Dictionary } from './Dictionary'; - -/** - * This is a string dictionary - */ -export type DictionaryWithDictionary = Dictionary>;" -`; - -exports[`v2 should generate: ./test/result/v2/models/DictionaryWithProperties.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { Dictionary } from './Dictionary'; - -/** - * This is a complex dictionary - */ -export type DictionaryWithProperties = Dictionary<{ - foo?: string, - bar?: string, -}>;" -`; - -exports[`v2 should generate: ./test/result/v2/models/DictionaryWithReference.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { Dictionary } from './Dictionary'; -import { ModelWithString } from './ModelWithString'; - -/** - * This is a string reference - */ -export type DictionaryWithReference = Dictionary;" -`; - -exports[`v2 should generate: ./test/result/v2/models/DictionaryWithString.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { Dictionary } from './Dictionary'; - -/** - * This is a string dictionary - */ -export type DictionaryWithString = Dictionary;" -`; - -exports[`v2 should generate: ./test/result/v2/models/EnumFromDescription.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - - -/** - * Success=1,Warning=2,Error=3 - */ -export enum EnumFromDescription { - SUCCESS = 1, - WARNING = 2, - ERROR = 3, -}" -`; - -exports[`v2 should generate: ./test/result/v2/models/EnumWithExtensions.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - - -/** - * This is a simple enum with numbers - */ -export enum EnumWithExtensions { - /** - * Used when the status of something is successful - */ - CUSTOM_SUCCESS = 200, - /** - * Used when the status of something has a warning - */ - CUSTOM_WARNING = 400, - /** - * Used when the status of something has an error - */ - CUSTOM_ERROR = 500, -}" -`; - -exports[`v2 should generate: ./test/result/v2/models/EnumWithNumbers.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - - -/** - * This is a simple enum with numbers - */ -export enum EnumWithNumbers { - _1 = 1, - _2 = 2, - _3 = 3, -}" -`; - -exports[`v2 should generate: ./test/result/v2/models/EnumWithStrings.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - - -/** - * This is a simple enum with strings - */ -export enum EnumWithStrings { - SUCCESS = 'Success', - WARNING = 'Warning', - ERROR = 'Error', -}" -`; - -exports[`v2 should generate: ./test/result/v2/models/ModelLink.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - - -/** - * This is a model that can have a template?? - */ -export interface ModelLink { - id?: string; -} -" -`; - -exports[`v2 should generate: ./test/result/v2/models/ModelThatExtends.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { ModelWithString } from './ModelWithString'; - -/** - * This is a model that extends another model - */ -export interface ModelThatExtends extends ModelWithString { - propExtendsA?: string; - propExtendsB?: ModelWithString; -} -" -`; - -exports[`v2 should generate: ./test/result/v2/models/ModelThatExtendsExtends.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { ModelThatExtends } from './ModelThatExtends'; -import { ModelWithString } from './ModelWithString'; - -/** - * This is a model that extends another model - */ -export interface ModelThatExtendsExtends extends ModelWithString, ModelThatExtends { - propExtendsC?: string; - propExtendsD?: ModelWithString; -} -" -`; - -exports[`v2 should generate: ./test/result/v2/models/ModelWithArray.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { ModelWithString } from './ModelWithString'; - -/** - * This is a model with one property containing an array - */ -export interface ModelWithArray { - prop?: Array; - propWithFile?: Array; - propWithNumber?: Array; -} -" -`; - -exports[`v2 should generate: ./test/result/v2/models/ModelWithBoolean.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - - -/** - * This is a model with one boolean property - */ -export interface ModelWithBoolean { - /** - * This is a simple boolean property - */ - prop?: boolean; -} -" -`; - -exports[`v2 should generate: ./test/result/v2/models/ModelWithCircularReference.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - - -/** - * This is a model with one property containing a circular reference - */ -export interface ModelWithCircularReference { - prop?: ModelWithCircularReference; -} -" -`; - -exports[`v2 should generate: ./test/result/v2/models/ModelWithDictionary.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { Dictionary } from './Dictionary'; - -/** - * This is a model with one property containing a dictionary - */ -export interface ModelWithDictionary { - prop?: Dictionary; -} -" -`; - -exports[`v2 should generate: ./test/result/v2/models/ModelWithDuplicateImports.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { ModelWithString } from './ModelWithString'; - -/** - * This is a model with duplicated imports - */ -export interface ModelWithDuplicateImports { - propA?: ModelWithString; - propB?: ModelWithString; - propC?: ModelWithString; -} -" -`; - -exports[`v2 should generate: ./test/result/v2/models/ModelWithDuplicateProperties.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { ModelWithString } from './ModelWithString'; - -/** - * This is a model with duplicated properties - */ -export interface ModelWithDuplicateProperties { - prop?: ModelWithString; -} -" -`; - -exports[`v2 should generate: ./test/result/v2/models/ModelWithEnum.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - - -/** - * This is a model with one enum - */ -export interface ModelWithEnum { - /** - * This is a simple enum with strings - */ - test?: ModelWithEnum.test; - /** - * These are the HTTP error code enums - */ - statusCode?: ModelWithEnum.statusCode; -} - -export namespace ModelWithEnum { - - /** - * This is a simple enum with strings - */ - export enum test { - SUCCESS = 'Success', - WARNING = 'Warning', - ERROR = 'Error', - } - - /** - * These are the HTTP error code enums - */ - export enum statusCode { - _100 = '100', - _200_FOO = '200 FOO', - _300_FOO_BAR = '300 FOO_BAR', - _400_FOO_BAR = '400 foo-bar', - _500_FOO_BAR = '500 foo.bar', - _600_FOO_BAR = '600 foo&bar', - } - - -} -" -`; - -exports[`v2 should generate: ./test/result/v2/models/ModelWithEnumFromDescription.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - - -/** - * This is a model with one enum - */ -export interface ModelWithEnumFromDescription { - /** - * Success=1,Warning=2,Error=3 - */ - test?: ModelWithEnumFromDescription.test; -} - -export namespace ModelWithEnumFromDescription { - - /** - * Success=1,Warning=2,Error=3 - */ - export enum test { - SUCCESS = 1, - WARNING = 2, - ERROR = 3, - } - - -} -" -`; - -exports[`v2 should generate: ./test/result/v2/models/ModelWithInteger.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - - -/** - * This is a model with one number property - */ -export interface ModelWithInteger { - /** - * This is a simple number property - */ - prop?: number; -} -" -`; - -exports[`v2 should generate: ./test/result/v2/models/ModelWithLink.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { ModelLink } from './ModelLink'; -import { ModelWithString } from './ModelWithString'; - -/** - * This is a model that can have a template?? - */ -export interface ModelWithLink { - prop?: ModelLink; -} -" -`; - -exports[`v2 should generate: ./test/result/v2/models/ModelWithNestedEnums.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { Dictionary } from './Dictionary'; - -/** - * This is a model with nested enums - */ -export interface ModelWithNestedEnums { - dictionaryWithEnum?: Dictionary<('Success' | 'Warning' | 'Error')>; - dictionaryWithEnumFromDescription?: Dictionary<(1 | 2 | 3)>; - arrayWithEnum?: Array<('Success' | 'Warning' | 'Error')>; - arrayWithDescription?: Array<(1 | 2 | 3)>; -} -" -`; - -exports[`v2 should generate: ./test/result/v2/models/ModelWithNestedProperties.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - - -/** - * This is a model with one nested property - */ -export interface ModelWithNestedProperties { - readonly first: { - readonly second: { - readonly third: string, - }, - }; -} -" -`; - -exports[`v2 should generate: ./test/result/v2/models/ModelWithOrderedProperties.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - - -/** - * This is a model with ordered properties - */ -export interface ModelWithOrderedProperties { - zebra?: string; - apple?: string; - hawaii?: string; -} -" -`; - -exports[`v2 should generate: ./test/result/v2/models/ModelWithPattern.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - - -/** - * This is a model that contains a some patterns - */ -export interface ModelWithPattern { - key: string; - name: string; - readonly enabled?: boolean; - readonly modified?: string; -} -" -`; - -exports[`v2 should generate: ./test/result/v2/models/ModelWithProperties.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { ModelWithString } from './ModelWithString'; - -/** - * This is a model with one nested property - */ -export interface ModelWithProperties { - required: string; - readonly requiredAndReadOnly: string; - string?: string; - number?: number; - boolean?: boolean; - reference?: ModelWithString; -} -" -`; - -exports[`v2 should generate: ./test/result/v2/models/ModelWithReference.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { ModelWithProperties } from './ModelWithProperties'; - -/** - * This is a model with one property containing a reference - */ -export interface ModelWithReference { - prop?: ModelWithProperties; -} -" -`; - -exports[`v2 should generate: ./test/result/v2/models/ModelWithString.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - - -/** - * This is a model with one string property - */ -export interface ModelWithString { - /** - * This is a simple string property - */ - prop?: string; -} -" -`; - -exports[`v2 should generate: ./test/result/v2/models/MultilineComment.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - - -/** - * Testing multiline comments. - * This must go to the next line. - * - * This will contain a break. - */ -export type MultilineComment = number;" -`; - -exports[`v2 should generate: ./test/result/v2/models/SimpleBoolean.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - - -/** - * This is a simple boolean - */ -export type SimpleBoolean = boolean;" -`; - -exports[`v2 should generate: ./test/result/v2/models/SimpleFile.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - - -/** - * This is a simple file - */ -export type SimpleFile = File;" -`; - -exports[`v2 should generate: ./test/result/v2/models/SimpleInteger.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - - -/** - * This is a simple number - */ -export type SimpleInteger = number;" -`; - -exports[`v2 should generate: ./test/result/v2/models/SimpleReference.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { ModelWithString } from './ModelWithString'; - -/** - * This is a simple reference - */ -export type SimpleReference = ModelWithString;" -`; - -exports[`v2 should generate: ./test/result/v2/models/SimpleString.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - - -/** - * This is a simple string - */ -export type SimpleString = string;" -`; - -exports[`v2 should generate: ./test/result/v2/schemas/$ArrayWithArray.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ArrayWithArray = { - type: 'Array', -};" -`; - -exports[`v2 should generate: ./test/result/v2/schemas/$ArrayWithBooleans.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ArrayWithBooleans = { - type: 'Array', -};" -`; - -exports[`v2 should generate: ./test/result/v2/schemas/$ArrayWithNumbers.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ArrayWithNumbers = { - type: 'Array', -};" -`; - -exports[`v2 should generate: ./test/result/v2/schemas/$ArrayWithProperties.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ArrayWithProperties = { - type: 'Array', -};" -`; - -exports[`v2 should generate: ./test/result/v2/schemas/$ArrayWithReferences.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ArrayWithReferences = { - type: 'Array', -};" -`; - -exports[`v2 should generate: ./test/result/v2/schemas/$ArrayWithStrings.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ArrayWithStrings = { - type: 'Array', -};" -`; - -exports[`v2 should generate: ./test/result/v2/schemas/$DictionaryWithArray.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $DictionaryWithArray = { - type: 'Dictionary', -};" -`; - -exports[`v2 should generate: ./test/result/v2/schemas/$DictionaryWithDictionary.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $DictionaryWithDictionary = { - type: 'Dictionary', -};" -`; - -exports[`v2 should generate: ./test/result/v2/schemas/$DictionaryWithProperties.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $DictionaryWithProperties = { - type: 'Dictionary', -};" -`; - -exports[`v2 should generate: ./test/result/v2/schemas/$DictionaryWithReference.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $DictionaryWithReference = { - type: 'Dictionary', -};" -`; - -exports[`v2 should generate: ./test/result/v2/schemas/$DictionaryWithString.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $DictionaryWithString = { - type: 'Dictionary', -};" -`; - -exports[`v2 should generate: ./test/result/v2/schemas/$EnumFromDescription.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $EnumFromDescription = { - type: 'Enum', -};" -`; - -exports[`v2 should generate: ./test/result/v2/schemas/$EnumWithExtensions.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $EnumWithExtensions = { - type: 'Enum', -};" -`; - -exports[`v2 should generate: ./test/result/v2/schemas/$EnumWithNumbers.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $EnumWithNumbers = { - type: 'Enum', -};" -`; - -exports[`v2 should generate: ./test/result/v2/schemas/$EnumWithStrings.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $EnumWithStrings = { - type: 'Enum', -};" -`; - -exports[`v2 should generate: ./test/result/v2/schemas/$ModelLink.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ModelLink = { - properties: { - id: { - type: 'string', - }, - }, -};" -`; - -exports[`v2 should generate: ./test/result/v2/schemas/$ModelThatExtends.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { $ModelWithString } from './$ModelWithString'; - -export const $ModelThatExtends = { - properties: { - ...$ModelWithString.properties, - propExtendsA: { - type: 'string', - }, - propExtendsB: { - type: 'ModelWithString', - }, - }, -};" -`; - -exports[`v2 should generate: ./test/result/v2/schemas/$ModelThatExtendsExtends.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { $ModelWithString } from './$ModelWithString'; -import { $ModelThatExtends } from './$ModelThatExtends'; - -export const $ModelThatExtendsExtends = { - properties: { - ...$ModelWithString.properties, - ...$ModelThatExtends.properties, - propExtendsC: { - type: 'string', - }, - propExtendsD: { - type: 'ModelWithString', - }, - }, -};" -`; - -exports[`v2 should generate: ./test/result/v2/schemas/$ModelWithArray.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ModelWithArray = { - properties: { - prop: { - type: 'Array', - }, - propWithFile: { - type: 'Array', - }, - propWithNumber: { - type: 'Array', - }, - }, -};" -`; - -exports[`v2 should generate: ./test/result/v2/schemas/$ModelWithBoolean.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ModelWithBoolean = { - properties: { - prop: { - type: 'boolean', - }, - }, -};" -`; - -exports[`v2 should generate: ./test/result/v2/schemas/$ModelWithCircularReference.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ModelWithCircularReference = { - properties: { - prop: { - type: 'ModelWithCircularReference', - }, - }, -};" -`; - -exports[`v2 should generate: ./test/result/v2/schemas/$ModelWithDictionary.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ModelWithDictionary = { - properties: { - prop: { - type: 'Dictionary', - }, - }, -};" -`; - -exports[`v2 should generate: ./test/result/v2/schemas/$ModelWithDuplicateImports.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ModelWithDuplicateImports = { - properties: { - propA: { - type: 'ModelWithString', - }, - propB: { - type: 'ModelWithString', - }, - propC: { - type: 'ModelWithString', - }, - }, -};" -`; - -exports[`v2 should generate: ./test/result/v2/schemas/$ModelWithDuplicateProperties.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ModelWithDuplicateProperties = { - properties: { - prop: { - type: 'ModelWithString', - }, - }, -};" -`; - -exports[`v2 should generate: ./test/result/v2/schemas/$ModelWithEnum.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ModelWithEnum = { - properties: { - test: { - type: 'Enum', - }, - statusCode: { - type: 'Enum', - }, - }, -};" -`; - -exports[`v2 should generate: ./test/result/v2/schemas/$ModelWithEnumFromDescription.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ModelWithEnumFromDescription = { - properties: { - test: { - type: 'Enum', - }, - }, -};" -`; - -exports[`v2 should generate: ./test/result/v2/schemas/$ModelWithInteger.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ModelWithInteger = { - properties: { - prop: { - type: 'number', - }, - }, -};" -`; - -exports[`v2 should generate: ./test/result/v2/schemas/$ModelWithLink.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ModelWithLink = { - properties: { - prop: { - type: 'ModelLink', - }, - }, -};" -`; - -exports[`v2 should generate: ./test/result/v2/schemas/$ModelWithNestedEnums.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ModelWithNestedEnums = { - properties: { - dictionaryWithEnum: { - type: 'Dictionary', - }, - dictionaryWithEnumFromDescription: { - type: 'Dictionary', - }, - arrayWithEnum: { - type: 'Array', - }, - arrayWithDescription: { - type: 'Array', - }, - }, -};" -`; - -exports[`v2 should generate: ./test/result/v2/schemas/$ModelWithNestedProperties.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ModelWithNestedProperties = { - properties: { - first: { - properties: { - second: { - properties: { - third: { - type: 'string', - isReadOnly: true, - isRequired: true, - }, - }, - isReadOnly: true, - isRequired: true, - }, - }, - isReadOnly: true, - isRequired: true, - }, - }, -};" -`; - -exports[`v2 should generate: ./test/result/v2/schemas/$ModelWithOrderedProperties.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ModelWithOrderedProperties = { - properties: { - zebra: { - type: 'string', - }, - apple: { - type: 'string', - }, - hawaii: { - type: 'string', - }, - }, -};" -`; - -exports[`v2 should generate: ./test/result/v2/schemas/$ModelWithPattern.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ModelWithPattern = { - properties: { - key: { - type: 'string', - isRequired: true, - maxLength: 64, - pattern: '^[a-zA-Z0-9_]*$', - }, - name: { - type: 'string', - isRequired: true, - maxLength: 255, - }, - enabled: { - type: 'boolean', - isReadOnly: true, - }, - modified: { - type: 'string', - isReadOnly: true, - format: 'date-time', - }, - }, -};" -`; - -exports[`v2 should generate: ./test/result/v2/schemas/$ModelWithProperties.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ModelWithProperties = { - properties: { - required: { - type: 'string', - isRequired: true, - }, - requiredAndReadOnly: { - type: 'string', - isReadOnly: true, - isRequired: true, - }, - string: { - type: 'string', - }, - number: { - type: 'number', - }, - boolean: { - type: 'boolean', - }, - reference: { - type: 'ModelWithString', - }, - }, -};" -`; - -exports[`v2 should generate: ./test/result/v2/schemas/$ModelWithReference.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ModelWithReference = { - properties: { - prop: { - type: 'ModelWithProperties', - }, - }, -};" -`; - -exports[`v2 should generate: ./test/result/v2/schemas/$ModelWithString.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ModelWithString = { - properties: { - prop: { - type: 'string', - }, - }, -};" -`; - -exports[`v2 should generate: ./test/result/v2/schemas/$MultilineComment.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $MultilineComment = { - type: 'number', -};" -`; - -exports[`v2 should generate: ./test/result/v2/schemas/$SimpleBoolean.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $SimpleBoolean = { - type: 'boolean', -};" -`; - -exports[`v2 should generate: ./test/result/v2/schemas/$SimpleFile.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $SimpleFile = { - type: 'File', -};" -`; - -exports[`v2 should generate: ./test/result/v2/schemas/$SimpleInteger.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $SimpleInteger = { - type: 'number', -};" -`; - -exports[`v2 should generate: ./test/result/v2/schemas/$SimpleReference.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $SimpleReference = { - type: 'ModelWithString', -};" -`; - -exports[`v2 should generate: ./test/result/v2/schemas/$SimpleString.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $SimpleString = { - type: 'string', -};" -`; - -exports[`v2 should generate: ./test/result/v2/services/ComplexService.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { ModelWithString } from '../models/ModelWithString'; -import { ApiError, catchGenericError } from '../core/ApiError'; -import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; - -export class ComplexService { - - /** - * @param parameterObject Parameter containing object - * @param parameterReference Parameter containing reference - * @result ModelWithString Successful response - * @throws ApiError - */ - public static async complexTypes( - parameterObject: { - first?: { - second?: { - third?: string, - }, - }, - }, - parameterReference: ModelWithString, - ): Promise> { - - const result = await __request({ - method: 'get', - path: \`/api/v\${OpenAPI.VERSION}/complex\`, - query: { - 'parameterObject': parameterObject, - 'parameterReference': parameterReference, - }, - }); - - if (!result.ok) { - switch (result.status) { - case 400: throw new ApiError(result, \`400 server error\`); - case 500: throw new ApiError(result, \`500 server error\`); - } - } - - catchGenericError(result); - - return result.body; - } - -}" -`; - -exports[`v2 should generate: ./test/result/v2/services/DefaultsService.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { ModelWithString } from '../models/ModelWithString'; -import { catchGenericError } from '../core/ApiError'; -import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; - -export class DefaultsService { - - /** - * @param parameterString This is a simple string with default value - * @param parameterNumber This is a simple number with default value - * @param parameterBoolean This is a simple boolean with default value - * @param parameterEnum This is a simple enum with default value - * @param parameterModel This is a simple model with default value - * @throws ApiError - */ - public static async callWithDefaultParameters( - parameterString: string = 'Hello World!', - parameterNumber: number = 123, - parameterBoolean: boolean = true, - parameterEnum: ('Success' | 'Warning' | 'Error') = 'Success', - parameterModel: ModelWithString = { - \\"prop\\": \\"Hello World\\" - }, - ): Promise { - - const result = await __request({ - method: 'get', - path: \`/api/v\${OpenAPI.VERSION}/defaults\`, - query: { - 'parameterString': parameterString, - 'parameterNumber': parameterNumber, - 'parameterBoolean': parameterBoolean, - 'parameterEnum': parameterEnum, - 'parameterModel': parameterModel, - }, - }); - - catchGenericError(result); - - return result.body; - } - - /** - * @param parameterString This is a simple string that is optional with default value - * @param parameterNumber This is a simple number that is optional with default value - * @param parameterBoolean This is a simple boolean that is optional with default value - * @param parameterEnum This is a simple enum that is optional with default value - * @param parameterModel This is a simple model that is optional with default value - * @throws ApiError - */ - public static async callWithDefaultOptionalParameters( - parameterString: string = 'Hello World!', - parameterNumber: number = 123, - parameterBoolean: boolean = true, - parameterEnum: ('Success' | 'Warning' | 'Error') = 'Success', - parameterModel: ModelWithString = { - \\"prop\\": \\"Hello World\\" - }, - ): Promise { - - const result = await __request({ - method: 'post', - path: \`/api/v\${OpenAPI.VERSION}/defaults\`, - query: { - 'parameterString': parameterString, - 'parameterNumber': parameterNumber, - 'parameterBoolean': parameterBoolean, - 'parameterEnum': parameterEnum, - 'parameterModel': parameterModel, - }, - }); - - catchGenericError(result); - - return result.body; - } - - /** - * @param parameterStringWithNoDefault This is a string with no default - * @param parameterOptionalStringWithDefault This is a optional string with default - * @param parameterOptionalStringWithEmptyDefault This is a optional string with empty default - * @param parameterOptionalStringWithNoDefault This is a optional string with no default - * @param parameterStringWithDefault This is a string with default - * @param parameterStringWithEmptyDefault This is a string with empty default - * @throws ApiError - */ - public static async callToTestOrderOfParams( - parameterStringWithNoDefault: string, - parameterOptionalStringWithDefault: string = 'Hello World!', - parameterOptionalStringWithEmptyDefault: string = '', - parameterOptionalStringWithNoDefault?: string, - parameterStringWithDefault: string = 'hello', - parameterStringWithEmptyDefault: string = '', - ): Promise { - - const result = await __request({ - method: 'put', - path: \`/api/v\${OpenAPI.VERSION}/defaults\`, - query: { - 'parameterStringWithNoDefault': parameterStringWithNoDefault, - 'parameterOptionalStringWithDefault': parameterOptionalStringWithDefault, - 'parameterOptionalStringWithEmptyDefault': parameterOptionalStringWithEmptyDefault, - 'parameterOptionalStringWithNoDefault': parameterOptionalStringWithNoDefault, - 'parameterStringWithDefault': parameterStringWithDefault, - 'parameterStringWithEmptyDefault': parameterStringWithEmptyDefault, - }, - }); - - catchGenericError(result); - - return result.body; - } - -}" -`; - -exports[`v2 should generate: ./test/result/v2/services/DuplicateService.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { catchGenericError } from '../core/ApiError'; -import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; - -export class DuplicateService { - - /** - * @throws ApiError - */ - public static async duplicateName(): Promise { - - const result = await __request({ - method: 'get', - path: \`/api/v\${OpenAPI.VERSION}/duplicate\`, - }); - - catchGenericError(result); - - return result.body; - } - - /** - * @throws ApiError - */ - public static async duplicateName1(): Promise { - - const result = await __request({ - method: 'post', - path: \`/api/v\${OpenAPI.VERSION}/duplicate\`, - }); - - catchGenericError(result); - - return result.body; - } - - /** - * @throws ApiError - */ - public static async duplicateName2(): Promise { - - const result = await __request({ - method: 'put', - path: \`/api/v\${OpenAPI.VERSION}/duplicate\`, - }); - - catchGenericError(result); - - return result.body; - } - - /** - * @throws ApiError - */ - public static async duplicateName3(): Promise { - - const result = await __request({ - method: 'delete', - path: \`/api/v\${OpenAPI.VERSION}/duplicate\`, - }); - - catchGenericError(result); - - return result.body; - } - -}" -`; - -exports[`v2 should generate: ./test/result/v2/services/HeaderService.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { ApiError, catchGenericError } from '../core/ApiError'; -import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; - -export class HeaderService { - - /** - * @result string Successful response - * @throws ApiError - */ - public static async callWithResultFromHeader(): Promise { - - const result = await __request({ - method: 'post', - path: \`/api/v\${OpenAPI.VERSION}/header\`, - responseHeader: 'operation-location', - }); - - if (!result.ok) { - switch (result.status) { - case 400: throw new ApiError(result, \`400 server error\`); - case 500: throw new ApiError(result, \`500 server error\`); - } - } - - catchGenericError(result); - - return result.body; - } - -}" -`; - -exports[`v2 should generate: ./test/result/v2/services/ParametersService.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { catchGenericError } from '../core/ApiError'; -import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; - -export class ParametersService { - - /** - * @param parameterHeader This is the parameter that goes into the header - * @param parameterQuery This is the parameter that goes into the query params - * @param parameterForm This is the parameter that goes into the form data - * @param parameterBody This is the parameter that is send as request body - * @param parameterPath This is the parameter that goes into the path - * @throws ApiError - */ - public static async callWithParameters( - parameterHeader: string, - parameterQuery: string, - parameterForm: string, - parameterBody: string, - parameterPath: string, - ): Promise { - - const result = await __request({ - method: 'get', - path: \`/api/v\${OpenAPI.VERSION}/parameters/\${parameterPath}\`, - headers: { - 'parameterHeader': parameterHeader, - }, - query: { - 'parameterQuery': parameterQuery, - }, - formData: { - 'parameterForm': parameterForm, - }, - body: parameterBody, - }); - - catchGenericError(result); - - return result.body; - } - - /** - * @param parameterHeader This is the parameter that goes into the request header - * @param parameterQuery This is the parameter that goes into the request query params - * @param parameterForm This is the parameter that goes into the request form data - * @param parameterBody This is the parameter that is send as request body - * @param parameterPath1 This is the parameter that goes into the path - * @param parameterPath2 This is the parameter that goes into the path - * @param parameterPath3 This is the parameter that goes into the path - * @throws ApiError - */ - public static async callWithWeirdParameterNames( - parameterHeader: string, - parameterQuery: string, - parameterForm: string, - parameterBody: string, - parameterPath1?: string, - parameterPath2?: string, - parameterPath3?: string, - ): Promise { - - const result = await __request({ - method: 'get', - path: \`/api/v\${OpenAPI.VERSION}/parameters/\${parameterPath1}/\${parameterPath2}/\${parameterPath3}\`, - headers: { - 'parameter.header': parameterHeader, - }, - query: { - 'parameter-query': parameterQuery, - }, - formData: { - 'parameter_form': parameterForm, - }, - body: parameterBody, - }); - - catchGenericError(result); - - return result.body; - } - -}" -`; - -exports[`v2 should generate: ./test/result/v2/services/ResponseService.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { ModelThatExtends } from '../models/ModelThatExtends'; -import { ModelThatExtendsExtends } from '../models/ModelThatExtendsExtends'; -import { ModelWithString } from '../models/ModelWithString'; -import { ApiError, catchGenericError } from '../core/ApiError'; -import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; - -export class ResponseService { - - /** - * @result ModelWithString Message for default response - * @throws ApiError - */ - public static async callWithResponse(): Promise { - - const result = await __request({ - method: 'get', - path: \`/api/v\${OpenAPI.VERSION}/response\`, - }); - - catchGenericError(result); - - return result.body; - } - - /** - * @result ModelWithString Message for default response - * @throws ApiError - */ - public static async callWithDuplicateResponses(): Promise { - - const result = await __request({ - method: 'post', - path: \`/api/v\${OpenAPI.VERSION}/response\`, - }); - - if (!result.ok) { - switch (result.status) { - case 500: throw new ApiError(result, \`Message for 500 error\`); - case 501: throw new ApiError(result, \`Message for 501 error\`); - case 502: throw new ApiError(result, \`Message for 502 error\`); - } - } - - catchGenericError(result); - - return result.body; - } - - /** - * @result ModelWithString Message for default response - * @result ModelThatExtends Message for 201 response - * @result ModelThatExtendsExtends Message for 202 response - * @throws ApiError - */ - public static async callWithResponses(): Promise { - - const result = await __request({ - method: 'put', - path: \`/api/v\${OpenAPI.VERSION}/response\`, - }); - - if (!result.ok) { - switch (result.status) { - case 500: throw new ApiError(result, \`Message for 500 error\`); - case 501: throw new ApiError(result, \`Message for 501 error\`); - case 502: throw new ApiError(result, \`Message for 502 error\`); - } - } - - catchGenericError(result); - - return result.body; - } - -}" -`; - -exports[`v2 should generate: ./test/result/v2/services/SimpleService.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { catchGenericError } from '../core/ApiError'; -import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; - -export class SimpleService { - - /** - * @throws ApiError - */ - public static async getCallWithoutParametersAndResponse(): Promise { - - const result = await __request({ - method: 'get', - path: \`/api/v\${OpenAPI.VERSION}/simple\`, - }); - - catchGenericError(result); - - return result.body; - } - - /** - * @throws ApiError - */ - public static async putCallWithoutParametersAndResponse(): Promise { - - const result = await __request({ - method: 'put', - path: \`/api/v\${OpenAPI.VERSION}/simple\`, - }); - - catchGenericError(result); - - return result.body; - } - - /** - * @throws ApiError - */ - public static async postCallWithoutParametersAndResponse(): Promise { - - const result = await __request({ - method: 'post', - path: \`/api/v\${OpenAPI.VERSION}/simple\`, - }); - - catchGenericError(result); - - return result.body; - } - - /** - * @throws ApiError - */ - public static async deleteCallWithoutParametersAndResponse(): Promise { - - const result = await __request({ - method: 'delete', - path: \`/api/v\${OpenAPI.VERSION}/simple\`, - }); - - catchGenericError(result); - - return result.body; - } - - /** - * @throws ApiError - */ - public static async optionsCallWithoutParametersAndResponse(): Promise { - - const result = await __request({ - method: 'options', - path: \`/api/v\${OpenAPI.VERSION}/simple\`, - }); - - catchGenericError(result); - - return result.body; - } - - /** - * @throws ApiError - */ - public static async headCallWithoutParametersAndResponse(): Promise { - - const result = await __request({ - method: 'head', - path: \`/api/v\${OpenAPI.VERSION}/simple\`, - }); - - catchGenericError(result); - - return result.body; - } - - /** - * @throws ApiError - */ - public static async patchCallWithoutParametersAndResponse(): Promise { - - const result = await __request({ - method: 'patch', - path: \`/api/v\${OpenAPI.VERSION}/simple\`, - }); - - catchGenericError(result); - - return result.body; - } - -}" -`; - -exports[`v2 should generate: ./test/result/v2/services/TypesService.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { Dictionary } from '../models/Dictionary'; -import { catchGenericError } from '../core/ApiError'; -import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; - -export class TypesService { - - /** - * @param parameterArray This is an array parameter - * @param parameterDictionary This is a dictionary parameter - * @param parameterEnum This is an enum parameter - * @param parameterNumber This is a number parameter - * @param parameterString This is a string parameter - * @param parameterBoolean This is a boolean parameter - * @param parameterObject This is an object parameter - * @param id This is a number parameter - * @result number Response is a simple number - * @result string Response is a simple string - * @result boolean Response is a simple boolean - * @result any Response is a simple object - * @throws ApiError - */ - public static async types( - parameterArray: Array, - parameterDictionary: Dictionary, - parameterEnum: ('Success' | 'Warning' | 'Error'), - parameterNumber: number = 123, - parameterString: string = 'default', - parameterBoolean: boolean = true, - parameterObject: any = null, - id?: number, - ): Promise { - - const result = await __request({ - method: 'get', - path: \`/api/v\${OpenAPI.VERSION}/types\`, - query: { - 'parameterArray': parameterArray, - 'parameterDictionary': parameterDictionary, - 'parameterEnum': parameterEnum, - 'parameterNumber': parameterNumber, - 'parameterString': parameterString, - 'parameterBoolean': parameterBoolean, - 'parameterObject': parameterObject, - }, - }); - - catchGenericError(result); - - return result.body; - } - -}" -`; - -exports[`v3 should generate: ./test/result/v3/core/ApiError.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { isSuccess } from './isSuccess'; -import { Result } from './Result'; - -export class ApiError extends Error { - - public readonly url: string; - public readonly status: number; - public readonly statusText: string; - public readonly body: any; - - constructor(result: Readonly, message: string) { - super(message); - - this.url = result.url; - this.status = result.status; - this.statusText = result.statusText; - this.body = result.body; - } -} - -export namespace ApiError { - export enum Message { - BAD_REQUEST = 'Bad Request', - UNAUTHORIZED = 'Unauthorized', - FORBIDDEN = 'Forbidden', - NOT_FOUND = 'Not Found', - INTERNAL_SERVER_ERROR = 'Internal Server Error', - BAD_GATEWAY = 'Bad Gateway', - SERVICE_UNAVAILABLE = 'Service Unavailable', - GENERIC_ERROR = 'Generic Error', - } -} - -/** - * Catch common errors (based on status code). - * @param result - */ -export function catchGenericError(result: Result): void { - switch (result.status) { - case 400: throw new ApiError(result, ApiError.Message.BAD_REQUEST); - case 401: throw new ApiError(result, ApiError.Message.UNAUTHORIZED); - case 403: throw new ApiError(result, ApiError.Message.FORBIDDEN); - case 404: throw new ApiError(result, ApiError.Message.NOT_FOUND); - case 500: throw new ApiError(result, ApiError.Message.INTERNAL_SERVER_ERROR); - case 502: throw new ApiError(result, ApiError.Message.BAD_GATEWAY); - case 503: throw new ApiError(result, ApiError.Message.SERVICE_UNAVAILABLE); - } - - if (!isSuccess(result.status)) { - throw new ApiError(result, ApiError.Message.GENERIC_ERROR); - } -} -" -`; - -exports[`v3 should generate: ./test/result/v3/core/OpenAPI.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -interface Config { - BASE: string; - VERSION: string; - CLIENT: 'fetch' | 'xhr'; - WITH_CREDENTIALS: boolean; - TOKEN: string; -} - -export const OpenAPI: Config = { - BASE: '/api', - VERSION: '1', - CLIENT: 'fetch', - WITH_CREDENTIALS: false, - TOKEN: '', -};" -`; - -exports[`v3 should generate: ./test/result/v3/core/RequestOptions.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export interface RequestOptions { - method: 'get' | 'put' | 'post' | 'delete' | 'options' | 'head' | 'patch'; - path: string; - cookies?: { [key: string]: any }; - headers?: { [key: string]: any }; - query?: { [key: string]: any }; - formData?: { [key: string]: any }; - body?: any; - responseHeader?: string; -} -" -`; - -exports[`v3 should generate: ./test/result/v3/core/Result.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export interface Result { - url: string; - ok: boolean; - status: number; - statusText: string; - body: any; -} -" -`; - -exports[`v3 should generate: ./test/result/v3/core/getFormData.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -/** - * Get FormData from object. This method is needed to upload - * multipart form data to the REST API. - * @param params Key value based object. - */ -export function getFormData(params: { [key: string]: any }): FormData { - const formData = new FormData(); - for (const key in params) { - if (typeof params[key] !== 'undefined') { - const value: any = params[key]; - if (value !== undefined && value !== null) { - formData.append(key, value); - } - } - } - return formData; -} -" -`; - -exports[`v3 should generate: ./test/result/v3/core/getQueryString.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -/** - * Get query string from query parameters object. This method also - * supports multi-value items by creating a key for each item. - * @param params Key value based object. - */ -export function getQueryString(params: { [key: string]: any }): string { - const qs: string[] = []; - for (const key in params) { - if (typeof params[key] !== 'undefined') { - const value: any = params[key]; - if (value !== undefined && value !== null) { - if (Array.isArray(value)) { - value.forEach(value => { - qs.push(\`\${encodeURIComponent(key)}=\${encodeURIComponent(String(value))}\`); - }); - } else { - qs.push(\`\${encodeURIComponent(key)}=\${encodeURIComponent(String(value))}\`); - } - } - } - } - if (qs.length > 0) { - return \`?\${qs.join('&')}\`; - } - return ''; -} -" -`; - -exports[`v3 should generate: ./test/result/v3/core/isSuccess.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -/** - * Check success response code. - * @param status Status code - */ -export function isSuccess(status: number): boolean { - return status >= 200 && status < 300; -} -" -`; - -exports[`v3 should generate: ./test/result/v3/core/request.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { getFormData } from './getFormData'; -import { getQueryString } from './getQueryString'; -import { OpenAPI } from './OpenAPI'; -import { RequestOptions } from './RequestOptions'; -import { requestUsingFetch } from './requestUsingFetch'; -import { requestUsingXHR } from './requestUsingXHR'; -import { Result } from './Result'; - -/** - * Create the request. - * @param options Request method options. - * @returns Result object (see above) - */ -export async function request(options: Readonly): Promise { - - // Escape path (RFC3986) and create the request URL - let path = options.path.replace(/[:]/g, '_'); - let url = \`\${OpenAPI.BASE}\${path}\`; - - // Create request headers - const headers = new Headers({ - ...options.headers, - Accept: 'application/json', - }); - - // Create request settings - const request: RequestInit = { - headers, - method: options.method, - }; - - // If we specified to send requests with credentials, then we - // set the request credentials options to include. This is only - // needed if you make cross-origin calls. - if (OpenAPI.WITH_CREDENTIALS) { - request.credentials = 'include'; - } - - // If we have a bearer token then we set the authentication header. - if (OpenAPI.TOKEN !== null && OpenAPI.TOKEN !== '') { - headers.append('Authorization', \`Bearer \${OpenAPI.TOKEN}\`); - } - - // Add the query parameters (if defined). - if (options.query) { - url += getQueryString(options.query); - } - - // Append formData as body - if (options.formData) { - request.body = getFormData(options.formData); - } else if (options.body) { - - // If this is blob data, then pass it directly to the body and set content type. - // Otherwise we just convert request data to JSON string (needed for fetch api) - if (options.body instanceof Blob) { - request.body = options.body; - if (options.body.type) { - headers.append('Content-Type', options.body.type); - } - } else { - request.body = JSON.stringify(options.body); - headers.append('Content-Type', 'application/json'); - } - } - - try { - switch (OpenAPI.CLIENT) { - case 'xhr': - return await requestUsingXHR(url, request, options.responseHeader); - default: - return await requestUsingFetch(url, request, options.responseHeader); - } - } catch (error) { - return { - url, - ok: false, - status: 0, - statusText: '', - body: error, - }; - } -} -" -`; - -exports[`v3 should generate: ./test/result/v3/core/requestUsingFetch.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { Result } from './Result'; - -/** - * Try to parse the content for any response status code. - * We check the \\"Content-Type\\" header to see if we need to parse the - * content as json or as plain text. - * @param response Response object from fetch - */ -async function parseBody(response: Response): Promise { - try { - const contentType = response.headers.get('Content-Type'); - if (contentType) { - switch (contentType.toLowerCase()) { - case 'application/json': - case 'application/json; charset=utf-8': - return await response.json(); - - default: - return await response.text(); - } - } - } catch (e) { - console.error(e); - } - return null; -} - -/** - * Fetch the response header (if specified) - * @param response Response object from fetch - * @param responseHeader The name of the header to fetch - */ -function parseHeader(response: Response, responseHeader?: string): string | null { - if (responseHeader) { - const content = response.headers.get(responseHeader); - if (typeof content === 'string') { - return content; - } - } - return null; -} - -/** - * Request content using the new Fetch API. This is the default API that is used and - * is create for all JSON, XML and text objects. However it is limited to UTF-8. - * This is a problem for some of the Docs content, since that requires UTF-16! - * @param url The url to request. - * @param request The request object, containing method, headers, body, etc. - * @param responseHeader The header we want to parse. - */ -export async function requestUsingFetch(url: string, request: Readonly, responseHeader?: string): Promise { - - // Fetch response using fetch API. - const response = await fetch(url, request); - - // Get content of response header or response body - const contentHeader = parseHeader(response, responseHeader); - const contentBody = await parseBody(response); - - // Create result object. - return { - url, - ok: response.ok, - status: response.status, - statusText: response.statusText, - body: contentHeader || contentBody, - }; -} -" -`; - -exports[`v3 should generate: ./test/result/v3/core/requestUsingXHR.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { isSuccess } from './isSuccess'; -import { Result } from './Result'; - -/** - * Try to parse the content for any response status code. - * We check the \\"Content-Type\\" header to see if we need to parse the - * content as json or as plain text. - * @param xhr XHR request object - */ -function parseBody(xhr: XMLHttpRequest): any { - try { - const contentType = xhr.getResponseHeader('Content-Type'); - if (contentType) { - switch (contentType.toLowerCase()) { - case 'application/json': - case 'application/json; charset=utf-8': - return JSON.parse(xhr.responseText); - - default: - return xhr.responseText; - } - } - } catch (e) { - console.error(e); - } - return null; -} - -/** - * Fetch the response header (if specified) - * @param xhr XHR request object - * @param responseHeader The name of the header to fetch - */ -function parseHeader(xhr: XMLHttpRequest, responseHeader?: string): string | null { - if (responseHeader) { - const content = xhr.getResponseHeader(responseHeader); - if (typeof content === 'string') { - return content; - } - } - return null; -} - -/** - * Request content using the new legacy XMLHttpRequest API. This method is useful - * when we want to request UTF-16 content, since it natively supports loading UTF-16. - * We could do the same with the Fetch API, but then we will need to convert the - * content using JavaScript... And that is very very slow. - * @param url The url to request. - * @param request The request object, containing method, headers, body, etc. - * @param responseHeader The header we want to parse. - */ -export async function requestUsingXHR(url: string, request: Readonly, responseHeader?: string): Promise { - return new Promise(resolve => { - const xhr = new XMLHttpRequest(); - - // Open the request, remember to do this before adding any headers, - // because the request needs to be initialized! - xhr.open(request.method!, url, true); - - // When request credentials are set to include then this is - // the same behaviour as withCredentials = true in XHR: - // https://developer.mozilla.org/en-US/docs/Web/API/Request/credentials - xhr.withCredentials = request.credentials === 'include'; - - // Add the headers (required when dealing with JSON) - const headers = request.headers as Headers; - headers.forEach((value: string, key: string): void => { - xhr.setRequestHeader(key, value); - }); - - // Register the readystate handler, this will fire when the request is done. - xhr.onreadystatechange = () => { - if (xhr.readyState === XMLHttpRequest.DONE) { - - // Get content of response header or response body - const contentHeader = parseHeader(xhr, responseHeader); - const contentBody = parseBody(xhr); - - // Create result object. - const result: Result = { - url, - ok: isSuccess(xhr.status), - status: xhr.status, - statusText: xhr.statusText, - body: contentHeader || contentBody, - }; - - // Done! - resolve(result); - } - }; - - // Start the request! - xhr.send(request.body); - }); -} -" -`; - -exports[`v3 should generate: ./test/result/v3/index.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export { ApiError } from './core/ApiError'; -export { isSuccess } from './core/isSuccess'; -export { OpenAPI } from './core/OpenAPI'; - -export type { ArrayWithArray } from './models/ArrayWithArray'; -export type { ArrayWithBooleans } from './models/ArrayWithBooleans'; -export type { ArrayWithNumbers } from './models/ArrayWithNumbers'; -export type { ArrayWithProperties } from './models/ArrayWithProperties'; -export type { ArrayWithReferences } from './models/ArrayWithReferences'; -export type { ArrayWithStrings } from './models/ArrayWithStrings'; -export type { DictionaryWithArray } from './models/DictionaryWithArray'; -export type { DictionaryWithDictionary } from './models/DictionaryWithDictionary'; -export type { DictionaryWithProperties } from './models/DictionaryWithProperties'; -export type { DictionaryWithReference } from './models/DictionaryWithReference'; -export type { DictionaryWithString } from './models/DictionaryWithString'; -export { EnumFromDescription } from './models/EnumFromDescription'; -export { EnumWithExtensions } from './models/EnumWithExtensions'; -export { EnumWithNumbers } from './models/EnumWithNumbers'; -export { EnumWithStrings } from './models/EnumWithStrings'; -export type { ModelLink } from './models/ModelLink'; -export type { ModelThatExtends } from './models/ModelThatExtends'; -export type { ModelThatExtendsExtends } from './models/ModelThatExtendsExtends'; -export type { ModelWithAnyOf } from './models/ModelWithAnyOf'; -export type { ModelWithArray } from './models/ModelWithArray'; -export type { ModelWithBoolean } from './models/ModelWithBoolean'; -export type { ModelWithCircularReference } from './models/ModelWithCircularReference'; -export type { ModelWithDictionary } from './models/ModelWithDictionary'; -export type { ModelWithDuplicateImports } from './models/ModelWithDuplicateImports'; -export type { ModelWithDuplicateProperties } from './models/ModelWithDuplicateProperties'; -export { ModelWithEnum } from './models/ModelWithEnum'; -export { ModelWithEnumFromDescription } from './models/ModelWithEnumFromDescription'; -export type { ModelWithInteger } from './models/ModelWithInteger'; -export type { ModelWithLink } from './models/ModelWithLink'; -export type { ModelWithNestedEnums } from './models/ModelWithNestedEnums'; -export type { ModelWithNestedProperties } from './models/ModelWithNestedProperties'; -export type { ModelWithOneOf } from './models/ModelWithOneOf'; -export type { ModelWithOrderedProperties } from './models/ModelWithOrderedProperties'; -export type { ModelWithPattern } from './models/ModelWithPattern'; -export type { ModelWithProperties } from './models/ModelWithProperties'; -export type { ModelWithReference } from './models/ModelWithReference'; -export type { ModelWithString } from './models/ModelWithString'; -export type { MultilineComment } from './models/MultilineComment'; -export type { SimpleBoolean } from './models/SimpleBoolean'; -export type { SimpleFile } from './models/SimpleFile'; -export type { SimpleInteger } from './models/SimpleInteger'; -export type { SimpleReference } from './models/SimpleReference'; -export type { SimpleString } from './models/SimpleString'; - -export { $ArrayWithArray } from './schemas/$ArrayWithArray'; -export { $ArrayWithBooleans } from './schemas/$ArrayWithBooleans'; -export { $ArrayWithNumbers } from './schemas/$ArrayWithNumbers'; -export { $ArrayWithProperties } from './schemas/$ArrayWithProperties'; -export { $ArrayWithReferences } from './schemas/$ArrayWithReferences'; -export { $ArrayWithStrings } from './schemas/$ArrayWithStrings'; -export { $DictionaryWithArray } from './schemas/$DictionaryWithArray'; -export { $DictionaryWithDictionary } from './schemas/$DictionaryWithDictionary'; -export { $DictionaryWithProperties } from './schemas/$DictionaryWithProperties'; -export { $DictionaryWithReference } from './schemas/$DictionaryWithReference'; -export { $DictionaryWithString } from './schemas/$DictionaryWithString'; -export { $EnumFromDescription } from './schemas/$EnumFromDescription'; -export { $EnumWithExtensions } from './schemas/$EnumWithExtensions'; -export { $EnumWithNumbers } from './schemas/$EnumWithNumbers'; -export { $EnumWithStrings } from './schemas/$EnumWithStrings'; -export { $ModelLink } from './schemas/$ModelLink'; -export { $ModelThatExtends } from './schemas/$ModelThatExtends'; -export { $ModelThatExtendsExtends } from './schemas/$ModelThatExtendsExtends'; -export { $ModelWithAnyOf } from './schemas/$ModelWithAnyOf'; -export { $ModelWithArray } from './schemas/$ModelWithArray'; -export { $ModelWithBoolean } from './schemas/$ModelWithBoolean'; -export { $ModelWithCircularReference } from './schemas/$ModelWithCircularReference'; -export { $ModelWithDictionary } from './schemas/$ModelWithDictionary'; -export { $ModelWithDuplicateImports } from './schemas/$ModelWithDuplicateImports'; -export { $ModelWithDuplicateProperties } from './schemas/$ModelWithDuplicateProperties'; -export { $ModelWithEnum } from './schemas/$ModelWithEnum'; -export { $ModelWithEnumFromDescription } from './schemas/$ModelWithEnumFromDescription'; -export { $ModelWithInteger } from './schemas/$ModelWithInteger'; -export { $ModelWithLink } from './schemas/$ModelWithLink'; -export { $ModelWithNestedEnums } from './schemas/$ModelWithNestedEnums'; -export { $ModelWithNestedProperties } from './schemas/$ModelWithNestedProperties'; -export { $ModelWithOneOf } from './schemas/$ModelWithOneOf'; -export { $ModelWithOrderedProperties } from './schemas/$ModelWithOrderedProperties'; -export { $ModelWithPattern } from './schemas/$ModelWithPattern'; -export { $ModelWithProperties } from './schemas/$ModelWithProperties'; -export { $ModelWithReference } from './schemas/$ModelWithReference'; -export { $ModelWithString } from './schemas/$ModelWithString'; -export { $MultilineComment } from './schemas/$MultilineComment'; -export { $SimpleBoolean } from './schemas/$SimpleBoolean'; -export { $SimpleFile } from './schemas/$SimpleFile'; -export { $SimpleInteger } from './schemas/$SimpleInteger'; -export { $SimpleReference } from './schemas/$SimpleReference'; -export { $SimpleString } from './schemas/$SimpleString'; - -export { ComplexService } from './services/ComplexService'; -export { DefaultsService } from './services/DefaultsService'; -export { DuplicateService } from './services/DuplicateService'; -export { HeaderService } from './services/HeaderService'; -export { MultipartService } from './services/MultipartService'; -export { ParametersService } from './services/ParametersService'; -export { ResponseService } from './services/ResponseService'; -export { SimpleService } from './services/SimpleService'; -export { TypesService } from './services/TypesService'; -export { UploadService } from './services/UploadService'; -" -`; - -exports[`v3 should generate: ./test/result/v3/models/ArrayWithArray.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { ModelWithString } from './ModelWithString'; - -/** - * This is a simple array containing an array - */ -export type ArrayWithArray = Array>;" -`; - -exports[`v3 should generate: ./test/result/v3/models/ArrayWithBooleans.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - - -/** - * This is a simple array with booleans - */ -export type ArrayWithBooleans = Array;" -`; - -exports[`v3 should generate: ./test/result/v3/models/ArrayWithNumbers.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - - -/** - * This is a simple array with numbers - */ -export type ArrayWithNumbers = Array;" -`; - -exports[`v3 should generate: ./test/result/v3/models/ArrayWithProperties.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - - -/** - * This is a simple array with properties - */ -export type ArrayWithProperties = Array<{ - foo?: string, - bar?: string, -}>;" -`; - -exports[`v3 should generate: ./test/result/v3/models/ArrayWithReferences.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { ModelWithString } from './ModelWithString'; - -/** - * This is a simple array with references - */ -export type ArrayWithReferences = Array;" -`; - -exports[`v3 should generate: ./test/result/v3/models/ArrayWithStrings.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - - -/** - * This is a simple array with strings - */ -export type ArrayWithStrings = Array;" -`; - -exports[`v3 should generate: ./test/result/v3/models/Dictionary.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export type Dictionary = { - [key: string]: T; -} -" -`; - -exports[`v3 should generate: ./test/result/v3/models/DictionaryWithArray.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { Dictionary } from './Dictionary'; -import { ModelWithString } from './ModelWithString'; - -/** - * This is a complex dictionary - */ -export type DictionaryWithArray = Dictionary>;" -`; - -exports[`v3 should generate: ./test/result/v3/models/DictionaryWithDictionary.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { Dictionary } from './Dictionary'; - -/** - * This is a string dictionary - */ -export type DictionaryWithDictionary = Dictionary>;" -`; - -exports[`v3 should generate: ./test/result/v3/models/DictionaryWithProperties.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { Dictionary } from './Dictionary'; - -/** - * This is a complex dictionary - */ -export type DictionaryWithProperties = Dictionary<{ - foo?: string, - bar?: string, -}>;" -`; - -exports[`v3 should generate: ./test/result/v3/models/DictionaryWithReference.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { Dictionary } from './Dictionary'; -import { ModelWithString } from './ModelWithString'; - -/** - * This is a string reference - */ -export type DictionaryWithReference = Dictionary;" -`; - -exports[`v3 should generate: ./test/result/v3/models/DictionaryWithString.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { Dictionary } from './Dictionary'; - -/** - * This is a string dictionary - */ -export type DictionaryWithString = Dictionary;" -`; - -exports[`v3 should generate: ./test/result/v3/models/EnumFromDescription.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - - -/** - * Success=1,Warning=2,Error=3 - */ -export enum EnumFromDescription { - SUCCESS = 1, - WARNING = 2, - ERROR = 3, -}" -`; - -exports[`v3 should generate: ./test/result/v3/models/EnumWithExtensions.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - - -/** - * This is a simple enum with numbers - */ -export enum EnumWithExtensions { - /** - * Used when the status of something is successful - */ - CUSTOM_SUCCESS = 200, - /** - * Used when the status of something has a warning - */ - CUSTOM_WARNING = 400, - /** - * Used when the status of something has an error - */ - CUSTOM_ERROR = 500, -}" -`; - -exports[`v3 should generate: ./test/result/v3/models/EnumWithNumbers.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - - -/** - * This is a simple enum with numbers - */ -export enum EnumWithNumbers { - _1 = 1, - _2 = 2, - _3 = 3, -}" -`; - -exports[`v3 should generate: ./test/result/v3/models/EnumWithStrings.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - - -/** - * This is a simple enum with strings - */ -export enum EnumWithStrings { - SUCCESS = 'Success', - WARNING = 'Warning', - ERROR = 'Error', -}" -`; - -exports[`v3 should generate: ./test/result/v3/models/ModelLink.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - - -/** - * This is a model that can have a template?? - */ -export interface ModelLink { - id?: string; -} -" -`; - -exports[`v3 should generate: ./test/result/v3/models/ModelThatExtends.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { ModelWithString } from './ModelWithString'; - -/** - * This is a model that extends another model - */ -export interface ModelThatExtends extends ModelWithString { - propExtendsA?: string; - propExtendsB?: ModelWithString; -} -" -`; - -exports[`v3 should generate: ./test/result/v3/models/ModelThatExtendsExtends.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { ModelThatExtends } from './ModelThatExtends'; -import { ModelWithString } from './ModelWithString'; - -/** - * This is a model that extends another model - */ -export interface ModelThatExtendsExtends extends ModelWithString, ModelThatExtends { - propExtendsC?: string; - propExtendsD?: ModelWithString; -} -" -`; - -exports[`v3 should generate: ./test/result/v3/models/ModelWithAnyOf.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { ModelWithArray } from './ModelWithArray'; -import { ModelWithDictionary } from './ModelWithDictionary'; -import { ModelWithEnum } from './ModelWithEnum'; -import { ModelWithString } from './ModelWithString'; - -/** - * This is a model with one property with a 'any of' relationship - */ -export interface ModelWithAnyOf { - propA?: ModelWithArray | ModelWithDictionary | ModelWithEnum | ModelWithString; -} -" -`; - -exports[`v3 should generate: ./test/result/v3/models/ModelWithArray.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { ModelWithString } from './ModelWithString'; - -/** - * This is a model with one property containing an array - */ -export interface ModelWithArray { - prop?: Array; - propWithFile?: Array; - propWithNumber?: Array; -} -" -`; - -exports[`v3 should generate: ./test/result/v3/models/ModelWithBoolean.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - - -/** - * This is a model with one boolean property - */ -export interface ModelWithBoolean { - /** - * This is a simple boolean property - */ - prop?: boolean; -} -" -`; - -exports[`v3 should generate: ./test/result/v3/models/ModelWithCircularReference.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - - -/** - * This is a model with one property containing a circular reference - */ -export interface ModelWithCircularReference { - prop?: ModelWithCircularReference; -} -" -`; - -exports[`v3 should generate: ./test/result/v3/models/ModelWithDictionary.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { Dictionary } from './Dictionary'; - -/** - * This is a model with one property containing a dictionary - */ -export interface ModelWithDictionary { - prop?: Dictionary; -} -" -`; - -exports[`v3 should generate: ./test/result/v3/models/ModelWithDuplicateImports.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { ModelWithString } from './ModelWithString'; - -/** - * This is a model with duplicated imports - */ -export interface ModelWithDuplicateImports { - propA?: ModelWithString; - propB?: ModelWithString; - propC?: ModelWithString; -} -" -`; - -exports[`v3 should generate: ./test/result/v3/models/ModelWithDuplicateProperties.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { ModelWithString } from './ModelWithString'; - -/** - * This is a model with duplicated properties - */ -export interface ModelWithDuplicateProperties { - prop?: ModelWithString; -} -" -`; - -exports[`v3 should generate: ./test/result/v3/models/ModelWithEnum.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - - -/** - * This is a model with one enum - */ -export interface ModelWithEnum { - /** - * This is a simple enum with strings - */ - test?: ModelWithEnum.test; - /** - * These are the HTTP error code enums - */ - statusCode?: ModelWithEnum.statusCode; -} - -export namespace ModelWithEnum { - - /** - * This is a simple enum with strings - */ - export enum test { - SUCCESS = 'Success', - WARNING = 'Warning', - ERROR = 'Error', - } - - /** - * These are the HTTP error code enums - */ - export enum statusCode { - _100 = '100', - _200_FOO = '200 FOO', - _300_FOO_BAR = '300 FOO_BAR', - _400_FOO_BAR = '400 foo-bar', - _500_FOO_BAR = '500 foo.bar', - _600_FOO_BAR = '600 foo&bar', - } - - -} -" -`; - -exports[`v3 should generate: ./test/result/v3/models/ModelWithEnumFromDescription.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - - -/** - * This is a model with one enum - */ -export interface ModelWithEnumFromDescription { - /** - * Success=1,Warning=2,Error=3 - */ - test?: ModelWithEnumFromDescription.test; -} - -export namespace ModelWithEnumFromDescription { - - /** - * Success=1,Warning=2,Error=3 - */ - export enum test { - SUCCESS = 1, - WARNING = 2, - ERROR = 3, - } - - -} -" -`; - -exports[`v3 should generate: ./test/result/v3/models/ModelWithInteger.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - - -/** - * This is a model with one number property - */ -export interface ModelWithInteger { - /** - * This is a simple number property - */ - prop?: number; -} -" -`; - -exports[`v3 should generate: ./test/result/v3/models/ModelWithLink.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { ModelLink } from './ModelLink'; -import { ModelWithString } from './ModelWithString'; - -/** - * This is a model that can have a template?? - */ -export interface ModelWithLink { - prop?: ModelLink; -} -" -`; - -exports[`v3 should generate: ./test/result/v3/models/ModelWithNestedEnums.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { Dictionary } from './Dictionary'; - -/** - * This is a model with nested enums - */ -export interface ModelWithNestedEnums { - dictionaryWithEnum?: Dictionary<('Success' | 'Warning' | 'Error')>; - dictionaryWithEnumFromDescription?: Dictionary<(1 | 2 | 3)>; - arrayWithEnum?: Array<('Success' | 'Warning' | 'Error')>; - arrayWithDescription?: Array<(1 | 2 | 3)>; -} -" -`; - -exports[`v3 should generate: ./test/result/v3/models/ModelWithNestedProperties.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - - -/** - * This is a model with one nested property - */ -export interface ModelWithNestedProperties { - readonly first: { - readonly second: { - readonly third: string | null, - } | null, - } | null; -} -" -`; - -exports[`v3 should generate: ./test/result/v3/models/ModelWithOneOf.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { ModelWithArray } from './ModelWithArray'; -import { ModelWithDictionary } from './ModelWithDictionary'; -import { ModelWithEnum } from './ModelWithEnum'; -import { ModelWithString } from './ModelWithString'; - -/** - * This is a model with one property with a 'one of' relationship - */ -export interface ModelWithOneOf { - propA?: ModelWithArray | ModelWithDictionary | ModelWithEnum | ModelWithString; -} -" -`; - -exports[`v3 should generate: ./test/result/v3/models/ModelWithOrderedProperties.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - - -/** - * This is a model with ordered properties - */ -export interface ModelWithOrderedProperties { - zebra?: string; - apple?: string; - hawaii?: string; -} -" -`; - -exports[`v3 should generate: ./test/result/v3/models/ModelWithPattern.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - - -/** - * This is a model that contains a some patterns - */ -export interface ModelWithPattern { - key: string; - name: string; - readonly enabled?: boolean; - readonly modified?: string; -} -" -`; - -exports[`v3 should generate: ./test/result/v3/models/ModelWithProperties.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { ModelWithString } from './ModelWithString'; - -/** - * This is a model with one nested property - */ -export interface ModelWithProperties { - required: string; - readonly requiredAndReadOnly: string; - requiredAndNullable: string | null; - string?: string; - number?: number; - boolean?: boolean; - reference?: ModelWithString; -} -" -`; - -exports[`v3 should generate: ./test/result/v3/models/ModelWithReference.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { ModelWithProperties } from './ModelWithProperties'; - -/** - * This is a model with one property containing a reference - */ -export interface ModelWithReference { - prop?: ModelWithProperties; -} -" -`; - -exports[`v3 should generate: ./test/result/v3/models/ModelWithString.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - - -/** - * This is a model with one string property - */ -export interface ModelWithString { - /** - * This is a simple string property - */ - prop?: string; -} -" -`; - -exports[`v3 should generate: ./test/result/v3/models/MultilineComment.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - - -/** - * Testing multiline comments. - * This must go to the next line. - * - * This will contain a break. - */ -export type MultilineComment = number;" -`; - -exports[`v3 should generate: ./test/result/v3/models/SimpleBoolean.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - - -/** - * This is a simple boolean - */ -export type SimpleBoolean = boolean;" -`; - -exports[`v3 should generate: ./test/result/v3/models/SimpleFile.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - - -/** - * This is a simple file - */ -export type SimpleFile = File;" -`; - -exports[`v3 should generate: ./test/result/v3/models/SimpleInteger.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - - -/** - * This is a simple number - */ -export type SimpleInteger = number;" -`; - -exports[`v3 should generate: ./test/result/v3/models/SimpleReference.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { ModelWithString } from './ModelWithString'; - -/** - * This is a simple reference - */ -export type SimpleReference = ModelWithString;" -`; - -exports[`v3 should generate: ./test/result/v3/models/SimpleString.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - - -/** - * This is a simple string - */ -export type SimpleString = string;" -`; - -exports[`v3 should generate: ./test/result/v3/schemas/$ArrayWithArray.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ArrayWithArray = { - type: 'Array', -};" -`; - -exports[`v3 should generate: ./test/result/v3/schemas/$ArrayWithBooleans.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ArrayWithBooleans = { - type: 'Array', -};" -`; - -exports[`v3 should generate: ./test/result/v3/schemas/$ArrayWithNumbers.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ArrayWithNumbers = { - type: 'Array', -};" -`; - -exports[`v3 should generate: ./test/result/v3/schemas/$ArrayWithProperties.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ArrayWithProperties = { - type: 'Array', -};" -`; - -exports[`v3 should generate: ./test/result/v3/schemas/$ArrayWithReferences.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ArrayWithReferences = { - type: 'Array', -};" -`; - -exports[`v3 should generate: ./test/result/v3/schemas/$ArrayWithStrings.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ArrayWithStrings = { - type: 'Array', -};" -`; - -exports[`v3 should generate: ./test/result/v3/schemas/$DictionaryWithArray.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $DictionaryWithArray = { - type: 'Dictionary', -};" -`; - -exports[`v3 should generate: ./test/result/v3/schemas/$DictionaryWithDictionary.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $DictionaryWithDictionary = { - type: 'Dictionary', -};" -`; - -exports[`v3 should generate: ./test/result/v3/schemas/$DictionaryWithProperties.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $DictionaryWithProperties = { - type: 'Dictionary', -};" -`; - -exports[`v3 should generate: ./test/result/v3/schemas/$DictionaryWithReference.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $DictionaryWithReference = { - type: 'Dictionary', -};" -`; - -exports[`v3 should generate: ./test/result/v3/schemas/$DictionaryWithString.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $DictionaryWithString = { - type: 'Dictionary', -};" -`; - -exports[`v3 should generate: ./test/result/v3/schemas/$EnumFromDescription.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $EnumFromDescription = { - type: 'Enum', -};" -`; - -exports[`v3 should generate: ./test/result/v3/schemas/$EnumWithExtensions.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $EnumWithExtensions = { - type: 'Enum', -};" -`; - -exports[`v3 should generate: ./test/result/v3/schemas/$EnumWithNumbers.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $EnumWithNumbers = { - type: 'Enum', -};" -`; - -exports[`v3 should generate: ./test/result/v3/schemas/$EnumWithStrings.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $EnumWithStrings = { - type: 'Enum', -};" -`; - -exports[`v3 should generate: ./test/result/v3/schemas/$ModelLink.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ModelLink = { - properties: { - id: { - type: 'string', - }, - }, -};" -`; - -exports[`v3 should generate: ./test/result/v3/schemas/$ModelThatExtends.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { $ModelWithString } from './$ModelWithString'; - -export const $ModelThatExtends = { - properties: { - ...$ModelWithString.properties, - propExtendsA: { - type: 'string', - }, - propExtendsB: { - type: 'ModelWithString', - }, - }, -};" -`; - -exports[`v3 should generate: ./test/result/v3/schemas/$ModelThatExtendsExtends.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { $ModelWithString } from './$ModelWithString'; -import { $ModelThatExtends } from './$ModelThatExtends'; - -export const $ModelThatExtendsExtends = { - properties: { - ...$ModelWithString.properties, - ...$ModelThatExtends.properties, - propExtendsC: { - type: 'string', - }, - propExtendsD: { - type: 'ModelWithString', - }, - }, -};" -`; - -exports[`v3 should generate: ./test/result/v3/schemas/$ModelWithAnyOf.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ModelWithAnyOf = { - properties: { - propA: { - type: 'ModelWithArray | ModelWithDictionary | ModelWithEnum | ModelWithString', - }, - }, -};" -`; - -exports[`v3 should generate: ./test/result/v3/schemas/$ModelWithArray.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ModelWithArray = { - properties: { - prop: { - type: 'Array', - }, - propWithFile: { - type: 'Array', - }, - propWithNumber: { - type: 'Array', - }, - }, -};" -`; - -exports[`v3 should generate: ./test/result/v3/schemas/$ModelWithBoolean.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ModelWithBoolean = { - properties: { - prop: { - type: 'boolean', - }, - }, -};" -`; - -exports[`v3 should generate: ./test/result/v3/schemas/$ModelWithCircularReference.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ModelWithCircularReference = { - properties: { - prop: { - type: 'ModelWithCircularReference', - }, - }, -};" -`; - -exports[`v3 should generate: ./test/result/v3/schemas/$ModelWithDictionary.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ModelWithDictionary = { - properties: { - prop: { - type: 'Dictionary', - }, - }, -};" -`; - -exports[`v3 should generate: ./test/result/v3/schemas/$ModelWithDuplicateImports.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ModelWithDuplicateImports = { - properties: { - propA: { - type: 'ModelWithString', - }, - propB: { - type: 'ModelWithString', - }, - propC: { - type: 'ModelWithString', - }, - }, -};" -`; - -exports[`v3 should generate: ./test/result/v3/schemas/$ModelWithDuplicateProperties.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ModelWithDuplicateProperties = { - properties: { - prop: { - type: 'ModelWithString', - }, - }, -};" -`; - -exports[`v3 should generate: ./test/result/v3/schemas/$ModelWithEnum.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ModelWithEnum = { - properties: { - test: { - type: 'Enum', - }, - statusCode: { - type: 'Enum', - }, - }, -};" -`; - -exports[`v3 should generate: ./test/result/v3/schemas/$ModelWithEnumFromDescription.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ModelWithEnumFromDescription = { - properties: { - test: { - type: 'Enum', - }, - }, -};" -`; - -exports[`v3 should generate: ./test/result/v3/schemas/$ModelWithInteger.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ModelWithInteger = { - properties: { - prop: { - type: 'number', - }, - }, -};" -`; - -exports[`v3 should generate: ./test/result/v3/schemas/$ModelWithLink.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ModelWithLink = { - properties: { - prop: { - type: 'ModelLink', - }, - }, -};" -`; - -exports[`v3 should generate: ./test/result/v3/schemas/$ModelWithNestedEnums.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ModelWithNestedEnums = { - properties: { - dictionaryWithEnum: { - type: 'Dictionary', - }, - dictionaryWithEnumFromDescription: { - type: 'Dictionary', - }, - arrayWithEnum: { - type: 'Array', - }, - arrayWithDescription: { - type: 'Array', - }, - }, -};" -`; - -exports[`v3 should generate: ./test/result/v3/schemas/$ModelWithNestedProperties.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ModelWithNestedProperties = { - properties: { - first: { - properties: { - second: { - properties: { - third: { - type: 'string', - isReadOnly: true, - isRequired: true, - isNullable: true, - }, - }, - isReadOnly: true, - isRequired: true, - isNullable: true, - }, - }, - isReadOnly: true, - isRequired: true, - isNullable: true, - }, - }, -};" -`; - -exports[`v3 should generate: ./test/result/v3/schemas/$ModelWithOneOf.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ModelWithOneOf = { - properties: { - propA: { - type: 'ModelWithArray | ModelWithDictionary | ModelWithEnum | ModelWithString', - }, - }, -};" -`; - -exports[`v3 should generate: ./test/result/v3/schemas/$ModelWithOrderedProperties.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ModelWithOrderedProperties = { - properties: { - zebra: { - type: 'string', - }, - apple: { - type: 'string', - }, - hawaii: { - type: 'string', - }, - }, -};" -`; - -exports[`v3 should generate: ./test/result/v3/schemas/$ModelWithPattern.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ModelWithPattern = { - properties: { - key: { - type: 'string', - isRequired: true, - maxLength: 64, - pattern: '^[a-zA-Z0-9_]*$', - }, - name: { - type: 'string', - isRequired: true, - maxLength: 255, - }, - enabled: { - type: 'boolean', - isReadOnly: true, - }, - modified: { - type: 'string', - isReadOnly: true, - format: 'date-time', - }, - }, -};" -`; - -exports[`v3 should generate: ./test/result/v3/schemas/$ModelWithProperties.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ModelWithProperties = { - properties: { - required: { - type: 'string', - isRequired: true, - }, - requiredAndReadOnly: { - type: 'string', - isReadOnly: true, - isRequired: true, - }, - requiredAndNullable: { - type: 'string', - isRequired: true, - isNullable: true, - }, - string: { - type: 'string', - }, - number: { - type: 'number', - }, - boolean: { - type: 'boolean', - }, - reference: { - type: 'ModelWithString', - }, - }, -};" -`; - -exports[`v3 should generate: ./test/result/v3/schemas/$ModelWithReference.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ModelWithReference = { - properties: { - prop: { - type: 'ModelWithProperties', - }, - }, -};" -`; - -exports[`v3 should generate: ./test/result/v3/schemas/$ModelWithString.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $ModelWithString = { - properties: { - prop: { - type: 'string', - }, - }, -};" -`; - -exports[`v3 should generate: ./test/result/v3/schemas/$MultilineComment.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $MultilineComment = { - type: 'number', -};" -`; - -exports[`v3 should generate: ./test/result/v3/schemas/$SimpleBoolean.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $SimpleBoolean = { - type: 'boolean', -};" -`; - -exports[`v3 should generate: ./test/result/v3/schemas/$SimpleFile.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $SimpleFile = { - type: 'File', -};" -`; - -exports[`v3 should generate: ./test/result/v3/schemas/$SimpleInteger.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $SimpleInteger = { - type: 'number', -};" -`; - -exports[`v3 should generate: ./test/result/v3/schemas/$SimpleReference.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $SimpleReference = { - type: 'ModelWithString', -};" -`; - -exports[`v3 should generate: ./test/result/v3/schemas/$SimpleString.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export const $SimpleString = { - type: 'string', -};" -`; - -exports[`v3 should generate: ./test/result/v3/services/ComplexService.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { ModelWithArray } from '../models/ModelWithArray'; -import { ModelWithDictionary } from '../models/ModelWithDictionary'; -import { ModelWithEnum } from '../models/ModelWithEnum'; -import { ModelWithString } from '../models/ModelWithString'; -import { ApiError, catchGenericError } from '../core/ApiError'; -import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; - -export class ComplexService { - - /** - * @param parameterObject Parameter containing object - * @param parameterReference Parameter containing reference - * @result ModelWithString Successful response - * @throws ApiError - */ - public static async complexTypes( - parameterObject: { - first?: { - second?: { - third?: string, - }, - }, - }, - parameterReference: ModelWithString, - ): Promise> { - - const result = await __request({ - method: 'get', - path: \`/api/v\${OpenAPI.VERSION}/complex\`, - query: { - 'parameterObject': parameterObject, - 'parameterReference': parameterReference, - }, - }); - - if (!result.ok) { - switch (result.status) { - case 400: throw new ApiError(result, \`400 server error\`); - case 500: throw new ApiError(result, \`500 server error\`); - } - } - - catchGenericError(result); - - return result.body; - } - - /** - * @param id - * @param requestBody - * @result ModelWithString Success - * @throws ApiError - */ - public static async complexParams( - id: number, - requestBody?: { - readonly key: string | null, - name: string | null, - enabled?: boolean, - readonly type: ('Monkey' | 'Horse' | 'Bird'), - listOfModels?: Array | null, - listOfStrings?: Array | null, - parameters: ModelWithArray | ModelWithDictionary | ModelWithEnum | ModelWithString, - readonly user?: { - readonly id?: number, - readonly name?: string | null, - }, - }, - ): Promise { - - const result = await __request({ - method: 'put', - path: \`/api/v\${OpenAPI.VERSION}/complex/\${id}\`, - body: requestBody, - }); - - catchGenericError(result); - - return result.body; - } - -}" -`; - -exports[`v3 should generate: ./test/result/v3/services/DefaultsService.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { ModelWithString } from '../models/ModelWithString'; -import { catchGenericError } from '../core/ApiError'; -import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; - -export class DefaultsService { - - /** - * @param parameterString This is a simple string with default value - * @param parameterNumber This is a simple number with default value - * @param parameterBoolean This is a simple boolean with default value - * @param parameterEnum This is a simple enum with default value - * @param parameterModel This is a simple model with default value - * @throws ApiError - */ - public static async callWithDefaultParameters( - parameterString: string | null = 'Hello World!', - parameterNumber: number | null = 123, - parameterBoolean: boolean | null = true, - parameterEnum: ('Success' | 'Warning' | 'Error') = 'Success', - parameterModel: ModelWithString | null = { - \\"prop\\": \\"Hello World\\" - }, - ): Promise { - - const result = await __request({ - method: 'get', - path: \`/api/v\${OpenAPI.VERSION}/defaults\`, - query: { - 'parameterString': parameterString, - 'parameterNumber': parameterNumber, - 'parameterBoolean': parameterBoolean, - 'parameterEnum': parameterEnum, - 'parameterModel': parameterModel, - }, - }); - - catchGenericError(result); - - return result.body; - } - - /** - * @param parameterString This is a simple string that is optional with default value - * @param parameterNumber This is a simple number that is optional with default value - * @param parameterBoolean This is a simple boolean that is optional with default value - * @param parameterEnum This is a simple enum that is optional with default value - * @param parameterModel This is a simple model that is optional with default value - * @throws ApiError - */ - public static async callWithDefaultOptionalParameters( - parameterString: string = 'Hello World!', - parameterNumber: number = 123, - parameterBoolean: boolean = true, - parameterEnum: ('Success' | 'Warning' | 'Error') = 'Success', - parameterModel: ModelWithString = { - \\"prop\\": \\"Hello World\\" - }, - ): Promise { - - const result = await __request({ - method: 'post', - path: \`/api/v\${OpenAPI.VERSION}/defaults\`, - query: { - 'parameterString': parameterString, - 'parameterNumber': parameterNumber, - 'parameterBoolean': parameterBoolean, - 'parameterEnum': parameterEnum, - 'parameterModel': parameterModel, - }, - }); - - catchGenericError(result); - - return result.body; - } - - /** - * @param parameterStringWithNoDefault This is a string with no default - * @param parameterOptionalStringWithDefault This is a optional string with default - * @param parameterOptionalStringWithEmptyDefault This is a optional string with empty default - * @param parameterOptionalStringWithNoDefault This is a optional string with no default - * @param parameterStringWithDefault This is a string with default - * @param parameterStringWithEmptyDefault This is a string with empty default - * @throws ApiError - */ - public static async callToTestOrderOfParams( - parameterStringWithNoDefault: string, - parameterOptionalStringWithDefault: string = 'hello', - parameterOptionalStringWithEmptyDefault: string = '', - parameterOptionalStringWithNoDefault?: string, - parameterStringWithDefault: string = 'hello', - parameterStringWithEmptyDefault: string = '', - ): Promise { - - const result = await __request({ - method: 'put', - path: \`/api/v\${OpenAPI.VERSION}/defaults\`, - query: { - 'parameterStringWithNoDefault': parameterStringWithNoDefault, - 'parameterOptionalStringWithDefault': parameterOptionalStringWithDefault, - 'parameterOptionalStringWithEmptyDefault': parameterOptionalStringWithEmptyDefault, - 'parameterOptionalStringWithNoDefault': parameterOptionalStringWithNoDefault, - 'parameterStringWithDefault': parameterStringWithDefault, - 'parameterStringWithEmptyDefault': parameterStringWithEmptyDefault, - }, - }); - - catchGenericError(result); - - return result.body; - } - -}" -`; - -exports[`v3 should generate: ./test/result/v3/services/DuplicateService.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { catchGenericError } from '../core/ApiError'; -import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; - -export class DuplicateService { - - /** - * @throws ApiError - */ - public static async duplicateName(): Promise { - - const result = await __request({ - method: 'get', - path: \`/api/v\${OpenAPI.VERSION}/duplicate\`, - }); - - catchGenericError(result); - - return result.body; - } - - /** - * @throws ApiError - */ - public static async duplicateName1(): Promise { - - const result = await __request({ - method: 'post', - path: \`/api/v\${OpenAPI.VERSION}/duplicate\`, - }); - - catchGenericError(result); - - return result.body; - } - - /** - * @throws ApiError - */ - public static async duplicateName2(): Promise { - - const result = await __request({ - method: 'put', - path: \`/api/v\${OpenAPI.VERSION}/duplicate\`, - }); - - catchGenericError(result); - - return result.body; - } - - /** - * @throws ApiError - */ - public static async duplicateName3(): Promise { - - const result = await __request({ - method: 'delete', - path: \`/api/v\${OpenAPI.VERSION}/duplicate\`, - }); - - catchGenericError(result); - - return result.body; - } - -}" -`; - -exports[`v3 should generate: ./test/result/v3/services/HeaderService.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { ApiError, catchGenericError } from '../core/ApiError'; -import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; - -export class HeaderService { - - /** - * @result string Successful response - * @throws ApiError - */ - public static async callWithResultFromHeader(): Promise { - - const result = await __request({ - method: 'post', - path: \`/api/v\${OpenAPI.VERSION}/header\`, - responseHeader: 'operation-location', - }); - - if (!result.ok) { - switch (result.status) { - case 400: throw new ApiError(result, \`400 server error\`); - case 500: throw new ApiError(result, \`500 server error\`); - } - } - - catchGenericError(result); - - return result.body; - } - -}" -`; - -exports[`v3 should generate: ./test/result/v3/services/MultipartService.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { catchGenericError } from '../core/ApiError'; -import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; - -export class MultipartService { - - /** - * @result any OK - * @throws ApiError - */ - public static async multipartResponse(): Promise<{ - file?: string, - metadata?: { - foo?: string, - bar?: string, - }, - }> { - - const result = await __request({ - method: 'get', - path: \`/api/v\${OpenAPI.VERSION}/multipart\`, - }); - - catchGenericError(result); - - return result.body; - } - -}" -`; - -exports[`v3 should generate: ./test/result/v3/services/ParametersService.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { ModelWithString } from '../models/ModelWithString'; -import { catchGenericError } from '../core/ApiError'; -import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; - -export class ParametersService { - - /** - * @param parameterHeader This is the parameter that goes into the header - * @param parameterQuery This is the parameter that goes into the query params - * @param parameterForm This is the parameter that goes into the form data - * @param parameterCookie This is the parameter that goes into the cookie - * @param parameterPath This is the parameter that goes into the path - * @param requestBody This is the parameter that goes into the body - * @throws ApiError - */ - public static async callWithParameters( - parameterHeader: string | null, - parameterQuery: string | null, - parameterForm: string | null, - parameterCookie: string | null, - parameterPath: string | null, - requestBody: ModelWithString | null, - ): Promise { - - const result = await __request({ - method: 'get', - path: \`/api/v\${OpenAPI.VERSION}/parameters/\${parameterPath}\`, - cookies: { - 'parameterCookie': parameterCookie, - }, - headers: { - 'parameterHeader': parameterHeader, - }, - query: { - 'parameterQuery': parameterQuery, - }, - formData: { - 'parameterForm': parameterForm, - }, - body: requestBody, - }); - - catchGenericError(result); - - return result.body; - } - - /** - * @param parameterHeader This is the parameter that goes into the request header - * @param parameterQuery This is the parameter that goes into the request query params - * @param parameterForm This is the parameter that goes into the request form data - * @param parameterCookie This is the parameter that goes into the cookie - * @param requestBody This is the parameter that goes into the body - * @param parameterPath1 This is the parameter that goes into the path - * @param parameterPath2 This is the parameter that goes into the path - * @param parameterPath3 This is the parameter that goes into the path - * @throws ApiError - */ - public static async callWithWeirdParameterNames( - parameterHeader: string | null, - parameterQuery: string | null, - parameterForm: string | null, - parameterCookie: string | null, - requestBody: ModelWithString | null, - parameterPath1?: string, - parameterPath2?: string, - parameterPath3?: string, - ): Promise { - - const result = await __request({ - method: 'get', - path: \`/api/v\${OpenAPI.VERSION}/parameters/\${parameterPath1}/\${parameterPath2}/\${parameterPath3}\`, - cookies: { - 'PARAMETER-COOKIE': parameterCookie, - }, - headers: { - 'parameter.header': parameterHeader, - }, - query: { - 'parameter-query': parameterQuery, - }, - formData: { - 'parameter_form': parameterForm, - }, - body: requestBody, - }); - - catchGenericError(result); - - return result.body; - } - - /** - * @param requestBody This is a required parameter - * @param parameter This is an optional parameter - * @throws ApiError - */ - public static async getCallWithOptionalParam( - requestBody: ModelWithString, - parameter?: string, - ): Promise { - - const result = await __request({ - method: 'get', - path: \`/api/v\${OpenAPI.VERSION}/parameters/\`, - query: { - 'parameter': parameter, - }, - body: requestBody, - }); - - catchGenericError(result); - - return result.body; - } - - /** - * @param parameter This is a required parameter - * @param requestBody This is an optional parameter - * @throws ApiError - */ - public static async postCallWithOptionalParam( - parameter: string, - requestBody?: ModelWithString, - ): Promise { - - const result = await __request({ - method: 'post', - path: \`/api/v\${OpenAPI.VERSION}/parameters/\`, - query: { - 'parameter': parameter, - }, - body: requestBody, - }); - - catchGenericError(result); - - return result.body; - } - -}" -`; - -exports[`v3 should generate: ./test/result/v3/services/ResponseService.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { ModelThatExtends } from '../models/ModelThatExtends'; -import { ModelThatExtendsExtends } from '../models/ModelThatExtendsExtends'; -import { ModelWithString } from '../models/ModelWithString'; -import { ApiError, catchGenericError } from '../core/ApiError'; -import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; - -export class ResponseService { - - /** - * @result ModelWithString - * @throws ApiError - */ - public static async callWithResponse(): Promise { - - const result = await __request({ - method: 'get', - path: \`/api/v\${OpenAPI.VERSION}/response\`, - }); - - catchGenericError(result); - - return result.body; - } - - /** - * @result ModelWithString Message for default response - * @throws ApiError - */ - public static async callWithDuplicateResponses(): Promise { - - const result = await __request({ - method: 'post', - path: \`/api/v\${OpenAPI.VERSION}/response\`, - }); - - if (!result.ok) { - switch (result.status) { - case 500: throw new ApiError(result, \`Message for 500 error\`); - case 501: throw new ApiError(result, \`Message for 501 error\`); - case 502: throw new ApiError(result, \`Message for 502 error\`); - } - } - - catchGenericError(result); - - return result.body; - } - - /** - * @result ModelWithString Message for default response - * @result ModelThatExtends Message for 201 response - * @result ModelThatExtendsExtends Message for 202 response - * @throws ApiError - */ - public static async callWithResponses(): Promise { - - const result = await __request({ - method: 'put', - path: \`/api/v\${OpenAPI.VERSION}/response\`, - }); - - if (!result.ok) { - switch (result.status) { - case 500: throw new ApiError(result, \`Message for 500 error\`); - case 501: throw new ApiError(result, \`Message for 501 error\`); - case 502: throw new ApiError(result, \`Message for 502 error\`); - } - } - - catchGenericError(result); - - return result.body; - } - -}" -`; - -exports[`v3 should generate: ./test/result/v3/services/SimpleService.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { catchGenericError } from '../core/ApiError'; -import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; - -export class SimpleService { - - /** - * @throws ApiError - */ - public static async getCallWithoutParametersAndResponse(): Promise { - - const result = await __request({ - method: 'get', - path: \`/api/v\${OpenAPI.VERSION}/simple\`, - }); - - catchGenericError(result); - - return result.body; - } - - /** - * @throws ApiError - */ - public static async putCallWithoutParametersAndResponse(): Promise { - - const result = await __request({ - method: 'put', - path: \`/api/v\${OpenAPI.VERSION}/simple\`, - }); - - catchGenericError(result); - - return result.body; - } - - /** - * @throws ApiError - */ - public static async postCallWithoutParametersAndResponse(): Promise { - - const result = await __request({ - method: 'post', - path: \`/api/v\${OpenAPI.VERSION}/simple\`, - }); - - catchGenericError(result); - - return result.body; - } - - /** - * @throws ApiError - */ - public static async deleteCallWithoutParametersAndResponse(): Promise { - - const result = await __request({ - method: 'delete', - path: \`/api/v\${OpenAPI.VERSION}/simple\`, - }); - - catchGenericError(result); - - return result.body; - } - - /** - * @throws ApiError - */ - public static async optionsCallWithoutParametersAndResponse(): Promise { - - const result = await __request({ - method: 'options', - path: \`/api/v\${OpenAPI.VERSION}/simple\`, - }); - - catchGenericError(result); - - return result.body; - } - - /** - * @throws ApiError - */ - public static async headCallWithoutParametersAndResponse(): Promise { - - const result = await __request({ - method: 'head', - path: \`/api/v\${OpenAPI.VERSION}/simple\`, - }); - - catchGenericError(result); - - return result.body; - } - - /** - * @throws ApiError - */ - public static async patchCallWithoutParametersAndResponse(): Promise { - - const result = await __request({ - method: 'patch', - path: \`/api/v\${OpenAPI.VERSION}/simple\`, - }); - - catchGenericError(result); - - return result.body; - } - -}" -`; - -exports[`v3 should generate: ./test/result/v3/services/TypesService.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { catchGenericError } from '../core/ApiError'; -import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; - -export class TypesService { - - /** - * @param parameterArray This is an array parameter - * @param parameterDictionary This is a dictionary parameter - * @param parameterEnum This is an enum parameter - * @param parameterNumber This is a number parameter - * @param parameterString This is a string parameter - * @param parameterBoolean This is a boolean parameter - * @param parameterObject This is an object parameter - * @param id This is a number parameter - * @result number Response is a simple number - * @result string Response is a simple string - * @result boolean Response is a simple boolean - * @result any Response is a simple object - * @throws ApiError - */ - public static async types( - parameterArray: Array | null, - parameterDictionary: any, - parameterEnum: ('Success' | 'Warning' | 'Error') | null, - parameterNumber: number = 123, - parameterString: string | null = 'default', - parameterBoolean: boolean | null = true, - parameterObject: any = null, - id?: number, - ): Promise { - - const result = await __request({ - method: 'get', - path: \`/api/v\${OpenAPI.VERSION}/types\`, - query: { - 'parameterArray': parameterArray, - 'parameterDictionary': parameterDictionary, - 'parameterEnum': parameterEnum, - 'parameterNumber': parameterNumber, - 'parameterString': parameterString, - 'parameterBoolean': parameterBoolean, - 'parameterObject': parameterObject, - }, - }); - - catchGenericError(result); - - return result.body; - } - -}" -`; - -exports[`v3 should generate: ./test/result/v3/services/UploadService.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import { catchGenericError } from '../core/ApiError'; -import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; - -export class UploadService { - - /** - * @param file Supply a file reference for upload - * @result boolean - * @throws ApiError - */ - public static async uploadFile( - file: File, - ): Promise { - - const result = await __request({ - method: 'post', - path: \`/api/v\${OpenAPI.VERSION}/upload\`, - formData: { - 'file': file, - }, - }); - - catchGenericError(result); - - return result.body; - } - -}" -`; diff --git a/yarn.lock b/yarn.lock index d6d42ece..cee4482a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -808,9 +808,9 @@ semver "^5.5.0" "@babel/preset-modules@^0.1.3": - version "0.1.3" - resolved "https://registry.yarnpkg.com/@babel/preset-modules/-/preset-modules-0.1.3.tgz#13242b53b5ef8c883c3cf7dddd55b36ce80fbc72" - integrity sha512-Ra3JXOHBq2xd56xSF7lMKXdjBn3T772Y1Wet3yWnkDly9zHvJki029tAFzvAAK5cf4YV3yoxuP61crYRol6SVg== + version "0.1.4" + resolved "https://registry.yarnpkg.com/@babel/preset-modules/-/preset-modules-0.1.4.tgz#362f2b68c662842970fdb5e254ffc8fc1c2e415e" + integrity sha512-J36NhwnfdzpmH41M1DrnkkgAqhZaqr/NBdPfQ677mLzlaXo+oDiv1deyCDtgAhz8p328otdob0Du7+xgHGZbKg== dependencies: "@babel/helper-plugin-utils" "^7.0.0" "@babel/plugin-proposal-unicode-property-regex" "^7.4.4" @@ -1254,10 +1254,10 @@ dependencies: "@types/node" "*" -"@types/node@*", "@types/node@14.6.0": - version "14.6.0" - resolved "https://registry.yarnpkg.com/@types/node/-/node-14.6.0.tgz#7d4411bf5157339337d7cff864d9ff45f177b499" - integrity sha512-mikldZQitV94akrc4sCcSjtJfsTKt4p+e/s0AGscVA6XArQ9kFclP+ZiYUMnq987rc6QlYxXv/EivqlfSLxpKA== +"@types/node@*", "@types/node@14.6.1": + version "14.6.1" + resolved "https://registry.yarnpkg.com/@types/node/-/node-14.6.1.tgz#fdf6f6c6c73d3d8eee9c98a9a0485bc524b048d7" + integrity sha512-HnYlg/BRF8uC1FyKRFZwRaCPTPYKa+6I8QiUZFLredaGOou481cgFS4wKRFyKvQtX8xudqkSdBczJHIYSQYKrQ== "@types/normalize-package-data@^2.4.0": version "2.4.0" @@ -1265,9 +1265,9 @@ integrity sha512-f5j5b/Gf71L+dbqxIpQ4Z2WlmI/mPJ0fOkGGmFgtb6sAu97EPczzbS3/tJKxmcYDj55OX6ssqwDAWOHIYDRDGA== "@types/prettier@^2.0.0": - version "2.0.2" - resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.0.2.tgz#5bb52ee68d0f8efa9cc0099920e56be6cc4e37f3" - integrity sha512-IkVfat549ggtkZUthUzEX49562eGikhSYeVGX97SkMFn+sTZrgRewXjQ4tPKFPCykZHkX1Zfd9OoELGqKU2jJA== + version "2.1.0" + resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.1.0.tgz#5f96562c1075ee715a5b138f0b7f591c1f40f6b8" + integrity sha512-hiYA88aHiEIgDmeKlsyVsuQdcFn3Z2VuFd/Xm/HCnGnPD8UFU5BM128uzzRVVGEzKDKYUrRsRH9S2o+NUy/3IA== "@types/resolve@1.17.1": version "1.17.1" @@ -1301,52 +1301,52 @@ dependencies: "@types/yargs-parser" "*" -"@typescript-eslint/eslint-plugin@3.9.1": - version "3.9.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-3.9.1.tgz#8cf27b6227d12d66dd8dc1f1a4b04d1daad51c2e" - integrity sha512-XIr+Mfv7i4paEdBf0JFdIl9/tVxyj+rlilWIfZ97Be0lZ7hPvUbS5iHt9Glc8kRI53dsr0PcAEudbf8rO2wGgg== +"@typescript-eslint/eslint-plugin@3.10.1": + version "3.10.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-3.10.1.tgz#7e061338a1383f59edc204c605899f93dc2e2c8f" + integrity sha512-PQg0emRtzZFWq6PxBcdxRH3QIQiyFO3WCVpRL3fgj5oQS3CDs3AeAKfv4DxNhzn8ITdNJGJ4D3Qw8eAJf3lXeQ== dependencies: - "@typescript-eslint/experimental-utils" "3.9.1" + "@typescript-eslint/experimental-utils" "3.10.1" debug "^4.1.1" functional-red-black-tree "^1.0.1" regexpp "^3.0.0" semver "^7.3.2" tsutils "^3.17.1" -"@typescript-eslint/experimental-utils@3.9.1": - version "3.9.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-3.9.1.tgz#b140b2dc7a7554a44f8a86fb6fe7cbfe57ca059e" - integrity sha512-lkiZ8iBBaYoyEKhCkkw4SAeatXyBq9Ece5bZXdLe1LWBUwTszGbmbiqmQbwWA8cSYDnjWXp9eDbXpf9Sn0hLAg== +"@typescript-eslint/experimental-utils@3.10.1": + version "3.10.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-3.10.1.tgz#e179ffc81a80ebcae2ea04e0332f8b251345a686" + integrity sha512-DewqIgscDzmAfd5nOGe4zm6Bl7PKtMG2Ad0KG8CUZAHlXfAKTF9Ol5PXhiMh39yRL2ChRH1cuuUGOcVyyrhQIw== dependencies: "@types/json-schema" "^7.0.3" - "@typescript-eslint/types" "3.9.1" - "@typescript-eslint/typescript-estree" "3.9.1" + "@typescript-eslint/types" "3.10.1" + "@typescript-eslint/typescript-estree" "3.10.1" eslint-scope "^5.0.0" eslint-utils "^2.0.0" -"@typescript-eslint/parser@3.9.1": - version "3.9.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-3.9.1.tgz#ab7983abaea0ae138ff5671c7c7739d8a191b181" - integrity sha512-y5QvPFUn4Vl4qM40lI+pNWhTcOWtpZAJ8pOEQ21fTTW4xTJkRplMjMRje7LYTXqVKKX9GJhcyweMz2+W1J5bMg== +"@typescript-eslint/parser@3.10.1": + version "3.10.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-3.10.1.tgz#1883858e83e8b442627e1ac6f408925211155467" + integrity sha512-Ug1RcWcrJP02hmtaXVS3axPPTTPnZjupqhgj+NnZ6BCkwSImWk/283347+x9wN+lqOdK9Eo3vsyiyDHgsmiEJw== dependencies: "@types/eslint-visitor-keys" "^1.0.0" - "@typescript-eslint/experimental-utils" "3.9.1" - "@typescript-eslint/types" "3.9.1" - "@typescript-eslint/typescript-estree" "3.9.1" + "@typescript-eslint/experimental-utils" "3.10.1" + "@typescript-eslint/types" "3.10.1" + "@typescript-eslint/typescript-estree" "3.10.1" eslint-visitor-keys "^1.1.0" -"@typescript-eslint/types@3.9.1": - version "3.9.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-3.9.1.tgz#b2a6eaac843cf2f2777b3f2464fb1fbce5111416" - integrity sha512-15JcTlNQE1BsYy5NBhctnEhEoctjXOjOK+Q+rk8ugC+WXU9rAcS2BYhoh6X4rOaXJEpIYDl+p7ix+A5U0BqPTw== +"@typescript-eslint/types@3.10.1": + version "3.10.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-3.10.1.tgz#1d7463fa7c32d8a23ab508a803ca2fe26e758727" + integrity sha512-+3+FCUJIahE9q0lDi1WleYzjCwJs5hIsbugIgnbB+dSCYUxl8L6PwmsyOPFZde2hc1DlTo/xnkOgiTLSyAbHiQ== -"@typescript-eslint/typescript-estree@3.9.1": - version "3.9.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-3.9.1.tgz#fd81cada74bc8a7f3a2345b00897acb087935779" - integrity sha512-IqM0gfGxOmIKPhiHW/iyAEXwSVqMmR2wJ9uXHNdFpqVvPaQ3dWg302vW127sBpAiqM9SfHhyS40NKLsoMpN2KA== +"@typescript-eslint/typescript-estree@3.10.1": + version "3.10.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-3.10.1.tgz#fd0061cc38add4fad45136d654408569f365b853" + integrity sha512-QbcXOuq6WYvnB3XPsZpIwztBoquEYLXh2MtwVU+kO8jgYCiv4G5xrSP/1wg4tkvrEE+esZVquIPX/dxPlePk1w== dependencies: - "@typescript-eslint/types" "3.9.1" - "@typescript-eslint/visitor-keys" "3.9.1" + "@typescript-eslint/types" "3.10.1" + "@typescript-eslint/visitor-keys" "3.10.1" debug "^4.1.1" glob "^7.1.6" is-glob "^4.0.1" @@ -1354,10 +1354,10 @@ semver "^7.3.2" tsutils "^3.17.1" -"@typescript-eslint/visitor-keys@3.9.1": - version "3.9.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-3.9.1.tgz#92af3747cdb71509199a8f7a4f00b41d636551d1" - integrity sha512-zxdtUjeoSh+prCpogswMwVUJfEFmCOjdzK9rpNjNBfm6EyPt99x3RrJoBOGZO23FCt0WPKUCOL5mb/9D5LjdwQ== +"@typescript-eslint/visitor-keys@3.10.1": + version "3.10.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-3.10.1.tgz#cd4274773e3eb63b2e870ac602274487ecd1e931" + integrity sha512-9JgC82AaQeglebjZMgYR5wgmfUdUc+EitGUUMW8u2nDckaeimzW+VsoLV6FoimPv2id3VQzfjwBxEMVz08ameQ== dependencies: eslint-visitor-keys "^1.1.0" @@ -1384,7 +1384,7 @@ acorn-walk@^7.1.1: resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-7.2.0.tgz#0de889a601203909b0fbe07b8938dc21d2e967bc" integrity sha512-OPdCF6GsMIP+Az+aWfAAOEt2/+iVDKE7oy6lJ098aoe59oAmK76qV6Gw60SbZ8jHuG2wH058GF4pLFbYamYrVA== -acorn@^7.1.1, acorn@^7.3.1: +acorn@^7.1.1, acorn@^7.4.0: version "7.4.0" resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.0.tgz#e1ad486e6c54501634c6c397c5c121daa383607c" integrity sha512-+G7P8jJmCHr+S+cLfQxygbWhXy+8YTVGzAkpEbcLo2mLoL7tij/VG41QSHACSf5QgYRhMZYHuNc6drJaO0Da+w== @@ -1713,20 +1713,20 @@ callsites@^3.0.0: resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73" integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ== -camelcase@5.3.1, camelcase@^5.0.0, camelcase@^5.3.1: - version "5.3.1" - resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" - integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg== - -camelcase@^6.0.0: +camelcase@6.0.0, camelcase@^6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.0.0.tgz#5259f7c30e35e278f1bdc2a4d91230b37cad981e" integrity sha512-8KMDF1Vz2gzOq54ONPJS65IvTUaB1cHJ2DMM7MbPmLZljDH1qpzzLsWdiN9pHh6qvkRVDTi/07+eNGch/oLU4w== +camelcase@^5.0.0, camelcase@^5.3.1: + version "5.3.1" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" + integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg== + caniuse-lite@^1.0.30001111: - version "1.0.30001117" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001117.tgz#69a9fae5d480eaa9589f7641a83842ad396d17c4" - integrity sha512-4tY0Fatzdx59kYjQs+bNxUwZB03ZEBgVmJ1UkFPz/Q8OLiUUbjct2EdpnXj0fvFTPej2EkbPIG0w8BWsjAyk1Q== + version "1.0.30001119" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001119.tgz#99185d04bc00e76a86c9ff731dc5ec8e53aefca1" + integrity sha512-Hpwa4obv7EGP+TjkCh/wVvbtNJewxmtg4yVJBLFnxo35vbPapBr138bUWENkb5j5L9JZJ9RXLn4OrXRG/cecPQ== capture-exit@^2.0.0: version "2.0.0" @@ -1854,10 +1854,10 @@ combined-stream@^1.0.6, combined-stream@~1.0.6: dependencies: delayed-stream "~1.0.0" -commander@6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-6.0.0.tgz#2b270da94f8fb9014455312f829a1129dbf8887e" - integrity sha512-s7EA+hDtTYNhuXkTlhqew4txMZVdszBmKWSPEMxGr8ru8JXR7bLUFIAtPhcSuFdJQ0ILMxnJi8GkQL0yvDy/YA== +commander@6.1.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-6.1.0.tgz#f8d722b78103141006b66f4c7ba1e97315ba75bc" + integrity sha512-wl7PNrYWd2y5mp1OK/LhTlv8Ff4kQJQRXXAvF+uU/TPNiVJUxZLRYGj/B0y/lPGAVcSbJqH2Za/cvHmrPMC8mA== commander@^2.20.0: version "2.20.3" @@ -2068,9 +2068,9 @@ ecc-jsbn@~0.1.1: safer-buffer "^2.1.0" electron-to-chromium@^1.3.523: - version "1.3.540" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.540.tgz#4e4c08d8c12bbd32cf090e143c0d546f017f9d43" - integrity sha512-IoGiZb8SMqTtkDYJtP8EtCdvv3VMtd1QoTlypO2RUBxRq/Wk0rU5IzhzhMckPaC9XxDqUvWsL0XKOBhTiYVN3w== + version "1.3.554" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.554.tgz#11d0619b927a25f300b787ad7ee1ece91384dde9" + integrity sha512-Vtz2dVH5nMtKK4brahmgScwFS8PBnpA4VObYXtlsqN8ZpT9IFelv0Rpflc1+NIILjGVaj6vEiXQbhrs3Pl8O7g== emittery@^0.7.1: version "0.7.1" @@ -2217,11 +2217,11 @@ eslint@7.7.0: v8-compile-cache "^2.0.3" espree@^7.2.0: - version "7.2.0" - resolved "https://registry.yarnpkg.com/espree/-/espree-7.2.0.tgz#1c263d5b513dbad0ac30c4991b93ac354e948d69" - integrity sha512-H+cQ3+3JYRMEIOl87e7QdHX70ocly5iW4+dttuR8iYSPr/hXKFb+7dBsZ7+u1adC4VrnPlTkv0+OwuPnDop19g== + version "7.3.0" + resolved "https://registry.yarnpkg.com/espree/-/espree-7.3.0.tgz#dc30437cf67947cf576121ebd780f15eeac72348" + integrity sha512-dksIWsvKCixn1yrEXO8UosNSxaDoSYpq9reEjZSbHLpT5hpaCAKTLBwq0RHtLrIr+c0ByiYzWT8KTMRzoRCNlw== dependencies: - acorn "^7.3.1" + acorn "^7.4.0" acorn-jsx "^5.2.0" eslint-visitor-keys "^1.3.0" @@ -3480,10 +3480,10 @@ jsesc@~0.5.0: resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-0.5.0.tgz#e7dee66e35d6fc16f710fe91d5cf69f70f08911d" integrity sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0= -json-parse-better-errors@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9" - integrity sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw== +json-parse-even-better-errors@^2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.0.tgz#371873c5ffa44304a6ba12419bcfa95f404ae081" + integrity sha512-o3aP+RsWDJZayj1SbHNQAI8x0v3T3SKiGoZlNYfbUP1S3omJQ6i9CnqADqkSPaOAxwua4/1YWx5CM7oiChJt2Q== json-schema-traverse@^0.4.1: version "0.4.1" @@ -3962,13 +3962,13 @@ parent-module@^1.0.0: callsites "^3.0.0" parse-json@^5.0.0: - version "5.0.1" - resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-5.0.1.tgz#7cfe35c1ccd641bce3981467e6c2ece61b3b3878" - integrity sha512-ztoZ4/DYeXQq4E21v169sC8qWINGpcosGv9XhTDvg9/hWvx/zrFkc9BiWxR58OJLHGk28j5BL0SDLeV2WmFZlQ== + version "5.1.0" + resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-5.1.0.tgz#f96088cdf24a8faa9aea9a009f2d9d942c999646" + integrity sha512-+mi/lmVVNKFNVyLXV31ERiy2CY5E1/F6QtJFEzoChPRwwngMNXRDQ9GJ5WdE2Z2P4AujsOi0/+2qHID68KwfIQ== dependencies: "@babel/code-frame" "^7.0.0" error-ex "^1.3.1" - json-parse-better-errors "^1.0.1" + json-parse-even-better-errors "^2.3.0" lines-and-columns "^1.1.6" parse5@5.1.1: @@ -4060,10 +4060,10 @@ prettier-linter-helpers@^1.0.0: dependencies: fast-diff "^1.1.2" -prettier@2.0.5: - version "2.0.5" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.0.5.tgz#d6d56282455243f2f92cc1716692c08aa31522d4" - integrity sha512-7PtVymN48hGcO4fGjybyBSIWDsLU4H4XlvOHfq91pz9kkGlonzwTfYkaIEwiRg/dAJF9YlbsduBAgtYLi+8cFg== +prettier@2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.1.1.tgz#d9485dd5e499daa6cb547023b87a6cf51bee37d6" + integrity sha512-9bY+5ZWCfqj3ghYBLxApy2zf6m+NJo5GzmLTpr9FsApsfjriNnS2dahWReHMi7qNPhhHl9SYHJs2cHZLgexNIw== pretty-format@^25.2.1, pretty-format@^25.5.0: version "25.5.0" @@ -4354,10 +4354,10 @@ rollup-plugin-typescript2@0.27.2: resolve "1.17.0" tslib "2.0.1" -rollup@2.26.5: - version "2.26.5" - resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.26.5.tgz#5562ec36fcba3eed65cfd630bd78e037ad0e0307" - integrity sha512-rCyFG3ZtQdnn9YwfuAVH0l/Om34BdO5lwCA0W6Hq+bNB21dVEBbCRxhaHOmu1G7OBFDWytbzAC104u7rxHwGjA== +rollup@2.26.7: + version "2.26.7" + resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.26.7.tgz#6188b38238cb198bef9f0d09f390c330ef766d27" + integrity sha512-3/aXJ+ibw2fqj6KBX4ioYcx8s3kseYXzyxLR6Xmm7Zakzd7WNvn9XDUahBCQ/oPVHmVO9gEeIYKHgFaZWqsJzg== optionalDependencies: fsevents "~2.1.2" @@ -4732,9 +4732,9 @@ supports-color@^5.3.0: has-flag "^3.0.0" supports-color@^7.0.0, supports-color@^7.1.0: - version "7.1.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.1.0.tgz#68e32591df73e25ad1c4b49108a2ec507962bfd1" - integrity sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g== + version "7.2.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" + integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== dependencies: has-flag "^4.0.0" @@ -4950,9 +4950,9 @@ typescript@4.0.2: integrity sha512-e4ERvRV2wb+rRZ/IQeb3jm2VxBsirQLpQhdxplZ2MEzGvDkkMmPglecnNDfSUBivMjP93vRbngYYDQqQ/78bcQ== uglify-js@^3.1.4: - version "3.10.1" - resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.10.1.tgz#dd14767eb7150de97f2573a5ff210db14fffe4ad" - integrity sha512-RjxApKkrPJB6kjJxQS3iZlf///REXWYxYJxO/MpmlQzVkDWVI3PSnCBWezMecmTU/TRkNxrl8bmsfFQCp+LO+Q== + version "3.10.2" + resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.10.2.tgz#8cfa1209fd04199cc8a7f9930ddedb30b0f1912d" + integrity sha512-GXCYNwqoo0MbLARghYjxVBxDCnU0tLqN7IPLdHHbibCb1NI5zBkU2EPcy/GaVxc0BtTjqyGXJCINe6JMR2Dpow== unicode-canonical-property-names-ecmascript@^1.0.4: version "1.0.4" @@ -5114,13 +5114,13 @@ whatwg-mimetype@^2.3.0: integrity sha512-M4yMwr6mAnQz76TbJm914+gPpB/nCwvZbJU28cUD6dR004SAxDLOOSUaB1JDRqLtaOV/vi0IC5lEAGFgrjGv/g== whatwg-url@^8.0.0: - version "8.1.0" - resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-8.1.0.tgz#c628acdcf45b82274ce7281ee31dd3c839791771" - integrity sha512-vEIkwNi9Hqt4TV9RdnaBPNt+E2Sgmo3gePebCRgZ1R7g6d23+53zCTnuB0amKI4AXq6VM8jj2DUAa0S1vjJxkw== + version "8.2.1" + resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-8.2.1.tgz#ed73417230784b281fb2a32c3c501738b46167c3" + integrity sha512-ZmVCr6nfBeaMxEHALLEGy0LszYjpJqf6PVNQUQ1qd9Et+q7Jpygd4rGGDXgHjD8e99yLFseD69msHDM4YwPZ4A== dependencies: lodash.sortby "^4.7.0" tr46 "^2.0.2" - webidl-conversions "^5.0.0" + webidl-conversions "^6.1.0" which-module@^2.0.0: version "2.0.0" From 3715ce2631414c912eb92f8cf42c4e751c76c010 Mon Sep 17 00:00:00 2001 From: Ferdi Koomen Date: Fri, 28 Aug 2020 21:20:11 +0200 Subject: [PATCH 3/4] - Fixed snapshot --- rollup.config.js | 10 +- test/__snapshots__/index.spec.js.snap | 5223 +++++++++++++++++++++++++ 2 files changed, 5228 insertions(+), 5 deletions(-) create mode 100644 test/__snapshots__/index.spec.js.snap diff --git a/rollup.config.js b/rollup.config.js index a8743a13..d6050c46 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -66,10 +66,10 @@ export default { }), nodeResolve(), commonjs(), - // terser({ - // output: { - // comments: false, - // }, - // }), + terser({ + output: { + comments: false, + }, + }), ], }; diff --git a/test/__snapshots__/index.spec.js.snap b/test/__snapshots__/index.spec.js.snap new file mode 100644 index 00000000..4c212bd1 --- /dev/null +++ b/test/__snapshots__/index.spec.js.snap @@ -0,0 +1,5223 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`v2 should generate: ./test/result/v2/core/ApiError.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { isSuccess } from './isSuccess'; +import { Result } from './Result'; + +export class ApiError extends Error { + + public readonly url: string; + public readonly status: number; + public readonly statusText: string; + public readonly body: any; + + constructor(result: Readonly, message: string) { + super(message); + + this.url = result.url; + this.status = result.status; + this.statusText = result.statusText; + this.body = result.body; + } +} + +export namespace ApiError { + export enum Message { + BAD_REQUEST = 'Bad Request', + UNAUTHORIZED = 'Unauthorized', + FORBIDDEN = 'Forbidden', + NOT_FOUND = 'Not Found', + INTERNAL_SERVER_ERROR = 'Internal Server Error', + BAD_GATEWAY = 'Bad Gateway', + SERVICE_UNAVAILABLE = 'Service Unavailable', + GENERIC_ERROR = 'Generic Error', + } +} + +/** + * Catch common errors (based on status code). + * @param result + */ +export function catchGenericError(result: Result): void { + switch (result.status) { + case 400: throw new ApiError(result, ApiError.Message.BAD_REQUEST); + case 401: throw new ApiError(result, ApiError.Message.UNAUTHORIZED); + case 403: throw new ApiError(result, ApiError.Message.FORBIDDEN); + case 404: throw new ApiError(result, ApiError.Message.NOT_FOUND); + case 500: throw new ApiError(result, ApiError.Message.INTERNAL_SERVER_ERROR); + case 502: throw new ApiError(result, ApiError.Message.BAD_GATEWAY); + case 503: throw new ApiError(result, ApiError.Message.SERVICE_UNAVAILABLE); + } + + if (!isSuccess(result.status)) { + throw new ApiError(result, ApiError.Message.GENERIC_ERROR); + } +} +" +`; + +exports[`v2 should generate: ./test/result/v2/core/OpenAPI.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +interface Config { + BASE: string; + VERSION: string; + CLIENT: 'fetch' | 'xhr'; + WITH_CREDENTIALS: boolean; + TOKEN: string; +} + +export const OpenAPI: Config = { + BASE: 'http://localhost:8080/api', + VERSION: '9.0', + CLIENT: 'fetch', + WITH_CREDENTIALS: false, + TOKEN: '', +};" +`; + +exports[`v2 should generate: ./test/result/v2/core/RequestOptions.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export interface RequestOptions { + method: 'get' | 'put' | 'post' | 'delete' | 'options' | 'head' | 'patch'; + path: string; + cookies?: { [key: string]: any }; + headers?: { [key: string]: any }; + query?: { [key: string]: any }; + formData?: { [key: string]: any }; + body?: any; + responseHeader?: string; +} +" +`; + +exports[`v2 should generate: ./test/result/v2/core/Result.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export interface Result { + url: string; + ok: boolean; + status: number; + statusText: string; + body: any; +} +" +`; + +exports[`v2 should generate: ./test/result/v2/core/getFormData.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * Get FormData from object. This method is needed to upload + * multipart form data to the REST API. + * @param params Key value based object. + */ +export function getFormData(params: { [key: string]: any }): FormData { + const formData = new FormData(); + for (const key in params) { + if (typeof params[key] !== 'undefined') { + const value: any = params[key]; + if (value !== undefined && value !== null) { + formData.append(key, value); + } + } + } + return formData; +} +" +`; + +exports[`v2 should generate: ./test/result/v2/core/getQueryString.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * Get query string from query parameters object. This method also + * supports multi-value items by creating a key for each item. + * @param params Key value based object. + */ +export function getQueryString(params: { [key: string]: any }): string { + const qs: string[] = []; + for (const key in params) { + if (typeof params[key] !== 'undefined') { + const value: any = params[key]; + if (value !== undefined && value !== null) { + if (Array.isArray(value)) { + value.forEach(value => { + qs.push(\`\${encodeURIComponent(key)}=\${encodeURIComponent(String(value))}\`); + }); + } else { + qs.push(\`\${encodeURIComponent(key)}=\${encodeURIComponent(String(value))}\`); + } + } + } + } + if (qs.length > 0) { + return \`?\${qs.join('&')}\`; + } + return ''; +} +" +`; + +exports[`v2 should generate: ./test/result/v2/core/isSuccess.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * Check success response code. + * @param status Status code + */ +export function isSuccess(status: number): boolean { + return status >= 200 && status < 300; +} +" +`; + +exports[`v2 should generate: ./test/result/v2/core/request.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { getFormData } from './getFormData'; +import { getQueryString } from './getQueryString'; +import { OpenAPI } from './OpenAPI'; +import { RequestOptions } from './RequestOptions'; +import { requestUsingFetch } from './requestUsingFetch'; +import { requestUsingXHR } from './requestUsingXHR'; +import { Result } from './Result'; + +/** + * Create the request. + * @param options Request method options. + * @returns Result object (see above) + */ +export async function request(options: Readonly): Promise { + + // Escape path (RFC3986) and create the request URL + let path = options.path.replace(/[:]/g, '_'); + let url = \`\${OpenAPI.BASE}\${path}\`; + + // Create request headers + const headers = new Headers({ + ...options.headers, + Accept: 'application/json', + }); + + // Create request settings + const request: RequestInit = { + headers, + method: options.method, + }; + + // If we specified to send requests with credentials, then we + // set the request credentials options to include. This is only + // needed if you make cross-origin calls. + if (OpenAPI.WITH_CREDENTIALS) { + request.credentials = 'include'; + } + + // If we have a bearer token then we set the authentication header. + if (OpenAPI.TOKEN !== null && OpenAPI.TOKEN !== '') { + headers.append('Authorization', \`Bearer \${OpenAPI.TOKEN}\`); + } + + // Add the query parameters (if defined). + if (options.query) { + url += getQueryString(options.query); + } + + // Append formData as body + if (options.formData) { + request.body = getFormData(options.formData); + } else if (options.body) { + + // If this is blob data, then pass it directly to the body and set content type. + // Otherwise we just convert request data to JSON string (needed for fetch api) + if (options.body instanceof Blob) { + request.body = options.body; + if (options.body.type) { + headers.append('Content-Type', options.body.type); + } + } else { + request.body = JSON.stringify(options.body); + headers.append('Content-Type', 'application/json'); + } + } + + try { + switch (OpenAPI.CLIENT) { + case 'xhr': + return await requestUsingXHR(url, request, options.responseHeader); + default: + return await requestUsingFetch(url, request, options.responseHeader); + } + } catch (error) { + return { + url, + ok: false, + status: 0, + statusText: '', + body: error, + }; + } +} +" +`; + +exports[`v2 should generate: ./test/result/v2/core/requestUsingFetch.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { Result } from './Result'; + +/** + * Try to parse the content for any response status code. + * We check the \\"Content-Type\\" header to see if we need to parse the + * content as json or as plain text. + * @param response Response object from fetch + */ +async function parseBody(response: Response): Promise { + try { + const contentType = response.headers.get('Content-Type'); + if (contentType) { + switch (contentType.toLowerCase()) { + case 'application/json': + case 'application/json; charset=utf-8': + return await response.json(); + + default: + return await response.text(); + } + } + } catch (e) { + console.error(e); + } + return null; +} + +/** + * Fetch the response header (if specified) + * @param response Response object from fetch + * @param responseHeader The name of the header to fetch + */ +function parseHeader(response: Response, responseHeader?: string): string | null { + if (responseHeader) { + const content = response.headers.get(responseHeader); + if (typeof content === 'string') { + return content; + } + } + return null; +} + +/** + * Request content using the new Fetch API. This is the default API that is used and + * is create for all JSON, XML and text objects. However it is limited to UTF-8. + * This is a problem for some of the Docs content, since that requires UTF-16! + * @param url The url to request. + * @param request The request object, containing method, headers, body, etc. + * @param responseHeader The header we want to parse. + */ +export async function requestUsingFetch(url: string, request: Readonly, responseHeader?: string): Promise { + + // Fetch response using fetch API. + const response = await fetch(url, request); + + // Get content of response header or response body + const contentHeader = parseHeader(response, responseHeader); + const contentBody = await parseBody(response); + + // Create result object. + return { + url, + ok: response.ok, + status: response.status, + statusText: response.statusText, + body: contentHeader || contentBody, + }; +} +" +`; + +exports[`v2 should generate: ./test/result/v2/core/requestUsingXHR.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { isSuccess } from './isSuccess'; +import { Result } from './Result'; + +/** + * Try to parse the content for any response status code. + * We check the \\"Content-Type\\" header to see if we need to parse the + * content as json or as plain text. + * @param xhr XHR request object + */ +function parseBody(xhr: XMLHttpRequest): any { + try { + const contentType = xhr.getResponseHeader('Content-Type'); + if (contentType) { + switch (contentType.toLowerCase()) { + case 'application/json': + case 'application/json; charset=utf-8': + return JSON.parse(xhr.responseText); + + default: + return xhr.responseText; + } + } + } catch (e) { + console.error(e); + } + return null; +} + +/** + * Fetch the response header (if specified) + * @param xhr XHR request object + * @param responseHeader The name of the header to fetch + */ +function parseHeader(xhr: XMLHttpRequest, responseHeader?: string): string | null { + if (responseHeader) { + const content = xhr.getResponseHeader(responseHeader); + if (typeof content === 'string') { + return content; + } + } + return null; +} + +/** + * Request content using the new legacy XMLHttpRequest API. This method is useful + * when we want to request UTF-16 content, since it natively supports loading UTF-16. + * We could do the same with the Fetch API, but then we will need to convert the + * content using JavaScript... And that is very very slow. + * @param url The url to request. + * @param request The request object, containing method, headers, body, etc. + * @param responseHeader The header we want to parse. + */ +export async function requestUsingXHR(url: string, request: Readonly, responseHeader?: string): Promise { + return new Promise(resolve => { + const xhr = new XMLHttpRequest(); + + // Open the request, remember to do this before adding any headers, + // because the request needs to be initialized! + xhr.open(request.method!, url, true); + + // When request credentials are set to include then this is + // the same behaviour as withCredentials = true in XHR: + // https://developer.mozilla.org/en-US/docs/Web/API/Request/credentials + xhr.withCredentials = request.credentials === 'include'; + + // Add the headers (required when dealing with JSON) + const headers = request.headers as Headers; + headers.forEach((value: string, key: string): void => { + xhr.setRequestHeader(key, value); + }); + + // Register the readystate handler, this will fire when the request is done. + xhr.onreadystatechange = () => { + if (xhr.readyState === XMLHttpRequest.DONE) { + + // Get content of response header or response body + const contentHeader = parseHeader(xhr, responseHeader); + const contentBody = parseBody(xhr); + + // Create result object. + const result: Result = { + url, + ok: isSuccess(xhr.status), + status: xhr.status, + statusText: xhr.statusText, + body: contentHeader || contentBody, + }; + + // Done! + resolve(result); + } + }; + + // Start the request! + xhr.send(request.body); + }); +} +" +`; + +exports[`v2 should generate: ./test/result/v2/index.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export { ApiError } from './core/ApiError'; +export { isSuccess } from './core/isSuccess'; +export { OpenAPI } from './core/OpenAPI'; + +export type { ArrayWithArray } from './models/ArrayWithArray'; +export type { ArrayWithBooleans } from './models/ArrayWithBooleans'; +export type { ArrayWithNumbers } from './models/ArrayWithNumbers'; +export type { ArrayWithProperties } from './models/ArrayWithProperties'; +export type { ArrayWithReferences } from './models/ArrayWithReferences'; +export type { ArrayWithStrings } from './models/ArrayWithStrings'; +export type { DictionaryWithArray } from './models/DictionaryWithArray'; +export type { DictionaryWithDictionary } from './models/DictionaryWithDictionary'; +export type { DictionaryWithProperties } from './models/DictionaryWithProperties'; +export type { DictionaryWithReference } from './models/DictionaryWithReference'; +export type { DictionaryWithString } from './models/DictionaryWithString'; +export { EnumFromDescription } from './models/EnumFromDescription'; +export { EnumWithExtensions } from './models/EnumWithExtensions'; +export { EnumWithNumbers } from './models/EnumWithNumbers'; +export { EnumWithStrings } from './models/EnumWithStrings'; +export type { ModelLink } from './models/ModelLink'; +export type { ModelThatExtends } from './models/ModelThatExtends'; +export type { ModelThatExtendsExtends } from './models/ModelThatExtendsExtends'; +export type { ModelWithArray } from './models/ModelWithArray'; +export type { ModelWithBoolean } from './models/ModelWithBoolean'; +export type { ModelWithCircularReference } from './models/ModelWithCircularReference'; +export type { ModelWithDictionary } from './models/ModelWithDictionary'; +export type { ModelWithDuplicateImports } from './models/ModelWithDuplicateImports'; +export type { ModelWithDuplicateProperties } from './models/ModelWithDuplicateProperties'; +export { ModelWithEnum } from './models/ModelWithEnum'; +export { ModelWithEnumFromDescription } from './models/ModelWithEnumFromDescription'; +export type { ModelWithInteger } from './models/ModelWithInteger'; +export type { ModelWithLink } from './models/ModelWithLink'; +export type { ModelWithNestedEnums } from './models/ModelWithNestedEnums'; +export type { ModelWithNestedProperties } from './models/ModelWithNestedProperties'; +export type { ModelWithOrderedProperties } from './models/ModelWithOrderedProperties'; +export type { ModelWithPattern } from './models/ModelWithPattern'; +export type { ModelWithProperties } from './models/ModelWithProperties'; +export type { ModelWithReference } from './models/ModelWithReference'; +export type { ModelWithString } from './models/ModelWithString'; +export type { MultilineComment } from './models/MultilineComment'; +export type { SimpleBoolean } from './models/SimpleBoolean'; +export type { SimpleFile } from './models/SimpleFile'; +export type { SimpleInteger } from './models/SimpleInteger'; +export type { SimpleReference } from './models/SimpleReference'; +export type { SimpleString } from './models/SimpleString'; + +export { $ArrayWithArray } from './schemas/$ArrayWithArray'; +export { $ArrayWithBooleans } from './schemas/$ArrayWithBooleans'; +export { $ArrayWithNumbers } from './schemas/$ArrayWithNumbers'; +export { $ArrayWithProperties } from './schemas/$ArrayWithProperties'; +export { $ArrayWithReferences } from './schemas/$ArrayWithReferences'; +export { $ArrayWithStrings } from './schemas/$ArrayWithStrings'; +export { $DictionaryWithArray } from './schemas/$DictionaryWithArray'; +export { $DictionaryWithDictionary } from './schemas/$DictionaryWithDictionary'; +export { $DictionaryWithProperties } from './schemas/$DictionaryWithProperties'; +export { $DictionaryWithReference } from './schemas/$DictionaryWithReference'; +export { $DictionaryWithString } from './schemas/$DictionaryWithString'; +export { $EnumFromDescription } from './schemas/$EnumFromDescription'; +export { $EnumWithExtensions } from './schemas/$EnumWithExtensions'; +export { $EnumWithNumbers } from './schemas/$EnumWithNumbers'; +export { $EnumWithStrings } from './schemas/$EnumWithStrings'; +export { $ModelLink } from './schemas/$ModelLink'; +export { $ModelThatExtends } from './schemas/$ModelThatExtends'; +export { $ModelThatExtendsExtends } from './schemas/$ModelThatExtendsExtends'; +export { $ModelWithArray } from './schemas/$ModelWithArray'; +export { $ModelWithBoolean } from './schemas/$ModelWithBoolean'; +export { $ModelWithCircularReference } from './schemas/$ModelWithCircularReference'; +export { $ModelWithDictionary } from './schemas/$ModelWithDictionary'; +export { $ModelWithDuplicateImports } from './schemas/$ModelWithDuplicateImports'; +export { $ModelWithDuplicateProperties } from './schemas/$ModelWithDuplicateProperties'; +export { $ModelWithEnum } from './schemas/$ModelWithEnum'; +export { $ModelWithEnumFromDescription } from './schemas/$ModelWithEnumFromDescription'; +export { $ModelWithInteger } from './schemas/$ModelWithInteger'; +export { $ModelWithLink } from './schemas/$ModelWithLink'; +export { $ModelWithNestedEnums } from './schemas/$ModelWithNestedEnums'; +export { $ModelWithNestedProperties } from './schemas/$ModelWithNestedProperties'; +export { $ModelWithOrderedProperties } from './schemas/$ModelWithOrderedProperties'; +export { $ModelWithPattern } from './schemas/$ModelWithPattern'; +export { $ModelWithProperties } from './schemas/$ModelWithProperties'; +export { $ModelWithReference } from './schemas/$ModelWithReference'; +export { $ModelWithString } from './schemas/$ModelWithString'; +export { $MultilineComment } from './schemas/$MultilineComment'; +export { $SimpleBoolean } from './schemas/$SimpleBoolean'; +export { $SimpleFile } from './schemas/$SimpleFile'; +export { $SimpleInteger } from './schemas/$SimpleInteger'; +export { $SimpleReference } from './schemas/$SimpleReference'; +export { $SimpleString } from './schemas/$SimpleString'; + +export { ComplexService } from './services/ComplexService'; +export { DefaultsService } from './services/DefaultsService'; +export { DuplicateService } from './services/DuplicateService'; +export { HeaderService } from './services/HeaderService'; +export { ParametersService } from './services/ParametersService'; +export { ResponseService } from './services/ResponseService'; +export { SimpleService } from './services/SimpleService'; +export { TypesService } from './services/TypesService'; +" +`; + +exports[`v2 should generate: ./test/result/v2/models/ArrayWithArray.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { ModelWithString } from './ModelWithString'; + +/** + * This is a simple array containing an array + */ +export type ArrayWithArray = Array>;" +`; + +exports[`v2 should generate: ./test/result/v2/models/ArrayWithBooleans.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + + +/** + * This is a simple array with booleans + */ +export type ArrayWithBooleans = Array;" +`; + +exports[`v2 should generate: ./test/result/v2/models/ArrayWithNumbers.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + + +/** + * This is a simple array with numbers + */ +export type ArrayWithNumbers = Array;" +`; + +exports[`v2 should generate: ./test/result/v2/models/ArrayWithProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + + +/** + * This is a simple array with properties + */ +export type ArrayWithProperties = Array<{ + foo?: string, + bar?: string, +}>;" +`; + +exports[`v2 should generate: ./test/result/v2/models/ArrayWithReferences.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { ModelWithString } from './ModelWithString'; + +/** + * This is a simple array with references + */ +export type ArrayWithReferences = Array;" +`; + +exports[`v2 should generate: ./test/result/v2/models/ArrayWithStrings.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + + +/** + * This is a simple array with strings + */ +export type ArrayWithStrings = Array;" +`; + +exports[`v2 should generate: ./test/result/v2/models/Dictionary.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type Dictionary = { + [key: string]: T; +} +" +`; + +exports[`v2 should generate: ./test/result/v2/models/DictionaryWithArray.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { Dictionary } from './Dictionary'; +import { ModelWithString } from './ModelWithString'; + +/** + * This is a complex dictionary + */ +export type DictionaryWithArray = Dictionary>;" +`; + +exports[`v2 should generate: ./test/result/v2/models/DictionaryWithDictionary.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { Dictionary } from './Dictionary'; + +/** + * This is a string dictionary + */ +export type DictionaryWithDictionary = Dictionary>;" +`; + +exports[`v2 should generate: ./test/result/v2/models/DictionaryWithProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { Dictionary } from './Dictionary'; + +/** + * This is a complex dictionary + */ +export type DictionaryWithProperties = Dictionary<{ + foo?: string, + bar?: string, +}>;" +`; + +exports[`v2 should generate: ./test/result/v2/models/DictionaryWithReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { Dictionary } from './Dictionary'; +import { ModelWithString } from './ModelWithString'; + +/** + * This is a string reference + */ +export type DictionaryWithReference = Dictionary;" +`; + +exports[`v2 should generate: ./test/result/v2/models/DictionaryWithString.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { Dictionary } from './Dictionary'; + +/** + * This is a string dictionary + */ +export type DictionaryWithString = Dictionary;" +`; + +exports[`v2 should generate: ./test/result/v2/models/EnumFromDescription.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + + +/** + * Success=1,Warning=2,Error=3 + */ +export enum EnumFromDescription { + SUCCESS = 1, + WARNING = 2, + ERROR = 3, +}" +`; + +exports[`v2 should generate: ./test/result/v2/models/EnumWithExtensions.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + + +/** + * This is a simple enum with numbers + */ +export enum EnumWithExtensions { + /** + * Used when the status of something is successful + */ + CUSTOM_SUCCESS = 200, + /** + * Used when the status of something has a warning + */ + CUSTOM_WARNING = 400, + /** + * Used when the status of something has an error + */ + CUSTOM_ERROR = 500, +}" +`; + +exports[`v2 should generate: ./test/result/v2/models/EnumWithNumbers.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + + +/** + * This is a simple enum with numbers + */ +export enum EnumWithNumbers { + _1 = 1, + _2 = 2, + _3 = 3, +}" +`; + +exports[`v2 should generate: ./test/result/v2/models/EnumWithStrings.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + + +/** + * This is a simple enum with strings + */ +export enum EnumWithStrings { + SUCCESS = 'Success', + WARNING = 'Warning', + ERROR = 'Error', +}" +`; + +exports[`v2 should generate: ./test/result/v2/models/ModelLink.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + + +/** + * This is a model that can have a template?? + */ +export interface ModelLink { + id?: string; +} +" +`; + +exports[`v2 should generate: ./test/result/v2/models/ModelThatExtends.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { ModelWithString } from './ModelWithString'; + +/** + * This is a model that extends another model + */ +export interface ModelThatExtends extends ModelWithString { + propExtendsA?: string; + propExtendsB?: ModelWithString; +} +" +`; + +exports[`v2 should generate: ./test/result/v2/models/ModelThatExtendsExtends.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { ModelThatExtends } from './ModelThatExtends'; +import { ModelWithString } from './ModelWithString'; + +/** + * This is a model that extends another model + */ +export interface ModelThatExtendsExtends extends ModelWithString, ModelThatExtends { + propExtendsC?: string; + propExtendsD?: ModelWithString; +} +" +`; + +exports[`v2 should generate: ./test/result/v2/models/ModelWithArray.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { ModelWithString } from './ModelWithString'; + +/** + * This is a model with one property containing an array + */ +export interface ModelWithArray { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +} +" +`; + +exports[`v2 should generate: ./test/result/v2/models/ModelWithBoolean.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + + +/** + * This is a model with one boolean property + */ +export interface ModelWithBoolean { + /** + * This is a simple boolean property + */ + prop?: boolean; +} +" +`; + +exports[`v2 should generate: ./test/result/v2/models/ModelWithCircularReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + + +/** + * This is a model with one property containing a circular reference + */ +export interface ModelWithCircularReference { + prop?: ModelWithCircularReference; +} +" +`; + +exports[`v2 should generate: ./test/result/v2/models/ModelWithDictionary.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { Dictionary } from './Dictionary'; + +/** + * This is a model with one property containing a dictionary + */ +export interface ModelWithDictionary { + prop?: Dictionary; +} +" +`; + +exports[`v2 should generate: ./test/result/v2/models/ModelWithDuplicateImports.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { ModelWithString } from './ModelWithString'; + +/** + * This is a model with duplicated imports + */ +export interface ModelWithDuplicateImports { + propA?: ModelWithString; + propB?: ModelWithString; + propC?: ModelWithString; +} +" +`; + +exports[`v2 should generate: ./test/result/v2/models/ModelWithDuplicateProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { ModelWithString } from './ModelWithString'; + +/** + * This is a model with duplicated properties + */ +export interface ModelWithDuplicateProperties { + prop?: ModelWithString; +} +" +`; + +exports[`v2 should generate: ./test/result/v2/models/ModelWithEnum.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + + +/** + * This is a model with one enum + */ +export interface ModelWithEnum { + /** + * This is a simple enum with strings + */ + test?: ModelWithEnum.test; + /** + * These are the HTTP error code enums + */ + statusCode?: ModelWithEnum.statusCode; +} + +export namespace ModelWithEnum { + + /** + * This is a simple enum with strings + */ + export enum test { + SUCCESS = 'Success', + WARNING = 'Warning', + ERROR = 'Error', + } + + /** + * These are the HTTP error code enums + */ + export enum statusCode { + _100 = '100', + _200_FOO = '200 FOO', + _300_FOO_BAR = '300 FOO_BAR', + _400_FOO_BAR = '400 foo-bar', + _500_FOO_BAR = '500 foo.bar', + _600_FOO_BAR = '600 foo&bar', + } + + +} +" +`; + +exports[`v2 should generate: ./test/result/v2/models/ModelWithEnumFromDescription.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + + +/** + * This is a model with one enum + */ +export interface ModelWithEnumFromDescription { + /** + * Success=1,Warning=2,Error=3 + */ + test?: ModelWithEnumFromDescription.test; +} + +export namespace ModelWithEnumFromDescription { + + /** + * Success=1,Warning=2,Error=3 + */ + export enum test { + SUCCESS = 1, + WARNING = 2, + ERROR = 3, + } + + +} +" +`; + +exports[`v2 should generate: ./test/result/v2/models/ModelWithInteger.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + + +/** + * This is a model with one number property + */ +export interface ModelWithInteger { + /** + * This is a simple number property + */ + prop?: number; +} +" +`; + +exports[`v2 should generate: ./test/result/v2/models/ModelWithLink.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { ModelLink } from './ModelLink'; +import { ModelWithString } from './ModelWithString'; + +/** + * This is a model that can have a template?? + */ +export interface ModelWithLink { + prop?: ModelLink; +} +" +`; + +exports[`v2 should generate: ./test/result/v2/models/ModelWithNestedEnums.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { Dictionary } from './Dictionary'; + +/** + * This is a model with nested enums + */ +export interface ModelWithNestedEnums { + dictionaryWithEnum?: Dictionary<('Success' | 'Warning' | 'Error')>; + dictionaryWithEnumFromDescription?: Dictionary<(1 | 2 | 3)>; + arrayWithEnum?: Array<('Success' | 'Warning' | 'Error')>; + arrayWithDescription?: Array<(1 | 2 | 3)>; +} +" +`; + +exports[`v2 should generate: ./test/result/v2/models/ModelWithNestedProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + + +/** + * This is a model with one nested property + */ +export interface ModelWithNestedProperties { + readonly first: { + readonly second: { + readonly third: string, + }, + }; +} +" +`; + +exports[`v2 should generate: ./test/result/v2/models/ModelWithOrderedProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + + +/** + * This is a model with ordered properties + */ +export interface ModelWithOrderedProperties { + zebra?: string; + apple?: string; + hawaii?: string; +} +" +`; + +exports[`v2 should generate: ./test/result/v2/models/ModelWithPattern.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + + +/** + * This is a model that contains a some patterns + */ +export interface ModelWithPattern { + key: string; + name: string; + readonly enabled?: boolean; + readonly modified?: string; +} +" +`; + +exports[`v2 should generate: ./test/result/v2/models/ModelWithProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { ModelWithString } from './ModelWithString'; + +/** + * This is a model with one nested property + */ +export interface ModelWithProperties { + required: string; + readonly requiredAndReadOnly: string; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; +} +" +`; + +exports[`v2 should generate: ./test/result/v2/models/ModelWithReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { ModelWithProperties } from './ModelWithProperties'; + +/** + * This is a model with one property containing a reference + */ +export interface ModelWithReference { + prop?: ModelWithProperties; +} +" +`; + +exports[`v2 should generate: ./test/result/v2/models/ModelWithString.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + + +/** + * This is a model with one string property + */ +export interface ModelWithString { + /** + * This is a simple string property + */ + prop?: string; +} +" +`; + +exports[`v2 should generate: ./test/result/v2/models/MultilineComment.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + + +/** + * Testing multiline comments. + * This must go to the next line. + * + * This will contain a break. + */ +export type MultilineComment = number;" +`; + +exports[`v2 should generate: ./test/result/v2/models/SimpleBoolean.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + + +/** + * This is a simple boolean + */ +export type SimpleBoolean = boolean;" +`; + +exports[`v2 should generate: ./test/result/v2/models/SimpleFile.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + + +/** + * This is a simple file + */ +export type SimpleFile = File;" +`; + +exports[`v2 should generate: ./test/result/v2/models/SimpleInteger.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + + +/** + * This is a simple number + */ +export type SimpleInteger = number;" +`; + +exports[`v2 should generate: ./test/result/v2/models/SimpleReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { ModelWithString } from './ModelWithString'; + +/** + * This is a simple reference + */ +export type SimpleReference = ModelWithString;" +`; + +exports[`v2 should generate: ./test/result/v2/models/SimpleString.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + + +/** + * This is a simple string + */ +export type SimpleString = string;" +`; + +exports[`v2 should generate: ./test/result/v2/schemas/$ArrayWithArray.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ArrayWithArray = { + type: 'Array', +};" +`; + +exports[`v2 should generate: ./test/result/v2/schemas/$ArrayWithBooleans.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ArrayWithBooleans = { + type: 'Array', +};" +`; + +exports[`v2 should generate: ./test/result/v2/schemas/$ArrayWithNumbers.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ArrayWithNumbers = { + type: 'Array', +};" +`; + +exports[`v2 should generate: ./test/result/v2/schemas/$ArrayWithProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ArrayWithProperties = { + type: 'Array', +};" +`; + +exports[`v2 should generate: ./test/result/v2/schemas/$ArrayWithReferences.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ArrayWithReferences = { + type: 'Array', +};" +`; + +exports[`v2 should generate: ./test/result/v2/schemas/$ArrayWithStrings.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ArrayWithStrings = { + type: 'Array', +};" +`; + +exports[`v2 should generate: ./test/result/v2/schemas/$DictionaryWithArray.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $DictionaryWithArray = { + type: 'Dictionary', +};" +`; + +exports[`v2 should generate: ./test/result/v2/schemas/$DictionaryWithDictionary.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $DictionaryWithDictionary = { + type: 'Dictionary', +};" +`; + +exports[`v2 should generate: ./test/result/v2/schemas/$DictionaryWithProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $DictionaryWithProperties = { + type: 'Dictionary', +};" +`; + +exports[`v2 should generate: ./test/result/v2/schemas/$DictionaryWithReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $DictionaryWithReference = { + type: 'Dictionary', +};" +`; + +exports[`v2 should generate: ./test/result/v2/schemas/$DictionaryWithString.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $DictionaryWithString = { + type: 'Dictionary', +};" +`; + +exports[`v2 should generate: ./test/result/v2/schemas/$EnumFromDescription.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $EnumFromDescription = { + type: 'Enum', +};" +`; + +exports[`v2 should generate: ./test/result/v2/schemas/$EnumWithExtensions.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $EnumWithExtensions = { + type: 'Enum', +};" +`; + +exports[`v2 should generate: ./test/result/v2/schemas/$EnumWithNumbers.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $EnumWithNumbers = { + type: 'Enum', +};" +`; + +exports[`v2 should generate: ./test/result/v2/schemas/$EnumWithStrings.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $EnumWithStrings = { + type: 'Enum', +};" +`; + +exports[`v2 should generate: ./test/result/v2/schemas/$ModelLink.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelLink = { + properties: { + id: { + type: 'string', + }, + }, +};" +`; + +exports[`v2 should generate: ./test/result/v2/schemas/$ModelThatExtends.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { $ModelWithString } from './$ModelWithString'; + +export const $ModelThatExtends = { + properties: { + ...$ModelWithString.properties, + propExtendsA: { + type: 'string', + }, + propExtendsB: { + type: 'ModelWithString', + }, + }, +};" +`; + +exports[`v2 should generate: ./test/result/v2/schemas/$ModelThatExtendsExtends.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { $ModelWithString } from './$ModelWithString'; +import { $ModelThatExtends } from './$ModelThatExtends'; + +export const $ModelThatExtendsExtends = { + properties: { + ...$ModelWithString.properties, + ...$ModelThatExtends.properties, + propExtendsC: { + type: 'string', + }, + propExtendsD: { + type: 'ModelWithString', + }, + }, +};" +`; + +exports[`v2 should generate: ./test/result/v2/schemas/$ModelWithArray.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithArray = { + properties: { + prop: { + type: 'Array', + }, + propWithFile: { + type: 'Array', + }, + propWithNumber: { + type: 'Array', + }, + }, +};" +`; + +exports[`v2 should generate: ./test/result/v2/schemas/$ModelWithBoolean.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithBoolean = { + properties: { + prop: { + type: 'boolean', + }, + }, +};" +`; + +exports[`v2 should generate: ./test/result/v2/schemas/$ModelWithCircularReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithCircularReference = { + properties: { + prop: { + type: 'ModelWithCircularReference', + }, + }, +};" +`; + +exports[`v2 should generate: ./test/result/v2/schemas/$ModelWithDictionary.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithDictionary = { + properties: { + prop: { + type: 'Dictionary', + }, + }, +};" +`; + +exports[`v2 should generate: ./test/result/v2/schemas/$ModelWithDuplicateImports.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithDuplicateImports = { + properties: { + propA: { + type: 'ModelWithString', + }, + propB: { + type: 'ModelWithString', + }, + propC: { + type: 'ModelWithString', + }, + }, +};" +`; + +exports[`v2 should generate: ./test/result/v2/schemas/$ModelWithDuplicateProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithDuplicateProperties = { + properties: { + prop: { + type: 'ModelWithString', + }, + }, +};" +`; + +exports[`v2 should generate: ./test/result/v2/schemas/$ModelWithEnum.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithEnum = { + properties: { + test: { + type: 'Enum', + }, + statusCode: { + type: 'Enum', + }, + }, +};" +`; + +exports[`v2 should generate: ./test/result/v2/schemas/$ModelWithEnumFromDescription.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithEnumFromDescription = { + properties: { + test: { + type: 'Enum', + }, + }, +};" +`; + +exports[`v2 should generate: ./test/result/v2/schemas/$ModelWithInteger.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithInteger = { + properties: { + prop: { + type: 'number', + }, + }, +};" +`; + +exports[`v2 should generate: ./test/result/v2/schemas/$ModelWithLink.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithLink = { + properties: { + prop: { + type: 'ModelLink', + }, + }, +};" +`; + +exports[`v2 should generate: ./test/result/v2/schemas/$ModelWithNestedEnums.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithNestedEnums = { + properties: { + dictionaryWithEnum: { + type: 'Dictionary', + }, + dictionaryWithEnumFromDescription: { + type: 'Dictionary', + }, + arrayWithEnum: { + type: 'Array', + }, + arrayWithDescription: { + type: 'Array', + }, + }, +};" +`; + +exports[`v2 should generate: ./test/result/v2/schemas/$ModelWithNestedProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithNestedProperties = { + properties: { + first: { + properties: { + second: { + properties: { + third: { + type: 'string', + isReadOnly: true, + isRequired: true, + }, + }, + isReadOnly: true, + isRequired: true, + }, + }, + isReadOnly: true, + isRequired: true, + }, + }, +};" +`; + +exports[`v2 should generate: ./test/result/v2/schemas/$ModelWithOrderedProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithOrderedProperties = { + properties: { + zebra: { + type: 'string', + }, + apple: { + type: 'string', + }, + hawaii: { + type: 'string', + }, + }, +};" +`; + +exports[`v2 should generate: ./test/result/v2/schemas/$ModelWithPattern.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithPattern = { + properties: { + key: { + type: 'string', + isRequired: true, + maxLength: 64, + pattern: '^[a-zA-Z0-9_]*$', + }, + name: { + type: 'string', + isRequired: true, + maxLength: 255, + }, + enabled: { + type: 'boolean', + isReadOnly: true, + }, + modified: { + type: 'string', + isReadOnly: true, + format: 'date-time', + }, + }, +};" +`; + +exports[`v2 should generate: ./test/result/v2/schemas/$ModelWithProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithProperties = { + properties: { + required: { + type: 'string', + isRequired: true, + }, + requiredAndReadOnly: { + type: 'string', + isReadOnly: true, + isRequired: true, + }, + string: { + type: 'string', + }, + number: { + type: 'number', + }, + boolean: { + type: 'boolean', + }, + reference: { + type: 'ModelWithString', + }, + }, +};" +`; + +exports[`v2 should generate: ./test/result/v2/schemas/$ModelWithReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithReference = { + properties: { + prop: { + type: 'ModelWithProperties', + }, + }, +};" +`; + +exports[`v2 should generate: ./test/result/v2/schemas/$ModelWithString.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithString = { + properties: { + prop: { + type: 'string', + }, + }, +};" +`; + +exports[`v2 should generate: ./test/result/v2/schemas/$MultilineComment.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $MultilineComment = { + type: 'number', +};" +`; + +exports[`v2 should generate: ./test/result/v2/schemas/$SimpleBoolean.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $SimpleBoolean = { + type: 'boolean', +};" +`; + +exports[`v2 should generate: ./test/result/v2/schemas/$SimpleFile.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $SimpleFile = { + type: 'File', +};" +`; + +exports[`v2 should generate: ./test/result/v2/schemas/$SimpleInteger.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $SimpleInteger = { + type: 'number', +};" +`; + +exports[`v2 should generate: ./test/result/v2/schemas/$SimpleReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $SimpleReference = { + type: 'ModelWithString', +};" +`; + +exports[`v2 should generate: ./test/result/v2/schemas/$SimpleString.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $SimpleString = { + type: 'string', +};" +`; + +exports[`v2 should generate: ./test/result/v2/services/ComplexService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { ModelWithString } from '../models/ModelWithString'; +import { ApiError, catchGenericError } from '../core/ApiError'; +import { request as __request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class ComplexService { + + /** + * @param parameterObject Parameter containing object + * @param parameterReference Parameter containing reference + * @result ModelWithString Successful response + * @throws ApiError + */ + public static async complexTypes( + parameterObject: { + first?: { + second?: { + third?: string, + }, + }, + }, + parameterReference: ModelWithString, + ): Promise> { + + const result = await __request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/complex\`, + query: { + 'parameterObject': parameterObject, + 'parameterReference': parameterReference, + }, + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`400 server error\`); + case 500: throw new ApiError(result, \`500 server error\`); + } + } + + catchGenericError(result); + + return result.body; + } + +}" +`; + +exports[`v2 should generate: ./test/result/v2/services/DefaultsService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { ModelWithString } from '../models/ModelWithString'; +import { catchGenericError } from '../core/ApiError'; +import { request as __request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class DefaultsService { + + /** + * @param parameterString This is a simple string with default value + * @param parameterNumber This is a simple number with default value + * @param parameterBoolean This is a simple boolean with default value + * @param parameterEnum This is a simple enum with default value + * @param parameterModel This is a simple model with default value + * @throws ApiError + */ + public static async callWithDefaultParameters( + parameterString: string = 'Hello World!', + parameterNumber: number = 123, + parameterBoolean: boolean = true, + parameterEnum: ('Success' | 'Warning' | 'Error') = 'Success', + parameterModel: ModelWithString = { + \\"prop\\": \\"Hello World\\" + }, + ): Promise { + + const result = await __request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/defaults\`, + query: { + 'parameterString': parameterString, + 'parameterNumber': parameterNumber, + 'parameterBoolean': parameterBoolean, + 'parameterEnum': parameterEnum, + 'parameterModel': parameterModel, + }, + }); + + catchGenericError(result); + + return result.body; + } + + /** + * @param parameterString This is a simple string that is optional with default value + * @param parameterNumber This is a simple number that is optional with default value + * @param parameterBoolean This is a simple boolean that is optional with default value + * @param parameterEnum This is a simple enum that is optional with default value + * @param parameterModel This is a simple model that is optional with default value + * @throws ApiError + */ + public static async callWithDefaultOptionalParameters( + parameterString: string = 'Hello World!', + parameterNumber: number = 123, + parameterBoolean: boolean = true, + parameterEnum: ('Success' | 'Warning' | 'Error') = 'Success', + parameterModel: ModelWithString = { + \\"prop\\": \\"Hello World\\" + }, + ): Promise { + + const result = await __request({ + method: 'post', + path: \`/api/v\${OpenAPI.VERSION}/defaults\`, + query: { + 'parameterString': parameterString, + 'parameterNumber': parameterNumber, + 'parameterBoolean': parameterBoolean, + 'parameterEnum': parameterEnum, + 'parameterModel': parameterModel, + }, + }); + + catchGenericError(result); + + return result.body; + } + + /** + * @param parameterStringWithNoDefault This is a string with no default + * @param parameterOptionalStringWithDefault This is a optional string with default + * @param parameterOptionalStringWithEmptyDefault This is a optional string with empty default + * @param parameterOptionalStringWithNoDefault This is a optional string with no default + * @param parameterStringWithDefault This is a string with default + * @param parameterStringWithEmptyDefault This is a string with empty default + * @throws ApiError + */ + public static async callToTestOrderOfParams( + parameterStringWithNoDefault: string, + parameterOptionalStringWithDefault: string = 'Hello World!', + parameterOptionalStringWithEmptyDefault: string = '', + parameterOptionalStringWithNoDefault?: string, + parameterStringWithDefault: string = 'hello', + parameterStringWithEmptyDefault: string = '', + ): Promise { + + const result = await __request({ + method: 'put', + path: \`/api/v\${OpenAPI.VERSION}/defaults\`, + query: { + 'parameterStringWithNoDefault': parameterStringWithNoDefault, + 'parameterOptionalStringWithDefault': parameterOptionalStringWithDefault, + 'parameterOptionalStringWithEmptyDefault': parameterOptionalStringWithEmptyDefault, + 'parameterOptionalStringWithNoDefault': parameterOptionalStringWithNoDefault, + 'parameterStringWithDefault': parameterStringWithDefault, + 'parameterStringWithEmptyDefault': parameterStringWithEmptyDefault, + }, + }); + + catchGenericError(result); + + return result.body; + } + +}" +`; + +exports[`v2 should generate: ./test/result/v2/services/DuplicateService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { catchGenericError } from '../core/ApiError'; +import { request as __request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class DuplicateService { + + /** + * @throws ApiError + */ + public static async duplicateName(): Promise { + + const result = await __request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/duplicate\`, + }); + + catchGenericError(result); + + return result.body; + } + + /** + * @throws ApiError + */ + public static async duplicateName1(): Promise { + + const result = await __request({ + method: 'post', + path: \`/api/v\${OpenAPI.VERSION}/duplicate\`, + }); + + catchGenericError(result); + + return result.body; + } + + /** + * @throws ApiError + */ + public static async duplicateName2(): Promise { + + const result = await __request({ + method: 'put', + path: \`/api/v\${OpenAPI.VERSION}/duplicate\`, + }); + + catchGenericError(result); + + return result.body; + } + + /** + * @throws ApiError + */ + public static async duplicateName3(): Promise { + + const result = await __request({ + method: 'delete', + path: \`/api/v\${OpenAPI.VERSION}/duplicate\`, + }); + + catchGenericError(result); + + return result.body; + } + +}" +`; + +exports[`v2 should generate: ./test/result/v2/services/HeaderService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { ApiError, catchGenericError } from '../core/ApiError'; +import { request as __request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class HeaderService { + + /** + * @result string Successful response + * @throws ApiError + */ + public static async callWithResultFromHeader(): Promise { + + const result = await __request({ + method: 'post', + path: \`/api/v\${OpenAPI.VERSION}/header\`, + responseHeader: 'operation-location', + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`400 server error\`); + case 500: throw new ApiError(result, \`500 server error\`); + } + } + + catchGenericError(result); + + return result.body; + } + +}" +`; + +exports[`v2 should generate: ./test/result/v2/services/ParametersService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { catchGenericError } from '../core/ApiError'; +import { request as __request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class ParametersService { + + /** + * @param parameterHeader This is the parameter that goes into the header + * @param parameterQuery This is the parameter that goes into the query params + * @param parameterForm This is the parameter that goes into the form data + * @param parameterBody This is the parameter that is send as request body + * @param parameterPath This is the parameter that goes into the path + * @throws ApiError + */ + public static async callWithParameters( + parameterHeader: string, + parameterQuery: string, + parameterForm: string, + parameterBody: string, + parameterPath: string, + ): Promise { + + const result = await __request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/parameters/\${parameterPath}\`, + headers: { + 'parameterHeader': parameterHeader, + }, + query: { + 'parameterQuery': parameterQuery, + }, + formData: { + 'parameterForm': parameterForm, + }, + body: parameterBody, + }); + + catchGenericError(result); + + return result.body; + } + + /** + * @param parameterHeader This is the parameter that goes into the request header + * @param parameterQuery This is the parameter that goes into the request query params + * @param parameterForm This is the parameter that goes into the request form data + * @param parameterBody This is the parameter that is send as request body + * @param parameterPath1 This is the parameter that goes into the path + * @param parameterPath2 This is the parameter that goes into the path + * @param parameterPath3 This is the parameter that goes into the path + * @throws ApiError + */ + public static async callWithWeirdParameterNames( + parameterHeader: string, + parameterQuery: string, + parameterForm: string, + parameterBody: string, + parameterPath1?: string, + parameterPath2?: string, + parameterPath3?: string, + ): Promise { + + const result = await __request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/parameters/\${parameterPath1}/\${parameterPath2}/\${parameterPath3}\`, + headers: { + 'parameter.header': parameterHeader, + }, + query: { + 'parameter-query': parameterQuery, + }, + formData: { + 'parameter_form': parameterForm, + }, + body: parameterBody, + }); + + catchGenericError(result); + + return result.body; + } + +}" +`; + +exports[`v2 should generate: ./test/result/v2/services/ResponseService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { ModelThatExtends } from '../models/ModelThatExtends'; +import { ModelThatExtendsExtends } from '../models/ModelThatExtendsExtends'; +import { ModelWithString } from '../models/ModelWithString'; +import { ApiError, catchGenericError } from '../core/ApiError'; +import { request as __request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class ResponseService { + + /** + * @result ModelWithString Message for default response + * @throws ApiError + */ + public static async callWithResponse(): Promise { + + const result = await __request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/response\`, + }); + + catchGenericError(result); + + return result.body; + } + + /** + * @result ModelWithString Message for default response + * @throws ApiError + */ + public static async callWithDuplicateResponses(): Promise { + + const result = await __request({ + method: 'post', + path: \`/api/v\${OpenAPI.VERSION}/response\`, + }); + + if (!result.ok) { + switch (result.status) { + case 500: throw new ApiError(result, \`Message for 500 error\`); + case 501: throw new ApiError(result, \`Message for 501 error\`); + case 502: throw new ApiError(result, \`Message for 502 error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @result ModelWithString Message for default response + * @result ModelThatExtends Message for 201 response + * @result ModelThatExtendsExtends Message for 202 response + * @throws ApiError + */ + public static async callWithResponses(): Promise { + + const result = await __request({ + method: 'put', + path: \`/api/v\${OpenAPI.VERSION}/response\`, + }); + + if (!result.ok) { + switch (result.status) { + case 500: throw new ApiError(result, \`Message for 500 error\`); + case 501: throw new ApiError(result, \`Message for 501 error\`); + case 502: throw new ApiError(result, \`Message for 502 error\`); + } + } + + catchGenericError(result); + + return result.body; + } + +}" +`; + +exports[`v2 should generate: ./test/result/v2/services/SimpleService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { catchGenericError } from '../core/ApiError'; +import { request as __request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class SimpleService { + + /** + * @throws ApiError + */ + public static async getCallWithoutParametersAndResponse(): Promise { + + const result = await __request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/simple\`, + }); + + catchGenericError(result); + + return result.body; + } + + /** + * @throws ApiError + */ + public static async putCallWithoutParametersAndResponse(): Promise { + + const result = await __request({ + method: 'put', + path: \`/api/v\${OpenAPI.VERSION}/simple\`, + }); + + catchGenericError(result); + + return result.body; + } + + /** + * @throws ApiError + */ + public static async postCallWithoutParametersAndResponse(): Promise { + + const result = await __request({ + method: 'post', + path: \`/api/v\${OpenAPI.VERSION}/simple\`, + }); + + catchGenericError(result); + + return result.body; + } + + /** + * @throws ApiError + */ + public static async deleteCallWithoutParametersAndResponse(): Promise { + + const result = await __request({ + method: 'delete', + path: \`/api/v\${OpenAPI.VERSION}/simple\`, + }); + + catchGenericError(result); + + return result.body; + } + + /** + * @throws ApiError + */ + public static async optionsCallWithoutParametersAndResponse(): Promise { + + const result = await __request({ + method: 'options', + path: \`/api/v\${OpenAPI.VERSION}/simple\`, + }); + + catchGenericError(result); + + return result.body; + } + + /** + * @throws ApiError + */ + public static async headCallWithoutParametersAndResponse(): Promise { + + const result = await __request({ + method: 'head', + path: \`/api/v\${OpenAPI.VERSION}/simple\`, + }); + + catchGenericError(result); + + return result.body; + } + + /** + * @throws ApiError + */ + public static async patchCallWithoutParametersAndResponse(): Promise { + + const result = await __request({ + method: 'patch', + path: \`/api/v\${OpenAPI.VERSION}/simple\`, + }); + + catchGenericError(result); + + return result.body; + } + +}" +`; + +exports[`v2 should generate: ./test/result/v2/services/TypesService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { Dictionary } from '../models/Dictionary'; +import { catchGenericError } from '../core/ApiError'; +import { request as __request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class TypesService { + + /** + * @param parameterArray This is an array parameter + * @param parameterDictionary This is a dictionary parameter + * @param parameterEnum This is an enum parameter + * @param parameterNumber This is a number parameter + * @param parameterString This is a string parameter + * @param parameterBoolean This is a boolean parameter + * @param parameterObject This is an object parameter + * @param id This is a number parameter + * @result number Response is a simple number + * @result string Response is a simple string + * @result boolean Response is a simple boolean + * @result any Response is a simple object + * @throws ApiError + */ + public static async types( + parameterArray: Array, + parameterDictionary: Dictionary, + parameterEnum: ('Success' | 'Warning' | 'Error'), + parameterNumber: number = 123, + parameterString: string = 'default', + parameterBoolean: boolean = true, + parameterObject: any = null, + id?: number, + ): Promise { + + const result = await __request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/types\`, + query: { + 'parameterArray': parameterArray, + 'parameterDictionary': parameterDictionary, + 'parameterEnum': parameterEnum, + 'parameterNumber': parameterNumber, + 'parameterString': parameterString, + 'parameterBoolean': parameterBoolean, + 'parameterObject': parameterObject, + }, + }); + + catchGenericError(result); + + return result.body; + } + +}" +`; + +exports[`v3 should generate: ./test/result/v3/core/ApiError.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { isSuccess } from './isSuccess'; +import { Result } from './Result'; + +export class ApiError extends Error { + + public readonly url: string; + public readonly status: number; + public readonly statusText: string; + public readonly body: any; + + constructor(result: Readonly, message: string) { + super(message); + + this.url = result.url; + this.status = result.status; + this.statusText = result.statusText; + this.body = result.body; + } +} + +export namespace ApiError { + export enum Message { + BAD_REQUEST = 'Bad Request', + UNAUTHORIZED = 'Unauthorized', + FORBIDDEN = 'Forbidden', + NOT_FOUND = 'Not Found', + INTERNAL_SERVER_ERROR = 'Internal Server Error', + BAD_GATEWAY = 'Bad Gateway', + SERVICE_UNAVAILABLE = 'Service Unavailable', + GENERIC_ERROR = 'Generic Error', + } +} + +/** + * Catch common errors (based on status code). + * @param result + */ +export function catchGenericError(result: Result): void { + switch (result.status) { + case 400: throw new ApiError(result, ApiError.Message.BAD_REQUEST); + case 401: throw new ApiError(result, ApiError.Message.UNAUTHORIZED); + case 403: throw new ApiError(result, ApiError.Message.FORBIDDEN); + case 404: throw new ApiError(result, ApiError.Message.NOT_FOUND); + case 500: throw new ApiError(result, ApiError.Message.INTERNAL_SERVER_ERROR); + case 502: throw new ApiError(result, ApiError.Message.BAD_GATEWAY); + case 503: throw new ApiError(result, ApiError.Message.SERVICE_UNAVAILABLE); + } + + if (!isSuccess(result.status)) { + throw new ApiError(result, ApiError.Message.GENERIC_ERROR); + } +} +" +`; + +exports[`v3 should generate: ./test/result/v3/core/OpenAPI.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +interface Config { + BASE: string; + VERSION: string; + CLIENT: 'fetch' | 'xhr'; + WITH_CREDENTIALS: boolean; + TOKEN: string; +} + +export const OpenAPI: Config = { + BASE: '/api', + VERSION: '1', + CLIENT: 'fetch', + WITH_CREDENTIALS: false, + TOKEN: '', +};" +`; + +exports[`v3 should generate: ./test/result/v3/core/RequestOptions.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export interface RequestOptions { + method: 'get' | 'put' | 'post' | 'delete' | 'options' | 'head' | 'patch'; + path: string; + cookies?: { [key: string]: any }; + headers?: { [key: string]: any }; + query?: { [key: string]: any }; + formData?: { [key: string]: any }; + body?: any; + responseHeader?: string; +} +" +`; + +exports[`v3 should generate: ./test/result/v3/core/Result.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export interface Result { + url: string; + ok: boolean; + status: number; + statusText: string; + body: any; +} +" +`; + +exports[`v3 should generate: ./test/result/v3/core/getFormData.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * Get FormData from object. This method is needed to upload + * multipart form data to the REST API. + * @param params Key value based object. + */ +export function getFormData(params: { [key: string]: any }): FormData { + const formData = new FormData(); + for (const key in params) { + if (typeof params[key] !== 'undefined') { + const value: any = params[key]; + if (value !== undefined && value !== null) { + formData.append(key, value); + } + } + } + return formData; +} +" +`; + +exports[`v3 should generate: ./test/result/v3/core/getQueryString.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * Get query string from query parameters object. This method also + * supports multi-value items by creating a key for each item. + * @param params Key value based object. + */ +export function getQueryString(params: { [key: string]: any }): string { + const qs: string[] = []; + for (const key in params) { + if (typeof params[key] !== 'undefined') { + const value: any = params[key]; + if (value !== undefined && value !== null) { + if (Array.isArray(value)) { + value.forEach(value => { + qs.push(\`\${encodeURIComponent(key)}=\${encodeURIComponent(String(value))}\`); + }); + } else { + qs.push(\`\${encodeURIComponent(key)}=\${encodeURIComponent(String(value))}\`); + } + } + } + } + if (qs.length > 0) { + return \`?\${qs.join('&')}\`; + } + return ''; +} +" +`; + +exports[`v3 should generate: ./test/result/v3/core/isSuccess.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * Check success response code. + * @param status Status code + */ +export function isSuccess(status: number): boolean { + return status >= 200 && status < 300; +} +" +`; + +exports[`v3 should generate: ./test/result/v3/core/request.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { getFormData } from './getFormData'; +import { getQueryString } from './getQueryString'; +import { OpenAPI } from './OpenAPI'; +import { RequestOptions } from './RequestOptions'; +import { requestUsingFetch } from './requestUsingFetch'; +import { requestUsingXHR } from './requestUsingXHR'; +import { Result } from './Result'; + +/** + * Create the request. + * @param options Request method options. + * @returns Result object (see above) + */ +export async function request(options: Readonly): Promise { + + // Escape path (RFC3986) and create the request URL + let path = options.path.replace(/[:]/g, '_'); + let url = \`\${OpenAPI.BASE}\${path}\`; + + // Create request headers + const headers = new Headers({ + ...options.headers, + Accept: 'application/json', + }); + + // Create request settings + const request: RequestInit = { + headers, + method: options.method, + }; + + // If we specified to send requests with credentials, then we + // set the request credentials options to include. This is only + // needed if you make cross-origin calls. + if (OpenAPI.WITH_CREDENTIALS) { + request.credentials = 'include'; + } + + // If we have a bearer token then we set the authentication header. + if (OpenAPI.TOKEN !== null && OpenAPI.TOKEN !== '') { + headers.append('Authorization', \`Bearer \${OpenAPI.TOKEN}\`); + } + + // Add the query parameters (if defined). + if (options.query) { + url += getQueryString(options.query); + } + + // Append formData as body + if (options.formData) { + request.body = getFormData(options.formData); + } else if (options.body) { + + // If this is blob data, then pass it directly to the body and set content type. + // Otherwise we just convert request data to JSON string (needed for fetch api) + if (options.body instanceof Blob) { + request.body = options.body; + if (options.body.type) { + headers.append('Content-Type', options.body.type); + } + } else { + request.body = JSON.stringify(options.body); + headers.append('Content-Type', 'application/json'); + } + } + + try { + switch (OpenAPI.CLIENT) { + case 'xhr': + return await requestUsingXHR(url, request, options.responseHeader); + default: + return await requestUsingFetch(url, request, options.responseHeader); + } + } catch (error) { + return { + url, + ok: false, + status: 0, + statusText: '', + body: error, + }; + } +} +" +`; + +exports[`v3 should generate: ./test/result/v3/core/requestUsingFetch.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { Result } from './Result'; + +/** + * Try to parse the content for any response status code. + * We check the \\"Content-Type\\" header to see if we need to parse the + * content as json or as plain text. + * @param response Response object from fetch + */ +async function parseBody(response: Response): Promise { + try { + const contentType = response.headers.get('Content-Type'); + if (contentType) { + switch (contentType.toLowerCase()) { + case 'application/json': + case 'application/json; charset=utf-8': + return await response.json(); + + default: + return await response.text(); + } + } + } catch (e) { + console.error(e); + } + return null; +} + +/** + * Fetch the response header (if specified) + * @param response Response object from fetch + * @param responseHeader The name of the header to fetch + */ +function parseHeader(response: Response, responseHeader?: string): string | null { + if (responseHeader) { + const content = response.headers.get(responseHeader); + if (typeof content === 'string') { + return content; + } + } + return null; +} + +/** + * Request content using the new Fetch API. This is the default API that is used and + * is create for all JSON, XML and text objects. However it is limited to UTF-8. + * This is a problem for some of the Docs content, since that requires UTF-16! + * @param url The url to request. + * @param request The request object, containing method, headers, body, etc. + * @param responseHeader The header we want to parse. + */ +export async function requestUsingFetch(url: string, request: Readonly, responseHeader?: string): Promise { + + // Fetch response using fetch API. + const response = await fetch(url, request); + + // Get content of response header or response body + const contentHeader = parseHeader(response, responseHeader); + const contentBody = await parseBody(response); + + // Create result object. + return { + url, + ok: response.ok, + status: response.status, + statusText: response.statusText, + body: contentHeader || contentBody, + }; +} +" +`; + +exports[`v3 should generate: ./test/result/v3/core/requestUsingXHR.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { isSuccess } from './isSuccess'; +import { Result } from './Result'; + +/** + * Try to parse the content for any response status code. + * We check the \\"Content-Type\\" header to see if we need to parse the + * content as json or as plain text. + * @param xhr XHR request object + */ +function parseBody(xhr: XMLHttpRequest): any { + try { + const contentType = xhr.getResponseHeader('Content-Type'); + if (contentType) { + switch (contentType.toLowerCase()) { + case 'application/json': + case 'application/json; charset=utf-8': + return JSON.parse(xhr.responseText); + + default: + return xhr.responseText; + } + } + } catch (e) { + console.error(e); + } + return null; +} + +/** + * Fetch the response header (if specified) + * @param xhr XHR request object + * @param responseHeader The name of the header to fetch + */ +function parseHeader(xhr: XMLHttpRequest, responseHeader?: string): string | null { + if (responseHeader) { + const content = xhr.getResponseHeader(responseHeader); + if (typeof content === 'string') { + return content; + } + } + return null; +} + +/** + * Request content using the new legacy XMLHttpRequest API. This method is useful + * when we want to request UTF-16 content, since it natively supports loading UTF-16. + * We could do the same with the Fetch API, but then we will need to convert the + * content using JavaScript... And that is very very slow. + * @param url The url to request. + * @param request The request object, containing method, headers, body, etc. + * @param responseHeader The header we want to parse. + */ +export async function requestUsingXHR(url: string, request: Readonly, responseHeader?: string): Promise { + return new Promise(resolve => { + const xhr = new XMLHttpRequest(); + + // Open the request, remember to do this before adding any headers, + // because the request needs to be initialized! + xhr.open(request.method!, url, true); + + // When request credentials are set to include then this is + // the same behaviour as withCredentials = true in XHR: + // https://developer.mozilla.org/en-US/docs/Web/API/Request/credentials + xhr.withCredentials = request.credentials === 'include'; + + // Add the headers (required when dealing with JSON) + const headers = request.headers as Headers; + headers.forEach((value: string, key: string): void => { + xhr.setRequestHeader(key, value); + }); + + // Register the readystate handler, this will fire when the request is done. + xhr.onreadystatechange = () => { + if (xhr.readyState === XMLHttpRequest.DONE) { + + // Get content of response header or response body + const contentHeader = parseHeader(xhr, responseHeader); + const contentBody = parseBody(xhr); + + // Create result object. + const result: Result = { + url, + ok: isSuccess(xhr.status), + status: xhr.status, + statusText: xhr.statusText, + body: contentHeader || contentBody, + }; + + // Done! + resolve(result); + } + }; + + // Start the request! + xhr.send(request.body); + }); +} +" +`; + +exports[`v3 should generate: ./test/result/v3/index.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export { ApiError } from './core/ApiError'; +export { isSuccess } from './core/isSuccess'; +export { OpenAPI } from './core/OpenAPI'; + +export type { ArrayWithArray } from './models/ArrayWithArray'; +export type { ArrayWithBooleans } from './models/ArrayWithBooleans'; +export type { ArrayWithNumbers } from './models/ArrayWithNumbers'; +export type { ArrayWithProperties } from './models/ArrayWithProperties'; +export type { ArrayWithReferences } from './models/ArrayWithReferences'; +export type { ArrayWithStrings } from './models/ArrayWithStrings'; +export type { DictionaryWithArray } from './models/DictionaryWithArray'; +export type { DictionaryWithDictionary } from './models/DictionaryWithDictionary'; +export type { DictionaryWithProperties } from './models/DictionaryWithProperties'; +export type { DictionaryWithReference } from './models/DictionaryWithReference'; +export type { DictionaryWithString } from './models/DictionaryWithString'; +export { EnumFromDescription } from './models/EnumFromDescription'; +export { EnumWithExtensions } from './models/EnumWithExtensions'; +export { EnumWithNumbers } from './models/EnumWithNumbers'; +export { EnumWithStrings } from './models/EnumWithStrings'; +export type { ModelLink } from './models/ModelLink'; +export type { ModelThatExtends } from './models/ModelThatExtends'; +export type { ModelThatExtendsExtends } from './models/ModelThatExtendsExtends'; +export type { ModelWithAnyOf } from './models/ModelWithAnyOf'; +export type { ModelWithArray } from './models/ModelWithArray'; +export type { ModelWithBoolean } from './models/ModelWithBoolean'; +export type { ModelWithCircularReference } from './models/ModelWithCircularReference'; +export type { ModelWithDictionary } from './models/ModelWithDictionary'; +export type { ModelWithDuplicateImports } from './models/ModelWithDuplicateImports'; +export type { ModelWithDuplicateProperties } from './models/ModelWithDuplicateProperties'; +export { ModelWithEnum } from './models/ModelWithEnum'; +export { ModelWithEnumFromDescription } from './models/ModelWithEnumFromDescription'; +export type { ModelWithInteger } from './models/ModelWithInteger'; +export type { ModelWithLink } from './models/ModelWithLink'; +export type { ModelWithNestedEnums } from './models/ModelWithNestedEnums'; +export type { ModelWithNestedProperties } from './models/ModelWithNestedProperties'; +export type { ModelWithOneOf } from './models/ModelWithOneOf'; +export type { ModelWithOrderedProperties } from './models/ModelWithOrderedProperties'; +export type { ModelWithPattern } from './models/ModelWithPattern'; +export type { ModelWithProperties } from './models/ModelWithProperties'; +export type { ModelWithReference } from './models/ModelWithReference'; +export type { ModelWithString } from './models/ModelWithString'; +export type { MultilineComment } from './models/MultilineComment'; +export type { SimpleBoolean } from './models/SimpleBoolean'; +export type { SimpleFile } from './models/SimpleFile'; +export type { SimpleInteger } from './models/SimpleInteger'; +export type { SimpleReference } from './models/SimpleReference'; +export type { SimpleString } from './models/SimpleString'; + +export { $ArrayWithArray } from './schemas/$ArrayWithArray'; +export { $ArrayWithBooleans } from './schemas/$ArrayWithBooleans'; +export { $ArrayWithNumbers } from './schemas/$ArrayWithNumbers'; +export { $ArrayWithProperties } from './schemas/$ArrayWithProperties'; +export { $ArrayWithReferences } from './schemas/$ArrayWithReferences'; +export { $ArrayWithStrings } from './schemas/$ArrayWithStrings'; +export { $DictionaryWithArray } from './schemas/$DictionaryWithArray'; +export { $DictionaryWithDictionary } from './schemas/$DictionaryWithDictionary'; +export { $DictionaryWithProperties } from './schemas/$DictionaryWithProperties'; +export { $DictionaryWithReference } from './schemas/$DictionaryWithReference'; +export { $DictionaryWithString } from './schemas/$DictionaryWithString'; +export { $EnumFromDescription } from './schemas/$EnumFromDescription'; +export { $EnumWithExtensions } from './schemas/$EnumWithExtensions'; +export { $EnumWithNumbers } from './schemas/$EnumWithNumbers'; +export { $EnumWithStrings } from './schemas/$EnumWithStrings'; +export { $ModelLink } from './schemas/$ModelLink'; +export { $ModelThatExtends } from './schemas/$ModelThatExtends'; +export { $ModelThatExtendsExtends } from './schemas/$ModelThatExtendsExtends'; +export { $ModelWithAnyOf } from './schemas/$ModelWithAnyOf'; +export { $ModelWithArray } from './schemas/$ModelWithArray'; +export { $ModelWithBoolean } from './schemas/$ModelWithBoolean'; +export { $ModelWithCircularReference } from './schemas/$ModelWithCircularReference'; +export { $ModelWithDictionary } from './schemas/$ModelWithDictionary'; +export { $ModelWithDuplicateImports } from './schemas/$ModelWithDuplicateImports'; +export { $ModelWithDuplicateProperties } from './schemas/$ModelWithDuplicateProperties'; +export { $ModelWithEnum } from './schemas/$ModelWithEnum'; +export { $ModelWithEnumFromDescription } from './schemas/$ModelWithEnumFromDescription'; +export { $ModelWithInteger } from './schemas/$ModelWithInteger'; +export { $ModelWithLink } from './schemas/$ModelWithLink'; +export { $ModelWithNestedEnums } from './schemas/$ModelWithNestedEnums'; +export { $ModelWithNestedProperties } from './schemas/$ModelWithNestedProperties'; +export { $ModelWithOneOf } from './schemas/$ModelWithOneOf'; +export { $ModelWithOrderedProperties } from './schemas/$ModelWithOrderedProperties'; +export { $ModelWithPattern } from './schemas/$ModelWithPattern'; +export { $ModelWithProperties } from './schemas/$ModelWithProperties'; +export { $ModelWithReference } from './schemas/$ModelWithReference'; +export { $ModelWithString } from './schemas/$ModelWithString'; +export { $MultilineComment } from './schemas/$MultilineComment'; +export { $SimpleBoolean } from './schemas/$SimpleBoolean'; +export { $SimpleFile } from './schemas/$SimpleFile'; +export { $SimpleInteger } from './schemas/$SimpleInteger'; +export { $SimpleReference } from './schemas/$SimpleReference'; +export { $SimpleString } from './schemas/$SimpleString'; + +export { ComplexService } from './services/ComplexService'; +export { DefaultsService } from './services/DefaultsService'; +export { DuplicateService } from './services/DuplicateService'; +export { HeaderService } from './services/HeaderService'; +export { MultipartService } from './services/MultipartService'; +export { ParametersService } from './services/ParametersService'; +export { ResponseService } from './services/ResponseService'; +export { SimpleService } from './services/SimpleService'; +export { TypesService } from './services/TypesService'; +export { UploadService } from './services/UploadService'; +" +`; + +exports[`v3 should generate: ./test/result/v3/models/ArrayWithArray.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { ModelWithString } from './ModelWithString'; + +/** + * This is a simple array containing an array + */ +export type ArrayWithArray = Array>;" +`; + +exports[`v3 should generate: ./test/result/v3/models/ArrayWithBooleans.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + + +/** + * This is a simple array with booleans + */ +export type ArrayWithBooleans = Array;" +`; + +exports[`v3 should generate: ./test/result/v3/models/ArrayWithNumbers.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + + +/** + * This is a simple array with numbers + */ +export type ArrayWithNumbers = Array;" +`; + +exports[`v3 should generate: ./test/result/v3/models/ArrayWithProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + + +/** + * This is a simple array with properties + */ +export type ArrayWithProperties = Array<{ + foo?: string, + bar?: string, +}>;" +`; + +exports[`v3 should generate: ./test/result/v3/models/ArrayWithReferences.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { ModelWithString } from './ModelWithString'; + +/** + * This is a simple array with references + */ +export type ArrayWithReferences = Array;" +`; + +exports[`v3 should generate: ./test/result/v3/models/ArrayWithStrings.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + + +/** + * This is a simple array with strings + */ +export type ArrayWithStrings = Array;" +`; + +exports[`v3 should generate: ./test/result/v3/models/Dictionary.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type Dictionary = { + [key: string]: T; +} +" +`; + +exports[`v3 should generate: ./test/result/v3/models/DictionaryWithArray.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { Dictionary } from './Dictionary'; +import { ModelWithString } from './ModelWithString'; + +/** + * This is a complex dictionary + */ +export type DictionaryWithArray = Dictionary>;" +`; + +exports[`v3 should generate: ./test/result/v3/models/DictionaryWithDictionary.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { Dictionary } from './Dictionary'; + +/** + * This is a string dictionary + */ +export type DictionaryWithDictionary = Dictionary>;" +`; + +exports[`v3 should generate: ./test/result/v3/models/DictionaryWithProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { Dictionary } from './Dictionary'; + +/** + * This is a complex dictionary + */ +export type DictionaryWithProperties = Dictionary<{ + foo?: string, + bar?: string, +}>;" +`; + +exports[`v3 should generate: ./test/result/v3/models/DictionaryWithReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { Dictionary } from './Dictionary'; +import { ModelWithString } from './ModelWithString'; + +/** + * This is a string reference + */ +export type DictionaryWithReference = Dictionary;" +`; + +exports[`v3 should generate: ./test/result/v3/models/DictionaryWithString.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { Dictionary } from './Dictionary'; + +/** + * This is a string dictionary + */ +export type DictionaryWithString = Dictionary;" +`; + +exports[`v3 should generate: ./test/result/v3/models/EnumFromDescription.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + + +/** + * Success=1,Warning=2,Error=3 + */ +export enum EnumFromDescription { + SUCCESS = 1, + WARNING = 2, + ERROR = 3, +}" +`; + +exports[`v3 should generate: ./test/result/v3/models/EnumWithExtensions.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + + +/** + * This is a simple enum with numbers + */ +export enum EnumWithExtensions { + /** + * Used when the status of something is successful + */ + CUSTOM_SUCCESS = 200, + /** + * Used when the status of something has a warning + */ + CUSTOM_WARNING = 400, + /** + * Used when the status of something has an error + */ + CUSTOM_ERROR = 500, +}" +`; + +exports[`v3 should generate: ./test/result/v3/models/EnumWithNumbers.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + + +/** + * This is a simple enum with numbers + */ +export enum EnumWithNumbers { + _1 = 1, + _2 = 2, + _3 = 3, +}" +`; + +exports[`v3 should generate: ./test/result/v3/models/EnumWithStrings.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + + +/** + * This is a simple enum with strings + */ +export enum EnumWithStrings { + SUCCESS = 'Success', + WARNING = 'Warning', + ERROR = 'Error', +}" +`; + +exports[`v3 should generate: ./test/result/v3/models/ModelLink.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + + +/** + * This is a model that can have a template?? + */ +export interface ModelLink { + id?: string; +} +" +`; + +exports[`v3 should generate: ./test/result/v3/models/ModelThatExtends.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { ModelWithString } from './ModelWithString'; + +/** + * This is a model that extends another model + */ +export interface ModelThatExtends extends ModelWithString { + propExtendsA?: string; + propExtendsB?: ModelWithString; +} +" +`; + +exports[`v3 should generate: ./test/result/v3/models/ModelThatExtendsExtends.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { ModelThatExtends } from './ModelThatExtends'; +import { ModelWithString } from './ModelWithString'; + +/** + * This is a model that extends another model + */ +export interface ModelThatExtendsExtends extends ModelWithString, ModelThatExtends { + propExtendsC?: string; + propExtendsD?: ModelWithString; +} +" +`; + +exports[`v3 should generate: ./test/result/v3/models/ModelWithAnyOf.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { ModelWithArray } from './ModelWithArray'; +import { ModelWithDictionary } from './ModelWithDictionary'; +import { ModelWithEnum } from './ModelWithEnum'; +import { ModelWithString } from './ModelWithString'; + +/** + * This is a model with one property with a 'any of' relationship + */ +export interface ModelWithAnyOf { + propA?: ModelWithArray | ModelWithDictionary | ModelWithEnum | ModelWithString; +} +" +`; + +exports[`v3 should generate: ./test/result/v3/models/ModelWithArray.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { ModelWithString } from './ModelWithString'; + +/** + * This is a model with one property containing an array + */ +export interface ModelWithArray { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +} +" +`; + +exports[`v3 should generate: ./test/result/v3/models/ModelWithBoolean.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + + +/** + * This is a model with one boolean property + */ +export interface ModelWithBoolean { + /** + * This is a simple boolean property + */ + prop?: boolean; +} +" +`; + +exports[`v3 should generate: ./test/result/v3/models/ModelWithCircularReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + + +/** + * This is a model with one property containing a circular reference + */ +export interface ModelWithCircularReference { + prop?: ModelWithCircularReference; +} +" +`; + +exports[`v3 should generate: ./test/result/v3/models/ModelWithDictionary.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { Dictionary } from './Dictionary'; + +/** + * This is a model with one property containing a dictionary + */ +export interface ModelWithDictionary { + prop?: Dictionary; +} +" +`; + +exports[`v3 should generate: ./test/result/v3/models/ModelWithDuplicateImports.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { ModelWithString } from './ModelWithString'; + +/** + * This is a model with duplicated imports + */ +export interface ModelWithDuplicateImports { + propA?: ModelWithString; + propB?: ModelWithString; + propC?: ModelWithString; +} +" +`; + +exports[`v3 should generate: ./test/result/v3/models/ModelWithDuplicateProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { ModelWithString } from './ModelWithString'; + +/** + * This is a model with duplicated properties + */ +export interface ModelWithDuplicateProperties { + prop?: ModelWithString; +} +" +`; + +exports[`v3 should generate: ./test/result/v3/models/ModelWithEnum.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + + +/** + * This is a model with one enum + */ +export interface ModelWithEnum { + /** + * This is a simple enum with strings + */ + test?: ModelWithEnum.test; + /** + * These are the HTTP error code enums + */ + statusCode?: ModelWithEnum.statusCode; +} + +export namespace ModelWithEnum { + + /** + * This is a simple enum with strings + */ + export enum test { + SUCCESS = 'Success', + WARNING = 'Warning', + ERROR = 'Error', + } + + /** + * These are the HTTP error code enums + */ + export enum statusCode { + _100 = '100', + _200_FOO = '200 FOO', + _300_FOO_BAR = '300 FOO_BAR', + _400_FOO_BAR = '400 foo-bar', + _500_FOO_BAR = '500 foo.bar', + _600_FOO_BAR = '600 foo&bar', + } + + +} +" +`; + +exports[`v3 should generate: ./test/result/v3/models/ModelWithEnumFromDescription.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + + +/** + * This is a model with one enum + */ +export interface ModelWithEnumFromDescription { + /** + * Success=1,Warning=2,Error=3 + */ + test?: ModelWithEnumFromDescription.test; +} + +export namespace ModelWithEnumFromDescription { + + /** + * Success=1,Warning=2,Error=3 + */ + export enum test { + SUCCESS = 1, + WARNING = 2, + ERROR = 3, + } + + +} +" +`; + +exports[`v3 should generate: ./test/result/v3/models/ModelWithInteger.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + + +/** + * This is a model with one number property + */ +export interface ModelWithInteger { + /** + * This is a simple number property + */ + prop?: number; +} +" +`; + +exports[`v3 should generate: ./test/result/v3/models/ModelWithLink.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { ModelLink } from './ModelLink'; +import { ModelWithString } from './ModelWithString'; + +/** + * This is a model that can have a template?? + */ +export interface ModelWithLink { + prop?: ModelLink; +} +" +`; + +exports[`v3 should generate: ./test/result/v3/models/ModelWithNestedEnums.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { Dictionary } from './Dictionary'; + +/** + * This is a model with nested enums + */ +export interface ModelWithNestedEnums { + dictionaryWithEnum?: Dictionary<('Success' | 'Warning' | 'Error')>; + dictionaryWithEnumFromDescription?: Dictionary<(1 | 2 | 3)>; + arrayWithEnum?: Array<('Success' | 'Warning' | 'Error')>; + arrayWithDescription?: Array<(1 | 2 | 3)>; +} +" +`; + +exports[`v3 should generate: ./test/result/v3/models/ModelWithNestedProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + + +/** + * This is a model with one nested property + */ +export interface ModelWithNestedProperties { + readonly first: { + readonly second: { + readonly third: string | null, + } | null, + } | null; +} +" +`; + +exports[`v3 should generate: ./test/result/v3/models/ModelWithOneOf.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { ModelWithArray } from './ModelWithArray'; +import { ModelWithDictionary } from './ModelWithDictionary'; +import { ModelWithEnum } from './ModelWithEnum'; +import { ModelWithString } from './ModelWithString'; + +/** + * This is a model with one property with a 'one of' relationship + */ +export interface ModelWithOneOf { + propA?: ModelWithArray | ModelWithDictionary | ModelWithEnum | ModelWithString; +} +" +`; + +exports[`v3 should generate: ./test/result/v3/models/ModelWithOrderedProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + + +/** + * This is a model with ordered properties + */ +export interface ModelWithOrderedProperties { + zebra?: string; + apple?: string; + hawaii?: string; +} +" +`; + +exports[`v3 should generate: ./test/result/v3/models/ModelWithPattern.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + + +/** + * This is a model that contains a some patterns + */ +export interface ModelWithPattern { + key: string; + name: string; + readonly enabled?: boolean; + readonly modified?: string; +} +" +`; + +exports[`v3 should generate: ./test/result/v3/models/ModelWithProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { ModelWithString } from './ModelWithString'; + +/** + * This is a model with one nested property + */ +export interface ModelWithProperties { + required: string; + readonly requiredAndReadOnly: string; + requiredAndNullable: string | null; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; +} +" +`; + +exports[`v3 should generate: ./test/result/v3/models/ModelWithReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { ModelWithProperties } from './ModelWithProperties'; + +/** + * This is a model with one property containing a reference + */ +export interface ModelWithReference { + prop?: ModelWithProperties; +} +" +`; + +exports[`v3 should generate: ./test/result/v3/models/ModelWithString.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + + +/** + * This is a model with one string property + */ +export interface ModelWithString { + /** + * This is a simple string property + */ + prop?: string; +} +" +`; + +exports[`v3 should generate: ./test/result/v3/models/MultilineComment.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + + +/** + * Testing multiline comments. + * This must go to the next line. + * + * This will contain a break. + */ +export type MultilineComment = number;" +`; + +exports[`v3 should generate: ./test/result/v3/models/SimpleBoolean.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + + +/** + * This is a simple boolean + */ +export type SimpleBoolean = boolean;" +`; + +exports[`v3 should generate: ./test/result/v3/models/SimpleFile.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + + +/** + * This is a simple file + */ +export type SimpleFile = File;" +`; + +exports[`v3 should generate: ./test/result/v3/models/SimpleInteger.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + + +/** + * This is a simple number + */ +export type SimpleInteger = number;" +`; + +exports[`v3 should generate: ./test/result/v3/models/SimpleReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { ModelWithString } from './ModelWithString'; + +/** + * This is a simple reference + */ +export type SimpleReference = ModelWithString;" +`; + +exports[`v3 should generate: ./test/result/v3/models/SimpleString.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + + +/** + * This is a simple string + */ +export type SimpleString = string;" +`; + +exports[`v3 should generate: ./test/result/v3/schemas/$ArrayWithArray.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ArrayWithArray = { + type: 'Array', +};" +`; + +exports[`v3 should generate: ./test/result/v3/schemas/$ArrayWithBooleans.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ArrayWithBooleans = { + type: 'Array', +};" +`; + +exports[`v3 should generate: ./test/result/v3/schemas/$ArrayWithNumbers.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ArrayWithNumbers = { + type: 'Array', +};" +`; + +exports[`v3 should generate: ./test/result/v3/schemas/$ArrayWithProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ArrayWithProperties = { + type: 'Array', +};" +`; + +exports[`v3 should generate: ./test/result/v3/schemas/$ArrayWithReferences.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ArrayWithReferences = { + type: 'Array', +};" +`; + +exports[`v3 should generate: ./test/result/v3/schemas/$ArrayWithStrings.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ArrayWithStrings = { + type: 'Array', +};" +`; + +exports[`v3 should generate: ./test/result/v3/schemas/$DictionaryWithArray.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $DictionaryWithArray = { + type: 'Dictionary', +};" +`; + +exports[`v3 should generate: ./test/result/v3/schemas/$DictionaryWithDictionary.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $DictionaryWithDictionary = { + type: 'Dictionary', +};" +`; + +exports[`v3 should generate: ./test/result/v3/schemas/$DictionaryWithProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $DictionaryWithProperties = { + type: 'Dictionary', +};" +`; + +exports[`v3 should generate: ./test/result/v3/schemas/$DictionaryWithReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $DictionaryWithReference = { + type: 'Dictionary', +};" +`; + +exports[`v3 should generate: ./test/result/v3/schemas/$DictionaryWithString.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $DictionaryWithString = { + type: 'Dictionary', +};" +`; + +exports[`v3 should generate: ./test/result/v3/schemas/$EnumFromDescription.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $EnumFromDescription = { + type: 'Enum', +};" +`; + +exports[`v3 should generate: ./test/result/v3/schemas/$EnumWithExtensions.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $EnumWithExtensions = { + type: 'Enum', +};" +`; + +exports[`v3 should generate: ./test/result/v3/schemas/$EnumWithNumbers.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $EnumWithNumbers = { + type: 'Enum', +};" +`; + +exports[`v3 should generate: ./test/result/v3/schemas/$EnumWithStrings.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $EnumWithStrings = { + type: 'Enum', +};" +`; + +exports[`v3 should generate: ./test/result/v3/schemas/$ModelLink.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelLink = { + properties: { + id: { + type: 'string', + }, + }, +};" +`; + +exports[`v3 should generate: ./test/result/v3/schemas/$ModelThatExtends.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { $ModelWithString } from './$ModelWithString'; + +export const $ModelThatExtends = { + properties: { + ...$ModelWithString.properties, + propExtendsA: { + type: 'string', + }, + propExtendsB: { + type: 'ModelWithString', + }, + }, +};" +`; + +exports[`v3 should generate: ./test/result/v3/schemas/$ModelThatExtendsExtends.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { $ModelWithString } from './$ModelWithString'; +import { $ModelThatExtends } from './$ModelThatExtends'; + +export const $ModelThatExtendsExtends = { + properties: { + ...$ModelWithString.properties, + ...$ModelThatExtends.properties, + propExtendsC: { + type: 'string', + }, + propExtendsD: { + type: 'ModelWithString', + }, + }, +};" +`; + +exports[`v3 should generate: ./test/result/v3/schemas/$ModelWithAnyOf.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithAnyOf = { + properties: { + propA: { + type: 'ModelWithArray | ModelWithDictionary | ModelWithEnum | ModelWithString', + }, + }, +};" +`; + +exports[`v3 should generate: ./test/result/v3/schemas/$ModelWithArray.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithArray = { + properties: { + prop: { + type: 'Array', + }, + propWithFile: { + type: 'Array', + }, + propWithNumber: { + type: 'Array', + }, + }, +};" +`; + +exports[`v3 should generate: ./test/result/v3/schemas/$ModelWithBoolean.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithBoolean = { + properties: { + prop: { + type: 'boolean', + }, + }, +};" +`; + +exports[`v3 should generate: ./test/result/v3/schemas/$ModelWithCircularReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithCircularReference = { + properties: { + prop: { + type: 'ModelWithCircularReference', + }, + }, +};" +`; + +exports[`v3 should generate: ./test/result/v3/schemas/$ModelWithDictionary.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithDictionary = { + properties: { + prop: { + type: 'Dictionary', + }, + }, +};" +`; + +exports[`v3 should generate: ./test/result/v3/schemas/$ModelWithDuplicateImports.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithDuplicateImports = { + properties: { + propA: { + type: 'ModelWithString', + }, + propB: { + type: 'ModelWithString', + }, + propC: { + type: 'ModelWithString', + }, + }, +};" +`; + +exports[`v3 should generate: ./test/result/v3/schemas/$ModelWithDuplicateProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithDuplicateProperties = { + properties: { + prop: { + type: 'ModelWithString', + }, + }, +};" +`; + +exports[`v3 should generate: ./test/result/v3/schemas/$ModelWithEnum.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithEnum = { + properties: { + test: { + type: 'Enum', + }, + statusCode: { + type: 'Enum', + }, + }, +};" +`; + +exports[`v3 should generate: ./test/result/v3/schemas/$ModelWithEnumFromDescription.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithEnumFromDescription = { + properties: { + test: { + type: 'Enum', + }, + }, +};" +`; + +exports[`v3 should generate: ./test/result/v3/schemas/$ModelWithInteger.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithInteger = { + properties: { + prop: { + type: 'number', + }, + }, +};" +`; + +exports[`v3 should generate: ./test/result/v3/schemas/$ModelWithLink.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithLink = { + properties: { + prop: { + type: 'ModelLink', + }, + }, +};" +`; + +exports[`v3 should generate: ./test/result/v3/schemas/$ModelWithNestedEnums.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithNestedEnums = { + properties: { + dictionaryWithEnum: { + type: 'Dictionary', + }, + dictionaryWithEnumFromDescription: { + type: 'Dictionary', + }, + arrayWithEnum: { + type: 'Array', + }, + arrayWithDescription: { + type: 'Array', + }, + }, +};" +`; + +exports[`v3 should generate: ./test/result/v3/schemas/$ModelWithNestedProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithNestedProperties = { + properties: { + first: { + properties: { + second: { + properties: { + third: { + type: 'string', + isReadOnly: true, + isRequired: true, + isNullable: true, + }, + }, + isReadOnly: true, + isRequired: true, + isNullable: true, + }, + }, + isReadOnly: true, + isRequired: true, + isNullable: true, + }, + }, +};" +`; + +exports[`v3 should generate: ./test/result/v3/schemas/$ModelWithOneOf.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithOneOf = { + properties: { + propA: { + type: 'ModelWithArray | ModelWithDictionary | ModelWithEnum | ModelWithString', + }, + }, +};" +`; + +exports[`v3 should generate: ./test/result/v3/schemas/$ModelWithOrderedProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithOrderedProperties = { + properties: { + zebra: { + type: 'string', + }, + apple: { + type: 'string', + }, + hawaii: { + type: 'string', + }, + }, +};" +`; + +exports[`v3 should generate: ./test/result/v3/schemas/$ModelWithPattern.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithPattern = { + properties: { + key: { + type: 'string', + isRequired: true, + maxLength: 64, + pattern: '^[a-zA-Z0-9_]*$', + }, + name: { + type: 'string', + isRequired: true, + maxLength: 255, + }, + enabled: { + type: 'boolean', + isReadOnly: true, + }, + modified: { + type: 'string', + isReadOnly: true, + format: 'date-time', + }, + }, +};" +`; + +exports[`v3 should generate: ./test/result/v3/schemas/$ModelWithProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithProperties = { + properties: { + required: { + type: 'string', + isRequired: true, + }, + requiredAndReadOnly: { + type: 'string', + isReadOnly: true, + isRequired: true, + }, + requiredAndNullable: { + type: 'string', + isRequired: true, + isNullable: true, + }, + string: { + type: 'string', + }, + number: { + type: 'number', + }, + boolean: { + type: 'boolean', + }, + reference: { + type: 'ModelWithString', + }, + }, +};" +`; + +exports[`v3 should generate: ./test/result/v3/schemas/$ModelWithReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithReference = { + properties: { + prop: { + type: 'ModelWithProperties', + }, + }, +};" +`; + +exports[`v3 should generate: ./test/result/v3/schemas/$ModelWithString.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithString = { + properties: { + prop: { + type: 'string', + }, + }, +};" +`; + +exports[`v3 should generate: ./test/result/v3/schemas/$MultilineComment.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $MultilineComment = { + type: 'number', +};" +`; + +exports[`v3 should generate: ./test/result/v3/schemas/$SimpleBoolean.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $SimpleBoolean = { + type: 'boolean', +};" +`; + +exports[`v3 should generate: ./test/result/v3/schemas/$SimpleFile.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $SimpleFile = { + type: 'File', +};" +`; + +exports[`v3 should generate: ./test/result/v3/schemas/$SimpleInteger.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $SimpleInteger = { + type: 'number', +};" +`; + +exports[`v3 should generate: ./test/result/v3/schemas/$SimpleReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $SimpleReference = { + type: 'ModelWithString', +};" +`; + +exports[`v3 should generate: ./test/result/v3/schemas/$SimpleString.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $SimpleString = { + type: 'string', +};" +`; + +exports[`v3 should generate: ./test/result/v3/services/ComplexService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { ModelWithArray } from '../models/ModelWithArray'; +import { ModelWithDictionary } from '../models/ModelWithDictionary'; +import { ModelWithEnum } from '../models/ModelWithEnum'; +import { ModelWithString } from '../models/ModelWithString'; +import { ApiError, catchGenericError } from '../core/ApiError'; +import { request as __request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class ComplexService { + + /** + * @param parameterObject Parameter containing object + * @param parameterReference Parameter containing reference + * @result ModelWithString Successful response + * @throws ApiError + */ + public static async complexTypes( + parameterObject: { + first?: { + second?: { + third?: string, + }, + }, + }, + parameterReference: ModelWithString, + ): Promise> { + + const result = await __request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/complex\`, + query: { + 'parameterObject': parameterObject, + 'parameterReference': parameterReference, + }, + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`400 server error\`); + case 500: throw new ApiError(result, \`500 server error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @param id + * @param requestBody + * @result ModelWithString Success + * @throws ApiError + */ + public static async complexParams( + id: number, + requestBody?: { + readonly key: string | null, + name: string | null, + enabled?: boolean, + readonly type: ('Monkey' | 'Horse' | 'Bird'), + listOfModels?: Array | null, + listOfStrings?: Array | null, + parameters: ModelWithArray | ModelWithDictionary | ModelWithEnum | ModelWithString, + readonly user?: { + readonly id?: number, + readonly name?: string | null, + }, + }, + ): Promise { + + const result = await __request({ + method: 'put', + path: \`/api/v\${OpenAPI.VERSION}/complex/\${id}\`, + body: requestBody, + }); + + catchGenericError(result); + + return result.body; + } + +}" +`; + +exports[`v3 should generate: ./test/result/v3/services/DefaultsService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { ModelWithString } from '../models/ModelWithString'; +import { catchGenericError } from '../core/ApiError'; +import { request as __request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class DefaultsService { + + /** + * @param parameterString This is a simple string with default value + * @param parameterNumber This is a simple number with default value + * @param parameterBoolean This is a simple boolean with default value + * @param parameterEnum This is a simple enum with default value + * @param parameterModel This is a simple model with default value + * @throws ApiError + */ + public static async callWithDefaultParameters( + parameterString: string | null = 'Hello World!', + parameterNumber: number | null = 123, + parameterBoolean: boolean | null = true, + parameterEnum: ('Success' | 'Warning' | 'Error') = 'Success', + parameterModel: ModelWithString | null = { + \\"prop\\": \\"Hello World\\" + }, + ): Promise { + + const result = await __request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/defaults\`, + query: { + 'parameterString': parameterString, + 'parameterNumber': parameterNumber, + 'parameterBoolean': parameterBoolean, + 'parameterEnum': parameterEnum, + 'parameterModel': parameterModel, + }, + }); + + catchGenericError(result); + + return result.body; + } + + /** + * @param parameterString This is a simple string that is optional with default value + * @param parameterNumber This is a simple number that is optional with default value + * @param parameterBoolean This is a simple boolean that is optional with default value + * @param parameterEnum This is a simple enum that is optional with default value + * @param parameterModel This is a simple model that is optional with default value + * @throws ApiError + */ + public static async callWithDefaultOptionalParameters( + parameterString: string = 'Hello World!', + parameterNumber: number = 123, + parameterBoolean: boolean = true, + parameterEnum: ('Success' | 'Warning' | 'Error') = 'Success', + parameterModel: ModelWithString = { + \\"prop\\": \\"Hello World\\" + }, + ): Promise { + + const result = await __request({ + method: 'post', + path: \`/api/v\${OpenAPI.VERSION}/defaults\`, + query: { + 'parameterString': parameterString, + 'parameterNumber': parameterNumber, + 'parameterBoolean': parameterBoolean, + 'parameterEnum': parameterEnum, + 'parameterModel': parameterModel, + }, + }); + + catchGenericError(result); + + return result.body; + } + + /** + * @param parameterStringWithNoDefault This is a string with no default + * @param parameterOptionalStringWithDefault This is a optional string with default + * @param parameterOptionalStringWithEmptyDefault This is a optional string with empty default + * @param parameterOptionalStringWithNoDefault This is a optional string with no default + * @param parameterStringWithDefault This is a string with default + * @param parameterStringWithEmptyDefault This is a string with empty default + * @throws ApiError + */ + public static async callToTestOrderOfParams( + parameterStringWithNoDefault: string, + parameterOptionalStringWithDefault: string = 'hello', + parameterOptionalStringWithEmptyDefault: string = '', + parameterOptionalStringWithNoDefault?: string, + parameterStringWithDefault: string = 'hello', + parameterStringWithEmptyDefault: string = '', + ): Promise { + + const result = await __request({ + method: 'put', + path: \`/api/v\${OpenAPI.VERSION}/defaults\`, + query: { + 'parameterStringWithNoDefault': parameterStringWithNoDefault, + 'parameterOptionalStringWithDefault': parameterOptionalStringWithDefault, + 'parameterOptionalStringWithEmptyDefault': parameterOptionalStringWithEmptyDefault, + 'parameterOptionalStringWithNoDefault': parameterOptionalStringWithNoDefault, + 'parameterStringWithDefault': parameterStringWithDefault, + 'parameterStringWithEmptyDefault': parameterStringWithEmptyDefault, + }, + }); + + catchGenericError(result); + + return result.body; + } + +}" +`; + +exports[`v3 should generate: ./test/result/v3/services/DuplicateService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { catchGenericError } from '../core/ApiError'; +import { request as __request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class DuplicateService { + + /** + * @throws ApiError + */ + public static async duplicateName(): Promise { + + const result = await __request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/duplicate\`, + }); + + catchGenericError(result); + + return result.body; + } + + /** + * @throws ApiError + */ + public static async duplicateName1(): Promise { + + const result = await __request({ + method: 'post', + path: \`/api/v\${OpenAPI.VERSION}/duplicate\`, + }); + + catchGenericError(result); + + return result.body; + } + + /** + * @throws ApiError + */ + public static async duplicateName2(): Promise { + + const result = await __request({ + method: 'put', + path: \`/api/v\${OpenAPI.VERSION}/duplicate\`, + }); + + catchGenericError(result); + + return result.body; + } + + /** + * @throws ApiError + */ + public static async duplicateName3(): Promise { + + const result = await __request({ + method: 'delete', + path: \`/api/v\${OpenAPI.VERSION}/duplicate\`, + }); + + catchGenericError(result); + + return result.body; + } + +}" +`; + +exports[`v3 should generate: ./test/result/v3/services/HeaderService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { ApiError, catchGenericError } from '../core/ApiError'; +import { request as __request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class HeaderService { + + /** + * @result string Successful response + * @throws ApiError + */ + public static async callWithResultFromHeader(): Promise { + + const result = await __request({ + method: 'post', + path: \`/api/v\${OpenAPI.VERSION}/header\`, + responseHeader: 'operation-location', + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`400 server error\`); + case 500: throw new ApiError(result, \`500 server error\`); + } + } + + catchGenericError(result); + + return result.body; + } + +}" +`; + +exports[`v3 should generate: ./test/result/v3/services/MultipartService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { catchGenericError } from '../core/ApiError'; +import { request as __request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class MultipartService { + + /** + * @result any OK + * @throws ApiError + */ + public static async multipartResponse(): Promise<{ + file?: string, + metadata?: { + foo?: string, + bar?: string, + }, + }> { + + const result = await __request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/multipart\`, + }); + + catchGenericError(result); + + return result.body; + } + +}" +`; + +exports[`v3 should generate: ./test/result/v3/services/ParametersService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { ModelWithString } from '../models/ModelWithString'; +import { catchGenericError } from '../core/ApiError'; +import { request as __request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class ParametersService { + + /** + * @param parameterHeader This is the parameter that goes into the header + * @param parameterQuery This is the parameter that goes into the query params + * @param parameterForm This is the parameter that goes into the form data + * @param parameterCookie This is the parameter that goes into the cookie + * @param parameterPath This is the parameter that goes into the path + * @param requestBody This is the parameter that goes into the body + * @throws ApiError + */ + public static async callWithParameters( + parameterHeader: string | null, + parameterQuery: string | null, + parameterForm: string | null, + parameterCookie: string | null, + parameterPath: string | null, + requestBody: ModelWithString | null, + ): Promise { + + const result = await __request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/parameters/\${parameterPath}\`, + cookies: { + 'parameterCookie': parameterCookie, + }, + headers: { + 'parameterHeader': parameterHeader, + }, + query: { + 'parameterQuery': parameterQuery, + }, + formData: { + 'parameterForm': parameterForm, + }, + body: requestBody, + }); + + catchGenericError(result); + + return result.body; + } + + /** + * @param parameterHeader This is the parameter that goes into the request header + * @param parameterQuery This is the parameter that goes into the request query params + * @param parameterForm This is the parameter that goes into the request form data + * @param parameterCookie This is the parameter that goes into the cookie + * @param requestBody This is the parameter that goes into the body + * @param parameterPath1 This is the parameter that goes into the path + * @param parameterPath2 This is the parameter that goes into the path + * @param parameterPath3 This is the parameter that goes into the path + * @throws ApiError + */ + public static async callWithWeirdParameterNames( + parameterHeader: string | null, + parameterQuery: string | null, + parameterForm: string | null, + parameterCookie: string | null, + requestBody: ModelWithString | null, + parameterPath1?: string, + parameterPath2?: string, + parameterPath3?: string, + ): Promise { + + const result = await __request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/parameters/\${parameterPath1}/\${parameterPath2}/\${parameterPath3}\`, + cookies: { + 'PARAMETER-COOKIE': parameterCookie, + }, + headers: { + 'parameter.header': parameterHeader, + }, + query: { + 'parameter-query': parameterQuery, + }, + formData: { + 'parameter_form': parameterForm, + }, + body: requestBody, + }); + + catchGenericError(result); + + return result.body; + } + + /** + * @param requestBody This is a required parameter + * @param parameter This is an optional parameter + * @throws ApiError + */ + public static async getCallWithOptionalParam( + requestBody: ModelWithString, + parameter?: string, + ): Promise { + + const result = await __request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/parameters/\`, + query: { + 'parameter': parameter, + }, + body: requestBody, + }); + + catchGenericError(result); + + return result.body; + } + + /** + * @param parameter This is a required parameter + * @param requestBody This is an optional parameter + * @throws ApiError + */ + public static async postCallWithOptionalParam( + parameter: string, + requestBody?: ModelWithString, + ): Promise { + + const result = await __request({ + method: 'post', + path: \`/api/v\${OpenAPI.VERSION}/parameters/\`, + query: { + 'parameter': parameter, + }, + body: requestBody, + }); + + catchGenericError(result); + + return result.body; + } + +}" +`; + +exports[`v3 should generate: ./test/result/v3/services/ResponseService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { ModelThatExtends } from '../models/ModelThatExtends'; +import { ModelThatExtendsExtends } from '../models/ModelThatExtendsExtends'; +import { ModelWithString } from '../models/ModelWithString'; +import { ApiError, catchGenericError } from '../core/ApiError'; +import { request as __request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class ResponseService { + + /** + * @result ModelWithString + * @throws ApiError + */ + public static async callWithResponse(): Promise { + + const result = await __request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/response\`, + }); + + catchGenericError(result); + + return result.body; + } + + /** + * @result ModelWithString Message for default response + * @throws ApiError + */ + public static async callWithDuplicateResponses(): Promise { + + const result = await __request({ + method: 'post', + path: \`/api/v\${OpenAPI.VERSION}/response\`, + }); + + if (!result.ok) { + switch (result.status) { + case 500: throw new ApiError(result, \`Message for 500 error\`); + case 501: throw new ApiError(result, \`Message for 501 error\`); + case 502: throw new ApiError(result, \`Message for 502 error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @result ModelWithString Message for default response + * @result ModelThatExtends Message for 201 response + * @result ModelThatExtendsExtends Message for 202 response + * @throws ApiError + */ + public static async callWithResponses(): Promise { + + const result = await __request({ + method: 'put', + path: \`/api/v\${OpenAPI.VERSION}/response\`, + }); + + if (!result.ok) { + switch (result.status) { + case 500: throw new ApiError(result, \`Message for 500 error\`); + case 501: throw new ApiError(result, \`Message for 501 error\`); + case 502: throw new ApiError(result, \`Message for 502 error\`); + } + } + + catchGenericError(result); + + return result.body; + } + +}" +`; + +exports[`v3 should generate: ./test/result/v3/services/SimpleService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { catchGenericError } from '../core/ApiError'; +import { request as __request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class SimpleService { + + /** + * @throws ApiError + */ + public static async getCallWithoutParametersAndResponse(): Promise { + + const result = await __request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/simple\`, + }); + + catchGenericError(result); + + return result.body; + } + + /** + * @throws ApiError + */ + public static async putCallWithoutParametersAndResponse(): Promise { + + const result = await __request({ + method: 'put', + path: \`/api/v\${OpenAPI.VERSION}/simple\`, + }); + + catchGenericError(result); + + return result.body; + } + + /** + * @throws ApiError + */ + public static async postCallWithoutParametersAndResponse(): Promise { + + const result = await __request({ + method: 'post', + path: \`/api/v\${OpenAPI.VERSION}/simple\`, + }); + + catchGenericError(result); + + return result.body; + } + + /** + * @throws ApiError + */ + public static async deleteCallWithoutParametersAndResponse(): Promise { + + const result = await __request({ + method: 'delete', + path: \`/api/v\${OpenAPI.VERSION}/simple\`, + }); + + catchGenericError(result); + + return result.body; + } + + /** + * @throws ApiError + */ + public static async optionsCallWithoutParametersAndResponse(): Promise { + + const result = await __request({ + method: 'options', + path: \`/api/v\${OpenAPI.VERSION}/simple\`, + }); + + catchGenericError(result); + + return result.body; + } + + /** + * @throws ApiError + */ + public static async headCallWithoutParametersAndResponse(): Promise { + + const result = await __request({ + method: 'head', + path: \`/api/v\${OpenAPI.VERSION}/simple\`, + }); + + catchGenericError(result); + + return result.body; + } + + /** + * @throws ApiError + */ + public static async patchCallWithoutParametersAndResponse(): Promise { + + const result = await __request({ + method: 'patch', + path: \`/api/v\${OpenAPI.VERSION}/simple\`, + }); + + catchGenericError(result); + + return result.body; + } + +}" +`; + +exports[`v3 should generate: ./test/result/v3/services/TypesService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { catchGenericError } from '../core/ApiError'; +import { request as __request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class TypesService { + + /** + * @param parameterArray This is an array parameter + * @param parameterDictionary This is a dictionary parameter + * @param parameterEnum This is an enum parameter + * @param parameterNumber This is a number parameter + * @param parameterString This is a string parameter + * @param parameterBoolean This is a boolean parameter + * @param parameterObject This is an object parameter + * @param id This is a number parameter + * @result number Response is a simple number + * @result string Response is a simple string + * @result boolean Response is a simple boolean + * @result any Response is a simple object + * @throws ApiError + */ + public static async types( + parameterArray: Array | null, + parameterDictionary: any, + parameterEnum: ('Success' | 'Warning' | 'Error') | null, + parameterNumber: number = 123, + parameterString: string | null = 'default', + parameterBoolean: boolean | null = true, + parameterObject: any = null, + id?: number, + ): Promise { + + const result = await __request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/types\`, + query: { + 'parameterArray': parameterArray, + 'parameterDictionary': parameterDictionary, + 'parameterEnum': parameterEnum, + 'parameterNumber': parameterNumber, + 'parameterString': parameterString, + 'parameterBoolean': parameterBoolean, + 'parameterObject': parameterObject, + }, + }); + + catchGenericError(result); + + return result.body; + } + +}" +`; + +exports[`v3 should generate: ./test/result/v3/services/UploadService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { catchGenericError } from '../core/ApiError'; +import { request as __request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class UploadService { + + /** + * @param file Supply a file reference for upload + * @result boolean + * @throws ApiError + */ + public static async uploadFile( + file: File, + ): Promise { + + const result = await __request({ + method: 'post', + path: \`/api/v\${OpenAPI.VERSION}/upload\`, + formData: { + 'file': file, + }, + }); + + catchGenericError(result); + + return result.body; + } + +}" +`; From f959bb08355741309178c75ea0bbe77fc3469b28 Mon Sep 17 00:00:00 2001 From: Ferdi Koomen Date: Fri, 28 Aug 2020 21:21:19 +0200 Subject: [PATCH 4/4] - Bumped version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index cedf16ad..91d9a7ab 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openapi-typescript-codegen", - "version": "0.4.10", + "version": "0.4.11", "description": "NodeJS library that generates Typescript or Javascript clients based on the OpenAPI specification.", "author": "Ferdi Koomen", "homepage": "https://github.com/ferdikoomen/openapi-typescript-codegen",