From e23135a2a37c6f8f323ed0fc9176f6e3d677845d Mon Sep 17 00:00:00 2001 From: lub0v-parsable Date: Wed, 4 Aug 2021 21:35:29 -0700 Subject: [PATCH 01/11] generate client instances with --exportClient option --- README.md | 25 + bin/index.js | 4 + jest.config.js | 12 +- src/index.ts | 14 +- .../v2/parser/getOperationPath.spec.ts | 4 +- src/openApi/v2/parser/getOperationPath.ts | 8 +- .../v3/parser/getOperationPath.spec.ts | 4 +- src/openApi/v3/parser/getOperationPath.ts | 8 +- src/templates/core/BaseHttpRequest.hbs | 17 + .../{request.hbs => ConcreteHttpRequest.hbs} | 0 src/templates/core/OpenAPI.hbs | 13 +- src/templates/core/fetch/getHeaders.hbs | 10 +- src/templates/core/fetch/request.hbs | 41 +- src/templates/core/fetch/sendRequest.hbs | 6 +- src/templates/core/functions/getUrl.hbs | 4 +- src/templates/core/node/getHeaders.hbs | 10 +- src/templates/core/node/request.hbs | 41 +- src/templates/core/node/sendRequest.hbs | 4 +- src/templates/core/xhr/getHeaders.hbs | 10 +- src/templates/core/xhr/request.hbs | 42 +- src/templates/core/xhr/sendRequest.hbs | 6 +- src/templates/exportAppClient.hbs | 32 + src/templates/exportService.hbs | 19 +- src/templates/index.hbs | 12 + src/utils/getHttpClientName.spec.ts | 14 + src/utils/getHttpRequestName.ts | 3 + src/utils/postProcessClient.ts | 5 +- src/utils/postProcessService.ts | 4 +- src/utils/postProcessServiceOperations.ts | 5 +- src/utils/registerHandlebarTemplates.spec.ts | 4 +- src/utils/registerHandlebarTemplates.ts | 12 +- src/utils/writeAppClient.spec.ts | 39 + src/utils/writeAppClient.ts | 32 + src/utils/writeClient.spec.ts | 6 +- src/utils/writeClient.ts | 17 +- src/utils/writeClientCore.spec.ts | 61 +- src/utils/writeClientCore.ts | 12 +- src/utils/writeClientIndex.spec.ts | 7 +- src/utils/writeClientIndex.ts | 13 +- src/utils/writeClientModels.spec.ts | 4 +- src/utils/writeClientSchemas.spec.ts | 4 +- src/utils/writeClientServices.spec.ts | 6 +- src/utils/writeClientServices.ts | 14 +- test/__snapshots__/index.client.spec.js.snap | 5416 +++++++++++++++++ test/__snapshots__/index.spec.js.snap | 86 +- test/e2e/scripts/generate.js | 3 +- test/e2e/v2.babel.spec.js | 47 +- test/e2e/v2.fetch.spec.js | 47 +- test/e2e/v2.node.spec.js | 42 +- test/e2e/v2.xhr.spec.js | 47 +- test/e2e/v3.babel.spec.js | 56 +- test/e2e/v3.fetch.spec.js | 56 +- test/e2e/v3.node.spec.js | 49 +- test/e2e/v3.xhr.spec.js | 56 +- test/index.client.spec.js | 51 + test/index.spec.js | 2 + 56 files changed, 6373 insertions(+), 193 deletions(-) create mode 100644 src/templates/core/BaseHttpRequest.hbs rename src/templates/core/{request.hbs => ConcreteHttpRequest.hbs} (100%) create mode 100644 src/templates/exportAppClient.hbs create mode 100644 src/utils/getHttpClientName.spec.ts create mode 100644 src/utils/getHttpRequestName.ts create mode 100644 src/utils/writeAppClient.spec.ts create mode 100644 src/utils/writeAppClient.ts create mode 100644 test/__snapshots__/index.client.spec.js.snap create mode 100644 test/index.client.spec.js diff --git a/README.md b/README.md index eacdf7069..b241c9703 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,8 @@ $ openapi --help --exportServices Write services to disk (default: true) --exportModels Write models to disk (default: true) --exportSchemas Write schemas to disk (default: false) + --exportClient Generate and write client class to disk (default: false) + --name Custom client class name (default: "AppClient") Examples $ openapi --input ./spec.json @@ -392,6 +394,29 @@ const getToken = async () => { OpenAPI.TOKEN = getToken; ``` +### Generate client instance with `--exportClient` option + +The OpenAPI generator allows to create client instances to support the multiple backend services use case. +The generated client uses an instance of the server configuration and not the global `OpenAPI` constant. + +To generate a client instance, use `--exportClient` option. To set a custom name to the client class, use `--name` option. + +``` +openapi --input ./spec.json --output ./dist --exportClient true --name DemoAppClient +``` + +The generated client will be exported from the `index` file and can be used as shown below: +```typescript +// create the client instance with server and authentication details +const appClient = new DemoAppClient({ BASE: 'http://server-host.com', TOKEN: '1234' }); + +// use the client instance to make the API call +const res: OrganizationResponse = await appClient.organizations.createOrganization({ + name: 'OrgName', + description: 'OrgDescription', +}); +``` + ### References Local references to schema definitions (those beginning with `#/definitions/schemas/`) diff --git a/bin/index.js b/bin/index.js index 4419b9964..27f34b71e 100755 --- a/bin/index.js +++ b/bin/index.js @@ -19,7 +19,9 @@ const params = program .option('--exportServices ', 'Write services to disk', true) .option('--exportModels ', 'Write models to disk', true) .option('--exportSchemas ', 'Write schemas to disk', false) + .option('--exportClient ', 'Generate and write client class to disk', false) .option('--request ', 'Path to custom request file') + .option('--name ', 'Custom client class name', 'AppClient') .parse(process.argv) .opts(); @@ -36,6 +38,8 @@ if (OpenAPI) { exportServices: JSON.parse(params.exportServices) === true, exportModels: JSON.parse(params.exportModels) === true, exportSchemas: JSON.parse(params.exportSchemas) === true, + exportClient: JSON.parse(params.exportClient) === true, + clientName: params.name, request: params.request, }) .then(() => { diff --git a/jest.config.js b/jest.config.js index 427bbb70a..ec73e8919 100644 --- a/jest.config.js +++ b/jest.config.js @@ -5,10 +5,7 @@ module.exports = { { displayName: 'UNIT', testEnvironment: 'node', - testMatch: [ - '/src/**/*.spec.ts', - '/test/index.spec.js', - ], + testMatch: ['/src/**/*.spec.ts', '/test/index.spec.js', '/test/index.client.spec.js'], moduleFileExtensions: ['js', 'ts', 'd.ts'], moduleNameMapper: { '\\.hbs$': '/src/templates/__mocks__/index.js', @@ -29,10 +26,5 @@ module.exports = { ], }, ], - collectCoverageFrom: [ - '/src/**/*.ts', - '!/src/**/*.d.ts', - '!/bin', - '!/dist', - ], + collectCoverageFrom: ['/src/**/*.ts', '!/src/**/*.d.ts', '!/bin', '!/dist'], }; diff --git a/src/index.ts b/src/index.ts index 7a67ee56d..a2e188402 100644 --- a/src/index.ts +++ b/src/index.ts @@ -20,7 +20,9 @@ export type Options = { exportServices?: boolean; exportModels?: boolean; exportSchemas?: boolean; + exportClient?: boolean; request?: string; + clientName?: string; write?: boolean; }; @@ -37,6 +39,8 @@ export type Options = { * @param exportServices: Generate services * @param exportModels: Generate models * @param exportSchemas: Generate schemas + * @param exportClient: Generate client class + * @param clientName: Custom client class name * @param request: Path to custom request file * @param write Write the files to disk (true or false) */ @@ -50,6 +54,8 @@ export async function generate({ exportServices = true, exportModels = true, exportSchemas = false, + exportClient = false, + clientName = 'AppClient', request, write = true, }: Options): Promise { @@ -64,17 +70,17 @@ export async function generate({ switch (openApiVersion) { case OpenApiVersion.V2: { const client = parseV2(openApi); - const clientFinal = postProcessClient(client); + const clientFinal = postProcessClient(client, exportClient); if (!write) break; - await writeClient(clientFinal, templates, output, httpClient, useOptions, useUnionTypes, exportCore, exportServices, exportModels, exportSchemas, request); + await writeClient(clientFinal, templates, output, httpClient, useOptions, useUnionTypes, exportCore, exportServices, exportModels, exportSchemas, exportClient, clientName, request); break; } case OpenApiVersion.V3: { const client = parseV3(openApi); - const clientFinal = postProcessClient(client); + const clientFinal = postProcessClient(client, exportClient); if (!write) break; - await writeClient(clientFinal, templates, output, httpClient, useOptions, useUnionTypes, exportCore, exportServices, exportModels, exportSchemas, request); + await writeClient(clientFinal, templates, output, httpClient, useOptions, useUnionTypes, exportCore, exportServices, exportModels, exportSchemas, exportClient, clientName, request); break; } } diff --git a/src/openApi/v2/parser/getOperationPath.spec.ts b/src/openApi/v2/parser/getOperationPath.spec.ts index 41df428d1..2fa2c0752 100644 --- a/src/openApi/v2/parser/getOperationPath.spec.ts +++ b/src/openApi/v2/parser/getOperationPath.spec.ts @@ -2,8 +2,8 @@ import { getOperationPath } from './getOperationPath'; describe('getOperationPath', () => { it('should produce correct result', () => { - expect(getOperationPath('/api/v{api-version}/list/{id}/{type}')).toEqual('/api/v${OpenAPI.VERSION}/list/${id}/${type}'); - expect(getOperationPath('/api/v{api-version}/list/{id}')).toEqual('/api/v${OpenAPI.VERSION}/list/${id}'); + expect(getOperationPath('/api/v{api-version}/list/{id}/{type}')).toEqual('/api/v${apiVersion}/list/${id}/${type}'); + expect(getOperationPath('/api/v{api-version}/list/{id}')).toEqual('/api/v${apiVersion}/list/${id}'); expect(getOperationPath('/api/v1/list/{id}')).toEqual('/api/v1/list/${id}'); expect(getOperationPath('/api/{foobar}')).toEqual('/api/${foobar}'); expect(getOperationPath('/api/{fooBar}')).toEqual('/api/${fooBar}'); diff --git a/src/openApi/v2/parser/getOperationPath.ts b/src/openApi/v2/parser/getOperationPath.ts index 7d2a07cff..8897d2db8 100644 --- a/src/openApi/v2/parser/getOperationPath.ts +++ b/src/openApi/v2/parser/getOperationPath.ts @@ -8,9 +8,7 @@ import { getOperationParameterName } from './getOperationParameterName'; * @param path */ export function getOperationPath(path: string): string { - return path - .replace(/\{(.*?)\}/g, (_, w: string) => { - return `\${${getOperationParameterName(w)}}`; - }) - .replace('${apiVersion}', '${OpenAPI.VERSION}'); + return path.replace(/\{(.*?)\}/g, (_, w: string) => { + return `\${${getOperationParameterName(w)}}`; + }); } diff --git a/src/openApi/v3/parser/getOperationPath.spec.ts b/src/openApi/v3/parser/getOperationPath.spec.ts index 41df428d1..2fa2c0752 100644 --- a/src/openApi/v3/parser/getOperationPath.spec.ts +++ b/src/openApi/v3/parser/getOperationPath.spec.ts @@ -2,8 +2,8 @@ import { getOperationPath } from './getOperationPath'; describe('getOperationPath', () => { it('should produce correct result', () => { - expect(getOperationPath('/api/v{api-version}/list/{id}/{type}')).toEqual('/api/v${OpenAPI.VERSION}/list/${id}/${type}'); - expect(getOperationPath('/api/v{api-version}/list/{id}')).toEqual('/api/v${OpenAPI.VERSION}/list/${id}'); + expect(getOperationPath('/api/v{api-version}/list/{id}/{type}')).toEqual('/api/v${apiVersion}/list/${id}/${type}'); + expect(getOperationPath('/api/v{api-version}/list/{id}')).toEqual('/api/v${apiVersion}/list/${id}'); expect(getOperationPath('/api/v1/list/{id}')).toEqual('/api/v1/list/${id}'); expect(getOperationPath('/api/{foobar}')).toEqual('/api/${foobar}'); expect(getOperationPath('/api/{fooBar}')).toEqual('/api/${fooBar}'); diff --git a/src/openApi/v3/parser/getOperationPath.ts b/src/openApi/v3/parser/getOperationPath.ts index 7d2a07cff..8897d2db8 100644 --- a/src/openApi/v3/parser/getOperationPath.ts +++ b/src/openApi/v3/parser/getOperationPath.ts @@ -8,9 +8,7 @@ import { getOperationParameterName } from './getOperationParameterName'; * @param path */ export function getOperationPath(path: string): string { - return path - .replace(/\{(.*?)\}/g, (_, w: string) => { - return `\${${getOperationParameterName(w)}}`; - }) - .replace('${apiVersion}', '${OpenAPI.VERSION}'); + return path.replace(/\{(.*?)\}/g, (_, w: string) => { + return `\${${getOperationParameterName(w)}}`; + }); } diff --git a/src/templates/core/BaseHttpRequest.hbs b/src/templates/core/BaseHttpRequest.hbs new file mode 100644 index 000000000..ad6636a32 --- /dev/null +++ b/src/templates/core/BaseHttpRequest.hbs @@ -0,0 +1,17 @@ +{{>header}} + +import type { ApiRequestOptions } from './ApiRequestOptions'; +import type { ApiResult } from './ApiResult'; +import type { OpenAPIConfig } from './OpenAPI'; + +export class BaseHttpRequest { + readonly openApiConfig: OpenAPIConfig; + + constructor(openApiConfig: OpenAPIConfig) { + this.openApiConfig = openApiConfig; + } + + async request(options: ApiRequestOptions): Promise { + throw new Error('Not Implemented'); + } +} diff --git a/src/templates/core/request.hbs b/src/templates/core/ConcreteHttpRequest.hbs similarity index 100% rename from src/templates/core/request.hbs rename to src/templates/core/ConcreteHttpRequest.hbs diff --git a/src/templates/core/OpenAPI.hbs b/src/templates/core/OpenAPI.hbs index 2b59a9708..6ddd59fd8 100644 --- a/src/templates/core/OpenAPI.hbs +++ b/src/templates/core/OpenAPI.hbs @@ -5,17 +5,17 @@ import type { ApiRequestOptions } from './ApiRequestOptions'; type Resolver = (options: ApiRequestOptions) => Promise; type Headers = Record; -type Config = { - BASE: string; - VERSION: string; - WITH_CREDENTIALS: boolean; +export type OpenAPIConfig = { + BASE?: string; + VERSION?: string; + WITH_CREDENTIALS?: boolean; TOKEN?: string | Resolver; USERNAME?: string | Resolver; PASSWORD?: string | Resolver; HEADERS?: Headers | Resolver; } - -export const OpenAPI: Config = { +{{#unless @root.exportClient}} +export const OpenAPI: OpenAPIConfig = { BASE: '{{{server}}}', VERSION: '{{{version}}}', WITH_CREDENTIALS: false, @@ -24,3 +24,4 @@ export const OpenAPI: Config = { PASSWORD: undefined, HEADERS: undefined, }; +{{/unless}} diff --git a/src/templates/core/fetch/getHeaders.hbs b/src/templates/core/fetch/getHeaders.hbs index 3d1a62c7e..1ef2301f0 100644 --- a/src/templates/core/fetch/getHeaders.hbs +++ b/src/templates/core/fetch/getHeaders.hbs @@ -1,8 +1,8 @@ -async function getHeaders(options: ApiRequestOptions): Promise { - const token = await resolve(options, OpenAPI.TOKEN); - const username = await resolve(options, OpenAPI.USERNAME); - const password = await resolve(options, OpenAPI.PASSWORD); - const defaultHeaders = await resolve(options, OpenAPI.HEADERS); +async function getHeaders(options: ApiRequestOptions, config: OpenAPIConfig): Promise { + const token = await resolve(options, config.TOKEN); + const username = await resolve(options, config.USERNAME); + const password = await resolve(options, config.PASSWORD); + const defaultHeaders = await resolve(options, config.HEADERS); const headers = new Headers({ Accept: 'application/json', diff --git a/src/templates/core/fetch/request.hbs b/src/templates/core/fetch/request.hbs index c22330e51..1e34f4fbb 100644 --- a/src/templates/core/fetch/request.hbs +++ b/src/templates/core/fetch/request.hbs @@ -3,7 +3,12 @@ import { ApiError } from './ApiError'; import type { ApiRequestOptions } from './ApiRequestOptions'; import type { ApiResult } from './ApiResult'; +import type { OpenAPIConfig } from './OpenAPI'; +{{#if @root.exportClient}} +import { BaseHttpRequest } from './BaseHttpRequest'; +{{else}} import { OpenAPI } from './OpenAPI'; +{{/if}} {{>functions/isDefined}} @@ -47,6 +52,37 @@ import { OpenAPI } from './OpenAPI'; {{>functions/catchErrors}} +{{#if @root.exportClient}} +export class FetchHttpRequest extends BaseHttpRequest { + constructor(openApiConfig: OpenAPIConfig) { + super(openApiConfig); + } + + /** + * Request using fetch client + * @param options The request options from the the service + * @returns ApiResult + * @throws ApiError + */ + async request(options: ApiRequestOptions): Promise { + const url = getUrl(options, this.openApiConfig); + const response = await sendRequest(options, this.openApiConfig, url); + const responseBody = await getResponseBody(response); + const responseHeader = getResponseHeader(response, options.responseHeader); + + const result: ApiResult = { + url, + ok: response.ok, + status: response.status, + statusText: response.statusText, + body: responseHeader || responseBody, + }; + + catchErrors(options, result); + return result; + } +} +{{else}} /** * Request using fetch client * @param options The request options from the the service @@ -54,8 +90,8 @@ import { OpenAPI } from './OpenAPI'; * @throws ApiError */ export async function request(options: ApiRequestOptions): Promise { - const url = getUrl(options); - const response = await sendRequest(options, url); + const url = getUrl(options, OpenAPI); + const response = await sendRequest(options, OpenAPI, url); const responseBody = await getResponseBody(response); const responseHeader = getResponseHeader(response, options.responseHeader); @@ -70,3 +106,4 @@ export async function request(options: ApiRequestOptions): Promise { catchErrors(options, result); return result; } +{{/if}} diff --git a/src/templates/core/fetch/sendRequest.hbs b/src/templates/core/fetch/sendRequest.hbs index 4afd07317..bdcf5b26f 100644 --- a/src/templates/core/fetch/sendRequest.hbs +++ b/src/templates/core/fetch/sendRequest.hbs @@ -1,10 +1,10 @@ -async function sendRequest(options: ApiRequestOptions, url: string): Promise { +async function sendRequest(options: ApiRequestOptions, config: OpenAPIConfig, url: string): Promise { const request: RequestInit = { method: options.method, - headers: await getHeaders(options), + headers: await getHeaders(options, config), body: getRequestBody(options), }; - if (OpenAPI.WITH_CREDENTIALS) { + if (config.WITH_CREDENTIALS) { request.credentials = 'include'; } return await fetch(url, request); diff --git a/src/templates/core/functions/getUrl.hbs b/src/templates/core/functions/getUrl.hbs index be040bbb6..758ab7549 100644 --- a/src/templates/core/functions/getUrl.hbs +++ b/src/templates/core/functions/getUrl.hbs @@ -1,6 +1,6 @@ -function getUrl(options: ApiRequestOptions): string { +function getUrl(options: ApiRequestOptions, config: OpenAPIConfig): string { const path = options.path.replace(/[:]/g, '_'); - const url = `${OpenAPI.BASE}${path}`; + const url = `${config.BASE}${path}`; if (options.query) { return `${url}${getQueryString(options.query)}`; diff --git a/src/templates/core/node/getHeaders.hbs b/src/templates/core/node/getHeaders.hbs index fc6d55164..61f2e47ce 100644 --- a/src/templates/core/node/getHeaders.hbs +++ b/src/templates/core/node/getHeaders.hbs @@ -1,8 +1,8 @@ -async function getHeaders(options: ApiRequestOptions): Promise { - const token = await resolve(options, OpenAPI.TOKEN); - const username = await resolve(options, OpenAPI.USERNAME); - const password = await resolve(options, OpenAPI.PASSWORD); - const defaultHeaders = await resolve(options, OpenAPI.HEADERS); +async function getHeaders(options: ApiRequestOptions, config: OpenAPIConfig): Promise { + const token = await resolve(options, config.TOKEN); + const username = await resolve(options, config.USERNAME); + const password = await resolve(options, config.PASSWORD); + const defaultHeaders = await resolve(options, config.HEADERS); const headers = new Headers({ Accept: 'application/json', diff --git a/src/templates/core/node/request.hbs b/src/templates/core/node/request.hbs index 1bf15050b..229c02fdb 100644 --- a/src/templates/core/node/request.hbs +++ b/src/templates/core/node/request.hbs @@ -7,7 +7,12 @@ import { types } from 'util'; import { ApiError } from './ApiError'; import type { ApiRequestOptions } from './ApiRequestOptions'; import type { ApiResult } from './ApiResult'; +import type { OpenAPIConfig } from './OpenAPI'; +{{#if @root.exportClient}} +import { BaseHttpRequest } from './BaseHttpRequest'; +{{else}} import { OpenAPI } from './OpenAPI'; +{{/if}} {{>functions/isDefined}} @@ -51,6 +56,37 @@ import { OpenAPI } from './OpenAPI'; {{>functions/catchErrors}} +{{#if @root.exportClient}} +export class NodeHttpRequest extends BaseHttpRequest { + constructor(openApiConfig: OpenAPIConfig) { + super(openApiConfig); + } + + /** + * Request using node-fetch client + * @param options The request options from the the service + * @returns ApiResult + * @throws ApiError + */ + async request(options: ApiRequestOptions): Promise { + const url = getUrl(options, this.openApiConfig); + const response = await sendRequest(options, this.openApiConfig, url); + const responseBody = await getResponseBody(response); + const responseHeader = getResponseHeader(response, options.responseHeader); + + const result: ApiResult = { + url, + ok: response.ok, + status: response.status, + statusText: response.statusText, + body: responseHeader || responseBody, + }; + + catchErrors(options, result); + return result; + } +} +{{else}} /** * Request using node-fetch client * @param options The request options from the the service @@ -58,8 +94,8 @@ import { OpenAPI } from './OpenAPI'; * @throws ApiError */ export async function request(options: ApiRequestOptions): Promise { - const url = getUrl(options); - const response = await sendRequest(options, url); + const url = getUrl(options, OpenAPI); + const response = await sendRequest(options, OpenAPI, url); const responseBody = await getResponseBody(response); const responseHeader = getResponseHeader(response, options.responseHeader); @@ -74,3 +110,4 @@ export async function request(options: ApiRequestOptions): Promise { catchErrors(options, result); return result; } +{{/if}} diff --git a/src/templates/core/node/sendRequest.hbs b/src/templates/core/node/sendRequest.hbs index e0a296e07..9ef53752f 100644 --- a/src/templates/core/node/sendRequest.hbs +++ b/src/templates/core/node/sendRequest.hbs @@ -1,7 +1,7 @@ -async function sendRequest(options: ApiRequestOptions, url: string): Promise { +async function sendRequest(options: ApiRequestOptions, config: OpenAPIConfig, url: string): Promise { const request: RequestInit = { method: options.method, - headers: await getHeaders(options), + headers: await getHeaders(options, config), body: getRequestBody(options), }; return await fetch(url, request); diff --git a/src/templates/core/xhr/getHeaders.hbs b/src/templates/core/xhr/getHeaders.hbs index 3d1a62c7e..1ef2301f0 100644 --- a/src/templates/core/xhr/getHeaders.hbs +++ b/src/templates/core/xhr/getHeaders.hbs @@ -1,8 +1,8 @@ -async function getHeaders(options: ApiRequestOptions): Promise { - const token = await resolve(options, OpenAPI.TOKEN); - const username = await resolve(options, OpenAPI.USERNAME); - const password = await resolve(options, OpenAPI.PASSWORD); - const defaultHeaders = await resolve(options, OpenAPI.HEADERS); +async function getHeaders(options: ApiRequestOptions, config: OpenAPIConfig): Promise { + const token = await resolve(options, config.TOKEN); + const username = await resolve(options, config.USERNAME); + const password = await resolve(options, config.PASSWORD); + const defaultHeaders = await resolve(options, config.HEADERS); const headers = new Headers({ Accept: 'application/json', diff --git a/src/templates/core/xhr/request.hbs b/src/templates/core/xhr/request.hbs index 9faf192f2..7749c7e35 100644 --- a/src/templates/core/xhr/request.hbs +++ b/src/templates/core/xhr/request.hbs @@ -3,7 +3,13 @@ import { ApiError } from './ApiError'; import type { ApiRequestOptions } from './ApiRequestOptions'; import type { ApiResult } from './ApiResult'; +import type { OpenAPIConfig } from './OpenAPI'; +{{#if @root.exportClient}} +import { BaseHttpRequest } from './BaseHttpRequest'; +{{else}} import { OpenAPI } from './OpenAPI'; +{{/if}} + {{>functions/isDefined}} @@ -50,6 +56,37 @@ import { OpenAPI } from './OpenAPI'; {{>functions/catchErrors}} +{{#if @root.exportClient}} +export class XhrHttpRequest extends BaseHttpRequest { + constructor(openApiConfig: OpenAPIConfig) { + super(openApiConfig); + } + + /** + * Request using XHR client + * @param options The request options from the the service + * @returns ApiResult + * @throws ApiError + */ + async request(options: ApiRequestOptions): Promise { + const url = getUrl(options, this.openApiConfig); + const response = await sendRequest(options, this.openApiConfig, url); + const responseBody = getResponseBody(response); + const responseHeader = getResponseHeader(response, options.responseHeader); + + const result: ApiResult = { + url, + ok: isSuccess(response.status), + status: response.status, + statusText: response.statusText, + body: responseHeader || responseBody, + }; + + catchErrors(options, result); + return result; + } +} +{{else}} /** * Request using XHR client * @param options The request options from the the service @@ -57,8 +94,8 @@ import { OpenAPI } from './OpenAPI'; * @throws ApiError */ export async function request(options: ApiRequestOptions): Promise { - const url = getUrl(options); - const response = await sendRequest(options, url); + const url = getUrl(options, OpenAPI); + const response = await sendRequest(options, OpenAPI, url); const responseBody = getResponseBody(response); const responseHeader = getResponseHeader(response, options.responseHeader); @@ -73,3 +110,4 @@ export async function request(options: ApiRequestOptions): Promise { catchErrors(options, result); return result; } +{{/if}} diff --git a/src/templates/core/xhr/sendRequest.hbs b/src/templates/core/xhr/sendRequest.hbs index 70c08b1fd..5c6d9bfd8 100644 --- a/src/templates/core/xhr/sendRequest.hbs +++ b/src/templates/core/xhr/sendRequest.hbs @@ -1,10 +1,10 @@ -async function sendRequest(options: ApiRequestOptions, url: string): Promise { +async function sendRequest(options: ApiRequestOptions, config: OpenAPIConfig, url: string): Promise { const xhr = new XMLHttpRequest(); xhr.open(options.method, url, true); - xhr.withCredentials = OpenAPI.WITH_CREDENTIALS; + xhr.withCredentials = config.WITH_CREDENTIALS ?? false; - const headers = await getHeaders(options); + const headers = await getHeaders(options, config); headers.forEach((value: string, key: string) => { xhr.setRequestHeader(key, value); }); diff --git a/src/templates/exportAppClient.hbs b/src/templates/exportAppClient.hbs new file mode 100644 index 000000000..3cb7417bc --- /dev/null +++ b/src/templates/exportAppClient.hbs @@ -0,0 +1,32 @@ +{{>header}} + +import { BaseHttpRequest } from './core/BaseHttpRequest'; +import type { OpenAPIConfig } from './core/OpenAPI'; +import { {{{httpClientRequest}}} } from './core/{{{httpClientRequest}}}'; +{{#if services}} +{{#each services}} +import { {{{name}}} } from './services/{{{name}}}'; +{{/each}} +{{/if}} + +export class {{{clientName}}} { +{{#each services}} + readonly {{{shortName}}}: {{{name}}}; +{{/each}} + readonly request: BaseHttpRequest; + + constructor(openApiConfig?: OpenAPIConfig, HttpRequest: new (config: OpenAPIConfig) => BaseHttpRequest = {{{httpClientRequest}}}) { + this.request = new HttpRequest({ + BASE: openApiConfig?.BASE ?? '{{{server}}}', + VERSION: openApiConfig?.VERSION ?? '{{{version}}}', + WITH_CREDENTIALS: openApiConfig?.WITH_CREDENTIALS ?? false, + TOKEN: openApiConfig?.TOKEN, + USERNAME: openApiConfig?.USERNAME, + PASSWORD: openApiConfig?.PASSWORD, + HEADERS: openApiConfig?.HEADERS, + }); + {{#each services}} + this.{{{shortName}}} = new {{{name}}}(this.request); + {{/each}} + } +} diff --git a/src/templates/exportService.hbs b/src/templates/exportService.hbs index c45ed830d..7e0f2a134 100644 --- a/src/templates/exportService.hbs +++ b/src/templates/exportService.hbs @@ -5,12 +5,23 @@ import type { {{{this}}} } from '../models/{{{this}}}'; {{/each}} {{/if}} +{{#if @root.exportClient}} +import { BaseHttpRequest } from '../core/BaseHttpRequest'; +{{else}} import { request as __request } from '../core/request'; {{#if @root.useVersion}} import { OpenAPI } from '../core/OpenAPI'; {{/if}} +{{/if}} export class {{{name}}} { + {{#if @root.exportClient}} + private httpRequest: BaseHttpRequest; + + constructor(httpRequest: BaseHttpRequest) { + this.httpRequest = httpRequest; + } + {{/if}} {{#each operations}} /** @@ -33,10 +44,10 @@ export class {{{name}}} { {{#each results}} * @returns {{{type}}} {{{description}}} {{/each}} - * @throws ApiError - */ - public static async {{{name}}}({{>parameters}}): Promise<{{>result}}> { - const result = await __request({ + * @throws ApiError + */ + public{{#unless @root.exportClient}} static{{/unless}} async {{{name}}}({{>parameters}}): Promise<{{>result}}> { + const result = await {{#if @root.exportClient}}this.httpRequest.request{{else}}__request{{/if}}({ method: '{{{method}}}', path: `{{{path}}}`, {{#if parametersCookie}} diff --git a/src/templates/index.hbs b/src/templates/index.hbs index e10436ba6..cb5b6b0b4 100644 --- a/src/templates/index.hbs +++ b/src/templates/index.hbs @@ -2,8 +2,16 @@ {{#if @root.exportCore}} export { ApiError } from './core/ApiError'; +{{#if @root.exportClient}} +export type { ApiRequestOptions } from './core/ApiRequestOptions'; +export type { ApiResult } from './core/ApiResult'; +export type { OpenAPIConfig } from './core/OpenAPI'; +export { BaseHttpRequest } from './core/BaseHttpRequest'; +export { {{{httpRequestName}}} } from './core/{{{httpRequestName}}}'; +{{else}} export { OpenAPI } from './core/OpenAPI'; {{/if}} +{{/if}} {{#if @root.exportModels}} {{#if models}} @@ -36,3 +44,7 @@ export { {{{name}}} } from './services/{{{name}}}'; {{/each}} {{/if}} {{/if}} + +{{#if @root.exportClient}} +export { {{{clientName}}} } from './client'; +{{/if}} diff --git a/src/utils/getHttpClientName.spec.ts b/src/utils/getHttpClientName.spec.ts new file mode 100644 index 000000000..ffeb13094 --- /dev/null +++ b/src/utils/getHttpClientName.spec.ts @@ -0,0 +1,14 @@ +import { HttpClient } from '../HttpClient'; +import { getHttpRequestName } from './getHttpRequestName'; + +describe('getHttpClientName', () => { + it('should convert the FETCH client', () => { + expect(getHttpRequestName(HttpClient.FETCH)).toEqual('FetchHttpRequest'); + }); + it('should convert the NODE client', () => { + expect(getHttpRequestName(HttpClient.NODE)).toEqual('NodeHttpRequest'); + }); + it('should convert the XHR client', () => { + expect(getHttpRequestName(HttpClient.XHR)).toEqual('XhrHttpRequest'); + }); +}); diff --git a/src/utils/getHttpRequestName.ts b/src/utils/getHttpRequestName.ts new file mode 100644 index 000000000..ab05375cf --- /dev/null +++ b/src/utils/getHttpRequestName.ts @@ -0,0 +1,3 @@ +export function getHttpRequestName(httpClientName: string): string { + return httpClientName[0].toUpperCase() + httpClientName.substring(1) + 'HttpRequest'; +} diff --git a/src/utils/postProcessClient.ts b/src/utils/postProcessClient.ts index 9e0e00dd7..f522044f1 100644 --- a/src/utils/postProcessClient.ts +++ b/src/utils/postProcessClient.ts @@ -5,11 +5,12 @@ import { postProcessService } from './postProcessService'; /** * Post process client * @param client Client object with all the models, services, etc. + * @param exportClient Create client class */ -export function postProcessClient(client: Client): Client { +export function postProcessClient(client: Client, exportClient: boolean): Client { return { ...client, models: client.models.map(model => postProcessModel(model)), - services: client.services.map(service => postProcessService(service)), + services: client.services.map(service => postProcessService(service, exportClient)), }; } diff --git a/src/utils/postProcessService.ts b/src/utils/postProcessService.ts index d604dcdd7..4b247c099 100644 --- a/src/utils/postProcessService.ts +++ b/src/utils/postProcessService.ts @@ -2,9 +2,9 @@ import type { Service } from '../client/interfaces/Service'; import { postProcessServiceImports } from './postProcessServiceImports'; import { postProcessServiceOperations } from './postProcessServiceOperations'; -export function postProcessService(service: Service): Service { +export function postProcessService(service: Service, exportClient: boolean): Service { const clone = { ...service }; - clone.operations = postProcessServiceOperations(clone); + clone.operations = postProcessServiceOperations(clone, exportClient); clone.operations.forEach(operation => { clone.imports.push(...operation.imports); }); diff --git a/src/utils/postProcessServiceOperations.ts b/src/utils/postProcessServiceOperations.ts index 62faad724..759af5573 100644 --- a/src/utils/postProcessServiceOperations.ts +++ b/src/utils/postProcessServiceOperations.ts @@ -2,7 +2,7 @@ import type { Operation } from '../client/interfaces/Operation'; import type { Service } from '../client/interfaces/Service'; import { flatMap } from './flatMap'; -export function postProcessServiceOperations(service: Service): Operation[] { +export function postProcessServiceOperations(service: Service, exportClient: boolean): Operation[] { const names = new Map(); return service.operations.map(operation => { @@ -21,6 +21,9 @@ export function postProcessServiceOperations(service: Service): Operation[] { } names.set(name, index + 1); + // Update the operation path with the dynamically injected version + clone.path = clone.path.replace('${apiVersion}', exportClient ? '${this.httpRequest.openApiConfig.VERSION}' : '${OpenAPI.VERSION}'); + return clone; }); } diff --git a/src/utils/registerHandlebarTemplates.spec.ts b/src/utils/registerHandlebarTemplates.spec.ts index 5e1302384..f5a90aa42 100644 --- a/src/utils/registerHandlebarTemplates.spec.ts +++ b/src/utils/registerHandlebarTemplates.spec.ts @@ -16,6 +16,8 @@ describe('registerHandlebarTemplates', () => { expect(templates.core.apiError).toBeDefined(); expect(templates.core.apiRequestOptions).toBeDefined(); expect(templates.core.apiResult).toBeDefined(); - expect(templates.core.request).toBeDefined(); + expect(templates.core.concreteHttpRequest).toBeDefined(); + expect(templates.core.baseHttpRequest).toBeDefined(); + expect(templates.client).toBeDefined(); }); }); diff --git a/src/utils/registerHandlebarTemplates.ts b/src/utils/registerHandlebarTemplates.ts index 347b2b98b..0b0c45913 100644 --- a/src/utils/registerHandlebarTemplates.ts +++ b/src/utils/registerHandlebarTemplates.ts @@ -4,6 +4,8 @@ import { HttpClient } from '../HttpClient'; import templateCoreApiError from '../templates/core/ApiError.hbs'; import templateCoreApiRequestOptions from '../templates/core/ApiRequestOptions.hbs'; import templateCoreApiResult from '../templates/core/ApiResult.hbs'; +import templateCoreBaseHttpClient from '../templates/core/BaseHttpRequest.hbs'; +import templateCoreConcreteHttpClient from '../templates/core/ConcreteHttpRequest.hbs'; import fetchGetHeaders from '../templates/core/fetch/getHeaders.hbs'; import fetchGetRequestBody from '../templates/core/fetch/getRequestBody.hbs'; import fetchGetResponseBody from '../templates/core/fetch/getResponseBody.hbs'; @@ -28,13 +30,13 @@ import nodeGetResponseHeader from '../templates/core/node/getResponseHeader.hbs' import nodeRequest from '../templates/core/node/request.hbs'; import nodeSendRequest from '../templates/core/node/sendRequest.hbs'; import templateCoreSettings from '../templates/core/OpenAPI.hbs'; -import templateCoreRequest from '../templates/core/request.hbs'; import xhrGetHeaders from '../templates/core/xhr/getHeaders.hbs'; import xhrGetRequestBody from '../templates/core/xhr/getRequestBody.hbs'; import xhrGetResponseBody from '../templates/core/xhr/getResponseBody.hbs'; import xhrGetResponseHeader from '../templates/core/xhr/getResponseHeader.hbs'; import xhrRequest from '../templates/core/xhr/request.hbs'; import xhrSendRequest from '../templates/core/xhr/sendRequest.hbs'; +import templateAppClient from '../templates/exportAppClient.hbs'; import templateExportModel from '../templates/exportModel.hbs'; import templateExportSchema from '../templates/exportSchema.hbs'; import templateExportService from '../templates/exportService.hbs'; @@ -70,6 +72,7 @@ import { registerHandlebarHelpers } from './registerHandlebarHelpers'; export interface Templates { index: Handlebars.TemplateDelegate; + client: Handlebars.TemplateDelegate; exports: { model: Handlebars.TemplateDelegate; schema: Handlebars.TemplateDelegate; @@ -80,7 +83,8 @@ export interface Templates { apiError: Handlebars.TemplateDelegate; apiRequestOptions: Handlebars.TemplateDelegate; apiResult: Handlebars.TemplateDelegate; - request: Handlebars.TemplateDelegate; + baseHttpRequest: Handlebars.TemplateDelegate; + concreteHttpRequest: Handlebars.TemplateDelegate; }; } @@ -94,6 +98,7 @@ export function registerHandlebarTemplates(root: { httpClient: HttpClient; useOp // Main templates (entry points for the files we write to disk) const templates: Templates = { index: Handlebars.template(templateIndex), + client: Handlebars.template(templateAppClient), exports: { model: Handlebars.template(templateExportModel), schema: Handlebars.template(templateExportSchema), @@ -104,7 +109,8 @@ export function registerHandlebarTemplates(root: { httpClient: HttpClient; useOp apiError: Handlebars.template(templateCoreApiError), apiRequestOptions: Handlebars.template(templateCoreApiRequestOptions), apiResult: Handlebars.template(templateCoreApiResult), - request: Handlebars.template(templateCoreRequest), + baseHttpRequest: Handlebars.template(templateCoreBaseHttpClient), + concreteHttpRequest: Handlebars.template(templateCoreConcreteHttpClient), }, }; diff --git a/src/utils/writeAppClient.spec.ts b/src/utils/writeAppClient.spec.ts new file mode 100644 index 000000000..0e2085c54 --- /dev/null +++ b/src/utils/writeAppClient.spec.ts @@ -0,0 +1,39 @@ +import type { Client } from '../client/interfaces/Client'; +import { HttpClient } from '../HttpClient'; +import { writeFile } from './fileSystem'; +import { Templates } from './registerHandlebarTemplates'; +import { writeAppClient } from './writeAppClient'; + +jest.mock('./fileSystem'); + +describe('writeAppClient', () => { + it('should write to filesystem', async () => { + const client: Client = { + server: 'http://localhost:8080', + version: 'v1', + models: [], + services: [], + }; + + const templates: Templates = { + index: () => 'index', + client: () => 'client', + exports: { + model: () => 'model', + schema: () => 'schema', + service: () => 'service', + }, + core: { + settings: () => 'settings', + apiError: () => 'apiError', + apiRequestOptions: () => 'apiRequestOptions', + apiResult: () => 'apiResult', + baseHttpRequest: () => 'baseHttpRequest', + concreteHttpRequest: () => 'concreteHttpRequest', + }, + }; + + await writeAppClient(client, templates, '/', HttpClient.FETCH, 'AppClient'); + expect(writeFile).toBeCalledWith('/client.ts', 'client'); + }); +}); diff --git a/src/utils/writeAppClient.ts b/src/utils/writeAppClient.ts new file mode 100644 index 000000000..fc2a86b6e --- /dev/null +++ b/src/utils/writeAppClient.ts @@ -0,0 +1,32 @@ +import { resolve } from 'path'; + +import { Client } from '../client/interfaces/Client'; +import { HttpClient } from '../HttpClient'; +import { writeFile } from './fileSystem'; +import { getHttpRequestName } from './getHttpRequestName'; +import { Templates } from './registerHandlebarTemplates'; +import { sortServicesByName } from './sortServicesByName'; + +/** + * Generate App Client class using the Handlebar template and write to disk. + * @param client Client object, containing, models, schemas and services + * @param templates The loaded handlebar templates + * @param outputPath Directory to write the generated files to + * @param httpClient The selected httpClient (fetch, xhr or node) + * @param clientName Client class name + */ +export async function writeAppClient(client: Client, templates: Templates, outputPath: string, httpClient: HttpClient, clientName: string): Promise { + await writeFile( + resolve(outputPath, 'client.ts'), + templates.client({ + services: sortServicesByName(client.services).map(s => ({ + name: s.name, + shortName: s.name.replace('Service', '').toLowerCase(), + })), + clientName, + httpClientRequest: getHttpRequestName(httpClient), + server: client.server, + version: client.version, + }) + ); +} diff --git a/src/utils/writeClient.spec.ts b/src/utils/writeClient.spec.ts index 75fdf1771..7f9d77810 100644 --- a/src/utils/writeClient.spec.ts +++ b/src/utils/writeClient.spec.ts @@ -17,6 +17,7 @@ describe('writeClient', () => { const templates: Templates = { index: () => 'index', + client: () => 'client', exports: { model: () => 'model', schema: () => 'schema', @@ -27,11 +28,12 @@ describe('writeClient', () => { apiError: () => 'apiError', apiRequestOptions: () => 'apiRequestOptions', apiResult: () => 'apiResult', - request: () => 'request', + baseHttpRequest: () => 'baseHttpRequest', + concreteHttpRequest: () => 'concreteHttpRequest', }, }; - await writeClient(client, templates, './dist', HttpClient.FETCH, false, false, true, true, true, true); + await writeClient(client, templates, './dist', HttpClient.FETCH, false, false, true, true, true, true, false, 'AppClient'); expect(rmdir).toBeCalled(); expect(mkdir).toBeCalled(); diff --git a/src/utils/writeClient.ts b/src/utils/writeClient.ts index 2cfc4e364..7b556f954 100644 --- a/src/utils/writeClient.ts +++ b/src/utils/writeClient.ts @@ -5,6 +5,7 @@ import { HttpClient } from '../HttpClient'; import { mkdir, rmdir } from './fileSystem'; import { isSubDirectory } from './isSubdirectory'; import { Templates } from './registerHandlebarTemplates'; +import { writeAppClient } from './writeAppClient'; import { writeClientCore } from './writeClientCore'; import { writeClientIndex } from './writeClientIndex'; import { writeClientModels } from './writeClientModels'; @@ -23,6 +24,8 @@ import { writeClientServices } from './writeClientServices'; * @param exportServices: Generate services * @param exportModels: Generate models * @param exportSchemas: Generate schemas + * @param exportClient: Generate client class + * @param clientName: Custom client class name * @param request: Path to custom request file */ export async function writeClient( @@ -36,6 +39,8 @@ export async function writeClient( exportServices: boolean, exportModels: boolean, exportSchemas: boolean, + exportClient: boolean, + clientName: string, request?: string ): Promise { const outputPath = resolve(process.cwd(), output); @@ -51,13 +56,13 @@ export async function writeClient( if (exportCore) { await rmdir(outputPathCore); await mkdir(outputPathCore); - await writeClientCore(client, templates, outputPathCore, httpClient, request); + await writeClientCore(client, templates, outputPathCore, httpClient, exportClient, request); } if (exportServices) { await rmdir(outputPathServices); await mkdir(outputPathServices); - await writeClientServices(client.services, templates, outputPathServices, httpClient, useUnionTypes, useOptions); + await writeClientServices(client.services, templates, outputPathServices, httpClient, useUnionTypes, useOptions, exportClient); } if (exportSchemas) { @@ -72,8 +77,12 @@ export async function writeClient( await writeClientModels(client.models, templates, outputPathModels, httpClient, useUnionTypes); } - if (exportCore || exportServices || exportSchemas || exportModels) { + if (exportClient) { + await writeAppClient(client, templates, outputPath, httpClient, clientName); + } + + if (exportCore || exportServices || exportSchemas || exportModels || exportClient) { await mkdir(outputPath); - await writeClientIndex(client, templates, outputPath, useUnionTypes, exportCore, exportServices, exportModels, exportSchemas); + await writeClientIndex(client, templates, outputPath, clientName, useUnionTypes, exportCore, exportServices, exportModels, exportSchemas, exportClient, httpClient); } } diff --git a/src/utils/writeClientCore.spec.ts b/src/utils/writeClientCore.spec.ts index 8f35776f8..e39d81214 100644 --- a/src/utils/writeClientCore.spec.ts +++ b/src/utils/writeClientCore.spec.ts @@ -7,36 +7,49 @@ import { writeClientCore } from './writeClientCore'; jest.mock('./fileSystem'); describe('writeClientCore', () => { - it('should write to filesystem', async () => { - const client: Client = { - server: 'http://localhost:8080', - version: '1.0', - models: [], - services: [], - }; + const client: Client = { + server: 'http://localhost:8080', + version: '1.0', + models: [], + services: [], + }; - const templates: Templates = { - index: () => 'index', - exports: { - model: () => 'model', - schema: () => 'schema', - service: () => 'service', - }, - core: { - settings: () => 'settings', - apiError: () => 'apiError', - apiRequestOptions: () => 'apiRequestOptions', - apiResult: () => 'apiResult', - request: () => 'request', - }, - }; + const templates: Templates = { + index: () => 'index', + client: () => 'client', + exports: { + model: () => 'model', + schema: () => 'schema', + service: () => 'service', + }, + core: { + settings: () => 'settings', + apiError: () => 'apiError', + apiRequestOptions: () => 'apiRequestOptions', + apiResult: () => 'apiResult', + baseHttpRequest: () => 'baseHttpRequest', + concreteHttpRequest: () => 'concreteHttpRequest', + }, + }; - await writeClientCore(client, templates, '/', HttpClient.FETCH); + it('should write to filesystem when exportClient false', async () => { + await writeClientCore(client, templates, '/', HttpClient.FETCH, false); expect(writeFile).toBeCalledWith('/OpenAPI.ts', 'settings'); expect(writeFile).toBeCalledWith('/ApiError.ts', 'apiError'); expect(writeFile).toBeCalledWith('/ApiRequestOptions.ts', 'apiRequestOptions'); expect(writeFile).toBeCalledWith('/ApiResult.ts', 'apiResult'); - expect(writeFile).toBeCalledWith('/request.ts', 'request'); + expect(writeFile).toBeCalledWith('/request.ts', 'concreteHttpRequest'); + }); + + it('should write to filesystem when exportClient true', async () => { + await writeClientCore(client, templates, '/', HttpClient.FETCH, true); + + expect(writeFile).toBeCalledWith('/OpenAPI.ts', 'settings'); + expect(writeFile).toBeCalledWith('/ApiError.ts', 'apiError'); + expect(writeFile).toBeCalledWith('/ApiRequestOptions.ts', 'apiRequestOptions'); + expect(writeFile).toBeCalledWith('/ApiResult.ts', 'apiResult'); + expect(writeFile).toBeCalledWith('/BaseHttpRequest.ts', 'baseHttpRequest'); + expect(writeFile).toBeCalledWith('/FetchHttpRequest.ts', 'concreteHttpRequest'); }); }); diff --git a/src/utils/writeClientCore.ts b/src/utils/writeClientCore.ts index c7cac72f8..21a4baa4e 100644 --- a/src/utils/writeClientCore.ts +++ b/src/utils/writeClientCore.ts @@ -3,6 +3,7 @@ import { resolve } from 'path'; import type { Client } from '../client/interfaces/Client'; import { HttpClient } from '../HttpClient'; import { copyFile, exists, writeFile } from './fileSystem'; +import { getHttpRequestName } from './getHttpRequestName'; import { Templates } from './registerHandlebarTemplates'; /** @@ -11,20 +12,27 @@ import { Templates } from './registerHandlebarTemplates'; * @param templates The loaded handlebar templates * @param outputPath Directory to write the generated files to * @param httpClient The selected httpClient (fetch, xhr or node) + * @param exportClient Create client class * @param request: Path to custom request file */ -export async function writeClientCore(client: Client, templates: Templates, outputPath: string, httpClient: HttpClient, request?: string): Promise { +export async function writeClientCore(client: Client, templates: Templates, outputPath: string, httpClient: HttpClient, exportClient: boolean, request?: string): Promise { const context = { httpClient, server: client.server, version: client.version, + exportClient, }; await writeFile(resolve(outputPath, 'OpenAPI.ts'), templates.core.settings(context)); await writeFile(resolve(outputPath, 'ApiError.ts'), templates.core.apiError({})); await writeFile(resolve(outputPath, 'ApiRequestOptions.ts'), templates.core.apiRequestOptions({})); await writeFile(resolve(outputPath, 'ApiResult.ts'), templates.core.apiResult({})); - await writeFile(resolve(outputPath, 'request.ts'), templates.core.request(context)); + if (exportClient) { + await writeFile(resolve(outputPath, 'BaseHttpRequest.ts'), templates.core.baseHttpRequest({})); + await writeFile(resolve(outputPath, `${getHttpRequestName(httpClient)}.ts`), templates.core.concreteHttpRequest(context)); + } else { + await writeFile(resolve(outputPath, `request.ts`), templates.core.concreteHttpRequest(context)); + } if (request) { const requestFile = resolve(process.cwd(), request); diff --git a/src/utils/writeClientIndex.spec.ts b/src/utils/writeClientIndex.spec.ts index ded3932fb..be821193b 100644 --- a/src/utils/writeClientIndex.spec.ts +++ b/src/utils/writeClientIndex.spec.ts @@ -1,4 +1,5 @@ import type { Client } from '../client/interfaces/Client'; +import { HttpClient } from '../HttpClient'; import { writeFile } from './fileSystem'; import { Templates } from './registerHandlebarTemplates'; import { writeClientIndex } from './writeClientIndex'; @@ -16,6 +17,7 @@ describe('writeClientIndex', () => { const templates: Templates = { index: () => 'index', + client: () => 'client', exports: { model: () => 'model', schema: () => 'schema', @@ -26,11 +28,12 @@ describe('writeClientIndex', () => { apiError: () => 'apiError', apiRequestOptions: () => 'apiRequestOptions', apiResult: () => 'apiResult', - request: () => 'request', + baseHttpRequest: () => 'baseHttpClient', + concreteHttpRequest: () => 'concreteHttpClient', }, }; - await writeClientIndex(client, templates, '/', true, true, true, true, true); + await writeClientIndex(client, templates, '/', 'AppClient', true, true, true, true, false, false, HttpClient.FETCH); expect(writeFile).toBeCalledWith('/index.ts', 'index'); }); diff --git a/src/utils/writeClientIndex.ts b/src/utils/writeClientIndex.ts index ca2e1645d..356148d3d 100644 --- a/src/utils/writeClientIndex.ts +++ b/src/utils/writeClientIndex.ts @@ -1,7 +1,9 @@ import { resolve } from 'path'; import type { Client } from '../client/interfaces/Client'; +import { HttpClient } from '../HttpClient'; import { writeFile } from './fileSystem'; +import { getHttpRequestName } from './getHttpRequestName'; import { Templates } from './registerHandlebarTemplates'; import { sortModelsByName } from './sortModelsByName'; import { sortServicesByName } from './sortServicesByName'; @@ -13,21 +15,27 @@ import { sortServicesByName } from './sortServicesByName'; * @param client Client object, containing, models, schemas and services * @param templates The loaded handlebar templates * @param outputPath Directory to write the generated files to + * @param clientName Custom client class name * @param useUnionTypes Use union types instead of enums * @param exportCore: Generate core * @param exportServices: Generate services * @param exportModels: Generate models * @param exportSchemas: Generate schemas + * @param exportClient: Generate client class + * @param httpClient The selected httpClient (fetch, xhr or node) */ export async function writeClientIndex( client: Client, templates: Templates, outputPath: string, + clientName: string, useUnionTypes: boolean, exportCore: boolean, exportServices: boolean, exportModels: boolean, - exportSchemas: boolean + exportSchemas: boolean, + exportClient: boolean, + httpClient: HttpClient ): Promise { await writeFile( resolve(outputPath, 'index.ts'), @@ -36,11 +44,14 @@ export async function writeClientIndex( exportServices, exportModels, exportSchemas, + exportClient, useUnionTypes, server: client.server, version: client.version, models: sortModelsByName(client.models), services: sortServicesByName(client.services), + httpRequestName: getHttpRequestName(httpClient), + clientName, }) ); } diff --git a/src/utils/writeClientModels.spec.ts b/src/utils/writeClientModels.spec.ts index 0186812b7..44227dc12 100644 --- a/src/utils/writeClientModels.spec.ts +++ b/src/utils/writeClientModels.spec.ts @@ -30,6 +30,7 @@ describe('writeClientModels', () => { const templates: Templates = { index: () => 'index', + client: () => 'client', exports: { model: () => 'model', schema: () => 'schema', @@ -40,7 +41,8 @@ describe('writeClientModels', () => { apiError: () => 'apiError', apiRequestOptions: () => 'apiRequestOptions', apiResult: () => 'apiResult', - request: () => 'request', + baseHttpRequest: () => 'baseHttpRequest', + concreteHttpRequest: () => 'concreteHttpRequest', }, }; diff --git a/src/utils/writeClientSchemas.spec.ts b/src/utils/writeClientSchemas.spec.ts index fd69fc1b4..1dd4e9196 100644 --- a/src/utils/writeClientSchemas.spec.ts +++ b/src/utils/writeClientSchemas.spec.ts @@ -30,6 +30,7 @@ describe('writeClientSchemas', () => { const templates: Templates = { index: () => 'index', + client: () => 'client', exports: { model: () => 'model', schema: () => 'schema', @@ -40,7 +41,8 @@ describe('writeClientSchemas', () => { apiError: () => 'apiError', apiRequestOptions: () => 'apiRequestOptions', apiResult: () => 'apiResult', - request: () => 'request', + baseHttpRequest: () => 'baseHttpRequest', + concreteHttpRequest: () => 'concreteHttpRequest', }, }; diff --git a/src/utils/writeClientServices.spec.ts b/src/utils/writeClientServices.spec.ts index a1be88096..91c105121 100644 --- a/src/utils/writeClientServices.spec.ts +++ b/src/utils/writeClientServices.spec.ts @@ -18,6 +18,7 @@ describe('writeClientServices', () => { const templates: Templates = { index: () => 'index', + client: () => 'client', exports: { model: () => 'model', schema: () => 'schema', @@ -28,11 +29,12 @@ describe('writeClientServices', () => { apiError: () => 'apiError', apiRequestOptions: () => 'apiRequestOptions', apiResult: () => 'apiResult', - request: () => 'request', + baseHttpRequest: () => 'baseHttpRequest', + concreteHttpRequest: () => 'concreteHttpRequest', }, }; - await writeClientServices(services, templates, '/', HttpClient.FETCH, false, false); + await writeClientServices(services, templates, '/', HttpClient.FETCH, false, false, false); expect(writeFile).toBeCalledWith('/MyService.ts', 'service'); }); diff --git a/src/utils/writeClientServices.ts b/src/utils/writeClientServices.ts index 8f82e0ce4..934d29bd8 100644 --- a/src/utils/writeClientServices.ts +++ b/src/utils/writeClientServices.ts @@ -4,6 +4,7 @@ import type { Service } from '../client/interfaces/Service'; import { HttpClient } from '../HttpClient'; import { writeFile } from './fileSystem'; import { format } from './format'; +import { getHttpRequestName } from './getHttpRequestName'; import { Templates } from './registerHandlebarTemplates'; const VERSION_TEMPLATE_STRING = 'OpenAPI.VERSION'; @@ -16,8 +17,17 @@ const VERSION_TEMPLATE_STRING = 'OpenAPI.VERSION'; * @param httpClient The selected httpClient (fetch, xhr or node) * @param useUnionTypes Use union types instead of enums * @param useOptions Use options or arguments functions + * @param exportClient Create client class */ -export async function writeClientServices(services: Service[], templates: Templates, outputPath: string, httpClient: HttpClient, useUnionTypes: boolean, useOptions: boolean): Promise { +export async function writeClientServices( + services: Service[], + templates: Templates, + outputPath: string, + httpClient: HttpClient, + useUnionTypes: boolean, + useOptions: boolean, + exportClient: boolean +): Promise { for (const service of services) { const file = resolve(outputPath, `${service.name}.ts`); const useVersion = service.operations.some(operation => operation.path.includes(VERSION_TEMPLATE_STRING)); @@ -27,6 +37,8 @@ export async function writeClientServices(services: Service[], templates: Templa useUnionTypes, useVersion, useOptions, + exportClient, + httpClientRequest: getHttpRequestName(httpClient), }); await writeFile(file, format(templateResult)); } diff --git a/test/__snapshots__/index.client.spec.js.snap b/test/__snapshots__/index.client.spec.js.snap new file mode 100644 index 000000000..b92bed6d9 --- /dev/null +++ b/test/__snapshots__/index.client.spec.js.snap @@ -0,0 +1,5416 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/client.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import { BaseHttpRequest } from './core/BaseHttpRequest'; +import type { OpenAPIConfig } from './core/OpenAPI'; +import { FetchHttpRequest } from './core/FetchHttpRequest'; +import { CollectionFormatService } from './services/CollectionFormatService'; +import { ComplexService } from './services/ComplexService'; +import { DefaultsService } from './services/DefaultsService'; +import { DuplicateService } from './services/DuplicateService'; +import { HeaderService } from './services/HeaderService'; +import { NoContentService } from './services/NoContentService'; +import { ParametersService } from './services/ParametersService'; +import { ResponseService } from './services/ResponseService'; +import { SimpleService } from './services/SimpleService'; +import { TypesService } from './services/TypesService'; + +export class TestClient { + readonly collectionformat: CollectionFormatService; + readonly complex: ComplexService; + readonly defaults: DefaultsService; + readonly duplicate: DuplicateService; + readonly header: HeaderService; + readonly nocontent: NoContentService; + readonly parameters: ParametersService; + readonly response: ResponseService; + readonly simple: SimpleService; + readonly types: TypesService; + readonly request: BaseHttpRequest; + + constructor(openApiConfig?: OpenAPIConfig, HttpRequest: new (config: OpenAPIConfig) => BaseHttpRequest = FetchHttpRequest) { + this.request = new HttpRequest({ + BASE: openApiConfig?.BASE ?? 'http://localhost:3000/base', + VERSION: openApiConfig?.VERSION ?? '1.0', + WITH_CREDENTIALS: openApiConfig?.WITH_CREDENTIALS ?? false, + TOKEN: openApiConfig?.TOKEN, + USERNAME: openApiConfig?.USERNAME, + PASSWORD: openApiConfig?.PASSWORD, + HEADERS: openApiConfig?.HEADERS, + }); + this.collectionformat = new CollectionFormatService(this.request); + this.complex = new ComplexService(this.request); + this.defaults = new DefaultsService(this.request); + this.duplicate = new DuplicateService(this.request); + this.header = new HeaderService(this.request); + this.nocontent = new NoContentService(this.request); + this.parameters = new ParametersService(this.request); + this.response = new ResponseService(this.request); + this.simple = new SimpleService(this.request); + this.types = new TypesService(this.request); + } +}" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/core/ApiError.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ApiResult } from './ApiResult'; + +export class ApiError extends Error { + public readonly url: string; + public readonly status: number; + public readonly statusText: string; + public readonly body: any; + + constructor(response: ApiResult, message: string) { + super(message); + + this.url = response.url; + this.status = response.status; + this.statusText = response.statusText; + this.body = response.body; + } +}" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/core/ApiRequestOptions.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type ApiRequestOptions = { + readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH'; + readonly path: string; + readonly cookies?: Record; + readonly headers?: Record; + readonly query?: Record; + readonly formData?: Record; + readonly body?: any; + readonly mediaType?: string; + readonly responseHeader?: string; + readonly errors?: Record; +}" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/core/ApiResult.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type ApiResult = { + readonly url: string; + readonly ok: boolean; + readonly status: number; + readonly statusText: string; + readonly body: any; +}" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/core/BaseHttpRequest.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ApiRequestOptions } from './ApiRequestOptions'; +import type { ApiResult } from './ApiResult'; +import type { OpenAPIConfig } from './OpenAPI'; + +export class BaseHttpRequest { + readonly openApiConfig: OpenAPIConfig; + + constructor(openApiConfig: OpenAPIConfig) { + this.openApiConfig = openApiConfig; + } + + async request(options: ApiRequestOptions): Promise { + throw new Error('Not Implemented'); + } +}" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/core/FetchHttpRequest.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import { ApiError } from './ApiError'; +import type { ApiRequestOptions } from './ApiRequestOptions'; +import type { ApiResult } from './ApiResult'; +import type { OpenAPIConfig } from './OpenAPI'; +import { BaseHttpRequest } from './BaseHttpRequest'; + +function isDefined(value: T | null | undefined): value is Exclude { + return value !== undefined && value !== null; +} + +function isString(value: any): value is string { + return typeof value === 'string'; +} + +function isStringWithValue(value: any): value is string { + return isString(value) && value !== ''; +} + +function isBlob(value: any): value is Blob { + return value instanceof Blob; +} + +function getQueryString(params: Record): string { + const qs: string[] = []; + Object.keys(params).forEach(key => { + const value = params[key]; + if (isDefined(value)) { + 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 ''; +} + +function getUrl(options: ApiRequestOptions, config: OpenAPIConfig): string { + const path = options.path.replace(/[:]/g, '_'); + const url = \`\${config.BASE}\${path}\`; + + if (options.query) { + return \`\${url}\${getQueryString(options.query)}\`; + } + return url; +} + +function getFormData(params: Record): FormData { + const formData = new FormData(); + Object.keys(params).forEach(key => { + const value = params[key]; + if (isDefined(value)) { + formData.append(key, value); + } + }); + return formData; +} + +type Resolver = (options: ApiRequestOptions) => Promise; + +async function resolve(options: ApiRequestOptions, resolver?: T | Resolver): Promise { + if (typeof resolver === 'function') { + return (resolver as Resolver)(options); + } + return resolver; +} + +async function getHeaders(options: ApiRequestOptions, config: OpenAPIConfig): Promise { + const token = await resolve(options, config.TOKEN); + const username = await resolve(options, config.USERNAME); + const password = await resolve(options, config.PASSWORD); + const defaultHeaders = await resolve(options, config.HEADERS); + + const headers = new Headers({ + Accept: 'application/json', + ...defaultHeaders, + ...options.headers, + }); + + if (isStringWithValue(token)) { + headers.append('Authorization', \`Bearer \${token}\`); + } + + if (isStringWithValue(username) && isStringWithValue(password)) { + const credentials = btoa(\`\${username}:\${password}\`); + headers.append('Authorization', \`Basic \${credentials}\`); + } + + if (options.body) { + if (options.mediaType) { + headers.append('Content-Type', options.mediaType); + } else if (isBlob(options.body)) { + headers.append('Content-Type', options.body.type || 'application/octet-stream'); + } else if (isString(options.body)) { + headers.append('Content-Type', 'text/plain'); + } else { + headers.append('Content-Type', 'application/json'); + } + } + return headers; +} + +function getRequestBody(options: ApiRequestOptions): BodyInit | undefined { + if (options.formData) { + return getFormData(options.formData); + } + if (options.body) { + if (options.mediaType?.includes('/json')) { + return JSON.stringify(options.body) + } else if (isString(options.body) || isBlob(options.body)) { + return options.body; + } else { + return JSON.stringify(options.body); + } + } + return undefined; +} + +async function sendRequest(options: ApiRequestOptions, config: OpenAPIConfig, url: string): Promise { + const request: RequestInit = { + method: options.method, + headers: await getHeaders(options, config), + body: getRequestBody(options), + }; + if (config.WITH_CREDENTIALS) { + request.credentials = 'include'; + } + return await fetch(url, request); +} + +function getResponseHeader(response: Response, responseHeader?: string): string | null { + if (responseHeader) { + const content = response.headers.get(responseHeader); + if (isString(content)) { + return content; + } + } + return null; +} + +async function getResponseBody(response: Response): Promise { + try { + const contentType = response.headers.get('Content-Type'); + if (contentType) { + const isJSON = contentType.toLowerCase().startsWith('application/json'); + if (isJSON) { + return await response.json(); + } else { + return await response.text(); + } + } + } catch (error) { + console.error(error); + } + return null; +} + +function catchErrors(options: ApiRequestOptions, result: ApiResult): void { + const errors: Record = { + 400: 'Bad Request', + 401: 'Unauthorized', + 403: 'Forbidden', + 404: 'Not Found', + 500: 'Internal Server Error', + 502: 'Bad Gateway', + 503: 'Service Unavailable', + ...options.errors, + } + + const error = errors[result.status]; + if (error) { + throw new ApiError(result, error); + } + + if (!result.ok) { + throw new ApiError(result, 'Generic Error'); + } +} + +export class FetchHttpRequest extends BaseHttpRequest { + constructor(openApiConfig: OpenAPIConfig) { + super(openApiConfig); + } + + /** + * Request using fetch client + * @param options The request options from the the service + * @returns ApiResult + * @throws ApiError + */ + async request(options: ApiRequestOptions): Promise { + const url = getUrl(options, this.openApiConfig); + const response = await sendRequest(options, this.openApiConfig, url); + const responseBody = await getResponseBody(response); + const responseHeader = getResponseHeader(response, options.responseHeader); + + const result: ApiResult = { + url, + ok: response.ok, + status: response.status, + statusText: response.statusText, + body: responseHeader || responseBody, + }; + + catchErrors(options, result); + return result; + } +} +" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/core/OpenAPI.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ApiRequestOptions } from './ApiRequestOptions'; + +type Resolver = (options: ApiRequestOptions) => Promise; +type Headers = Record; + +export type OpenAPIConfig = { + BASE?: string; + VERSION?: string; + WITH_CREDENTIALS?: boolean; + TOKEN?: string | Resolver; + USERNAME?: string | Resolver; + PASSWORD?: string | Resolver; + HEADERS?: Headers | Resolver; +} +" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/index.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export { ApiError } from './core/ApiError'; +export type { ApiRequestOptions } from './core/ApiRequestOptions'; +export type { ApiResult } from './core/ApiResult'; +export type { OpenAPIConfig } from './core/OpenAPI'; +export { BaseHttpRequest } from './core/BaseHttpRequest'; +export { FetchHttpRequest } from './core/FetchHttpRequest'; + +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 { Date } from './models/Date'; +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 { 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 { ModelWithNestedEnums } from './models/ModelWithNestedEnums'; +export type { ModelWithNestedProperties } from './models/ModelWithNestedProperties'; +export type { ModelWithNullableString } from './models/ModelWithNullableString'; +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 type { SimpleStringWithPattern } from './models/SimpleStringWithPattern'; + +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 { $Date } from './schemas/$Date'; +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 { $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 { $ModelWithNestedEnums } from './schemas/$ModelWithNestedEnums'; +export { $ModelWithNestedProperties } from './schemas/$ModelWithNestedProperties'; +export { $ModelWithNullableString } from './schemas/$ModelWithNullableString'; +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 { $SimpleStringWithPattern } from './schemas/$SimpleStringWithPattern'; + +export { CollectionFormatService } from './services/CollectionFormatService'; +export { ComplexService } from './services/ComplexService'; +export { DefaultsService } from './services/DefaultsService'; +export { DuplicateService } from './services/DuplicateService'; +export { HeaderService } from './services/HeaderService'; +export { NoContentService } from './services/NoContentService'; +export { ParametersService } from './services/ParametersService'; +export { ResponseService } from './services/ResponseService'; +export { SimpleService } from './services/SimpleService'; +export { TypesService } from './services/TypesService'; + +export { TestClient } from './client'; +" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ArrayWithArray.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a simple array containing an array + */ +export type ArrayWithArray = Array>;" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/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 with exportClient: ./test/generated/v2_client/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 with exportClient: ./test/generated/v2_client/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 with exportClient: ./test/generated/v2_client/models/ArrayWithReferences.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a simple array with references + */ +export type ArrayWithReferences = Array;" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/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 with exportClient: ./test/generated/v2_client/models/Date.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a type-only model that defines Date as a string + */ +export type Date = string;" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/DictionaryWithArray.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a complex dictionary + */ +export type DictionaryWithArray = Record>;" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/DictionaryWithDictionary.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a string dictionary + */ +export type DictionaryWithDictionary = Record>;" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/DictionaryWithProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a complex dictionary + */ +export type DictionaryWithProperties = Record;" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/DictionaryWithReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a string reference + */ +export type DictionaryWithReference = Record;" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/DictionaryWithString.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a string dictionary + */ +export type DictionaryWithString = Record;" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/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 with exportClient: ./test/generated/v2_client/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 with exportClient: ./test/generated/v2_client/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, + '_1.1' = 1.1, + '_1.2' = 1.2, + '_1.3' = 1.3, + '_100' = 100, + '_200' = 200, + '_300' = 300, + '_-100' = -100, + '_-200' = -200, + '_-300' = -300, + '_-1.1' = -1.1, + '_-1.2' = -1.2, + '_-1.3' = -1.3, +}" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/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 with exportClient: ./test/generated/v2_client/models/ModelThatExtends.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model that extends another model + */ +export type ModelThatExtends = (ModelWithString & { + propExtendsA?: string, + propExtendsB?: ModelWithString, +}); +" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelThatExtendsExtends.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelThatExtends } from './ModelThatExtends'; +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model that extends another model + */ +export type ModelThatExtendsExtends = (ModelWithString & ModelThatExtends & { + propExtendsC?: string, + propExtendsD?: ModelWithString, +}); +" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithArray.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArray = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +} +" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithBoolean.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one boolean property + */ +export type ModelWithBoolean = { + /** + * This is a simple boolean property + */ + prop?: boolean; +} +" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithCircularReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one property containing a circular reference + */ +export type ModelWithCircularReference = { + prop?: ModelWithCircularReference; +} +" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithDictionary.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one property containing a dictionary + */ +export type ModelWithDictionary = { + prop?: Record; +} +" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithDuplicateImports.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model with duplicated imports + */ +export type ModelWithDuplicateImports = { + propA?: ModelWithString; + propB?: ModelWithString; + propC?: ModelWithString; +} +" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithDuplicateProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model with duplicated properties + */ +export type ModelWithDuplicateProperties = { + prop?: ModelWithString; +} +" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithEnum.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one enum + */ +export type ModelWithEnum = { + /** + * This is a simple enum with strings + */ + test?: ModelWithEnum.test; + /** + * These are the HTTP error code enums + */ + statusCode?: ModelWithEnum.statusCode; + /** + * Simple boolean enum + */ + bool?: boolean; +} + +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 with exportClient: ./test/generated/v2_client/models/ModelWithEnumFromDescription.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one enum + */ +export type 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 with exportClient: ./test/generated/v2_client/models/ModelWithInteger.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one number property + */ +export type ModelWithInteger = { + /** + * This is a simple number property + */ + prop?: number; +} +" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithNestedEnums.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with nested enums + */ +export type ModelWithNestedEnums = { + dictionaryWithEnum?: Record; + dictionaryWithEnumFromDescription?: Record; + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; + arrayWithDescription?: Array<1 | 2 | 3>; +} +" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithNestedProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one nested property + */ +export type ModelWithNestedProperties = { + readonly first: { + readonly second: { + readonly third: string, + }, + }; +} +" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithNullableString.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one string property + */ +export type ModelWithNullableString = { + /** + * This is a simple string property + */ + nullableProp?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp: string | null; +} +" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithOrderedProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with ordered properties + */ +export type ModelWithOrderedProperties = { + zebra?: string; + apple?: string; + hawaii?: string; +} +" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithPattern.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPattern = { + key: string; + name: string; + readonly enabled?: boolean; + readonly modified?: string; + id?: string; + text?: string; +} +" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model with one nested property + */ +export type ModelWithProperties = { + required: string; + readonly requiredAndReadOnly: string; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + 'property with space'?: string; + default?: string; + try?: string; + readonly '@namespace.string'?: string; + readonly '@namespace.integer'?: number; +} +" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithProperties } from './ModelWithProperties'; + +/** + * This is a model with one property containing a reference + */ +export type ModelWithReference = { + prop?: ModelWithProperties; +} +" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithString.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one string property + */ +export type ModelWithString = { + /** + * This is a simple string property + */ + prop?: string; +} +" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/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 with exportClient: ./test/generated/v2_client/models/SimpleBoolean.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a simple boolean + */ +export type SimpleBoolean = boolean;" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/SimpleFile.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a simple file + */ +export type SimpleFile = Blob;" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/SimpleInteger.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a simple number + */ +export type SimpleInteger = number;" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/SimpleReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a simple reference + */ +export type SimpleReference = ModelWithString;" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/SimpleString.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a simple string + */ +export type SimpleString = string;" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/SimpleStringWithPattern.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a simple string + */ +export type SimpleStringWithPattern = string;" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ArrayWithArray.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ArrayWithArray = { + type: 'array', + contains: { + type: 'array', + contains: { + type: 'ModelWithString', + }, + }, +};" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ArrayWithBooleans.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ArrayWithBooleans = { + type: 'array', + contains: { + type: 'boolean', + }, +};" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ArrayWithNumbers.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ArrayWithNumbers = { + type: 'array', + contains: { + type: 'number', + }, +};" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ArrayWithProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ArrayWithProperties = { + type: 'array', + contains: { + properties: { + foo: { + type: 'string', + }, + bar: { + type: 'string', + }, + }, + }, +};" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ArrayWithReferences.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ArrayWithReferences = { + type: 'array', + contains: { + type: 'ModelWithString', + }, +};" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ArrayWithStrings.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ArrayWithStrings = { + type: 'array', + contains: { + type: 'string', + }, +};" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$Date.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $Date = { + type: 'string', +};" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$DictionaryWithArray.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $DictionaryWithArray = { + type: 'dictionary', + contains: { + type: 'array', + contains: { + type: 'ModelWithString', + }, + }, +};" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$DictionaryWithDictionary.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $DictionaryWithDictionary = { + type: 'dictionary', + contains: { + type: 'dictionary', + contains: { + type: 'string', + }, + }, +};" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$DictionaryWithProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $DictionaryWithProperties = { + type: 'dictionary', + contains: { + properties: { + foo: { + type: 'string', + }, + bar: { + type: 'string', + }, + }, + }, +};" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$DictionaryWithReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $DictionaryWithReference = { + type: 'dictionary', + contains: { + type: 'ModelWithString', + }, +};" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$DictionaryWithString.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $DictionaryWithString = { + type: 'dictionary', + contains: { + type: 'string', + }, +};" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$EnumFromDescription.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $EnumFromDescription = { + type: 'Enum', +};" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$EnumWithExtensions.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $EnumWithExtensions = { + type: 'Enum', +};" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$EnumWithNumbers.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $EnumWithNumbers = { + type: 'Enum', +};" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$EnumWithStrings.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $EnumWithStrings = { + type: 'Enum', +};" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelThatExtends.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelThatExtends = { + type: 'all-of', + contains: [{ + type: 'ModelWithString', + }, { + properties: { + propExtendsA: { + type: 'string', + }, + propExtendsB: { + type: 'ModelWithString', + }, + }, + }], +};" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelThatExtendsExtends.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelThatExtendsExtends = { + type: 'all-of', + contains: [{ + type: 'ModelWithString', + }, { + type: 'ModelThatExtends', + }, { + properties: { + propExtendsC: { + type: 'string', + }, + propExtendsD: { + type: 'ModelWithString', + }, + }, + }], +};" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithArray.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithArray = { + properties: { + prop: { + type: 'array', + contains: { + type: 'ModelWithString', + }, + }, + propWithFile: { + type: 'array', + contains: { + type: 'File', + }, + }, + propWithNumber: { + type: 'array', + contains: { + type: 'number', + }, + }, + }, +};" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithBoolean.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithBoolean = { + properties: { + prop: { + type: 'boolean', + }, + }, +};" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithCircularReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithCircularReference = { + properties: { + prop: { + type: 'ModelWithCircularReference', + }, + }, +};" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithDictionary.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithDictionary = { + properties: { + prop: { + type: 'dictionary', + contains: { + type: 'string', + }, + }, + }, +};" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/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 with exportClient: ./test/generated/v2_client/schemas/$ModelWithDuplicateProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithDuplicateProperties = { + properties: { + prop: { + type: 'ModelWithString', + }, + }, +};" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithEnum.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithEnum = { + properties: { + test: { + type: 'Enum', + }, + statusCode: { + type: 'Enum', + }, + bool: { + type: 'boolean', + }, + }, +};" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithEnumFromDescription.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithEnumFromDescription = { + properties: { + test: { + type: 'Enum', + }, + }, +};" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithInteger.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithInteger = { + properties: { + prop: { + type: 'number', + }, + }, +};" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithNestedEnums.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithNestedEnums = { + properties: { + dictionaryWithEnum: { + type: 'dictionary', + contains: { + type: 'Enum', + }, + }, + dictionaryWithEnumFromDescription: { + type: 'dictionary', + contains: { + type: 'Enum', + }, + }, + arrayWithEnum: { + type: 'array', + contains: { + type: 'Enum', + }, + }, + arrayWithDescription: { + type: 'array', + contains: { + type: 'Enum', + }, + }, + }, +};" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/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 with exportClient: ./test/generated/v2_client/schemas/$ModelWithNullableString.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithNullableString = { + properties: { + nullableProp: { + type: 'string', + isNullable: true, + }, + nullableRequiredProp: { + type: 'string', + isRequired: true, + isNullable: true, + }, + }, +};" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/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 with exportClient: ./test/generated/v2_client/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', + }, + id: { + type: 'string', + pattern: '^\\\\\\\\d{2}-\\\\\\\\d{3}-\\\\\\\\d{4}$', + }, + text: { + type: 'string', + pattern: '^\\\\\\\\w+$', + }, + }, +};" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/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', + }, + 'property with space': { + type: 'string', + }, + default: { + type: 'string', + }, + try: { + type: 'string', + }, + '@namespace.string': { + type: 'string', + isReadOnly: true, + }, + '@namespace.integer': { + type: 'number', + isReadOnly: true, + }, + }, +};" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithReference = { + properties: { + prop: { + type: 'ModelWithProperties', + }, + }, +};" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithString.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithString = { + properties: { + prop: { + type: 'string', + }, + }, +};" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$MultilineComment.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $MultilineComment = { + type: 'number', +};" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$SimpleBoolean.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $SimpleBoolean = { + type: 'boolean', +};" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$SimpleFile.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $SimpleFile = { + type: 'File', +};" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$SimpleInteger.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $SimpleInteger = { + type: 'number', +};" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$SimpleReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $SimpleReference = { + type: 'ModelWithString', +};" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$SimpleString.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $SimpleString = { + type: 'string', +};" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$SimpleStringWithPattern.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $SimpleStringWithPattern = { + type: 'string', + maxLength: 64, + pattern: '^[a-zA-Z0-9_]*$', +};" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/CollectionFormatService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export class CollectionFormatService { + private httpRequest: BaseHttpRequest; + + constructor(httpRequest: BaseHttpRequest) { + this.httpRequest = httpRequest; + } + + /** + * @param parameterArrayCsv This is an array parameter that is send as csv format (comma-separated values) + * @param parameterArraySsv This is an array parameter that is send as ssv format (space-separated values) + * @param parameterArrayTsv This is an array parameter that is send as tsv format (tab-separated values) + * @param parameterArrayPipes This is an array parameter that is send as pipes format (pipe-separated values) + * @param parameterArrayMulti This is an array parameter that is send as multi format (multiple parameter instances) + * @throws ApiError + */ + public async collectionFormat( + parameterArrayCsv: Array, + parameterArraySsv: Array, + parameterArrayTsv: Array, + parameterArrayPipes: Array, + parameterArrayMulti: Array, + ): Promise { + const result = await this.httpRequest.request({ + method: 'GET', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/collectionFormat\`, + query: { + 'parameterArrayCSV': parameterArrayCsv, + 'parameterArraySSV': parameterArraySsv, + 'parameterArrayTSV': parameterArrayTsv, + 'parameterArrayPipes': parameterArrayPipes, + 'parameterArrayMulti': parameterArrayMulti, + }, + }); + return result.body; + } + +}" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/ComplexService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ModelWithString } from '../models/ModelWithString'; +import { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export class ComplexService { + private httpRequest: BaseHttpRequest; + + constructor(httpRequest: BaseHttpRequest) { + this.httpRequest = httpRequest; + } + + /** + * @param parameterObject Parameter containing object + * @param parameterReference Parameter containing reference + * @returns ModelWithString Successful response + * @throws ApiError + */ + public async complexTypes( + parameterObject: { + first?: { + second?: { + third?: string, + }, + }, + }, + parameterReference: ModelWithString, + ): Promise> { + const result = await this.httpRequest.request({ + method: 'GET', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/complex\`, + query: { + 'parameterObject': parameterObject, + 'parameterReference': parameterReference, + }, + errors: { + 400: \`400 server error\`, + 500: \`500 server error\`, + }, + }); + return result.body; + } + +}" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/DefaultsService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ModelWithString } from '../models/ModelWithString'; +import { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export class DefaultsService { + private httpRequest: BaseHttpRequest; + + constructor(httpRequest: BaseHttpRequest) { + this.httpRequest = httpRequest; + } + + /** + * @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 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 this.httpRequest.request({ + method: 'GET', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/defaults\`, + query: { + 'parameterString': parameterString, + 'parameterNumber': parameterNumber, + 'parameterBoolean': parameterBoolean, + 'parameterEnum': parameterEnum, + 'parameterModel': parameterModel, + }, + }); + 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 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 this.httpRequest.request({ + method: 'POST', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/defaults\`, + query: { + 'parameterString': parameterString, + 'parameterNumber': parameterNumber, + 'parameterBoolean': parameterBoolean, + 'parameterEnum': parameterEnum, + 'parameterModel': parameterModel, + }, + }); + 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 async callToTestOrderOfParams( + parameterStringWithNoDefault: string, + parameterOptionalStringWithDefault: string = 'Hello World!', + parameterOptionalStringWithEmptyDefault: string = '', + parameterOptionalStringWithNoDefault?: string, + parameterStringWithDefault: string = 'Hello World!', + parameterStringWithEmptyDefault: string = '', + ): Promise { + const result = await this.httpRequest.request({ + method: 'PUT', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/defaults\`, + query: { + 'parameterStringWithNoDefault': parameterStringWithNoDefault, + 'parameterOptionalStringWithDefault': parameterOptionalStringWithDefault, + 'parameterOptionalStringWithEmptyDefault': parameterOptionalStringWithEmptyDefault, + 'parameterOptionalStringWithNoDefault': parameterOptionalStringWithNoDefault, + 'parameterStringWithDefault': parameterStringWithDefault, + 'parameterStringWithEmptyDefault': parameterStringWithEmptyDefault, + }, + }); + return result.body; + } + +}" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/DuplicateService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export class DuplicateService { + private httpRequest: BaseHttpRequest; + + constructor(httpRequest: BaseHttpRequest) { + this.httpRequest = httpRequest; + } + + /** + * @throws ApiError + */ + public async duplicateName(): Promise { + const result = await this.httpRequest.request({ + method: 'GET', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/duplicate\`, + }); + return result.body; + } + + /** + * @throws ApiError + */ + public async duplicateName1(): Promise { + const result = await this.httpRequest.request({ + method: 'POST', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/duplicate\`, + }); + return result.body; + } + + /** + * @throws ApiError + */ + public async duplicateName2(): Promise { + const result = await this.httpRequest.request({ + method: 'PUT', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/duplicate\`, + }); + return result.body; + } + + /** + * @throws ApiError + */ + public async duplicateName3(): Promise { + const result = await this.httpRequest.request({ + method: 'DELETE', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/duplicate\`, + }); + return result.body; + } + +}" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/HeaderService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export class HeaderService { + private httpRequest: BaseHttpRequest; + + constructor(httpRequest: BaseHttpRequest) { + this.httpRequest = httpRequest; + } + + /** + * @returns string Successful response + * @throws ApiError + */ + public async callWithResultFromHeader(): Promise { + const result = await this.httpRequest.request({ + method: 'POST', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/header\`, + responseHeader: 'operation-location', + errors: { + 400: \`400 server error\`, + 500: \`500 server error\`, + }, + }); + return result.body; + } + +}" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/NoContentService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export class NoContentService { + private httpRequest: BaseHttpRequest; + + constructor(httpRequest: BaseHttpRequest) { + this.httpRequest = httpRequest; + } + + /** + * @returns void + * @throws ApiError + */ + public async callWithNoContentResponse(): Promise { + const result = await this.httpRequest.request({ + method: 'GET', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/no-content\`, + }); + return result.body; + } + +}" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/ParametersService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export class ParametersService { + private httpRequest: BaseHttpRequest; + + constructor(httpRequest: BaseHttpRequest) { + this.httpRequest = httpRequest; + } + + /** + * @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 async callWithParameters( + parameterHeader: string, + parameterQuery: string, + parameterForm: string, + parameterBody: string, + parameterPath: string, + ): Promise { + const result = await this.httpRequest.request({ + method: 'GET', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/parameters/\${parameterPath}\`, + headers: { + 'parameterHeader': parameterHeader, + }, + query: { + 'parameterQuery': parameterQuery, + }, + formData: { + 'parameterForm': parameterForm, + }, + body: parameterBody, + }); + 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 + * @param _default This is the parameter with a reserved keyword + * @throws ApiError + */ + public async callWithWeirdParameterNames( + parameterHeader: string, + parameterQuery: string, + parameterForm: string, + parameterBody: string, + parameterPath1?: string, + parameterPath2?: string, + parameterPath3?: string, + _default?: string, + ): Promise { + const result = await this.httpRequest.request({ + method: 'GET', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/parameters/\${parameterPath1}/\${parameterPath2}/\${parameterPath3}\`, + headers: { + 'parameter.header': parameterHeader, + }, + query: { + 'parameter-query': parameterQuery, + 'default': _default, + }, + formData: { + 'parameter_form': parameterForm, + }, + body: parameterBody, + }); + return result.body; + } + +}" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/ResponseService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ModelThatExtends } from '../models/ModelThatExtends'; +import type { ModelThatExtendsExtends } from '../models/ModelThatExtendsExtends'; +import type { ModelWithString } from '../models/ModelWithString'; +import { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export class ResponseService { + private httpRequest: BaseHttpRequest; + + constructor(httpRequest: BaseHttpRequest) { + this.httpRequest = httpRequest; + } + + /** + * @returns ModelWithString Message for default response + * @throws ApiError + */ + public async callWithResponse(): Promise { + const result = await this.httpRequest.request({ + method: 'GET', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/response\`, + }); + return result.body; + } + + /** + * @returns ModelWithString Message for default response + * @throws ApiError + */ + public async callWithDuplicateResponses(): Promise { + const result = await this.httpRequest.request({ + method: 'POST', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/response\`, + errors: { + 500: \`Message for 500 error\`, + 501: \`Message for 501 error\`, + 502: \`Message for 502 error\`, + }, + }); + return result.body; + } + + /** + * @returns any Message for 200 response + * @returns ModelWithString Message for default response + * @returns ModelThatExtends Message for 201 response + * @returns ModelThatExtendsExtends Message for 202 response + * @throws ApiError + */ + public async callWithResponses(): Promise<{ + readonly '@namespace.string'?: string, + readonly '@namespace.integer'?: number, + readonly value?: Array, + } | ModelWithString | ModelThatExtends | ModelThatExtendsExtends> { + const result = await this.httpRequest.request({ + method: 'PUT', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/response\`, + errors: { + 500: \`Message for 500 error\`, + 501: \`Message for 501 error\`, + 502: \`Message for 502 error\`, + }, + }); + return result.body; + } + +}" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/SimpleService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export class SimpleService { + private httpRequest: BaseHttpRequest; + + constructor(httpRequest: BaseHttpRequest) { + this.httpRequest = httpRequest; + } + + /** + * @throws ApiError + */ + public async getCallWithoutParametersAndResponse(): Promise { + const result = await this.httpRequest.request({ + method: 'GET', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/simple\`, + }); + return result.body; + } + + /** + * @throws ApiError + */ + public async putCallWithoutParametersAndResponse(): Promise { + const result = await this.httpRequest.request({ + method: 'PUT', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/simple\`, + }); + return result.body; + } + + /** + * @throws ApiError + */ + public async postCallWithoutParametersAndResponse(): Promise { + const result = await this.httpRequest.request({ + method: 'POST', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/simple\`, + }); + return result.body; + } + + /** + * @throws ApiError + */ + public async deleteCallWithoutParametersAndResponse(): Promise { + const result = await this.httpRequest.request({ + method: 'DELETE', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/simple\`, + }); + return result.body; + } + + /** + * @throws ApiError + */ + public async optionsCallWithoutParametersAndResponse(): Promise { + const result = await this.httpRequest.request({ + method: 'OPTIONS', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/simple\`, + }); + return result.body; + } + + /** + * @throws ApiError + */ + public async headCallWithoutParametersAndResponse(): Promise { + const result = await this.httpRequest.request({ + method: 'HEAD', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/simple\`, + }); + return result.body; + } + + /** + * @throws ApiError + */ + public async patchCallWithoutParametersAndResponse(): Promise { + const result = await this.httpRequest.request({ + method: 'PATCH', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/simple\`, + }); + return result.body; + } + +}" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/TypesService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export class TypesService { + private httpRequest: BaseHttpRequest; + + constructor(httpRequest: BaseHttpRequest) { + this.httpRequest = httpRequest; + } + + /** + * @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 + * @returns number Response is a simple number + * @returns string Response is a simple string + * @returns boolean Response is a simple boolean + * @returns any Response is a simple object + * @throws ApiError + */ + public async types( + parameterArray: Array, + parameterDictionary: Record, + parameterEnum: 'Success' | 'Warning' | 'Error', + parameterNumber: number = 123, + parameterString: string = 'default', + parameterBoolean: boolean = true, + parameterObject: any = null, + id?: number, + ): Promise { + const result = await this.httpRequest.request({ + method: 'GET', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/types\`, + query: { + 'parameterArray': parameterArray, + 'parameterDictionary': parameterDictionary, + 'parameterEnum': parameterEnum, + 'parameterNumber': parameterNumber, + 'parameterString': parameterString, + 'parameterBoolean': parameterBoolean, + 'parameterObject': parameterObject, + }, + }); + return result.body; + } + +}" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/client.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import { BaseHttpRequest } from './core/BaseHttpRequest'; +import type { OpenAPIConfig } from './core/OpenAPI'; +import { FetchHttpRequest } from './core/FetchHttpRequest'; +import { CollectionFormatService } from './services/CollectionFormatService'; +import { ComplexService } from './services/ComplexService'; +import { DefaultsService } from './services/DefaultsService'; +import { DuplicateService } from './services/DuplicateService'; +import { HeaderService } from './services/HeaderService'; +import { MultipartService } from './services/MultipartService'; +import { NoContentService } from './services/NoContentService'; +import { ParametersService } from './services/ParametersService'; +import { RequestBodyService } from './services/RequestBodyService'; +import { ResponseService } from './services/ResponseService'; +import { SimpleService } from './services/SimpleService'; +import { TypesService } from './services/TypesService'; +import { UploadService } from './services/UploadService'; + +export class TestClient { + readonly collectionformat: CollectionFormatService; + readonly complex: ComplexService; + readonly defaults: DefaultsService; + readonly duplicate: DuplicateService; + readonly header: HeaderService; + readonly multipart: MultipartService; + readonly nocontent: NoContentService; + readonly parameters: ParametersService; + readonly requestbody: RequestBodyService; + readonly response: ResponseService; + readonly simple: SimpleService; + readonly types: TypesService; + readonly upload: UploadService; + readonly request: BaseHttpRequest; + + constructor(openApiConfig?: OpenAPIConfig, HttpRequest: new (config: OpenAPIConfig) => BaseHttpRequest = FetchHttpRequest) { + this.request = new HttpRequest({ + BASE: openApiConfig?.BASE ?? 'http://localhost:3000/base', + VERSION: openApiConfig?.VERSION ?? '1.0', + WITH_CREDENTIALS: openApiConfig?.WITH_CREDENTIALS ?? false, + TOKEN: openApiConfig?.TOKEN, + USERNAME: openApiConfig?.USERNAME, + PASSWORD: openApiConfig?.PASSWORD, + HEADERS: openApiConfig?.HEADERS, + }); + this.collectionformat = new CollectionFormatService(this.request); + this.complex = new ComplexService(this.request); + this.defaults = new DefaultsService(this.request); + this.duplicate = new DuplicateService(this.request); + this.header = new HeaderService(this.request); + this.multipart = new MultipartService(this.request); + this.nocontent = new NoContentService(this.request); + this.parameters = new ParametersService(this.request); + this.requestbody = new RequestBodyService(this.request); + this.response = new ResponseService(this.request); + this.simple = new SimpleService(this.request); + this.types = new TypesService(this.request); + this.upload = new UploadService(this.request); + } +}" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/core/ApiError.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ApiResult } from './ApiResult'; + +export class ApiError extends Error { + public readonly url: string; + public readonly status: number; + public readonly statusText: string; + public readonly body: any; + + constructor(response: ApiResult, message: string) { + super(message); + + this.url = response.url; + this.status = response.status; + this.statusText = response.statusText; + this.body = response.body; + } +}" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/core/ApiRequestOptions.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type ApiRequestOptions = { + readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH'; + readonly path: string; + readonly cookies?: Record; + readonly headers?: Record; + readonly query?: Record; + readonly formData?: Record; + readonly body?: any; + readonly mediaType?: string; + readonly responseHeader?: string; + readonly errors?: Record; +}" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/core/ApiResult.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type ApiResult = { + readonly url: string; + readonly ok: boolean; + readonly status: number; + readonly statusText: string; + readonly body: any; +}" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/core/BaseHttpRequest.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ApiRequestOptions } from './ApiRequestOptions'; +import type { ApiResult } from './ApiResult'; +import type { OpenAPIConfig } from './OpenAPI'; + +export class BaseHttpRequest { + readonly openApiConfig: OpenAPIConfig; + + constructor(openApiConfig: OpenAPIConfig) { + this.openApiConfig = openApiConfig; + } + + async request(options: ApiRequestOptions): Promise { + throw new Error('Not Implemented'); + } +}" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/core/FetchHttpRequest.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import { ApiError } from './ApiError'; +import type { ApiRequestOptions } from './ApiRequestOptions'; +import type { ApiResult } from './ApiResult'; +import type { OpenAPIConfig } from './OpenAPI'; +import { BaseHttpRequest } from './BaseHttpRequest'; + +function isDefined(value: T | null | undefined): value is Exclude { + return value !== undefined && value !== null; +} + +function isString(value: any): value is string { + return typeof value === 'string'; +} + +function isStringWithValue(value: any): value is string { + return isString(value) && value !== ''; +} + +function isBlob(value: any): value is Blob { + return value instanceof Blob; +} + +function getQueryString(params: Record): string { + const qs: string[] = []; + Object.keys(params).forEach(key => { + const value = params[key]; + if (isDefined(value)) { + 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 ''; +} + +function getUrl(options: ApiRequestOptions, config: OpenAPIConfig): string { + const path = options.path.replace(/[:]/g, '_'); + const url = \`\${config.BASE}\${path}\`; + + if (options.query) { + return \`\${url}\${getQueryString(options.query)}\`; + } + return url; +} + +function getFormData(params: Record): FormData { + const formData = new FormData(); + Object.keys(params).forEach(key => { + const value = params[key]; + if (isDefined(value)) { + formData.append(key, value); + } + }); + return formData; +} + +type Resolver = (options: ApiRequestOptions) => Promise; + +async function resolve(options: ApiRequestOptions, resolver?: T | Resolver): Promise { + if (typeof resolver === 'function') { + return (resolver as Resolver)(options); + } + return resolver; +} + +async function getHeaders(options: ApiRequestOptions, config: OpenAPIConfig): Promise { + const token = await resolve(options, config.TOKEN); + const username = await resolve(options, config.USERNAME); + const password = await resolve(options, config.PASSWORD); + const defaultHeaders = await resolve(options, config.HEADERS); + + const headers = new Headers({ + Accept: 'application/json', + ...defaultHeaders, + ...options.headers, + }); + + if (isStringWithValue(token)) { + headers.append('Authorization', \`Bearer \${token}\`); + } + + if (isStringWithValue(username) && isStringWithValue(password)) { + const credentials = btoa(\`\${username}:\${password}\`); + headers.append('Authorization', \`Basic \${credentials}\`); + } + + if (options.body) { + if (options.mediaType) { + headers.append('Content-Type', options.mediaType); + } else if (isBlob(options.body)) { + headers.append('Content-Type', options.body.type || 'application/octet-stream'); + } else if (isString(options.body)) { + headers.append('Content-Type', 'text/plain'); + } else { + headers.append('Content-Type', 'application/json'); + } + } + return headers; +} + +function getRequestBody(options: ApiRequestOptions): BodyInit | undefined { + if (options.formData) { + return getFormData(options.formData); + } + if (options.body) { + if (options.mediaType?.includes('/json')) { + return JSON.stringify(options.body) + } else if (isString(options.body) || isBlob(options.body)) { + return options.body; + } else { + return JSON.stringify(options.body); + } + } + return undefined; +} + +async function sendRequest(options: ApiRequestOptions, config: OpenAPIConfig, url: string): Promise { + const request: RequestInit = { + method: options.method, + headers: await getHeaders(options, config), + body: getRequestBody(options), + }; + if (config.WITH_CREDENTIALS) { + request.credentials = 'include'; + } + return await fetch(url, request); +} + +function getResponseHeader(response: Response, responseHeader?: string): string | null { + if (responseHeader) { + const content = response.headers.get(responseHeader); + if (isString(content)) { + return content; + } + } + return null; +} + +async function getResponseBody(response: Response): Promise { + try { + const contentType = response.headers.get('Content-Type'); + if (contentType) { + const isJSON = contentType.toLowerCase().startsWith('application/json'); + if (isJSON) { + return await response.json(); + } else { + return await response.text(); + } + } + } catch (error) { + console.error(error); + } + return null; +} + +function catchErrors(options: ApiRequestOptions, result: ApiResult): void { + const errors: Record = { + 400: 'Bad Request', + 401: 'Unauthorized', + 403: 'Forbidden', + 404: 'Not Found', + 500: 'Internal Server Error', + 502: 'Bad Gateway', + 503: 'Service Unavailable', + ...options.errors, + } + + const error = errors[result.status]; + if (error) { + throw new ApiError(result, error); + } + + if (!result.ok) { + throw new ApiError(result, 'Generic Error'); + } +} + +export class FetchHttpRequest extends BaseHttpRequest { + constructor(openApiConfig: OpenAPIConfig) { + super(openApiConfig); + } + + /** + * Request using fetch client + * @param options The request options from the the service + * @returns ApiResult + * @throws ApiError + */ + async request(options: ApiRequestOptions): Promise { + const url = getUrl(options, this.openApiConfig); + const response = await sendRequest(options, this.openApiConfig, url); + const responseBody = await getResponseBody(response); + const responseHeader = getResponseHeader(response, options.responseHeader); + + const result: ApiResult = { + url, + ok: response.ok, + status: response.status, + statusText: response.statusText, + body: responseHeader || responseBody, + }; + + catchErrors(options, result); + return result; + } +} +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/core/OpenAPI.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ApiRequestOptions } from './ApiRequestOptions'; + +type Resolver = (options: ApiRequestOptions) => Promise; +type Headers = Record; + +export type OpenAPIConfig = { + BASE?: string; + VERSION?: string; + WITH_CREDENTIALS?: boolean; + TOKEN?: string | Resolver; + USERNAME?: string | Resolver; + PASSWORD?: string | Resolver; + HEADERS?: Headers | Resolver; +} +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/index.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export { ApiError } from './core/ApiError'; +export type { ApiRequestOptions } from './core/ApiRequestOptions'; +export type { ApiResult } from './core/ApiResult'; +export type { OpenAPIConfig } from './core/OpenAPI'; +export { BaseHttpRequest } from './core/BaseHttpRequest'; +export { FetchHttpRequest } from './core/FetchHttpRequest'; + +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 { CompositionWithAllOfAndNullable } from './models/CompositionWithAllOfAndNullable'; +export type { CompositionWithAnyOf } from './models/CompositionWithAnyOf'; +export type { CompositionWithAnyOfAndNullable } from './models/CompositionWithAnyOfAndNullable'; +export type { CompositionWithAnyOfAnonymous } from './models/CompositionWithAnyOfAnonymous'; +export type { CompositionWithOneOf } from './models/CompositionWithOneOf'; +export type { CompositionWithOneOfAndNullable } from './models/CompositionWithOneOfAndNullable'; +export type { CompositionWithOneOfAnonymous } from './models/CompositionWithOneOfAnonymous'; +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 { 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 { 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 type { SimpleStringWithPattern } from './models/SimpleStringWithPattern'; + +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 { $CompositionWithAllOfAndNullable } from './schemas/$CompositionWithAllOfAndNullable'; +export { $CompositionWithAnyOf } from './schemas/$CompositionWithAnyOf'; +export { $CompositionWithAnyOfAndNullable } from './schemas/$CompositionWithAnyOfAndNullable'; +export { $CompositionWithAnyOfAnonymous } from './schemas/$CompositionWithAnyOfAnonymous'; +export { $CompositionWithOneOf } from './schemas/$CompositionWithOneOf'; +export { $CompositionWithOneOfAndNullable } from './schemas/$CompositionWithOneOfAndNullable'; +export { $CompositionWithOneOfAnonymous } from './schemas/$CompositionWithOneOfAnonymous'; +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 { $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 { $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 { $SimpleStringWithPattern } from './schemas/$SimpleStringWithPattern'; + +export { CollectionFormatService } from './services/CollectionFormatService'; +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 { NoContentService } from './services/NoContentService'; +export { ParametersService } from './services/ParametersService'; +export { RequestBodyService } from './services/RequestBodyService'; +export { ResponseService } from './services/ResponseService'; +export { SimpleService } from './services/SimpleService'; +export { TypesService } from './services/TypesService'; +export { UploadService } from './services/UploadService'; + +export { TestClient } from './client'; +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ArrayWithArray.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a simple array containing an array + */ +export type ArrayWithArray = Array>;" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/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 with exportClient: ./test/generated/v3_client/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 with exportClient: ./test/generated/v3_client/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 with exportClient: ./test/generated/v3_client/models/ArrayWithReferences.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a simple array with references + */ +export type ArrayWithReferences = Array;" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/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 with exportClient: ./test/generated/v3_client/models/CompositionWithAllOfAndNullable.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithArray } from './ModelWithArray'; +import type { ModelWithDictionary } from './ModelWithDictionary'; +import type { ModelWithEnum } from './ModelWithEnum'; + +/** + * This is a model with one property with a 'all of' relationship + */ +export type CompositionWithAllOfAndNullable = { + propA?: ({ + boolean?: boolean, + } & ModelWithEnum & ModelWithArray & ModelWithDictionary) | null; +} +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/CompositionWithAnyOf.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithArray } from './ModelWithArray'; +import type { ModelWithDictionary } from './ModelWithDictionary'; +import type { ModelWithEnum } from './ModelWithEnum'; +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOf = { + propA?: (ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary); +} +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/CompositionWithAnyOfAndNullable.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithArray } from './ModelWithArray'; +import type { ModelWithDictionary } from './ModelWithDictionary'; +import type { ModelWithEnum } from './ModelWithEnum'; + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOfAndNullable = { + propA?: ({ + boolean?: boolean, + } | ModelWithEnum | ModelWithArray | ModelWithDictionary) | null; +} +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/CompositionWithAnyOfAnonymous.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithAnyOfAnonymous = { + propA?: ({ + propA?: any, + } | string | number); +} +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/CompositionWithOneOf.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithArray } from './ModelWithArray'; +import type { ModelWithDictionary } from './ModelWithDictionary'; +import type { ModelWithEnum } from './ModelWithEnum'; +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOf = { + propA?: (ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary); +} +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/CompositionWithOneOfAndNullable.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithArray } from './ModelWithArray'; +import type { ModelWithDictionary } from './ModelWithDictionary'; +import type { ModelWithEnum } from './ModelWithEnum'; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOfAndNullable = { + propA?: ({ + boolean?: boolean, + } | ModelWithEnum | ModelWithArray | ModelWithDictionary) | null; +} +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/CompositionWithOneOfAnonymous.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfAnonymous = { + propA?: ({ + propA?: any, + } | string | number); +} +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/DictionaryWithArray.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a complex dictionary + */ +export type DictionaryWithArray = Record>;" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/DictionaryWithDictionary.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a string dictionary + */ +export type DictionaryWithDictionary = Record>;" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/DictionaryWithProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a complex dictionary + */ +export type DictionaryWithProperties = Record;" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/DictionaryWithReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a string reference + */ +export type DictionaryWithReference = Record;" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/DictionaryWithString.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a string dictionary + */ +export type DictionaryWithString = Record;" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/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 with exportClient: ./test/generated/v3_client/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 with exportClient: ./test/generated/v3_client/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, + '_1.1' = 1.1, + '_1.2' = 1.2, + '_1.3' = 1.3, + '_100' = 100, + '_200' = 200, + '_300' = 300, + '_-100' = -100, + '_-200' = -200, + '_-300' = -300, + '_-1.1' = -1.1, + '_-1.2' = -1.2, + '_-1.3' = -1.3, +}" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/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 with exportClient: ./test/generated/v3_client/models/ModelThatExtends.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model that extends another model + */ +export type ModelThatExtends = (ModelWithString & { + propExtendsA?: string, + propExtendsB?: ModelWithString, +}); +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelThatExtendsExtends.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelThatExtends } from './ModelThatExtends'; +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model that extends another model + */ +export type ModelThatExtendsExtends = (ModelWithString & ModelThatExtends & { + propExtendsC?: string, + propExtendsD?: ModelWithString, +}); +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithArray.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArray = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +} +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithBoolean.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one boolean property + */ +export type ModelWithBoolean = { + /** + * This is a simple boolean property + */ + prop?: boolean; +} +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithCircularReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one property containing a circular reference + */ +export type ModelWithCircularReference = { + prop?: ModelWithCircularReference; +} +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithDictionary.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one property containing a dictionary + */ +export type ModelWithDictionary = { + prop?: Record; +} +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithDuplicateImports.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model with duplicated imports + */ +export type ModelWithDuplicateImports = { + propA?: ModelWithString; + propB?: ModelWithString; + propC?: ModelWithString; +} +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithDuplicateProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model with duplicated properties + */ +export type ModelWithDuplicateProperties = { + prop?: ModelWithString; +} +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithEnum.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one enum + */ +export type ModelWithEnum = { + /** + * This is a simple enum with strings + */ + test?: ModelWithEnum.test; + /** + * These are the HTTP error code enums + */ + statusCode?: ModelWithEnum.statusCode; + /** + * Simple boolean enum + */ + bool?: boolean; +} + +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 with exportClient: ./test/generated/v3_client/models/ModelWithEnumFromDescription.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one enum + */ +export type 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 with exportClient: ./test/generated/v3_client/models/ModelWithInteger.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one number property + */ +export type ModelWithInteger = { + /** + * This is a simple number property + */ + prop?: number; +} +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithNestedEnums.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with nested enums + */ +export type ModelWithNestedEnums = { + dictionaryWithEnum?: Record; + dictionaryWithEnumFromDescription?: Record; + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; + arrayWithDescription?: Array<1 | 2 | 3>; +} +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithNestedProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one nested property + */ +export type ModelWithNestedProperties = { + readonly first: { + readonly second: { + readonly third: string | null, + } | null, + } | null; +} +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithOrderedProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with ordered properties + */ +export type ModelWithOrderedProperties = { + zebra?: string; + apple?: string; + hawaii?: string; +} +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithPattern.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPattern = { + key: string; + name: string; + readonly enabled?: boolean; + readonly modified?: string; + id?: string; + text?: string; +} +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model with one nested property + */ +export type ModelWithProperties = { + required: string; + readonly requiredAndReadOnly: string; + requiredAndNullable: string | null; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + 'property with space'?: string; + default?: string; + try?: string; + readonly '@namespace.string'?: string; + readonly '@namespace.integer'?: number; +} +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithProperties } from './ModelWithProperties'; + +/** + * This is a model with one property containing a reference + */ +export type ModelWithReference = { + prop?: ModelWithProperties; +} +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithString.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one string property + */ +export type ModelWithString = { + /** + * This is a simple string property + */ + prop?: string; +} +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/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 with exportClient: ./test/generated/v3_client/models/SimpleBoolean.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a simple boolean + */ +export type SimpleBoolean = boolean;" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/SimpleFile.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a simple file + */ +export type SimpleFile = Blob;" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/SimpleInteger.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a simple number + */ +export type SimpleInteger = number;" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/SimpleReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a simple reference + */ +export type SimpleReference = ModelWithString;" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/SimpleString.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a simple string + */ +export type SimpleString = string;" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/SimpleStringWithPattern.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a simple string + */ +export type SimpleStringWithPattern = string | null;" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ArrayWithArray.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ArrayWithArray = { + type: 'array', + contains: { + type: 'array', + contains: { + type: 'ModelWithString', + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ArrayWithBooleans.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ArrayWithBooleans = { + type: 'array', + contains: { + type: 'boolean', + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ArrayWithNumbers.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ArrayWithNumbers = { + type: 'array', + contains: { + type: 'number', + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ArrayWithProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ArrayWithProperties = { + type: 'array', + contains: { + properties: { + foo: { + type: 'string', + }, + bar: { + type: 'string', + }, + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ArrayWithReferences.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ArrayWithReferences = { + type: 'array', + contains: { + type: 'ModelWithString', + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ArrayWithStrings.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ArrayWithStrings = { + type: 'array', + contains: { + type: 'string', + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$CompositionWithAllOfAndNullable.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $CompositionWithAllOfAndNullable = { + properties: { + propA: { + type: 'all-of', + contains: [{ + properties: { + boolean: { + type: 'boolean', + }, + }, + }, { + type: 'ModelWithEnum', + }, { + type: 'ModelWithArray', + }, { + type: 'ModelWithDictionary', + }], + isNullable: true, + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$CompositionWithAnyOf.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $CompositionWithAnyOf = { + properties: { + propA: { + type: 'any-of', + contains: [{ + type: 'ModelWithString', + }, { + type: 'ModelWithEnum', + }, { + type: 'ModelWithArray', + }, { + type: 'ModelWithDictionary', + }], + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$CompositionWithAnyOfAndNullable.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $CompositionWithAnyOfAndNullable = { + properties: { + propA: { + type: 'any-of', + contains: [{ + properties: { + boolean: { + type: 'boolean', + }, + }, + }, { + type: 'ModelWithEnum', + }, { + type: 'ModelWithArray', + }, { + type: 'ModelWithDictionary', + }], + isNullable: true, + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$CompositionWithAnyOfAnonymous.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $CompositionWithAnyOfAnonymous = { + properties: { + propA: { + type: 'any-of', + contains: [{ + properties: { + propA: { + properties: { + }, + }, + }, + }, { + type: 'string', + }, { + type: 'number', + }], + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$CompositionWithOneOf.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $CompositionWithOneOf = { + properties: { + propA: { + type: 'one-of', + contains: [{ + type: 'ModelWithString', + }, { + type: 'ModelWithEnum', + }, { + type: 'ModelWithArray', + }, { + type: 'ModelWithDictionary', + }], + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$CompositionWithOneOfAndNullable.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $CompositionWithOneOfAndNullable = { + properties: { + propA: { + type: 'one-of', + contains: [{ + properties: { + boolean: { + type: 'boolean', + }, + }, + }, { + type: 'ModelWithEnum', + }, { + type: 'ModelWithArray', + }, { + type: 'ModelWithDictionary', + }], + isNullable: true, + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$CompositionWithOneOfAnonymous.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $CompositionWithOneOfAnonymous = { + properties: { + propA: { + type: 'one-of', + contains: [{ + properties: { + propA: { + properties: { + }, + }, + }, + }, { + type: 'string', + }, { + type: 'number', + }], + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$DictionaryWithArray.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $DictionaryWithArray = { + type: 'dictionary', + contains: { + type: 'array', + contains: { + type: 'ModelWithString', + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$DictionaryWithDictionary.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $DictionaryWithDictionary = { + type: 'dictionary', + contains: { + type: 'dictionary', + contains: { + type: 'string', + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$DictionaryWithProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $DictionaryWithProperties = { + type: 'dictionary', + contains: { + properties: { + foo: { + type: 'string', + }, + bar: { + type: 'string', + }, + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$DictionaryWithReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $DictionaryWithReference = { + type: 'dictionary', + contains: { + type: 'ModelWithString', + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$DictionaryWithString.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $DictionaryWithString = { + type: 'dictionary', + contains: { + type: 'string', + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$EnumFromDescription.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $EnumFromDescription = { + type: 'Enum', +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$EnumWithExtensions.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $EnumWithExtensions = { + type: 'Enum', +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$EnumWithNumbers.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $EnumWithNumbers = { + type: 'Enum', +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$EnumWithStrings.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $EnumWithStrings = { + type: 'Enum', +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelThatExtends.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelThatExtends = { + type: 'all-of', + contains: [{ + type: 'ModelWithString', + }, { + properties: { + propExtendsA: { + type: 'string', + }, + propExtendsB: { + type: 'ModelWithString', + }, + }, + }], +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelThatExtendsExtends.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelThatExtendsExtends = { + type: 'all-of', + contains: [{ + type: 'ModelWithString', + }, { + type: 'ModelThatExtends', + }, { + properties: { + propExtendsC: { + type: 'string', + }, + propExtendsD: { + type: 'ModelWithString', + }, + }, + }], +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithArray.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithArray = { + properties: { + prop: { + type: 'array', + contains: { + type: 'ModelWithString', + }, + }, + propWithFile: { + type: 'array', + contains: { + type: 'File', + }, + }, + propWithNumber: { + type: 'array', + contains: { + type: 'number', + }, + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithBoolean.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithBoolean = { + properties: { + prop: { + type: 'boolean', + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithCircularReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithCircularReference = { + properties: { + prop: { + type: 'ModelWithCircularReference', + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithDictionary.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithDictionary = { + properties: { + prop: { + type: 'dictionary', + contains: { + type: 'string', + }, + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/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 with exportClient: ./test/generated/v3_client/schemas/$ModelWithDuplicateProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithDuplicateProperties = { + properties: { + prop: { + type: 'ModelWithString', + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithEnum.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithEnum = { + properties: { + test: { + type: 'Enum', + }, + statusCode: { + type: 'Enum', + }, + bool: { + type: 'boolean', + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithEnumFromDescription.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithEnumFromDescription = { + properties: { + test: { + type: 'Enum', + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithInteger.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithInteger = { + properties: { + prop: { + type: 'number', + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithNestedEnums.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithNestedEnums = { + properties: { + dictionaryWithEnum: { + type: 'dictionary', + contains: { + type: 'Enum', + }, + }, + dictionaryWithEnumFromDescription: { + type: 'dictionary', + contains: { + type: 'Enum', + }, + }, + arrayWithEnum: { + type: 'array', + contains: { + type: 'Enum', + }, + }, + arrayWithDescription: { + type: 'array', + contains: { + type: 'Enum', + }, + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/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 with exportClient: ./test/generated/v3_client/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 with exportClient: ./test/generated/v3_client/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', + }, + id: { + type: 'string', + pattern: '^\\\\\\\\d{2}-\\\\\\\\d{3}-\\\\\\\\d{4}$', + }, + text: { + type: 'string', + pattern: '^\\\\\\\\w+$', + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/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', + }, + 'property with space': { + type: 'string', + }, + default: { + type: 'string', + }, + try: { + type: 'string', + }, + '@namespace.string': { + type: 'string', + isReadOnly: true, + }, + '@namespace.integer': { + type: 'number', + isReadOnly: true, + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithReference = { + properties: { + prop: { + type: 'ModelWithProperties', + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithString.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithString = { + properties: { + prop: { + type: 'string', + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$MultilineComment.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $MultilineComment = { + type: 'number', +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$SimpleBoolean.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $SimpleBoolean = { + type: 'boolean', +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$SimpleFile.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $SimpleFile = { + type: 'File', +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$SimpleInteger.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $SimpleInteger = { + type: 'number', +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$SimpleReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $SimpleReference = { + type: 'ModelWithString', +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$SimpleString.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $SimpleString = { + type: 'string', +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$SimpleStringWithPattern.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $SimpleStringWithPattern = { + type: 'string', + isNullable: true, + maxLength: 64, + pattern: '^[a-zA-Z0-9_]*$', +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/CollectionFormatService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export class CollectionFormatService { + private httpRequest: BaseHttpRequest; + + constructor(httpRequest: BaseHttpRequest) { + this.httpRequest = httpRequest; + } + + /** + * @param parameterArrayCsv This is an array parameter that is send as csv format (comma-separated values) + * @param parameterArraySsv This is an array parameter that is send as ssv format (space-separated values) + * @param parameterArrayTsv This is an array parameter that is send as tsv format (tab-separated values) + * @param parameterArrayPipes This is an array parameter that is send as pipes format (pipe-separated values) + * @param parameterArrayMulti This is an array parameter that is send as multi format (multiple parameter instances) + * @throws ApiError + */ + public async collectionFormat( + parameterArrayCsv: Array | null, + parameterArraySsv: Array | null, + parameterArrayTsv: Array | null, + parameterArrayPipes: Array | null, + parameterArrayMulti: Array | null, + ): Promise { + const result = await this.httpRequest.request({ + method: 'GET', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/collectionFormat\`, + query: { + 'parameterArrayCSV': parameterArrayCsv, + 'parameterArraySSV': parameterArraySsv, + 'parameterArrayTSV': parameterArrayTsv, + 'parameterArrayPipes': parameterArrayPipes, + 'parameterArrayMulti': parameterArrayMulti, + }, + }); + return result.body; + } + +}" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/ComplexService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ModelWithArray } from '../models/ModelWithArray'; +import type { ModelWithDictionary } from '../models/ModelWithDictionary'; +import type { ModelWithEnum } from '../models/ModelWithEnum'; +import type { ModelWithString } from '../models/ModelWithString'; +import { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export class ComplexService { + private httpRequest: BaseHttpRequest; + + constructor(httpRequest: BaseHttpRequest) { + this.httpRequest = httpRequest; + } + + /** + * @param parameterObject Parameter containing object + * @param parameterReference Parameter containing reference + * @returns ModelWithString Successful response + * @throws ApiError + */ + public async complexTypes( + parameterObject: { + first?: { + second?: { + third?: string, + }, + }, + }, + parameterReference: ModelWithString, + ): Promise> { + const result = await this.httpRequest.request({ + method: 'GET', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/complex\`, + query: { + 'parameterObject': parameterObject, + 'parameterReference': parameterReference, + }, + errors: { + 400: \`400 server error\`, + 500: \`500 server error\`, + }, + }); + return result.body; + } + + /** + * @param id + * @param requestBody + * @returns ModelWithString Success + * @throws ApiError + */ + public 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: (ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary), + readonly user?: { + readonly id?: number, + readonly name?: string | null, + }, + }, + ): Promise { + const result = await this.httpRequest.request({ + method: 'PUT', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/complex/\${id}\`, + body: requestBody, + mediaType: 'application/json-patch+json', + }); + return result.body; + } + +}" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/DefaultsService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ModelWithString } from '../models/ModelWithString'; +import { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export class DefaultsService { + private httpRequest: BaseHttpRequest; + + constructor(httpRequest: BaseHttpRequest) { + this.httpRequest = httpRequest; + } + + /** + * @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 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 this.httpRequest.request({ + method: 'GET', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/defaults\`, + query: { + 'parameterString': parameterString, + 'parameterNumber': parameterNumber, + 'parameterBoolean': parameterBoolean, + 'parameterEnum': parameterEnum, + 'parameterModel': parameterModel, + }, + }); + 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 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 this.httpRequest.request({ + method: 'POST', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/defaults\`, + query: { + 'parameterString': parameterString, + 'parameterNumber': parameterNumber, + 'parameterBoolean': parameterBoolean, + 'parameterEnum': parameterEnum, + 'parameterModel': parameterModel, + }, + }); + 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 async callToTestOrderOfParams( + parameterStringWithNoDefault: string, + parameterOptionalStringWithDefault: string = 'Hello World!', + parameterOptionalStringWithEmptyDefault: string = '', + parameterOptionalStringWithNoDefault?: string, + parameterStringWithDefault: string = 'Hello World!', + parameterStringWithEmptyDefault: string = '', + ): Promise { + const result = await this.httpRequest.request({ + method: 'PUT', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/defaults\`, + query: { + 'parameterStringWithNoDefault': parameterStringWithNoDefault, + 'parameterOptionalStringWithDefault': parameterOptionalStringWithDefault, + 'parameterOptionalStringWithEmptyDefault': parameterOptionalStringWithEmptyDefault, + 'parameterOptionalStringWithNoDefault': parameterOptionalStringWithNoDefault, + 'parameterStringWithDefault': parameterStringWithDefault, + 'parameterStringWithEmptyDefault': parameterStringWithEmptyDefault, + }, + }); + return result.body; + } + +}" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/DuplicateService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export class DuplicateService { + private httpRequest: BaseHttpRequest; + + constructor(httpRequest: BaseHttpRequest) { + this.httpRequest = httpRequest; + } + + /** + * @throws ApiError + */ + public async duplicateName(): Promise { + const result = await this.httpRequest.request({ + method: 'GET', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/duplicate\`, + }); + return result.body; + } + + /** + * @throws ApiError + */ + public async duplicateName1(): Promise { + const result = await this.httpRequest.request({ + method: 'POST', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/duplicate\`, + }); + return result.body; + } + + /** + * @throws ApiError + */ + public async duplicateName2(): Promise { + const result = await this.httpRequest.request({ + method: 'PUT', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/duplicate\`, + }); + return result.body; + } + + /** + * @throws ApiError + */ + public async duplicateName3(): Promise { + const result = await this.httpRequest.request({ + method: 'DELETE', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/duplicate\`, + }); + return result.body; + } + +}" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/HeaderService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export class HeaderService { + private httpRequest: BaseHttpRequest; + + constructor(httpRequest: BaseHttpRequest) { + this.httpRequest = httpRequest; + } + + /** + * @returns string Successful response + * @throws ApiError + */ + public async callWithResultFromHeader(): Promise { + const result = await this.httpRequest.request({ + method: 'POST', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/header\`, + responseHeader: 'operation-location', + errors: { + 400: \`400 server error\`, + 500: \`500 server error\`, + }, + }); + return result.body; + } + +}" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/MultipartService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export class MultipartService { + private httpRequest: BaseHttpRequest; + + constructor(httpRequest: BaseHttpRequest) { + this.httpRequest = httpRequest; + } + + /** + * @returns any OK + * @throws ApiError + */ + public async multipartResponse(): Promise<{ + file?: string, + metadata?: { + foo?: string, + bar?: string, + }, + }> { + const result = await this.httpRequest.request({ + method: 'GET', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/multipart\`, + }); + return result.body; + } + +}" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/NoContentService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export class NoContentService { + private httpRequest: BaseHttpRequest; + + constructor(httpRequest: BaseHttpRequest) { + this.httpRequest = httpRequest; + } + + /** + * @returns void + * @throws ApiError + */ + public async callWithNoContentResponse(): Promise { + const result = await this.httpRequest.request({ + method: 'GET', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/no-content\`, + }); + return result.body; + } + +}" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/ParametersService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ModelWithString } from '../models/ModelWithString'; +import { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export class ParametersService { + private httpRequest: BaseHttpRequest; + + constructor(httpRequest: BaseHttpRequest) { + this.httpRequest = httpRequest; + } + + /** + * @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 async callWithParameters( + parameterHeader: string | null, + parameterQuery: string | null, + parameterForm: string | null, + parameterCookie: string | null, + parameterPath: string | null, + requestBody: ModelWithString | null, + ): Promise { + const result = await this.httpRequest.request({ + method: 'GET', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/parameters/\${parameterPath}\`, + cookies: { + 'parameterCookie': parameterCookie, + }, + headers: { + 'parameterHeader': parameterHeader, + }, + query: { + 'parameterQuery': parameterQuery, + }, + formData: { + 'parameterForm': parameterForm, + }, + body: requestBody, + mediaType: 'application/json', + }); + 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 + * @param _default This is the parameter with a reserved keyword + * @throws ApiError + */ + public async callWithWeirdParameterNames( + parameterHeader: string | null, + parameterQuery: string | null, + parameterForm: string | null, + parameterCookie: string | null, + requestBody: ModelWithString | null, + parameterPath1?: string, + parameterPath2?: string, + parameterPath3?: string, + _default?: string, + ): Promise { + const result = await this.httpRequest.request({ + method: 'GET', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/parameters/\${parameterPath1}/\${parameterPath2}/\${parameterPath3}\`, + cookies: { + 'PARAMETER-COOKIE': parameterCookie, + }, + headers: { + 'parameter.header': parameterHeader, + }, + query: { + 'parameter-query': parameterQuery, + 'default': _default, + }, + formData: { + 'parameter_form': parameterForm, + }, + body: requestBody, + mediaType: 'application/json', + }); + return result.body; + } + + /** + * @param requestBody This is a required parameter + * @param parameter This is an optional parameter + * @throws ApiError + */ + public async getCallWithOptionalParam( + requestBody: ModelWithString, + parameter?: string, + ): Promise { + const result = await this.httpRequest.request({ + method: 'GET', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/parameters/\`, + query: { + 'parameter': parameter, + }, + body: requestBody, + mediaType: 'application/json', + }); + return result.body; + } + + /** + * @param parameter This is a required parameter + * @param requestBody This is an optional parameter + * @throws ApiError + */ + public async postCallWithOptionalParam( + parameter: string, + requestBody?: ModelWithString, + ): Promise { + const result = await this.httpRequest.request({ + method: 'POST', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/parameters/\`, + query: { + 'parameter': parameter, + }, + body: requestBody, + mediaType: 'application/json', + }); + return result.body; + } + +}" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/RequestBodyService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ModelWithString } from '../models/ModelWithString'; +import { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export class RequestBodyService { + private httpRequest: BaseHttpRequest; + + constructor(httpRequest: BaseHttpRequest) { + this.httpRequest = httpRequest; + } + + /** + * @param requestBody A reusable request body + * @throws ApiError + */ + public async postRequestBodyService( + requestBody?: ModelWithString, + ): Promise { + const result = await this.httpRequest.request({ + method: 'POST', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/requestBody/\`, + body: requestBody, + mediaType: 'application/json', + }); + return result.body; + } + +}" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/ResponseService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ModelThatExtends } from '../models/ModelThatExtends'; +import type { ModelThatExtendsExtends } from '../models/ModelThatExtendsExtends'; +import type { ModelWithString } from '../models/ModelWithString'; +import { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export class ResponseService { + private httpRequest: BaseHttpRequest; + + constructor(httpRequest: BaseHttpRequest) { + this.httpRequest = httpRequest; + } + + /** + * @returns ModelWithString + * @throws ApiError + */ + public async callWithResponse(): Promise { + const result = await this.httpRequest.request({ + method: 'GET', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/response\`, + }); + return result.body; + } + + /** + * @returns ModelWithString Message for default response + * @throws ApiError + */ + public async callWithDuplicateResponses(): Promise { + const result = await this.httpRequest.request({ + method: 'POST', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/response\`, + errors: { + 500: \`Message for 500 error\`, + 501: \`Message for 501 error\`, + 502: \`Message for 502 error\`, + }, + }); + return result.body; + } + + /** + * @returns any Message for 200 response + * @returns ModelWithString Message for default response + * @returns ModelThatExtends Message for 201 response + * @returns ModelThatExtendsExtends Message for 202 response + * @throws ApiError + */ + public async callWithResponses(): Promise<{ + readonly '@namespace.string'?: string, + readonly '@namespace.integer'?: number, + readonly value?: Array, + } | ModelWithString | ModelThatExtends | ModelThatExtendsExtends> { + const result = await this.httpRequest.request({ + method: 'PUT', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/response\`, + errors: { + 500: \`Message for 500 error\`, + 501: \`Message for 501 error\`, + 502: \`Message for 502 error\`, + }, + }); + return result.body; + } + +}" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/SimpleService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export class SimpleService { + private httpRequest: BaseHttpRequest; + + constructor(httpRequest: BaseHttpRequest) { + this.httpRequest = httpRequest; + } + + /** + * @throws ApiError + */ + public async getCallWithoutParametersAndResponse(): Promise { + const result = await this.httpRequest.request({ + method: 'GET', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/simple\`, + }); + return result.body; + } + + /** + * @throws ApiError + */ + public async putCallWithoutParametersAndResponse(): Promise { + const result = await this.httpRequest.request({ + method: 'PUT', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/simple\`, + }); + return result.body; + } + + /** + * @throws ApiError + */ + public async postCallWithoutParametersAndResponse(): Promise { + const result = await this.httpRequest.request({ + method: 'POST', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/simple\`, + }); + return result.body; + } + + /** + * @throws ApiError + */ + public async deleteCallWithoutParametersAndResponse(): Promise { + const result = await this.httpRequest.request({ + method: 'DELETE', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/simple\`, + }); + return result.body; + } + + /** + * @throws ApiError + */ + public async optionsCallWithoutParametersAndResponse(): Promise { + const result = await this.httpRequest.request({ + method: 'OPTIONS', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/simple\`, + }); + return result.body; + } + + /** + * @throws ApiError + */ + public async headCallWithoutParametersAndResponse(): Promise { + const result = await this.httpRequest.request({ + method: 'HEAD', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/simple\`, + }); + return result.body; + } + + /** + * @throws ApiError + */ + public async patchCallWithoutParametersAndResponse(): Promise { + const result = await this.httpRequest.request({ + method: 'PATCH', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/simple\`, + }); + return result.body; + } + +}" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/TypesService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export class TypesService { + private httpRequest: BaseHttpRequest; + + constructor(httpRequest: BaseHttpRequest) { + this.httpRequest = httpRequest; + } + + /** + * @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 + * @returns number Response is a simple number + * @returns string Response is a simple string + * @returns boolean Response is a simple boolean + * @returns any Response is a simple object + * @throws ApiError + */ + public 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 this.httpRequest.request({ + method: 'GET', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/types\`, + query: { + 'parameterArray': parameterArray, + 'parameterDictionary': parameterDictionary, + 'parameterEnum': parameterEnum, + 'parameterNumber': parameterNumber, + 'parameterString': parameterString, + 'parameterBoolean': parameterBoolean, + 'parameterObject': parameterObject, + }, + }); + return result.body; + } + +}" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/UploadService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export class UploadService { + private httpRequest: BaseHttpRequest; + + constructor(httpRequest: BaseHttpRequest) { + this.httpRequest = httpRequest; + } + + /** + * @param file Supply a file reference for upload + * @returns boolean + * @throws ApiError + */ + public async uploadFile( + file: Blob, + ): Promise { + const result = await this.httpRequest.request({ + method: 'POST', + path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/upload\`, + formData: { + 'file': file, + }, + }); + return result.body; + } + +}" +`; diff --git a/test/__snapshots__/index.spec.js.snap b/test/__snapshots__/index.spec.js.snap index 0047c137c..44da68af4 100644 --- a/test/__snapshots__/index.spec.js.snap +++ b/test/__snapshots__/index.spec.js.snap @@ -63,17 +63,16 @@ import type { ApiRequestOptions } from './ApiRequestOptions'; type Resolver = (options: ApiRequestOptions) => Promise; type Headers = Record; -type Config = { - BASE: string; - VERSION: string; - WITH_CREDENTIALS: boolean; +export type OpenAPIConfig = { + BASE?: string; + VERSION?: string; + WITH_CREDENTIALS?: boolean; TOKEN?: string | Resolver; USERNAME?: string | Resolver; PASSWORD?: string | Resolver; HEADERS?: Headers | Resolver; } - -export const OpenAPI: Config = { +export const OpenAPI: OpenAPIConfig = { BASE: 'http://localhost:3000/base', VERSION: '1.0', WITH_CREDENTIALS: false, @@ -81,7 +80,8 @@ export const OpenAPI: Config = { USERNAME: undefined, PASSWORD: undefined, HEADERS: undefined, -};" +}; +" `; exports[`v2 should generate: ./test/generated/v2/core/request.ts 1`] = ` @@ -91,6 +91,7 @@ exports[`v2 should generate: ./test/generated/v2/core/request.ts 1`] = ` import { ApiError } from './ApiError'; import type { ApiRequestOptions } from './ApiRequestOptions'; import type { ApiResult } from './ApiResult'; +import type { OpenAPIConfig } from './OpenAPI'; import { OpenAPI } from './OpenAPI'; function isDefined(value: T | null | undefined): value is Exclude { @@ -129,9 +130,9 @@ function getQueryString(params: Record): string { return ''; } -function getUrl(options: ApiRequestOptions): string { +function getUrl(options: ApiRequestOptions, config: OpenAPIConfig): string { const path = options.path.replace(/[:]/g, '_'); - const url = \`\${OpenAPI.BASE}\${path}\`; + const url = \`\${config.BASE}\${path}\`; if (options.query) { return \`\${url}\${getQueryString(options.query)}\`; @@ -159,11 +160,11 @@ async function resolve(options: ApiRequestOptions, resolver?: T | Resolver return resolver; } -async function getHeaders(options: ApiRequestOptions): Promise { - const token = await resolve(options, OpenAPI.TOKEN); - const username = await resolve(options, OpenAPI.USERNAME); - const password = await resolve(options, OpenAPI.PASSWORD); - const defaultHeaders = await resolve(options, OpenAPI.HEADERS); +async function getHeaders(options: ApiRequestOptions, config: OpenAPIConfig): Promise { + const token = await resolve(options, config.TOKEN); + const username = await resolve(options, config.USERNAME); + const password = await resolve(options, config.PASSWORD); + const defaultHeaders = await resolve(options, config.HEADERS); const headers = new Headers({ Accept: 'application/json', @@ -210,13 +211,13 @@ function getRequestBody(options: ApiRequestOptions): BodyInit | undefined { return undefined; } -async function sendRequest(options: ApiRequestOptions, url: string): Promise { +async function sendRequest(options: ApiRequestOptions, config: OpenAPIConfig, url: string): Promise { const request: RequestInit = { method: options.method, - headers: await getHeaders(options), + headers: await getHeaders(options, config), body: getRequestBody(options), }; - if (OpenAPI.WITH_CREDENTIALS) { + if (config.WITH_CREDENTIALS) { request.credentials = 'include'; } return await fetch(url, request); @@ -278,8 +279,8 @@ function catchErrors(options: ApiRequestOptions, result: ApiResult): void { * @throws ApiError */ export async function request(options: ApiRequestOptions): Promise { - const url = getUrl(options); - const response = await sendRequest(options, url); + const url = getUrl(options, OpenAPI); + const response = await sendRequest(options, OpenAPI, url); const responseBody = await getResponseBody(response); const responseHeader = getResponseHeader(response, options.responseHeader); @@ -293,7 +294,8 @@ export async function request(options: ApiRequestOptions): Promise { catchErrors(options, result); return result; -}" +} +" `; exports[`v2 should generate: ./test/generated/v2/index.ts 1`] = ` @@ -399,6 +401,7 @@ export { ParametersService } from './services/ParametersService'; export { ResponseService } from './services/ResponseService'; export { SimpleService } from './services/SimpleService'; export { TypesService } from './services/TypesService'; + " `; @@ -2416,17 +2419,16 @@ import type { ApiRequestOptions } from './ApiRequestOptions'; type Resolver = (options: ApiRequestOptions) => Promise; type Headers = Record; -type Config = { - BASE: string; - VERSION: string; - WITH_CREDENTIALS: boolean; +export type OpenAPIConfig = { + BASE?: string; + VERSION?: string; + WITH_CREDENTIALS?: boolean; TOKEN?: string | Resolver; USERNAME?: string | Resolver; PASSWORD?: string | Resolver; HEADERS?: Headers | Resolver; } - -export const OpenAPI: Config = { +export const OpenAPI: OpenAPIConfig = { BASE: 'http://localhost:3000/base', VERSION: '1.0', WITH_CREDENTIALS: false, @@ -2434,7 +2436,8 @@ export const OpenAPI: Config = { USERNAME: undefined, PASSWORD: undefined, HEADERS: undefined, -};" +}; +" `; exports[`v3 should generate: ./test/generated/v3/core/request.ts 1`] = ` @@ -2444,6 +2447,7 @@ exports[`v3 should generate: ./test/generated/v3/core/request.ts 1`] = ` import { ApiError } from './ApiError'; import type { ApiRequestOptions } from './ApiRequestOptions'; import type { ApiResult } from './ApiResult'; +import type { OpenAPIConfig } from './OpenAPI'; import { OpenAPI } from './OpenAPI'; function isDefined(value: T | null | undefined): value is Exclude { @@ -2482,9 +2486,9 @@ function getQueryString(params: Record): string { return ''; } -function getUrl(options: ApiRequestOptions): string { +function getUrl(options: ApiRequestOptions, config: OpenAPIConfig): string { const path = options.path.replace(/[:]/g, '_'); - const url = \`\${OpenAPI.BASE}\${path}\`; + const url = \`\${config.BASE}\${path}\`; if (options.query) { return \`\${url}\${getQueryString(options.query)}\`; @@ -2512,11 +2516,11 @@ async function resolve(options: ApiRequestOptions, resolver?: T | Resolver return resolver; } -async function getHeaders(options: ApiRequestOptions): Promise { - const token = await resolve(options, OpenAPI.TOKEN); - const username = await resolve(options, OpenAPI.USERNAME); - const password = await resolve(options, OpenAPI.PASSWORD); - const defaultHeaders = await resolve(options, OpenAPI.HEADERS); +async function getHeaders(options: ApiRequestOptions, config: OpenAPIConfig): Promise { + const token = await resolve(options, config.TOKEN); + const username = await resolve(options, config.USERNAME); + const password = await resolve(options, config.PASSWORD); + const defaultHeaders = await resolve(options, config.HEADERS); const headers = new Headers({ Accept: 'application/json', @@ -2563,13 +2567,13 @@ function getRequestBody(options: ApiRequestOptions): BodyInit | undefined { return undefined; } -async function sendRequest(options: ApiRequestOptions, url: string): Promise { +async function sendRequest(options: ApiRequestOptions, config: OpenAPIConfig, url: string): Promise { const request: RequestInit = { method: options.method, - headers: await getHeaders(options), + headers: await getHeaders(options, config), body: getRequestBody(options), }; - if (OpenAPI.WITH_CREDENTIALS) { + if (config.WITH_CREDENTIALS) { request.credentials = 'include'; } return await fetch(url, request); @@ -2631,8 +2635,8 @@ function catchErrors(options: ApiRequestOptions, result: ApiResult): void { * @throws ApiError */ export async function request(options: ApiRequestOptions): Promise { - const url = getUrl(options); - const response = await sendRequest(options, url); + const url = getUrl(options, OpenAPI); + const response = await sendRequest(options, OpenAPI, url); const responseBody = await getResponseBody(response); const responseHeader = getResponseHeader(response, options.responseHeader); @@ -2646,7 +2650,8 @@ export async function request(options: ApiRequestOptions): Promise { catchErrors(options, result); return result; -}" +} +" `; exports[`v3 should generate: ./test/generated/v3/index.ts 1`] = ` @@ -2765,6 +2770,7 @@ export { ResponseService } from './services/ResponseService'; export { SimpleService } from './services/SimpleService'; export { TypesService } from './services/TypesService'; export { UploadService } from './services/UploadService'; + " `; diff --git a/test/e2e/scripts/generate.js b/test/e2e/scripts/generate.js index 426ebb213..a8b534591 100644 --- a/test/e2e/scripts/generate.js +++ b/test/e2e/scripts/generate.js @@ -2,13 +2,14 @@ const OpenAPI = require('../../../dist'); -async function generate(dir, version, client, useOptions = false, useUnionTypes = false) { +async function generate(dir, version, client, useOptions = false, useUnionTypes = false, exportClient = false) { await OpenAPI.generate({ input: `./test/spec/${version}.json`, output: `./test/e2e/generated/${dir}/`, httpClient: client, useOptions, useUnionTypes, + exportClient, }); } diff --git a/test/e2e/v2.babel.spec.js b/test/e2e/v2.babel.spec.js index e08e420d7..ca3bd1925 100644 --- a/test/e2e/v2.babel.spec.js +++ b/test/e2e/v2.babel.spec.js @@ -7,7 +7,6 @@ const server = require('./scripts/server'); const browser = require('./scripts/browser'); describe('v2.fetch', () => { - beforeAll(async () => { await generate('v2/babel', 'v2', 'fetch', true, true); await copy('v2/babel'); @@ -37,9 +36,49 @@ describe('v2.fetch', () => { return await ComplexService.complexTypes({ first: { second: { - third: 'Hello World!' - } - } + third: 'Hello World!', + }, + }, + }); + }); + expect(result).toBeDefined(); + }); +}); + +describe('v2.fetch with client', () => { + beforeAll(async () => { + await generate('v2/babel_client', 'v2', 'fetch', true, true, true); + await copy('v2/babel_client'); + compileWithBabel('v2/babel_client'); + await server.start('v2/babel_client'); + await browser.start(); + }, 30000); + + afterAll(async () => { + await server.stop(); + await browser.stop(); + }); + + it('requests token', async () => { + await browser.exposeFunction('tokenRequest', jest.fn().mockResolvedValue('MY_TOKEN')); + const result = await browser.evaluate(async () => { + const { AppClient } = window.api; + const client = new AppClient({ TOKEN: window.tokenRequest }); + return await client.simple.getCallWithoutParametersAndResponse(); + }); + expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); + }); + + it('complexService', async () => { + const result = await browser.evaluate(async () => { + const { AppClient } = window.api; + const client = new AppClient(); + return await client.complex.complexTypes({ + first: { + second: { + third: 'Hello World!', + }, + }, }); }); expect(result).toBeDefined(); diff --git a/test/e2e/v2.fetch.spec.js b/test/e2e/v2.fetch.spec.js index 3eb58162f..412392577 100644 --- a/test/e2e/v2.fetch.spec.js +++ b/test/e2e/v2.fetch.spec.js @@ -7,7 +7,6 @@ const server = require('./scripts/server'); const browser = require('./scripts/browser'); describe('v2.fetch', () => { - beforeAll(async () => { await generate('v2/fetch', 'v2', 'fetch'); await copy('v2/fetch'); @@ -37,9 +36,49 @@ describe('v2.fetch', () => { return await ComplexService.complexTypes({ first: { second: { - third: 'Hello World!' - } - } + third: 'Hello World!', + }, + }, + }); + }); + expect(result).toBeDefined(); + }); +}); + +describe('v2.fetch with client', () => { + beforeAll(async () => { + await generate('v2/fetch_client', 'v2', 'fetch', false, false, true); + await copy('v2/fetch_client'); + compileWithTypescript('v2/fetch_client'); + await server.start('v2/fetch_client'); + await browser.start(); + }, 30000); + + afterAll(async () => { + await server.stop(); + await browser.stop(); + }); + + it('requests token', async () => { + await browser.exposeFunction('tokenRequest', jest.fn().mockResolvedValue('MY_TOKEN')); + const result = await browser.evaluate(async () => { + const { AppClient } = window.api; + const client = new AppClient({ TOKEN: window.tokenRequest }); + return await client.simple.getCallWithoutParametersAndResponse(); + }); + expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); + }); + + it('complexService', async () => { + const result = await browser.evaluate(async () => { + const { AppClient } = window.api; + const client = new AppClient(); + return await client.complex.complexTypes({ + first: { + second: { + third: 'Hello World!', + }, + }, }); }); expect(result).toBeDefined(); diff --git a/test/e2e/v2.node.spec.js b/test/e2e/v2.node.spec.js index 12d1d85b1..c3cab8f5f 100644 --- a/test/e2e/v2.node.spec.js +++ b/test/e2e/v2.node.spec.js @@ -5,7 +5,6 @@ const compileWithTypescript = require('./scripts/compileWithTypescript'); const server = require('./scripts/server'); describe('v2.node', () => { - beforeAll(async () => { await generate('v2/node', 'v2', 'node'); compileWithTypescript('v2/node'); @@ -18,7 +17,7 @@ describe('v2.node', () => { it('requests token', async () => { const { OpenAPI, SimpleService } = require('./generated/v2/node/index.js'); - const tokenRequest = jest.fn().mockResolvedValue('MY_TOKEN') + const tokenRequest = jest.fn().mockResolvedValue('MY_TOKEN'); OpenAPI.TOKEN = tokenRequest; const result = await SimpleService.getCallWithoutParametersAndResponse(); expect(tokenRequest.mock.calls.length).toBe(1); @@ -30,11 +29,44 @@ describe('v2.node', () => { const result = await ComplexService.complexTypes({ first: { second: { - third: 'Hello World!' - } - } + third: 'Hello World!', + }, + }, }); expect(result).toBeDefined(); }); +}); + +describe('v2.node with client', () => { + beforeAll(async () => { + await generate('v2/node_client', 'v2', 'node', false, false, true); + compileWithTypescript('v2/node_client'); + await server.start('v2/node_client'); + }, 30000); + + afterAll(async () => { + await server.stop(); + }); + + it('requests token', async () => { + const tokenRequest = jest.fn().mockResolvedValue('MY_TOKEN'); + const { AppClient } = require('./generated/v2/node_client/index.js'); + const client = new AppClient({ TOKEN: tokenRequest }); + const result = await client.simple.getCallWithoutParametersAndResponse(); + expect(tokenRequest.mock.calls.length).toBe(1); + expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); + }); + it('complexService', async () => { + const { AppClient } = require('./generated/v2/node_client/index.js'); + const client = new AppClient(); + const result = await client.complex.complexTypes({ + first: { + second: { + third: 'Hello World!', + }, + }, + }); + expect(result).toBeDefined(); + }); }); diff --git a/test/e2e/v2.xhr.spec.js b/test/e2e/v2.xhr.spec.js index 6791cc243..09b1c219b 100644 --- a/test/e2e/v2.xhr.spec.js +++ b/test/e2e/v2.xhr.spec.js @@ -7,7 +7,6 @@ const server = require('./scripts/server'); const browser = require('./scripts/browser'); describe('v2.xhr', () => { - beforeAll(async () => { await generate('v2/xhr', 'v2', 'xhr'); await copy('v2/xhr'); @@ -37,9 +36,49 @@ describe('v2.xhr', () => { return await ComplexService.complexTypes({ first: { second: { - third: 'Hello World!' - } - } + third: 'Hello World!', + }, + }, + }); + }); + expect(result).toBeDefined(); + }); +}); + +describe('v2.xhr with client', () => { + beforeAll(async () => { + await generate('v2/xhr_client', 'v2', 'xhr', false, false, true); + await copy('v2/xhr_client'); + compileWithTypescript('v2/xhr_client'); + await server.start('v2/xhr_client'); + await browser.start(); + }, 30000); + + afterAll(async () => { + await server.stop(); + await browser.stop(); + }); + + it('requests token', async () => { + await browser.exposeFunction('tokenRequest', jest.fn().mockResolvedValue('MY_TOKEN')); + const result = await browser.evaluate(async () => { + const { AppClient } = window.api; + const client = new AppClient({ TOKEN: window.tokenRequest }); + return await client.simple.getCallWithoutParametersAndResponse(); + }); + expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); + }); + + it('complexService', async () => { + const result = await browser.evaluate(async () => { + const { AppClient } = window.api; + const client = new AppClient(); + return await client.complex.complexTypes({ + first: { + second: { + third: 'Hello World!', + }, + }, }); }); expect(result).toBeDefined(); diff --git a/test/e2e/v3.babel.spec.js b/test/e2e/v3.babel.spec.js index e5ea0f841..3a5a9c538 100644 --- a/test/e2e/v3.babel.spec.js +++ b/test/e2e/v3.babel.spec.js @@ -7,7 +7,6 @@ const server = require('./scripts/server'); const browser = require('./scripts/browser'); describe('v3.fetch', () => { - beforeAll(async () => { await generate('v3/babel', 'v3', 'fetch', true, true); await copy('v3/babel'); @@ -50,9 +49,58 @@ describe('v3.fetch', () => { return await ComplexService.complexTypes({ first: { second: { - third: 'Hello World!' - } - } + third: 'Hello World!', + }, + }, + }); + }); + expect(result).toBeDefined(); + }); +}); + +describe('v3.fetch with client', () => { + beforeAll(async () => { + await generate('v3/babel', 'v3', 'fetch', true, true, true); + await copy('v3/babel'); + compileWithBabel('v3/babel'); + await server.start('v3/babel'); + await browser.start(); + }, 30000); + + afterAll(async () => { + await server.stop(); + await browser.stop(); + }); + + it('requests token', async () => { + await browser.exposeFunction('tokenRequest', jest.fn().mockResolvedValue('MY_TOKEN')); + const result = await browser.evaluate(async () => { + const { AppClient } = window.api; + const client = new AppClient({ TOKEN: window.tokenRequest, USERNAME: undefined, PASSWORD: undefined }); + return await client.simple.getCallWithoutParametersAndResponse(); + }); + expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); + }); + + it('uses credentials', async () => { + const result = await browser.evaluate(async () => { + const { AppClient } = window.api; + const client = new AppClient({ TOKEN: undefined, USERNAME: 'username', PASSWORD: 'password' }); + return await client.simple.getCallWithoutParametersAndResponse(); + }); + expect(result.headers.authorization).toBe('Basic dXNlcm5hbWU6cGFzc3dvcmQ='); + }); + + it('complexService', async () => { + const result = await browser.evaluate(async () => { + const { AppClient } = window.api; + const client = new AppClient({}); + return await client.complex.complexTypes({ + first: { + second: { + third: 'Hello World!', + }, + }, }); }); expect(result).toBeDefined(); diff --git a/test/e2e/v3.fetch.spec.js b/test/e2e/v3.fetch.spec.js index 435fd57dd..cd2a1996a 100644 --- a/test/e2e/v3.fetch.spec.js +++ b/test/e2e/v3.fetch.spec.js @@ -7,7 +7,6 @@ const server = require('./scripts/server'); const browser = require('./scripts/browser'); describe('v3.fetch', () => { - beforeAll(async () => { await generate('v3/fetch', 'v3', 'fetch'); await copy('v3/fetch'); @@ -50,9 +49,58 @@ describe('v3.fetch', () => { return await ComplexService.complexTypes({ first: { second: { - third: 'Hello World!' - } - } + third: 'Hello World!', + }, + }, + }); + }); + expect(result).toBeDefined(); + }); +}); + +describe('v3.fetch with client', () => { + beforeAll(async () => { + await generate('v3/fetch_client', 'v3', 'fetch', false, false, true); + await copy('v3/fetch_client'); + compileWithTypescript('v3/fetch_client'); + await server.start('v3/fetch_client'); + await browser.start(); + }, 30000); + + afterAll(async () => { + await server.stop(); + await browser.stop(); + }); + + it('requests token', async () => { + await browser.exposeFunction('tokenRequest', jest.fn().mockResolvedValue('MY_TOKEN')); + const result = await browser.evaluate(async () => { + const { AppClient } = window.api; + const client = new AppClient({ TOKEN: window.tokenRequest, USERNAME: undefined, PASSWORD: undefined }); + return await client.simple.getCallWithoutParametersAndResponse(); + }); + expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); + }); + + it('uses credentials', async () => { + const result = await browser.evaluate(async () => { + const { AppClient } = window.api; + const client = new AppClient({ TOKEN: undefined, USERNAME: 'username', PASSWORD: 'password' }); + return await client.simple.getCallWithoutParametersAndResponse(); + }); + expect(result.headers.authorization).toBe('Basic dXNlcm5hbWU6cGFzc3dvcmQ='); + }); + + it('complexService', async () => { + const result = await browser.evaluate(async () => { + const { AppClient } = window.api; + const client = new AppClient({}); + return await client.complex.complexTypes({ + first: { + second: { + third: 'Hello World!', + }, + }, }); }); expect(result).toBeDefined(); diff --git a/test/e2e/v3.node.spec.js b/test/e2e/v3.node.spec.js index 88626d73e..42ac11acc 100644 --- a/test/e2e/v3.node.spec.js +++ b/test/e2e/v3.node.spec.js @@ -5,7 +5,6 @@ const compileWithTypescript = require('./scripts/compileWithTypescript'); const server = require('./scripts/server'); describe('v3.node', () => { - beforeAll(async () => { await generate('v3/node', 'v3', 'node'); compileWithTypescript('v3/node'); @@ -18,7 +17,7 @@ describe('v3.node', () => { it('requests token', async () => { const { OpenAPI, SimpleService } = require('./generated/v3/node/index.js'); - const tokenRequest = jest.fn().mockResolvedValue('MY_TOKEN') + const tokenRequest = jest.fn().mockResolvedValue('MY_TOKEN'); OpenAPI.TOKEN = tokenRequest; OpenAPI.USERNAME = undefined; OpenAPI.PASSWORD = undefined; @@ -41,11 +40,51 @@ describe('v3.node', () => { const result = await ComplexService.complexTypes({ first: { second: { - third: 'Hello World!' - } - } + third: 'Hello World!', + }, + }, }); expect(result).toBeDefined(); }); +}); + +describe('v3.node with client', () => { + beforeAll(async () => { + await generate('v3/node_client', 'v3', 'node', false, false, true); + compileWithTypescript('v3/node_client'); + await server.start('v3/node_client'); + }, 30000); + + afterAll(async () => { + await server.stop(); + }); + + it('requests token', async () => { + const { AppClient } = require('./generated/v3/node_client/index.js'); + const tokenRequest = jest.fn().mockResolvedValue('MY_TOKEN'); + const client = new AppClient({ TOKEN: tokenRequest, username: undefined, password: undefined }); + const result = await client.simple.getCallWithoutParametersAndResponse(); + expect(tokenRequest.mock.calls.length).toBe(1); + expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); + }); + + it('uses credentials', async () => { + const { AppClient } = require('./generated/v3/node_client/index.js'); + const client = new AppClient({ TOKEN: undefined, USERNAME: 'username', PASSWORD: 'password' }); + const result = await client.simple.getCallWithoutParametersAndResponse(); + expect(result.headers.authorization).toBe('Basic dXNlcm5hbWU6cGFzc3dvcmQ='); + }); + it('complexService', async () => { + const { AppClient } = require('./generated/v3/node_client/index.js'); + const client = new AppClient(); + const result = await client.complex.complexTypes({ + first: { + second: { + third: 'Hello World!', + }, + }, + }); + expect(result).toBeDefined(); + }); }); diff --git a/test/e2e/v3.xhr.spec.js b/test/e2e/v3.xhr.spec.js index 88e0ff227..4bcdabf60 100644 --- a/test/e2e/v3.xhr.spec.js +++ b/test/e2e/v3.xhr.spec.js @@ -7,7 +7,6 @@ const server = require('./scripts/server'); const browser = require('./scripts/browser'); describe('v3.xhr', () => { - beforeAll(async () => { await generate('v3/xhr', 'v3', 'xhr'); await copy('v3/xhr'); @@ -50,9 +49,58 @@ describe('v3.xhr', () => { return await ComplexService.complexTypes({ first: { second: { - third: 'Hello World!' - } - } + third: 'Hello World!', + }, + }, + }); + }); + expect(result).toBeDefined(); + }); +}); + +describe('v3.xhr with client', () => { + beforeAll(async () => { + await generate('v3/xhr_client', 'v3', 'xhr', false, false, true); + await copy('v3/xhr_client'); + compileWithTypescript('v3/xhr_client'); + await server.start('v3/xhr_client'); + await browser.start(); + }, 30000); + + afterAll(async () => { + await server.stop(); + await browser.stop(); + }); + + it('requests token', async () => { + await browser.exposeFunction('tokenRequest', jest.fn().mockResolvedValue('MY_TOKEN')); + const result = await browser.evaluate(async () => { + const { AppClient } = window.api; + const client = new AppClient({ TOKEN: window.tokenRequest, USERNAME: undefined, PASSWORD: undefined }); + return await client.simple.getCallWithoutParametersAndResponse(); + }); + expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); + }); + + it('uses credentials', async () => { + const result = await browser.evaluate(async () => { + const { AppClient } = window.api; + const client = new AppClient({ TOKEN: undefined, USERNAME: 'username', PASSWORD: 'password' }); + return await client.simple.getCallWithoutParametersAndResponse(); + }); + expect(result.headers.authorization).toBe('Basic dXNlcm5hbWU6cGFzc3dvcmQ='); + }); + + it('complexService', async () => { + const result = await browser.evaluate(async () => { + const { AppClient } = window.api; + const client = new AppClient({}); + return await client.complex.complexTypes({ + first: { + second: { + third: 'Hello World!', + }, + }, }); }); expect(result).toBeDefined(); diff --git a/test/index.client.spec.js b/test/index.client.spec.js new file mode 100644 index 000000000..fdce7fff1 --- /dev/null +++ b/test/index.client.spec.js @@ -0,0 +1,51 @@ +'use strict'; + +const OpenAPI = require('../dist'); +const glob = require('glob'); +const fs = require('fs'); + +describe('v2', () => { + it('should generate with exportClient', async () => { + await OpenAPI.generate({ + input: './test/spec/v2.json', + output: './test/generated/v2_client', + httpClient: OpenAPI.HttpClient.FETCH, + useOptions: false, + useUnionTypes: false, + exportCore: true, + exportSchemas: true, + exportModels: true, + exportServices: true, + exportClient: true, + clientName: 'TestClient', + }); + + glob.sync('./test/generated/v2_client/**/*.ts').forEach(file => { + const content = fs.readFileSync(file, 'utf8').toString(); + expect(content).toMatchSnapshot(file); + }); + }); +}); + +describe('v3', () => { + it('should generate with exportClient', async () => { + await OpenAPI.generate({ + input: './test/spec/v3.json', + output: './test/generated/v3_client', + httpClient: OpenAPI.HttpClient.FETCH, + useOptions: false, + useUnionTypes: false, + exportCore: true, + exportSchemas: true, + exportModels: true, + exportServices: true, + exportClient: true, + clientName: 'TestClient', + }); + + glob.sync('./test/generated/v3_client/**/*.ts').forEach(file => { + const content = fs.readFileSync(file, 'utf8').toString(); + expect(content).toMatchSnapshot(file); + }); + }); +}); diff --git a/test/index.spec.js b/test/index.spec.js index 946e6fa15..2f8169282 100644 --- a/test/index.spec.js +++ b/test/index.spec.js @@ -16,6 +16,7 @@ describe('v2', () => { exportSchemas: true, exportModels: true, exportServices: true, + exportClient: false, }); glob.sync('./test/generated/v2/**/*.ts').forEach(file => { @@ -37,6 +38,7 @@ describe('v3', () => { exportSchemas: true, exportModels: true, exportServices: true, + exportClient: false, }); glob.sync('./test/generated/v3/**/*.ts').forEach(file => { From 9c9fae22946d5df7ccc8e216872492c5b956cf0c Mon Sep 17 00:00:00 2001 From: lub0v-parsable Date: Thu, 5 Aug 2021 10:09:50 -0700 Subject: [PATCH 02/11] PE-2152 - add multiple http clients --- .gitignore | 1 + package.json | 4 +- .../{ConcreteHttpRequest.hbs => request.hbs} | 0 src/utils/registerHandlebarTemplates.spec.ts | 2 +- src/utils/registerHandlebarTemplates.ts | 16 +- src/utils/writeAppClient.spec.ts | 7 +- src/utils/writeClient.spec.ts | 2 +- src/utils/writeClientCore.spec.ts | 13 +- src/utils/writeClientCore.ts | 6 +- src/utils/writeClientIndex.spec.ts | 7 +- src/utils/writeClientModels.spec.ts | 7 +- src/utils/writeClientSchemas.spec.ts | 7 +- src/utils/writeClientServices.spec.ts | 7 +- test/__snapshots__/index.client.spec.js.snap | 970 +++++++++++++++++- 14 files changed, 1005 insertions(+), 44 deletions(-) rename src/templates/core/{ConcreteHttpRequest.hbs => request.hbs} (100%) diff --git a/.gitignore b/.gitignore index 2b7422568..5507b7a60 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ test/e2e/generated samples/generated samples/swagger-codegen-cli-v2.jar samples/swagger-codegen-cli-v3.jar +example diff --git a/package.json b/package.json index 9b56ef5e4..65101289d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "openapi-typescript-codegen", - "version": "0.9.3", + "name": "@parsable/openapi-typescript-codegen", + "version": "0.0.1-alpha-2", "description": "Library that generates Typescript clients based on the OpenAPI specification.", "author": "Ferdi Koomen", "homepage": "https://github.com/ferdikoomen/openapi-typescript-codegen", diff --git a/src/templates/core/ConcreteHttpRequest.hbs b/src/templates/core/request.hbs similarity index 100% rename from src/templates/core/ConcreteHttpRequest.hbs rename to src/templates/core/request.hbs diff --git a/src/utils/registerHandlebarTemplates.spec.ts b/src/utils/registerHandlebarTemplates.spec.ts index f5a90aa42..ff254cc00 100644 --- a/src/utils/registerHandlebarTemplates.spec.ts +++ b/src/utils/registerHandlebarTemplates.spec.ts @@ -16,7 +16,7 @@ describe('registerHandlebarTemplates', () => { expect(templates.core.apiError).toBeDefined(); expect(templates.core.apiRequestOptions).toBeDefined(); expect(templates.core.apiResult).toBeDefined(); - expect(templates.core.concreteHttpRequest).toBeDefined(); + expect(templates.core.request).toBeDefined(); expect(templates.core.baseHttpRequest).toBeDefined(); expect(templates.client).toBeDefined(); }); diff --git a/src/utils/registerHandlebarTemplates.ts b/src/utils/registerHandlebarTemplates.ts index 0b0c45913..44762d5a1 100644 --- a/src/utils/registerHandlebarTemplates.ts +++ b/src/utils/registerHandlebarTemplates.ts @@ -5,7 +5,6 @@ import templateCoreApiError from '../templates/core/ApiError.hbs'; import templateCoreApiRequestOptions from '../templates/core/ApiRequestOptions.hbs'; import templateCoreApiResult from '../templates/core/ApiResult.hbs'; import templateCoreBaseHttpClient from '../templates/core/BaseHttpRequest.hbs'; -import templateCoreConcreteHttpClient from '../templates/core/ConcreteHttpRequest.hbs'; import fetchGetHeaders from '../templates/core/fetch/getHeaders.hbs'; import fetchGetRequestBody from '../templates/core/fetch/getRequestBody.hbs'; import fetchGetResponseBody from '../templates/core/fetch/getResponseBody.hbs'; @@ -30,6 +29,7 @@ import nodeGetResponseHeader from '../templates/core/node/getResponseHeader.hbs' import nodeRequest from '../templates/core/node/request.hbs'; import nodeSendRequest from '../templates/core/node/sendRequest.hbs'; import templateCoreSettings from '../templates/core/OpenAPI.hbs'; +import templateCoreRequest from '../templates/core/request.hbs'; import xhrGetHeaders from '../templates/core/xhr/getHeaders.hbs'; import xhrGetRequestBody from '../templates/core/xhr/getRequestBody.hbs'; import xhrGetResponseBody from '../templates/core/xhr/getResponseBody.hbs'; @@ -84,7 +84,12 @@ export interface Templates { apiRequestOptions: Handlebars.TemplateDelegate; apiResult: Handlebars.TemplateDelegate; baseHttpRequest: Handlebars.TemplateDelegate; - concreteHttpRequest: Handlebars.TemplateDelegate; + request: Handlebars.TemplateDelegate; + httpRequest: { + fetch: Handlebars.TemplateDelegate; + node: Handlebars.TemplateDelegate; + xhr: Handlebars.TemplateDelegate; + }; }; } @@ -110,7 +115,12 @@ export function registerHandlebarTemplates(root: { httpClient: HttpClient; useOp apiRequestOptions: Handlebars.template(templateCoreApiRequestOptions), apiResult: Handlebars.template(templateCoreApiResult), baseHttpRequest: Handlebars.template(templateCoreBaseHttpClient), - concreteHttpRequest: Handlebars.template(templateCoreConcreteHttpClient), + request: Handlebars.template(templateCoreRequest), + httpRequest: { + fetch: Handlebars.template(fetchRequest), + node: Handlebars.template(nodeRequest), + xhr: Handlebars.template(xhrRequest), + }, }, }; diff --git a/src/utils/writeAppClient.spec.ts b/src/utils/writeAppClient.spec.ts index 0e2085c54..abafed8cf 100644 --- a/src/utils/writeAppClient.spec.ts +++ b/src/utils/writeAppClient.spec.ts @@ -29,7 +29,12 @@ describe('writeAppClient', () => { apiRequestOptions: () => 'apiRequestOptions', apiResult: () => 'apiResult', baseHttpRequest: () => 'baseHttpRequest', - concreteHttpRequest: () => 'concreteHttpRequest', + request: () => 'concreteHttpRequest', + httpRequest: { + fetch: () => 'fetchRequest', + node: () => 'nodeRequest', + xhr: () => 'xhrRequest', + }, }, }; diff --git a/src/utils/writeClient.spec.ts b/src/utils/writeClient.spec.ts index 7f9d77810..649ceab4b 100644 --- a/src/utils/writeClient.spec.ts +++ b/src/utils/writeClient.spec.ts @@ -29,7 +29,7 @@ describe('writeClient', () => { apiRequestOptions: () => 'apiRequestOptions', apiResult: () => 'apiResult', baseHttpRequest: () => 'baseHttpRequest', - concreteHttpRequest: () => 'concreteHttpRequest', + request: () => 'concreteHttpRequest', }, }; diff --git a/src/utils/writeClientCore.spec.ts b/src/utils/writeClientCore.spec.ts index e39d81214..ea2d4de2b 100644 --- a/src/utils/writeClientCore.spec.ts +++ b/src/utils/writeClientCore.spec.ts @@ -28,7 +28,12 @@ describe('writeClientCore', () => { apiRequestOptions: () => 'apiRequestOptions', apiResult: () => 'apiResult', baseHttpRequest: () => 'baseHttpRequest', - concreteHttpRequest: () => 'concreteHttpRequest', + request: () => 'request', + httpRequest: { + fetch: () => 'fetchRequest', + node: () => 'nodeRequest', + xhr: () => 'xhrRequest', + }, }, }; @@ -39,7 +44,7 @@ describe('writeClientCore', () => { expect(writeFile).toBeCalledWith('/ApiError.ts', 'apiError'); expect(writeFile).toBeCalledWith('/ApiRequestOptions.ts', 'apiRequestOptions'); expect(writeFile).toBeCalledWith('/ApiResult.ts', 'apiResult'); - expect(writeFile).toBeCalledWith('/request.ts', 'concreteHttpRequest'); + expect(writeFile).toBeCalledWith('/request.ts', 'request'); }); it('should write to filesystem when exportClient true', async () => { @@ -50,6 +55,8 @@ describe('writeClientCore', () => { expect(writeFile).toBeCalledWith('/ApiRequestOptions.ts', 'apiRequestOptions'); expect(writeFile).toBeCalledWith('/ApiResult.ts', 'apiResult'); expect(writeFile).toBeCalledWith('/BaseHttpRequest.ts', 'baseHttpRequest'); - expect(writeFile).toBeCalledWith('/FetchHttpRequest.ts', 'concreteHttpRequest'); + expect(writeFile).toBeCalledWith('/FetchHttpRequest.ts', 'fetchRequest'); + expect(writeFile).toBeCalledWith('/NodeHttpRequest.ts', 'nodeRequest'); + expect(writeFile).toBeCalledWith('/XhrHttpRequest.ts', 'xhrRequest'); }); }); diff --git a/src/utils/writeClientCore.ts b/src/utils/writeClientCore.ts index 21a4baa4e..11db70c2c 100644 --- a/src/utils/writeClientCore.ts +++ b/src/utils/writeClientCore.ts @@ -29,9 +29,11 @@ export async function writeClientCore(client: Client, templates: Templates, outp await writeFile(resolve(outputPath, 'ApiResult.ts'), templates.core.apiResult({})); if (exportClient) { await writeFile(resolve(outputPath, 'BaseHttpRequest.ts'), templates.core.baseHttpRequest({})); - await writeFile(resolve(outputPath, `${getHttpRequestName(httpClient)}.ts`), templates.core.concreteHttpRequest(context)); + for (const client of Object.values(HttpClient)) { + await writeFile(resolve(outputPath, `${getHttpRequestName(client)}.ts`), templates.core.httpRequest[client](context)); + } } else { - await writeFile(resolve(outputPath, `request.ts`), templates.core.concreteHttpRequest(context)); + await writeFile(resolve(outputPath, `request.ts`), templates.core.request(context)); } if (request) { diff --git a/src/utils/writeClientIndex.spec.ts b/src/utils/writeClientIndex.spec.ts index be821193b..f657b7926 100644 --- a/src/utils/writeClientIndex.spec.ts +++ b/src/utils/writeClientIndex.spec.ts @@ -29,7 +29,12 @@ describe('writeClientIndex', () => { apiRequestOptions: () => 'apiRequestOptions', apiResult: () => 'apiResult', baseHttpRequest: () => 'baseHttpClient', - concreteHttpRequest: () => 'concreteHttpClient', + request: () => 'request', + httpRequest: { + fetch: () => 'fetchRequest', + node: () => 'nodeRequest', + xhr: () => 'xhrRequest', + }, }, }; diff --git a/src/utils/writeClientModels.spec.ts b/src/utils/writeClientModels.spec.ts index 44227dc12..75c547f40 100644 --- a/src/utils/writeClientModels.spec.ts +++ b/src/utils/writeClientModels.spec.ts @@ -42,7 +42,12 @@ describe('writeClientModels', () => { apiRequestOptions: () => 'apiRequestOptions', apiResult: () => 'apiResult', baseHttpRequest: () => 'baseHttpRequest', - concreteHttpRequest: () => 'concreteHttpRequest', + request: () => 'request', + httpRequest: { + fetch: () => 'fetchRequest', + node: () => 'nodeRequest', + xhr: () => 'xhrRequest', + }, }, }; diff --git a/src/utils/writeClientSchemas.spec.ts b/src/utils/writeClientSchemas.spec.ts index 1dd4e9196..f2bab8bed 100644 --- a/src/utils/writeClientSchemas.spec.ts +++ b/src/utils/writeClientSchemas.spec.ts @@ -42,7 +42,12 @@ describe('writeClientSchemas', () => { apiRequestOptions: () => 'apiRequestOptions', apiResult: () => 'apiResult', baseHttpRequest: () => 'baseHttpRequest', - concreteHttpRequest: () => 'concreteHttpRequest', + request: () => 'request', + httpRequest: { + fetch: () => 'fetchRequest', + node: () => 'nodeRequest', + xhr: () => 'xhrRequest', + }, }, }; diff --git a/src/utils/writeClientServices.spec.ts b/src/utils/writeClientServices.spec.ts index 91c105121..4230aca8b 100644 --- a/src/utils/writeClientServices.spec.ts +++ b/src/utils/writeClientServices.spec.ts @@ -30,7 +30,12 @@ describe('writeClientServices', () => { apiRequestOptions: () => 'apiRequestOptions', apiResult: () => 'apiResult', baseHttpRequest: () => 'baseHttpRequest', - concreteHttpRequest: () => 'concreteHttpRequest', + request: () => 'request', + httpRequest: { + fetch: () => 'fetchRequest', + node: () => 'nodeRequest', + xhr: () => 'xhrRequest', + }, }, }; diff --git a/test/__snapshots__/index.client.spec.js.snap b/test/__snapshots__/index.client.spec.js.snap index b92bed6d9..5bebae462 100644 --- a/test/__snapshots__/index.client.spec.js.snap +++ b/test/__snapshots__/index.client.spec.js.snap @@ -350,23 +350,481 @@ export class FetchHttpRequest extends BaseHttpRequest { " `; +exports[`v2 should generate with exportClient: ./test/generated/v2_client/core/NodeHttpRequest.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import FormData from 'form-data'; +import fetch, { BodyInit, Headers, RequestInit, Response } from 'node-fetch'; +import { types } from 'util'; + +import { ApiError } from './ApiError'; +import type { ApiRequestOptions } from './ApiRequestOptions'; +import type { ApiResult } from './ApiResult'; +import type { OpenAPIConfig } from './OpenAPI'; +import { BaseHttpRequest } from './BaseHttpRequest'; + +function isDefined(value: T | null | undefined): value is Exclude { + return value !== undefined && value !== null; +} + +function isString(value: any): value is string { + return typeof value === 'string'; +} + +function isStringWithValue(value: any): value is string { + return isString(value) && value !== ''; +} + +function isBinary(value: any): value is Buffer | ArrayBuffer | ArrayBufferView { + const isBuffer = Buffer.isBuffer(value); + const isArrayBuffer = types.isArrayBuffer(value); + const isArrayBufferView = types.isArrayBufferView(value); + return isBuffer || isArrayBuffer || isArrayBufferView; +} + +function getQueryString(params: Record): string { + const qs: string[] = []; + Object.keys(params).forEach(key => { + const value = params[key]; + if (isDefined(value)) { + 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 ''; +} + +function getUrl(options: ApiRequestOptions, config: OpenAPIConfig): string { + const path = options.path.replace(/[:]/g, '_'); + const url = \`\${config.BASE}\${path}\`; + + if (options.query) { + return \`\${url}\${getQueryString(options.query)}\`; + } + return url; +} + +function getFormData(params: Record): FormData { + const formData = new FormData(); + Object.keys(params).forEach(key => { + const value = params[key]; + if (isDefined(value)) { + formData.append(key, value); + } + }); + return formData; +} + +type Resolver = (options: ApiRequestOptions) => Promise; + +async function resolve(options: ApiRequestOptions, resolver?: T | Resolver): Promise { + if (typeof resolver === 'function') { + return (resolver as Resolver)(options); + } + return resolver; +} + +async function getHeaders(options: ApiRequestOptions, config: OpenAPIConfig): Promise { + const token = await resolve(options, config.TOKEN); + const username = await resolve(options, config.USERNAME); + const password = await resolve(options, config.PASSWORD); + const defaultHeaders = await resolve(options, config.HEADERS); + + const headers = new Headers({ + Accept: 'application/json', + ...defaultHeaders, + ...options.headers, + }); + + if (isStringWithValue(token)) { + headers.append('Authorization', \`Bearer \${token}\`); + } + + if (isStringWithValue(username) && isStringWithValue(password)) { + const credentials = Buffer.from(\`\${username}:\${password}\`).toString('base64'); + headers.append('Authorization', \`Basic \${credentials}\`); + } + + if (options.body) { + if (options.mediaType) { + headers.append('Content-Type', options.mediaType); + } else if (isBinary(options.body)) { + headers.append('Content-Type', 'application/octet-stream'); + } else if (isString(options.body)) { + headers.append('Content-Type', 'text/plain'); + } else { + headers.append('Content-Type', 'application/json'); + } + } + return headers; +} + +function getRequestBody(options: ApiRequestOptions): BodyInit | undefined { + if (options.formData) { + return getFormData(options.formData); + } + if (options.body) { + if (options.mediaType?.includes('/json')) { + return JSON.stringify(options.body) + } else if (isString(options.body) || isBinary(options.body)) { + return options.body; + } else { + return JSON.stringify(options.body); + } + } + return undefined; +} + +async function sendRequest(options: ApiRequestOptions, config: OpenAPIConfig, url: string): Promise { + const request: RequestInit = { + method: options.method, + headers: await getHeaders(options, config), + body: getRequestBody(options), + }; + return await fetch(url, request); +} + +function getResponseHeader(response: Response, responseHeader?: string): string | null { + if (responseHeader) { + const content = response.headers.get(responseHeader); + if (isString(content)) { + return content; + } + } + return null; +} + +async function getResponseBody(response: Response): Promise { + try { + const contentType = response.headers.get('Content-Type'); + if (contentType) { + const isJSON = contentType.toLowerCase().startsWith('application/json'); + if (isJSON) { + return await response.json(); + } else { + return await response.text(); + } + } + } catch (error) { + console.error(error); + } + return null; +} + +function catchErrors(options: ApiRequestOptions, result: ApiResult): void { + const errors: Record = { + 400: 'Bad Request', + 401: 'Unauthorized', + 403: 'Forbidden', + 404: 'Not Found', + 500: 'Internal Server Error', + 502: 'Bad Gateway', + 503: 'Service Unavailable', + ...options.errors, + } + + const error = errors[result.status]; + if (error) { + throw new ApiError(result, error); + } + + if (!result.ok) { + throw new ApiError(result, 'Generic Error'); + } +} + +export class NodeHttpRequest extends BaseHttpRequest { + constructor(openApiConfig: OpenAPIConfig) { + super(openApiConfig); + } + + /** + * Request using node-fetch client + * @param options The request options from the the service + * @returns ApiResult + * @throws ApiError + */ + async request(options: ApiRequestOptions): Promise { + const url = getUrl(options, this.openApiConfig); + const response = await sendRequest(options, this.openApiConfig, url); + const responseBody = await getResponseBody(response); + const responseHeader = getResponseHeader(response, options.responseHeader); + + const result: ApiResult = { + url, + ok: response.ok, + status: response.status, + statusText: response.statusText, + body: responseHeader || responseBody, + }; + + catchErrors(options, result); + return result; + } +} +" +`; + exports[`v2 should generate with exportClient: ./test/generated/v2_client/core/OpenAPI.ts 1`] = ` "/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ import type { ApiRequestOptions } from './ApiRequestOptions'; -type Resolver = (options: ApiRequestOptions) => Promise; -type Headers = Record; +type Resolver = (options: ApiRequestOptions) => Promise; +type Headers = Record; + +export type OpenAPIConfig = { + BASE?: string; + VERSION?: string; + WITH_CREDENTIALS?: boolean; + TOKEN?: string | Resolver; + USERNAME?: string | Resolver; + PASSWORD?: string | Resolver; + HEADERS?: Headers | Resolver; +} +" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/core/XhrHttpRequest.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import { ApiError } from './ApiError'; +import type { ApiRequestOptions } from './ApiRequestOptions'; +import type { ApiResult } from './ApiResult'; +import type { OpenAPIConfig } from './OpenAPI'; +import { BaseHttpRequest } from './BaseHttpRequest'; + + +function isDefined(value: T | null | undefined): value is Exclude { + return value !== undefined && value !== null; +} + +function isString(value: any): value is string { + return typeof value === 'string'; +} + +function isStringWithValue(value: any): value is string { + return isString(value) && value !== ''; +} + +function isBlob(value: any): value is Blob { + return value instanceof Blob; +} + +function isSuccess(status: number): boolean { + return status >= 200 && status < 300; +} + +function getQueryString(params: Record): string { + const qs: string[] = []; + Object.keys(params).forEach(key => { + const value = params[key]; + if (isDefined(value)) { + 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 ''; +} + +function getUrl(options: ApiRequestOptions, config: OpenAPIConfig): string { + const path = options.path.replace(/[:]/g, '_'); + const url = \`\${config.BASE}\${path}\`; + + if (options.query) { + return \`\${url}\${getQueryString(options.query)}\`; + } + return url; +} + +function getFormData(params: Record): FormData { + const formData = new FormData(); + Object.keys(params).forEach(key => { + const value = params[key]; + if (isDefined(value)) { + formData.append(key, value); + } + }); + return formData; +} + +type Resolver = (options: ApiRequestOptions) => Promise; + +async function resolve(options: ApiRequestOptions, resolver?: T | Resolver): Promise { + if (typeof resolver === 'function') { + return (resolver as Resolver)(options); + } + return resolver; +} + +async function getHeaders(options: ApiRequestOptions, config: OpenAPIConfig): Promise { + const token = await resolve(options, config.TOKEN); + const username = await resolve(options, config.USERNAME); + const password = await resolve(options, config.PASSWORD); + const defaultHeaders = await resolve(options, config.HEADERS); + + const headers = new Headers({ + Accept: 'application/json', + ...defaultHeaders, + ...options.headers, + }); + + if (isStringWithValue(token)) { + headers.append('Authorization', \`Bearer \${token}\`); + } + + if (isStringWithValue(username) && isStringWithValue(password)) { + const credentials = btoa(\`\${username}:\${password}\`); + headers.append('Authorization', \`Basic \${credentials}\`); + } + + if (options.body) { + if (options.mediaType) { + headers.append('Content-Type', options.mediaType); + } else if (isBlob(options.body)) { + headers.append('Content-Type', options.body.type || 'application/octet-stream'); + } else if (isString(options.body)) { + headers.append('Content-Type', 'text/plain'); + } else { + headers.append('Content-Type', 'application/json'); + } + } + return headers; +} + +function getRequestBody(options: ApiRequestOptions): any { + if (options.formData) { + return getFormData(options.formData); + } + if (options.body) { + if (options.mediaType?.includes('/json')) { + return JSON.stringify(options.body) + } else if (isString(options.body) || isBlob(options.body)) { + return options.body; + } else { + return JSON.stringify(options.body); + } + } + return undefined; +} + +async function sendRequest(options: ApiRequestOptions, config: OpenAPIConfig, url: string): Promise { + + const xhr = new XMLHttpRequest(); + xhr.open(options.method, url, true); + xhr.withCredentials = config.WITH_CREDENTIALS ?? false; + + const headers = await getHeaders(options, config); + headers.forEach((value: string, key: string) => { + xhr.setRequestHeader(key, value); + }); + + return new Promise(resolve => { + xhr.onreadystatechange = () => { + if (xhr.readyState === XMLHttpRequest.DONE) { + resolve(xhr); + } + }; + xhr.send(getRequestBody(options)); + }); +} + +function getResponseHeader(xhr: XMLHttpRequest, responseHeader?: string): string | null { + if (responseHeader) { + const content = xhr.getResponseHeader(responseHeader); + if (isString(content)) { + return content; + } + } + return null; +} + +function getResponseBody(xhr: XMLHttpRequest): any { + try { + const contentType = xhr.getResponseHeader('Content-Type'); + if (contentType) { + const isJSON = contentType.toLowerCase().startsWith('application/json'); + if (isJSON) { + return JSON.parse(xhr.responseText); + } else { + return xhr.responseText; + } + } + } catch (error) { + console.error(error); + } + return null; +} + +function catchErrors(options: ApiRequestOptions, result: ApiResult): void { + const errors: Record = { + 400: 'Bad Request', + 401: 'Unauthorized', + 403: 'Forbidden', + 404: 'Not Found', + 500: 'Internal Server Error', + 502: 'Bad Gateway', + 503: 'Service Unavailable', + ...options.errors, + } -export type OpenAPIConfig = { - BASE?: string; - VERSION?: string; - WITH_CREDENTIALS?: boolean; - TOKEN?: string | Resolver; - USERNAME?: string | Resolver; - PASSWORD?: string | Resolver; - HEADERS?: Headers | Resolver; + const error = errors[result.status]; + if (error) { + throw new ApiError(result, error); + } + + if (!result.ok) { + throw new ApiError(result, 'Generic Error'); + } +} + +export class XhrHttpRequest extends BaseHttpRequest { + constructor(openApiConfig: OpenAPIConfig) { + super(openApiConfig); + } + + /** + * Request using XHR client + * @param options The request options from the the service + * @returns ApiResult + * @throws ApiError + */ + async request(options: ApiRequestOptions): Promise { + const url = getUrl(options, this.openApiConfig); + const response = await sendRequest(options, this.openApiConfig, url); + const responseBody = getResponseBody(response); + const responseHeader = getResponseHeader(response, options.responseHeader); + + const result: ApiResult = { + url, + ok: isSuccess(response.status), + status: response.status, + statusText: response.statusText, + body: responseHeader || responseBody, + }; + + catchErrors(options, result); + return result; + } } " `; @@ -2600,23 +3058,247 @@ import type { ApiRequestOptions } from './ApiRequestOptions'; import type { ApiResult } from './ApiResult'; import type { OpenAPIConfig } from './OpenAPI'; -export class BaseHttpRequest { - readonly openApiConfig: OpenAPIConfig; +export class BaseHttpRequest { + readonly openApiConfig: OpenAPIConfig; + + constructor(openApiConfig: OpenAPIConfig) { + this.openApiConfig = openApiConfig; + } + + async request(options: ApiRequestOptions): Promise { + throw new Error('Not Implemented'); + } +}" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/core/FetchHttpRequest.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import { ApiError } from './ApiError'; +import type { ApiRequestOptions } from './ApiRequestOptions'; +import type { ApiResult } from './ApiResult'; +import type { OpenAPIConfig } from './OpenAPI'; +import { BaseHttpRequest } from './BaseHttpRequest'; + +function isDefined(value: T | null | undefined): value is Exclude { + return value !== undefined && value !== null; +} + +function isString(value: any): value is string { + return typeof value === 'string'; +} + +function isStringWithValue(value: any): value is string { + return isString(value) && value !== ''; +} + +function isBlob(value: any): value is Blob { + return value instanceof Blob; +} + +function getQueryString(params: Record): string { + const qs: string[] = []; + Object.keys(params).forEach(key => { + const value = params[key]; + if (isDefined(value)) { + 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 ''; +} + +function getUrl(options: ApiRequestOptions, config: OpenAPIConfig): string { + const path = options.path.replace(/[:]/g, '_'); + const url = \`\${config.BASE}\${path}\`; + + if (options.query) { + return \`\${url}\${getQueryString(options.query)}\`; + } + return url; +} + +function getFormData(params: Record): FormData { + const formData = new FormData(); + Object.keys(params).forEach(key => { + const value = params[key]; + if (isDefined(value)) { + formData.append(key, value); + } + }); + return formData; +} + +type Resolver = (options: ApiRequestOptions) => Promise; + +async function resolve(options: ApiRequestOptions, resolver?: T | Resolver): Promise { + if (typeof resolver === 'function') { + return (resolver as Resolver)(options); + } + return resolver; +} + +async function getHeaders(options: ApiRequestOptions, config: OpenAPIConfig): Promise { + const token = await resolve(options, config.TOKEN); + const username = await resolve(options, config.USERNAME); + const password = await resolve(options, config.PASSWORD); + const defaultHeaders = await resolve(options, config.HEADERS); + + const headers = new Headers({ + Accept: 'application/json', + ...defaultHeaders, + ...options.headers, + }); + + if (isStringWithValue(token)) { + headers.append('Authorization', \`Bearer \${token}\`); + } + + if (isStringWithValue(username) && isStringWithValue(password)) { + const credentials = btoa(\`\${username}:\${password}\`); + headers.append('Authorization', \`Basic \${credentials}\`); + } + + if (options.body) { + if (options.mediaType) { + headers.append('Content-Type', options.mediaType); + } else if (isBlob(options.body)) { + headers.append('Content-Type', options.body.type || 'application/octet-stream'); + } else if (isString(options.body)) { + headers.append('Content-Type', 'text/plain'); + } else { + headers.append('Content-Type', 'application/json'); + } + } + return headers; +} + +function getRequestBody(options: ApiRequestOptions): BodyInit | undefined { + if (options.formData) { + return getFormData(options.formData); + } + if (options.body) { + if (options.mediaType?.includes('/json')) { + return JSON.stringify(options.body) + } else if (isString(options.body) || isBlob(options.body)) { + return options.body; + } else { + return JSON.stringify(options.body); + } + } + return undefined; +} + +async function sendRequest(options: ApiRequestOptions, config: OpenAPIConfig, url: string): Promise { + const request: RequestInit = { + method: options.method, + headers: await getHeaders(options, config), + body: getRequestBody(options), + }; + if (config.WITH_CREDENTIALS) { + request.credentials = 'include'; + } + return await fetch(url, request); +} + +function getResponseHeader(response: Response, responseHeader?: string): string | null { + if (responseHeader) { + const content = response.headers.get(responseHeader); + if (isString(content)) { + return content; + } + } + return null; +} + +async function getResponseBody(response: Response): Promise { + try { + const contentType = response.headers.get('Content-Type'); + if (contentType) { + const isJSON = contentType.toLowerCase().startsWith('application/json'); + if (isJSON) { + return await response.json(); + } else { + return await response.text(); + } + } + } catch (error) { + console.error(error); + } + return null; +} + +function catchErrors(options: ApiRequestOptions, result: ApiResult): void { + const errors: Record = { + 400: 'Bad Request', + 401: 'Unauthorized', + 403: 'Forbidden', + 404: 'Not Found', + 500: 'Internal Server Error', + 502: 'Bad Gateway', + 503: 'Service Unavailable', + ...options.errors, + } + + const error = errors[result.status]; + if (error) { + throw new ApiError(result, error); + } + + if (!result.ok) { + throw new ApiError(result, 'Generic Error'); + } +} +export class FetchHttpRequest extends BaseHttpRequest { constructor(openApiConfig: OpenAPIConfig) { - this.openApiConfig = openApiConfig; + super(openApiConfig); } + /** + * Request using fetch client + * @param options The request options from the the service + * @returns ApiResult + * @throws ApiError + */ async request(options: ApiRequestOptions): Promise { - throw new Error('Not Implemented'); + const url = getUrl(options, this.openApiConfig); + const response = await sendRequest(options, this.openApiConfig, url); + const responseBody = await getResponseBody(response); + const responseHeader = getResponseHeader(response, options.responseHeader); + + const result: ApiResult = { + url, + ok: response.ok, + status: response.status, + statusText: response.statusText, + body: responseHeader || responseBody, + }; + + catchErrors(options, result); + return result; } -}" +} +" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/core/FetchHttpRequest.ts 1`] = ` +exports[`v3 should generate with exportClient: ./test/generated/v3_client/core/NodeHttpRequest.ts 1`] = ` "/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import FormData from 'form-data'; +import fetch, { BodyInit, Headers, RequestInit, Response } from 'node-fetch'; +import { types } from 'util'; + import { ApiError } from './ApiError'; import type { ApiRequestOptions } from './ApiRequestOptions'; import type { ApiResult } from './ApiResult'; @@ -2635,8 +3317,11 @@ function isStringWithValue(value: any): value is string { return isString(value) && value !== ''; } -function isBlob(value: any): value is Blob { - return value instanceof Blob; +function isBinary(value: any): value is Buffer | ArrayBuffer | ArrayBufferView { + const isBuffer = Buffer.isBuffer(value); + const isArrayBuffer = types.isArrayBuffer(value); + const isArrayBufferView = types.isArrayBufferView(value); + return isBuffer || isArrayBuffer || isArrayBufferView; } function getQueryString(params: Record): string { @@ -2706,15 +3391,15 @@ async function getHeaders(options: ApiRequestOptions, config: OpenAPIConfig): Pr } if (isStringWithValue(username) && isStringWithValue(password)) { - const credentials = btoa(\`\${username}:\${password}\`); + const credentials = Buffer.from(\`\${username}:\${password}\`).toString('base64'); headers.append('Authorization', \`Basic \${credentials}\`); } if (options.body) { if (options.mediaType) { headers.append('Content-Type', options.mediaType); - } else if (isBlob(options.body)) { - headers.append('Content-Type', options.body.type || 'application/octet-stream'); + } else if (isBinary(options.body)) { + headers.append('Content-Type', 'application/octet-stream'); } else if (isString(options.body)) { headers.append('Content-Type', 'text/plain'); } else { @@ -2731,7 +3416,7 @@ function getRequestBody(options: ApiRequestOptions): BodyInit | undefined { if (options.body) { if (options.mediaType?.includes('/json')) { return JSON.stringify(options.body) - } else if (isString(options.body) || isBlob(options.body)) { + } else if (isString(options.body) || isBinary(options.body)) { return options.body; } else { return JSON.stringify(options.body); @@ -2746,9 +3431,6 @@ async function sendRequest(options: ApiRequestOptions, config: OpenAPIConfig, ur headers: await getHeaders(options, config), body: getRequestBody(options), }; - if (config.WITH_CREDENTIALS) { - request.credentials = 'include'; - } return await fetch(url, request); } @@ -2801,13 +3483,13 @@ function catchErrors(options: ApiRequestOptions, result: ApiResult): void { } } -export class FetchHttpRequest extends BaseHttpRequest { +export class NodeHttpRequest extends BaseHttpRequest { constructor(openApiConfig: OpenAPIConfig) { super(openApiConfig); } /** - * Request using fetch client + * Request using node-fetch client * @param options The request options from the the service * @returns ApiResult * @throws ApiError @@ -2854,6 +3536,240 @@ export type OpenAPIConfig = { " `; +exports[`v3 should generate with exportClient: ./test/generated/v3_client/core/XhrHttpRequest.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import { ApiError } from './ApiError'; +import type { ApiRequestOptions } from './ApiRequestOptions'; +import type { ApiResult } from './ApiResult'; +import type { OpenAPIConfig } from './OpenAPI'; +import { BaseHttpRequest } from './BaseHttpRequest'; + + +function isDefined(value: T | null | undefined): value is Exclude { + return value !== undefined && value !== null; +} + +function isString(value: any): value is string { + return typeof value === 'string'; +} + +function isStringWithValue(value: any): value is string { + return isString(value) && value !== ''; +} + +function isBlob(value: any): value is Blob { + return value instanceof Blob; +} + +function isSuccess(status: number): boolean { + return status >= 200 && status < 300; +} + +function getQueryString(params: Record): string { + const qs: string[] = []; + Object.keys(params).forEach(key => { + const value = params[key]; + if (isDefined(value)) { + 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 ''; +} + +function getUrl(options: ApiRequestOptions, config: OpenAPIConfig): string { + const path = options.path.replace(/[:]/g, '_'); + const url = \`\${config.BASE}\${path}\`; + + if (options.query) { + return \`\${url}\${getQueryString(options.query)}\`; + } + return url; +} + +function getFormData(params: Record): FormData { + const formData = new FormData(); + Object.keys(params).forEach(key => { + const value = params[key]; + if (isDefined(value)) { + formData.append(key, value); + } + }); + return formData; +} + +type Resolver = (options: ApiRequestOptions) => Promise; + +async function resolve(options: ApiRequestOptions, resolver?: T | Resolver): Promise { + if (typeof resolver === 'function') { + return (resolver as Resolver)(options); + } + return resolver; +} + +async function getHeaders(options: ApiRequestOptions, config: OpenAPIConfig): Promise { + const token = await resolve(options, config.TOKEN); + const username = await resolve(options, config.USERNAME); + const password = await resolve(options, config.PASSWORD); + const defaultHeaders = await resolve(options, config.HEADERS); + + const headers = new Headers({ + Accept: 'application/json', + ...defaultHeaders, + ...options.headers, + }); + + if (isStringWithValue(token)) { + headers.append('Authorization', \`Bearer \${token}\`); + } + + if (isStringWithValue(username) && isStringWithValue(password)) { + const credentials = btoa(\`\${username}:\${password}\`); + headers.append('Authorization', \`Basic \${credentials}\`); + } + + if (options.body) { + if (options.mediaType) { + headers.append('Content-Type', options.mediaType); + } else if (isBlob(options.body)) { + headers.append('Content-Type', options.body.type || 'application/octet-stream'); + } else if (isString(options.body)) { + headers.append('Content-Type', 'text/plain'); + } else { + headers.append('Content-Type', 'application/json'); + } + } + return headers; +} + +function getRequestBody(options: ApiRequestOptions): any { + if (options.formData) { + return getFormData(options.formData); + } + if (options.body) { + if (options.mediaType?.includes('/json')) { + return JSON.stringify(options.body) + } else if (isString(options.body) || isBlob(options.body)) { + return options.body; + } else { + return JSON.stringify(options.body); + } + } + return undefined; +} + +async function sendRequest(options: ApiRequestOptions, config: OpenAPIConfig, url: string): Promise { + + const xhr = new XMLHttpRequest(); + xhr.open(options.method, url, true); + xhr.withCredentials = config.WITH_CREDENTIALS ?? false; + + const headers = await getHeaders(options, config); + headers.forEach((value: string, key: string) => { + xhr.setRequestHeader(key, value); + }); + + return new Promise(resolve => { + xhr.onreadystatechange = () => { + if (xhr.readyState === XMLHttpRequest.DONE) { + resolve(xhr); + } + }; + xhr.send(getRequestBody(options)); + }); +} + +function getResponseHeader(xhr: XMLHttpRequest, responseHeader?: string): string | null { + if (responseHeader) { + const content = xhr.getResponseHeader(responseHeader); + if (isString(content)) { + return content; + } + } + return null; +} + +function getResponseBody(xhr: XMLHttpRequest): any { + try { + const contentType = xhr.getResponseHeader('Content-Type'); + if (contentType) { + const isJSON = contentType.toLowerCase().startsWith('application/json'); + if (isJSON) { + return JSON.parse(xhr.responseText); + } else { + return xhr.responseText; + } + } + } catch (error) { + console.error(error); + } + return null; +} + +function catchErrors(options: ApiRequestOptions, result: ApiResult): void { + const errors: Record = { + 400: 'Bad Request', + 401: 'Unauthorized', + 403: 'Forbidden', + 404: 'Not Found', + 500: 'Internal Server Error', + 502: 'Bad Gateway', + 503: 'Service Unavailable', + ...options.errors, + } + + const error = errors[result.status]; + if (error) { + throw new ApiError(result, error); + } + + if (!result.ok) { + throw new ApiError(result, 'Generic Error'); + } +} + +export class XhrHttpRequest extends BaseHttpRequest { + constructor(openApiConfig: OpenAPIConfig) { + super(openApiConfig); + } + + /** + * Request using XHR client + * @param options The request options from the the service + * @returns ApiResult + * @throws ApiError + */ + async request(options: ApiRequestOptions): Promise { + const url = getUrl(options, this.openApiConfig); + const response = await sendRequest(options, this.openApiConfig, url); + const responseBody = getResponseBody(response); + const responseHeader = getResponseHeader(response, options.responseHeader); + + const result: ApiResult = { + url, + ok: isSuccess(response.status), + status: response.status, + statusText: response.statusText, + body: responseHeader || responseBody, + }; + + catchErrors(options, result); + return result; + } +} +" +`; + exports[`v3 should generate with exportClient: ./test/generated/v3_client/index.ts 1`] = ` "/* istanbul ignore file */ /* tslint:disable */ From 163b358481683c99b332caa2b9f3907f57fa32ca Mon Sep 17 00:00:00 2001 From: lub0v-parsable Date: Thu, 5 Aug 2021 12:27:03 -0700 Subject: [PATCH 03/11] [no-jira] - update header --- package.json | 2 +- src/templates/partials/header.hbs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 65101289d..1451c1bc3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@parsable/openapi-typescript-codegen", - "version": "0.0.1-alpha-2", + "version": "0.0.1", "description": "Library that generates Typescript clients based on the OpenAPI specification.", "author": "Ferdi Koomen", "homepage": "https://github.com/ferdikoomen/openapi-typescript-codegen", diff --git a/src/templates/partials/header.hbs b/src/templates/partials/header.hbs index d592379e7..fd4ab3ad3 100644 --- a/src/templates/partials/header.hbs +++ b/src/templates/partials/header.hbs @@ -1,3 +1,4 @@ +/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ From 131d3f542213a68df97c22633d02575b881b58d9 Mon Sep 17 00:00:00 2001 From: lub0v-parsable Date: Mon, 9 Aug 2021 12:53:24 -0700 Subject: [PATCH 04/11] PE-2152 - export index files --- package.json | 2 +- src/templates/core/index.hbs | 13 + src/templates/exportAppClient.hbs | 9 +- src/templates/index.hbs | 42 +- src/templates/{ => models}/exportModel.hbs | 0 src/templates/models/index.hbs | 13 + src/templates/{ => schemas}/exportSchema.hbs | 0 src/templates/schemas/index.hbs | 5 + .../{ => services}/exportService.hbs | 12 +- src/templates/services/index.hbs | 5 + src/utils/registerHandlebarTemplates.spec.ts | 9 +- src/utils/registerHandlebarTemplates.ts | 34 +- src/utils/writeClient.spec.ts | 19 +- src/utils/writeClientCore.spec.ts | 16 +- src/utils/writeClientCore.ts | 7 +- src/utils/writeClientIndex.spec.ts | 14 +- src/utils/writeClientModels.spec.ts | 13 +- src/utils/writeClientModels.ts | 4 +- src/utils/writeClientSchemas.spec.ts | 13 +- src/utils/writeClientSchemas.ts | 4 +- src/utils/writeClientServices.spec.ts | 13 +- src/utils/writeClientServices.ts | 5 +- test/__snapshots__/index.client.spec.js.snap | 2291 ++++++----------- test/__snapshots__/index.spec.js.snap | 1325 ++++++---- 24 files changed, 1848 insertions(+), 2020 deletions(-) create mode 100644 src/templates/core/index.hbs rename src/templates/{ => models}/exportModel.hbs (100%) create mode 100644 src/templates/models/index.hbs rename src/templates/{ => schemas}/exportSchema.hbs (100%) create mode 100644 src/templates/schemas/index.hbs rename src/templates/{ => services}/exportService.hbs (92%) create mode 100644 src/templates/services/index.hbs diff --git a/package.json b/package.json index 1451c1bc3..5c6ac00c3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@parsable/openapi-typescript-codegen", - "version": "0.0.1", + "version": "0.0.2-alpha-4", "description": "Library that generates Typescript clients based on the OpenAPI specification.", "author": "Ferdi Koomen", "homepage": "https://github.com/ferdikoomen/openapi-typescript-codegen", diff --git a/src/templates/core/index.hbs b/src/templates/core/index.hbs new file mode 100644 index 000000000..d04f13142 --- /dev/null +++ b/src/templates/core/index.hbs @@ -0,0 +1,13 @@ +{{>header}} + +export { ApiError } from './ApiError'; +export type { ApiRequestOptions } from './ApiRequestOptions'; +export type { ApiResult } from './ApiResult'; +{{#if @root.exportClient}} +export { BaseHttpRequest } from './BaseHttpRequest'; +export { {{{httpRequestName}}} } from './{{{httpRequestName}}}'; +export type { OpenAPIConfig } from './OpenAPI'; +{{else}} +export { OpenAPI } from './OpenAPI'; +export { request } from './request'; +{{/if}} diff --git a/src/templates/exportAppClient.hbs b/src/templates/exportAppClient.hbs index 3cb7417bc..c9ac6c9d2 100644 --- a/src/templates/exportAppClient.hbs +++ b/src/templates/exportAppClient.hbs @@ -1,12 +1,13 @@ {{>header}} -import { BaseHttpRequest } from './core/BaseHttpRequest'; -import type { OpenAPIConfig } from './core/OpenAPI'; -import { {{{httpClientRequest}}} } from './core/{{{httpClientRequest}}}'; +import { BaseHttpRequest, {{{httpClientRequest}}} } from './core'; +import type { OpenAPIConfig } from './core'; {{#if services}} +import { {{#each services}} -import { {{{name}}} } from './services/{{{name}}}'; + {{{name}}}, {{/each}} +} from './services'; {{/if}} export class {{{clientName}}} { diff --git a/src/templates/index.hbs b/src/templates/index.hbs index cb5b6b0b4..3b8deb6f9 100644 --- a/src/templates/index.hbs +++ b/src/templates/index.hbs @@ -1,48 +1,16 @@ {{>header}} -{{#if @root.exportCore}} -export { ApiError } from './core/ApiError'; -{{#if @root.exportClient}} -export type { ApiRequestOptions } from './core/ApiRequestOptions'; -export type { ApiResult } from './core/ApiResult'; -export type { OpenAPIConfig } from './core/OpenAPI'; -export { BaseHttpRequest } from './core/BaseHttpRequest'; -export { {{{httpRequestName}}} } from './core/{{{httpRequestName}}}'; -{{else}} -export { OpenAPI } from './core/OpenAPI'; -{{/if}} +{{#if @root.exportCore}} +export * from './core'; {{/if}} {{#if @root.exportModels}} -{{#if models}} - -{{#each models}} -{{#if enum}} -export { {{{name}}} } from './models/{{{name}}}'; -{{else if @root.useUnionTypes}} -export type { {{{name}}} } from './models/{{{name}}}'; -{{else if enums}} -export { {{{name}}} } from './models/{{{name}}}'; -{{else}} -export type { {{{name}}} } from './models/{{{name}}}'; -{{/if}} -{{/each}} -{{/if}} +export * from './models'; {{/if}} {{#if @root.exportSchemas}} -{{#if models}} - -{{#each models}} -export { ${{{name}}} } from './schemas/${{{name}}}'; -{{/each}} -{{/if}} +export * from './schemas'; {{/if}} {{#if @root.exportServices}} -{{#if services}} - -{{#each services}} -export { {{{name}}} } from './services/{{{name}}}'; -{{/each}} -{{/if}} +export * from './services'; {{/if}} {{#if @root.exportClient}} diff --git a/src/templates/exportModel.hbs b/src/templates/models/exportModel.hbs similarity index 100% rename from src/templates/exportModel.hbs rename to src/templates/models/exportModel.hbs diff --git a/src/templates/models/index.hbs b/src/templates/models/index.hbs new file mode 100644 index 000000000..b911ec131 --- /dev/null +++ b/src/templates/models/index.hbs @@ -0,0 +1,13 @@ +{{>header}} + +{{#each models}} +{{#if enum}} +export { {{{name}}} } from './{{{name}}}'; +{{else if @root.useUnionTypes}} +export type { {{{name}}} } from './{{{name}}}'; +{{else if enums}} +export type { {{{name}}} } from './{{{name}}}'; +{{else}} +export type { {{{name}}} } from './{{{name}}}'; +{{/if}} +{{/each}} diff --git a/src/templates/exportSchema.hbs b/src/templates/schemas/exportSchema.hbs similarity index 100% rename from src/templates/exportSchema.hbs rename to src/templates/schemas/exportSchema.hbs diff --git a/src/templates/schemas/index.hbs b/src/templates/schemas/index.hbs new file mode 100644 index 000000000..c4a701b5b --- /dev/null +++ b/src/templates/schemas/index.hbs @@ -0,0 +1,5 @@ +{{>header}} + +{{#each models}} +export { ${{{name}}} } from './${{{name}}}'; +{{/each}} diff --git a/src/templates/exportService.hbs b/src/templates/services/exportService.hbs similarity index 92% rename from src/templates/exportService.hbs rename to src/templates/services/exportService.hbs index 7e0f2a134..2eab5f787 100644 --- a/src/templates/exportService.hbs +++ b/src/templates/services/exportService.hbs @@ -1,17 +1,21 @@ {{>header}} {{#if imports}} +import type { {{#each imports}} -import type { {{{this}}} } from '../models/{{{this}}}'; + {{{this}}}, {{/each}} +} from '../models'; {{/if}} {{#if @root.exportClient}} -import { BaseHttpRequest } from '../core/BaseHttpRequest'; +import { BaseHttpRequest } from '../core'; {{else}} -import { request as __request } from '../core/request'; +import { + request as __request, {{#if @root.useVersion}} -import { OpenAPI } from '../core/OpenAPI'; + OpenAPI, {{/if}} +} from '../core'; {{/if}} export class {{{name}}} { diff --git a/src/templates/services/index.hbs b/src/templates/services/index.hbs new file mode 100644 index 000000000..3b7b27a9e --- /dev/null +++ b/src/templates/services/index.hbs @@ -0,0 +1,5 @@ +{{>header}} + +{{#each services}} +export { {{{name}}} } from './{{{name}}}'; +{{/each}} diff --git a/src/utils/registerHandlebarTemplates.spec.ts b/src/utils/registerHandlebarTemplates.spec.ts index ff254cc00..1aea8fc12 100644 --- a/src/utils/registerHandlebarTemplates.spec.ts +++ b/src/utils/registerHandlebarTemplates.spec.ts @@ -9,9 +9,12 @@ describe('registerHandlebarTemplates', () => { useUnionTypes: false, }); expect(templates.index).toBeDefined(); - expect(templates.exports.model).toBeDefined(); - expect(templates.exports.schema).toBeDefined(); - expect(templates.exports.service).toBeDefined(); + expect(templates.models.model).toBeDefined(); + expect(templates.models.index).toBeDefined(); + expect(templates.services.service).toBeDefined(); + expect(templates.services.index).toBeDefined(); + expect(templates.schemas.schema).toBeDefined(); + expect(templates.schemas.index).toBeDefined(); expect(templates.core.settings).toBeDefined(); expect(templates.core.apiError).toBeDefined(); expect(templates.core.apiRequestOptions).toBeDefined(); diff --git a/src/utils/registerHandlebarTemplates.ts b/src/utils/registerHandlebarTemplates.ts index 44762d5a1..e222709df 100644 --- a/src/utils/registerHandlebarTemplates.ts +++ b/src/utils/registerHandlebarTemplates.ts @@ -22,6 +22,7 @@ import functionIsString from '../templates/core/functions/isString.hbs'; import functionIsStringWithValue from '../templates/core/functions/isStringWithValue.hbs'; import functionIsSuccess from '../templates/core/functions/isSuccess.hbs'; import functionResolve from '../templates/core/functions/resolve.hbs'; +import templateCoreIndex from '../templates/core/index.hbs'; import nodeGetHeaders from '../templates/core/node/getHeaders.hbs'; import nodeGetRequestBody from '../templates/core/node/getRequestBody.hbs'; import nodeGetResponseBody from '../templates/core/node/getResponseBody.hbs'; @@ -37,10 +38,9 @@ import xhrGetResponseHeader from '../templates/core/xhr/getResponseHeader.hbs'; import xhrRequest from '../templates/core/xhr/request.hbs'; import xhrSendRequest from '../templates/core/xhr/sendRequest.hbs'; import templateAppClient from '../templates/exportAppClient.hbs'; -import templateExportModel from '../templates/exportModel.hbs'; -import templateExportSchema from '../templates/exportSchema.hbs'; -import templateExportService from '../templates/exportService.hbs'; import templateIndex from '../templates/index.hbs'; +import templateExportModel from '../templates/models/exportModel.hbs'; +import templateExportModelIndex from '../templates/models/index.hbs'; import partialBase from '../templates/partials/base.hbs'; import partialExportComposition from '../templates/partials/exportComposition.hbs'; import partialExportEnum from '../templates/partials/exportEnum.hbs'; @@ -68,17 +68,29 @@ import partialTypeInterface from '../templates/partials/typeInterface.hbs'; import partialTypeIntersection from '../templates/partials/typeIntersection.hbs'; import partialTypeReference from '../templates/partials/typeReference.hbs'; import partialTypeUnion from '../templates/partials/typeUnion.hbs'; +import templateExportSchema from '../templates/schemas/exportSchema.hbs'; +import templateExportSchemaIndex from '../templates/schemas/index.hbs'; +import templateExportService from '../templates/services/exportService.hbs'; +import templateExportServiceIndex from '../templates/services/index.hbs'; import { registerHandlebarHelpers } from './registerHandlebarHelpers'; export interface Templates { index: Handlebars.TemplateDelegate; client: Handlebars.TemplateDelegate; - exports: { + models: { model: Handlebars.TemplateDelegate; - schema: Handlebars.TemplateDelegate; + index: Handlebars.TemplateDelegate; + }; + services: { service: Handlebars.TemplateDelegate; + index: Handlebars.TemplateDelegate; + }; + schemas: { + schema: Handlebars.TemplateDelegate; + index: Handlebars.TemplateDelegate; }; core: { + index: Handlebars.TemplateDelegate; settings: Handlebars.TemplateDelegate; apiError: Handlebars.TemplateDelegate; apiRequestOptions: Handlebars.TemplateDelegate; @@ -104,12 +116,20 @@ export function registerHandlebarTemplates(root: { httpClient: HttpClient; useOp const templates: Templates = { index: Handlebars.template(templateIndex), client: Handlebars.template(templateAppClient), - exports: { + models: { model: Handlebars.template(templateExportModel), - schema: Handlebars.template(templateExportSchema), + index: Handlebars.template(templateExportModelIndex), + }, + services: { service: Handlebars.template(templateExportService), + index: Handlebars.template(templateExportServiceIndex), + }, + schemas: { + schema: Handlebars.template(templateExportSchema), + index: Handlebars.template(templateExportSchemaIndex), }, core: { + index: Handlebars.template(templateCoreIndex), settings: Handlebars.template(templateCoreSettings), apiError: Handlebars.template(templateCoreApiError), apiRequestOptions: Handlebars.template(templateCoreApiRequestOptions), diff --git a/src/utils/writeClient.spec.ts b/src/utils/writeClient.spec.ts index 649ceab4b..a91b53419 100644 --- a/src/utils/writeClient.spec.ts +++ b/src/utils/writeClient.spec.ts @@ -18,18 +18,31 @@ describe('writeClient', () => { const templates: Templates = { index: () => 'index', client: () => 'client', - exports: { + models: { model: () => 'model', - schema: () => 'schema', + index: () => 'modelIndex', + }, + services: { service: () => 'service', + index: () => 'serviceIndex', + }, + schemas: { + schema: () => 'schema', + index: () => 'schemaIndex', }, core: { + index: () => 'coreIndex', settings: () => 'settings', apiError: () => 'apiError', apiRequestOptions: () => 'apiRequestOptions', apiResult: () => 'apiResult', baseHttpRequest: () => 'baseHttpRequest', - request: () => 'concreteHttpRequest', + request: () => 'request', + httpRequest: { + fetch: () => 'fetchRequest', + node: () => 'nodeRequest', + xhr: () => 'xhrRequest', + }, }, }; diff --git a/src/utils/writeClientCore.spec.ts b/src/utils/writeClientCore.spec.ts index ea2d4de2b..e2c86e22c 100644 --- a/src/utils/writeClientCore.spec.ts +++ b/src/utils/writeClientCore.spec.ts @@ -17,12 +17,20 @@ describe('writeClientCore', () => { const templates: Templates = { index: () => 'index', client: () => 'client', - exports: { + models: { model: () => 'model', - schema: () => 'schema', + index: () => 'modelIndex', + }, + services: { service: () => 'service', + index: () => 'serviceIndex', + }, + schemas: { + schema: () => 'schema', + index: () => 'schemaIndex', }, core: { + index: () => 'coreIndex', settings: () => 'settings', apiError: () => 'apiError', apiRequestOptions: () => 'apiRequestOptions', @@ -45,6 +53,7 @@ describe('writeClientCore', () => { expect(writeFile).toBeCalledWith('/ApiRequestOptions.ts', 'apiRequestOptions'); expect(writeFile).toBeCalledWith('/ApiResult.ts', 'apiResult'); expect(writeFile).toBeCalledWith('/request.ts', 'request'); + expect(writeFile).toBeCalledWith('/index.ts', 'coreIndex'); }); it('should write to filesystem when exportClient true', async () => { @@ -56,7 +65,6 @@ describe('writeClientCore', () => { expect(writeFile).toBeCalledWith('/ApiResult.ts', 'apiResult'); expect(writeFile).toBeCalledWith('/BaseHttpRequest.ts', 'baseHttpRequest'); expect(writeFile).toBeCalledWith('/FetchHttpRequest.ts', 'fetchRequest'); - expect(writeFile).toBeCalledWith('/NodeHttpRequest.ts', 'nodeRequest'); - expect(writeFile).toBeCalledWith('/XhrHttpRequest.ts', 'xhrRequest'); + expect(writeFile).toBeCalledWith('/index.ts', 'coreIndex'); }); }); diff --git a/src/utils/writeClientCore.ts b/src/utils/writeClientCore.ts index 11db70c2c..f76c62ae7 100644 --- a/src/utils/writeClientCore.ts +++ b/src/utils/writeClientCore.ts @@ -21,6 +21,7 @@ export async function writeClientCore(client: Client, templates: Templates, outp server: client.server, version: client.version, exportClient, + httpRequestName: getHttpRequestName(httpClient), }; await writeFile(resolve(outputPath, 'OpenAPI.ts'), templates.core.settings(context)); @@ -29,9 +30,7 @@ export async function writeClientCore(client: Client, templates: Templates, outp await writeFile(resolve(outputPath, 'ApiResult.ts'), templates.core.apiResult({})); if (exportClient) { await writeFile(resolve(outputPath, 'BaseHttpRequest.ts'), templates.core.baseHttpRequest({})); - for (const client of Object.values(HttpClient)) { - await writeFile(resolve(outputPath, `${getHttpRequestName(client)}.ts`), templates.core.httpRequest[client](context)); - } + await writeFile(resolve(outputPath, `${getHttpRequestName(httpClient)}.ts`), templates.core.httpRequest[httpClient](context)); } else { await writeFile(resolve(outputPath, `request.ts`), templates.core.request(context)); } @@ -44,4 +43,6 @@ export async function writeClientCore(client: Client, templates: Templates, outp } await copyFile(requestFile, resolve(outputPath, 'request.ts')); } + + await writeFile(resolve(outputPath, 'index.ts'), templates.core.index(context)); } diff --git a/src/utils/writeClientIndex.spec.ts b/src/utils/writeClientIndex.spec.ts index f657b7926..583bf070e 100644 --- a/src/utils/writeClientIndex.spec.ts +++ b/src/utils/writeClientIndex.spec.ts @@ -18,17 +18,25 @@ describe('writeClientIndex', () => { const templates: Templates = { index: () => 'index', client: () => 'client', - exports: { + models: { model: () => 'model', - schema: () => 'schema', + index: () => 'modelIndex', + }, + services: { service: () => 'service', + index: () => 'serviceIndex', + }, + schemas: { + schema: () => 'schema', + index: () => 'schemaIndex', }, core: { + index: () => 'coreIndex', settings: () => 'settings', apiError: () => 'apiError', apiRequestOptions: () => 'apiRequestOptions', apiResult: () => 'apiResult', - baseHttpRequest: () => 'baseHttpClient', + baseHttpRequest: () => 'baseHttpRequest', request: () => 'request', httpRequest: { fetch: () => 'fetchRequest', diff --git a/src/utils/writeClientModels.spec.ts b/src/utils/writeClientModels.spec.ts index 75c547f40..207a371c3 100644 --- a/src/utils/writeClientModels.spec.ts +++ b/src/utils/writeClientModels.spec.ts @@ -31,12 +31,20 @@ describe('writeClientModels', () => { const templates: Templates = { index: () => 'index', client: () => 'client', - exports: { + models: { model: () => 'model', - schema: () => 'schema', + index: () => 'modelIndex', + }, + services: { service: () => 'service', + index: () => 'serviceIndex', + }, + schemas: { + schema: () => 'schema', + index: () => 'schemaIndex', }, core: { + index: () => 'coreIndex', settings: () => 'settings', apiError: () => 'apiError', apiRequestOptions: () => 'apiRequestOptions', @@ -54,5 +62,6 @@ describe('writeClientModels', () => { await writeClientModels(models, templates, '/', HttpClient.FETCH, false); expect(writeFile).toBeCalledWith('/MyModel.ts', 'model'); + expect(writeFile).toBeCalledWith('/index.ts', 'modelIndex'); }); }); diff --git a/src/utils/writeClientModels.ts b/src/utils/writeClientModels.ts index 7df9cdc46..ee22edd8e 100644 --- a/src/utils/writeClientModels.ts +++ b/src/utils/writeClientModels.ts @@ -5,6 +5,7 @@ import { HttpClient } from '../HttpClient'; import { writeFile } from './fileSystem'; import { format } from './format'; import { Templates } from './registerHandlebarTemplates'; +import { sortModelsByName } from './sortModelsByName'; /** * Generate Models using the Handlebar template and write to disk. @@ -17,11 +18,12 @@ import { Templates } from './registerHandlebarTemplates'; export async function writeClientModels(models: Model[], templates: Templates, outputPath: string, httpClient: HttpClient, useUnionTypes: boolean): Promise { for (const model of models) { const file = resolve(outputPath, `${model.name}.ts`); - const templateResult = templates.exports.model({ + const templateResult = templates.models.model({ ...model, httpClient, useUnionTypes, }); await writeFile(file, format(templateResult)); } + await writeFile(resolve(outputPath, `index.ts`), templates.models.index({ models: sortModelsByName(models) })); } diff --git a/src/utils/writeClientSchemas.spec.ts b/src/utils/writeClientSchemas.spec.ts index f2bab8bed..8bc152056 100644 --- a/src/utils/writeClientSchemas.spec.ts +++ b/src/utils/writeClientSchemas.spec.ts @@ -31,12 +31,20 @@ describe('writeClientSchemas', () => { const templates: Templates = { index: () => 'index', client: () => 'client', - exports: { + models: { model: () => 'model', - schema: () => 'schema', + index: () => 'modelIndex', + }, + services: { service: () => 'service', + index: () => 'serviceIndex', + }, + schemas: { + schema: () => 'schema', + index: () => 'schemaIndex', }, core: { + index: () => 'coreIndex', settings: () => 'settings', apiError: () => 'apiError', apiRequestOptions: () => 'apiRequestOptions', @@ -54,5 +62,6 @@ describe('writeClientSchemas', () => { await writeClientSchemas(models, templates, '/', HttpClient.FETCH, false); expect(writeFile).toBeCalledWith('/$MyModel.ts', 'schema'); + expect(writeFile).toBeCalledWith('/index.ts', 'schemaIndex'); }); }); diff --git a/src/utils/writeClientSchemas.ts b/src/utils/writeClientSchemas.ts index 048558d9d..b6c241d04 100644 --- a/src/utils/writeClientSchemas.ts +++ b/src/utils/writeClientSchemas.ts @@ -5,6 +5,7 @@ import { HttpClient } from '../HttpClient'; import { writeFile } from './fileSystem'; import { format } from './format'; import { Templates } from './registerHandlebarTemplates'; +import { sortModelsByName } from './sortModelsByName'; /** * Generate Schemas using the Handlebar template and write to disk. @@ -17,11 +18,12 @@ import { Templates } from './registerHandlebarTemplates'; export async function writeClientSchemas(models: Model[], templates: Templates, outputPath: string, httpClient: HttpClient, useUnionTypes: boolean): Promise { for (const model of models) { const file = resolve(outputPath, `$${model.name}.ts`); - const templateResult = templates.exports.schema({ + const templateResult = templates.schemas.schema({ ...model, httpClient, useUnionTypes, }); await writeFile(file, format(templateResult)); } + await writeFile(resolve(outputPath, `index.ts`), templates.schemas.index({ models: sortModelsByName(models) })); } diff --git a/src/utils/writeClientServices.spec.ts b/src/utils/writeClientServices.spec.ts index 4230aca8b..6e44dc2b7 100644 --- a/src/utils/writeClientServices.spec.ts +++ b/src/utils/writeClientServices.spec.ts @@ -19,12 +19,20 @@ describe('writeClientServices', () => { const templates: Templates = { index: () => 'index', client: () => 'client', - exports: { + models: { model: () => 'model', - schema: () => 'schema', + index: () => 'modelIndex', + }, + services: { service: () => 'service', + index: () => 'serviceIndex', + }, + schemas: { + schema: () => 'schema', + index: () => 'schemaIndex', }, core: { + index: () => 'coreIndex', settings: () => 'settings', apiError: () => 'apiError', apiRequestOptions: () => 'apiRequestOptions', @@ -42,5 +50,6 @@ describe('writeClientServices', () => { await writeClientServices(services, templates, '/', HttpClient.FETCH, false, false, false); expect(writeFile).toBeCalledWith('/MyService.ts', 'service'); + expect(writeFile).toBeCalledWith('/index.ts', 'serviceIndex'); }); }); diff --git a/src/utils/writeClientServices.ts b/src/utils/writeClientServices.ts index 934d29bd8..7732f5e2f 100644 --- a/src/utils/writeClientServices.ts +++ b/src/utils/writeClientServices.ts @@ -6,6 +6,7 @@ import { writeFile } from './fileSystem'; import { format } from './format'; import { getHttpRequestName } from './getHttpRequestName'; import { Templates } from './registerHandlebarTemplates'; +import { sortServicesByName } from './sortServicesByName'; const VERSION_TEMPLATE_STRING = 'OpenAPI.VERSION'; @@ -31,7 +32,7 @@ export async function writeClientServices( for (const service of services) { const file = resolve(outputPath, `${service.name}.ts`); const useVersion = service.operations.some(operation => operation.path.includes(VERSION_TEMPLATE_STRING)); - const templateResult = templates.exports.service({ + const templateResult = templates.services.service({ ...service, httpClient, useUnionTypes, @@ -42,4 +43,6 @@ export async function writeClientServices( }); await writeFile(file, format(templateResult)); } + + await writeFile(resolve(outputPath, 'index.ts'), templates.services.index({ services: sortServicesByName(services) })); } diff --git a/test/__snapshots__/index.client.spec.js.snap b/test/__snapshots__/index.client.spec.js.snap index 5bebae462..e785f4fbb 100644 --- a/test/__snapshots__/index.client.spec.js.snap +++ b/test/__snapshots__/index.client.spec.js.snap @@ -1,22 +1,24 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`v2 should generate with exportClient: ./test/generated/v2_client/client.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -import { BaseHttpRequest } from './core/BaseHttpRequest'; -import type { OpenAPIConfig } from './core/OpenAPI'; -import { FetchHttpRequest } from './core/FetchHttpRequest'; -import { CollectionFormatService } from './services/CollectionFormatService'; -import { ComplexService } from './services/ComplexService'; -import { DefaultsService } from './services/DefaultsService'; -import { DuplicateService } from './services/DuplicateService'; -import { HeaderService } from './services/HeaderService'; -import { NoContentService } from './services/NoContentService'; -import { ParametersService } from './services/ParametersService'; -import { ResponseService } from './services/ResponseService'; -import { SimpleService } from './services/SimpleService'; -import { TypesService } from './services/TypesService'; +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import { BaseHttpRequest, FetchHttpRequest } from './core'; +import type { OpenAPIConfig } from './core'; +import { + CollectionFormatService, + ComplexService, + DefaultsService, + DuplicateService, + HeaderService, + NoContentService, + ParametersService, + ResponseService, + SimpleService, + TypesService, +} from './services'; export class TestClient { readonly collectionformat: CollectionFormatService; @@ -56,7 +58,8 @@ export class TestClient { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/core/ApiError.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ import type { ApiResult } from './ApiResult'; @@ -79,7 +82,8 @@ export class ApiError extends Error { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/core/ApiRequestOptions.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export type ApiRequestOptions = { @@ -97,7 +101,8 @@ export type ApiRequestOptions = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/core/ApiResult.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export type ApiResult = { @@ -110,7 +115,8 @@ export type ApiResult = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/core/BaseHttpRequest.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ import type { ApiRequestOptions } from './ApiRequestOptions'; @@ -131,7 +137,8 @@ export class BaseHttpRequest { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/core/FetchHttpRequest.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ import { ApiError } from './ApiError'; @@ -350,599 +357,59 @@ export class FetchHttpRequest extends BaseHttpRequest { " `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/core/NodeHttpRequest.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -import FormData from 'form-data'; -import fetch, { BodyInit, Headers, RequestInit, Response } from 'node-fetch'; -import { types } from 'util'; - -import { ApiError } from './ApiError'; -import type { ApiRequestOptions } from './ApiRequestOptions'; -import type { ApiResult } from './ApiResult'; -import type { OpenAPIConfig } from './OpenAPI'; -import { BaseHttpRequest } from './BaseHttpRequest'; - -function isDefined(value: T | null | undefined): value is Exclude { - return value !== undefined && value !== null; -} - -function isString(value: any): value is string { - return typeof value === 'string'; -} - -function isStringWithValue(value: any): value is string { - return isString(value) && value !== ''; -} - -function isBinary(value: any): value is Buffer | ArrayBuffer | ArrayBufferView { - const isBuffer = Buffer.isBuffer(value); - const isArrayBuffer = types.isArrayBuffer(value); - const isArrayBufferView = types.isArrayBufferView(value); - return isBuffer || isArrayBuffer || isArrayBufferView; -} - -function getQueryString(params: Record): string { - const qs: string[] = []; - Object.keys(params).forEach(key => { - const value = params[key]; - if (isDefined(value)) { - 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 ''; -} - -function getUrl(options: ApiRequestOptions, config: OpenAPIConfig): string { - const path = options.path.replace(/[:]/g, '_'); - const url = \`\${config.BASE}\${path}\`; - - if (options.query) { - return \`\${url}\${getQueryString(options.query)}\`; - } - return url; -} - -function getFormData(params: Record): FormData { - const formData = new FormData(); - Object.keys(params).forEach(key => { - const value = params[key]; - if (isDefined(value)) { - formData.append(key, value); - } - }); - return formData; -} - -type Resolver = (options: ApiRequestOptions) => Promise; - -async function resolve(options: ApiRequestOptions, resolver?: T | Resolver): Promise { - if (typeof resolver === 'function') { - return (resolver as Resolver)(options); - } - return resolver; -} - -async function getHeaders(options: ApiRequestOptions, config: OpenAPIConfig): Promise { - const token = await resolve(options, config.TOKEN); - const username = await resolve(options, config.USERNAME); - const password = await resolve(options, config.PASSWORD); - const defaultHeaders = await resolve(options, config.HEADERS); - - const headers = new Headers({ - Accept: 'application/json', - ...defaultHeaders, - ...options.headers, - }); - - if (isStringWithValue(token)) { - headers.append('Authorization', \`Bearer \${token}\`); - } - - if (isStringWithValue(username) && isStringWithValue(password)) { - const credentials = Buffer.from(\`\${username}:\${password}\`).toString('base64'); - headers.append('Authorization', \`Basic \${credentials}\`); - } - - if (options.body) { - if (options.mediaType) { - headers.append('Content-Type', options.mediaType); - } else if (isBinary(options.body)) { - headers.append('Content-Type', 'application/octet-stream'); - } else if (isString(options.body)) { - headers.append('Content-Type', 'text/plain'); - } else { - headers.append('Content-Type', 'application/json'); - } - } - return headers; -} - -function getRequestBody(options: ApiRequestOptions): BodyInit | undefined { - if (options.formData) { - return getFormData(options.formData); - } - if (options.body) { - if (options.mediaType?.includes('/json')) { - return JSON.stringify(options.body) - } else if (isString(options.body) || isBinary(options.body)) { - return options.body; - } else { - return JSON.stringify(options.body); - } - } - return undefined; -} - -async function sendRequest(options: ApiRequestOptions, config: OpenAPIConfig, url: string): Promise { - const request: RequestInit = { - method: options.method, - headers: await getHeaders(options, config), - body: getRequestBody(options), - }; - return await fetch(url, request); -} - -function getResponseHeader(response: Response, responseHeader?: string): string | null { - if (responseHeader) { - const content = response.headers.get(responseHeader); - if (isString(content)) { - return content; - } - } - return null; -} - -async function getResponseBody(response: Response): Promise { - try { - const contentType = response.headers.get('Content-Type'); - if (contentType) { - const isJSON = contentType.toLowerCase().startsWith('application/json'); - if (isJSON) { - return await response.json(); - } else { - return await response.text(); - } - } - } catch (error) { - console.error(error); - } - return null; -} - -function catchErrors(options: ApiRequestOptions, result: ApiResult): void { - const errors: Record = { - 400: 'Bad Request', - 401: 'Unauthorized', - 403: 'Forbidden', - 404: 'Not Found', - 500: 'Internal Server Error', - 502: 'Bad Gateway', - 503: 'Service Unavailable', - ...options.errors, - } - - const error = errors[result.status]; - if (error) { - throw new ApiError(result, error); - } - - if (!result.ok) { - throw new ApiError(result, 'Generic Error'); - } -} - -export class NodeHttpRequest extends BaseHttpRequest { - constructor(openApiConfig: OpenAPIConfig) { - super(openApiConfig); - } - - /** - * Request using node-fetch client - * @param options The request options from the the service - * @returns ApiResult - * @throws ApiError - */ - async request(options: ApiRequestOptions): Promise { - const url = getUrl(options, this.openApiConfig); - const response = await sendRequest(options, this.openApiConfig, url); - const responseBody = await getResponseBody(response); - const responseHeader = getResponseHeader(response, options.responseHeader); - - const result: ApiResult = { - url, - ok: response.ok, - status: response.status, - statusText: response.statusText, - body: responseHeader || responseBody, - }; - - catchErrors(options, result); - return result; - } -} -" -`; - -exports[`v2 should generate with exportClient: ./test/generated/v2_client/core/OpenAPI.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -import type { ApiRequestOptions } from './ApiRequestOptions'; - -type Resolver = (options: ApiRequestOptions) => Promise; -type Headers = Record; - -export type OpenAPIConfig = { - BASE?: string; - VERSION?: string; - WITH_CREDENTIALS?: boolean; - TOKEN?: string | Resolver; - USERNAME?: string | Resolver; - PASSWORD?: string | Resolver; - HEADERS?: Headers | Resolver; -} -" -`; - -exports[`v2 should generate with exportClient: ./test/generated/v2_client/core/XhrHttpRequest.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -import { ApiError } from './ApiError'; -import type { ApiRequestOptions } from './ApiRequestOptions'; -import type { ApiResult } from './ApiResult'; -import type { OpenAPIConfig } from './OpenAPI'; -import { BaseHttpRequest } from './BaseHttpRequest'; - - -function isDefined(value: T | null | undefined): value is Exclude { - return value !== undefined && value !== null; -} - -function isString(value: any): value is string { - return typeof value === 'string'; -} - -function isStringWithValue(value: any): value is string { - return isString(value) && value !== ''; -} - -function isBlob(value: any): value is Blob { - return value instanceof Blob; -} - -function isSuccess(status: number): boolean { - return status >= 200 && status < 300; -} - -function getQueryString(params: Record): string { - const qs: string[] = []; - Object.keys(params).forEach(key => { - const value = params[key]; - if (isDefined(value)) { - 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 ''; -} - -function getUrl(options: ApiRequestOptions, config: OpenAPIConfig): string { - const path = options.path.replace(/[:]/g, '_'); - const url = \`\${config.BASE}\${path}\`; - - if (options.query) { - return \`\${url}\${getQueryString(options.query)}\`; - } - return url; -} - -function getFormData(params: Record): FormData { - const formData = new FormData(); - Object.keys(params).forEach(key => { - const value = params[key]; - if (isDefined(value)) { - formData.append(key, value); - } - }); - return formData; -} - -type Resolver = (options: ApiRequestOptions) => Promise; - -async function resolve(options: ApiRequestOptions, resolver?: T | Resolver): Promise { - if (typeof resolver === 'function') { - return (resolver as Resolver)(options); - } - return resolver; -} - -async function getHeaders(options: ApiRequestOptions, config: OpenAPIConfig): Promise { - const token = await resolve(options, config.TOKEN); - const username = await resolve(options, config.USERNAME); - const password = await resolve(options, config.PASSWORD); - const defaultHeaders = await resolve(options, config.HEADERS); - - const headers = new Headers({ - Accept: 'application/json', - ...defaultHeaders, - ...options.headers, - }); - - if (isStringWithValue(token)) { - headers.append('Authorization', \`Bearer \${token}\`); - } - - if (isStringWithValue(username) && isStringWithValue(password)) { - const credentials = btoa(\`\${username}:\${password}\`); - headers.append('Authorization', \`Basic \${credentials}\`); - } - - if (options.body) { - if (options.mediaType) { - headers.append('Content-Type', options.mediaType); - } else if (isBlob(options.body)) { - headers.append('Content-Type', options.body.type || 'application/octet-stream'); - } else if (isString(options.body)) { - headers.append('Content-Type', 'text/plain'); - } else { - headers.append('Content-Type', 'application/json'); - } - } - return headers; -} - -function getRequestBody(options: ApiRequestOptions): any { - if (options.formData) { - return getFormData(options.formData); - } - if (options.body) { - if (options.mediaType?.includes('/json')) { - return JSON.stringify(options.body) - } else if (isString(options.body) || isBlob(options.body)) { - return options.body; - } else { - return JSON.stringify(options.body); - } - } - return undefined; -} - -async function sendRequest(options: ApiRequestOptions, config: OpenAPIConfig, url: string): Promise { - - const xhr = new XMLHttpRequest(); - xhr.open(options.method, url, true); - xhr.withCredentials = config.WITH_CREDENTIALS ?? false; - - const headers = await getHeaders(options, config); - headers.forEach((value: string, key: string) => { - xhr.setRequestHeader(key, value); - }); - - return new Promise(resolve => { - xhr.onreadystatechange = () => { - if (xhr.readyState === XMLHttpRequest.DONE) { - resolve(xhr); - } - }; - xhr.send(getRequestBody(options)); - }); -} - -function getResponseHeader(xhr: XMLHttpRequest, responseHeader?: string): string | null { - if (responseHeader) { - const content = xhr.getResponseHeader(responseHeader); - if (isString(content)) { - return content; - } - } - return null; -} - -function getResponseBody(xhr: XMLHttpRequest): any { - try { - const contentType = xhr.getResponseHeader('Content-Type'); - if (contentType) { - const isJSON = contentType.toLowerCase().startsWith('application/json'); - if (isJSON) { - return JSON.parse(xhr.responseText); - } else { - return xhr.responseText; - } - } - } catch (error) { - console.error(error); - } - return null; -} - -function catchErrors(options: ApiRequestOptions, result: ApiResult): void { - const errors: Record = { - 400: 'Bad Request', - 401: 'Unauthorized', - 403: 'Forbidden', - 404: 'Not Found', - 500: 'Internal Server Error', - 502: 'Bad Gateway', - 503: 'Service Unavailable', - ...options.errors, - } - - const error = errors[result.status]; - if (error) { - throw new ApiError(result, error); - } - - if (!result.ok) { - throw new ApiError(result, 'Generic Error'); - } -} - -export class XhrHttpRequest extends BaseHttpRequest { - constructor(openApiConfig: OpenAPIConfig) { - super(openApiConfig); - } - - /** - * Request using XHR client - * @param options The request options from the the service - * @returns ApiResult - * @throws ApiError - */ - async request(options: ApiRequestOptions): Promise { - const url = getUrl(options, this.openApiConfig); - const response = await sendRequest(options, this.openApiConfig, url); - const responseBody = getResponseBody(response); - const responseHeader = getResponseHeader(response, options.responseHeader); +exports[`v2 should generate with exportClient: ./test/generated/v2_client/core/OpenAPI.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ApiRequestOptions } from './ApiRequestOptions'; - const result: ApiResult = { - url, - ok: isSuccess(response.status), - status: response.status, - statusText: response.statusText, - body: responseHeader || responseBody, - }; +type Resolver = (options: ApiRequestOptions) => Promise; +type Headers = Record; - catchErrors(options, result); - return result; - } +export type OpenAPIConfig = { + BASE?: string; + VERSION?: string; + WITH_CREDENTIALS?: boolean; + TOKEN?: string | Resolver; + USERNAME?: string | Resolver; + PASSWORD?: string | Resolver; + HEADERS?: Headers | Resolver; } " `; +exports[`v2 should generate with exportClient: ./test/generated/v2_client/core/index.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export { ApiError } from './ApiError'; +export type { ApiRequestOptions } from './ApiRequestOptions'; +export type { ApiResult } from './ApiResult'; +export { BaseHttpRequest } from './BaseHttpRequest'; +export { FetchHttpRequest } from './FetchHttpRequest'; +export type { OpenAPIConfig } from './OpenAPI'; +" +`; + exports[`v2 should generate with exportClient: ./test/generated/v2_client/index.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -export { ApiError } from './core/ApiError'; -export type { ApiRequestOptions } from './core/ApiRequestOptions'; -export type { ApiResult } from './core/ApiResult'; -export type { OpenAPIConfig } from './core/OpenAPI'; -export { BaseHttpRequest } from './core/BaseHttpRequest'; -export { FetchHttpRequest } from './core/FetchHttpRequest'; - -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 { Date } from './models/Date'; -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 { 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 { ModelWithNestedEnums } from './models/ModelWithNestedEnums'; -export type { ModelWithNestedProperties } from './models/ModelWithNestedProperties'; -export type { ModelWithNullableString } from './models/ModelWithNullableString'; -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 type { SimpleStringWithPattern } from './models/SimpleStringWithPattern'; - -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 { $Date } from './schemas/$Date'; -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 { $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 { $ModelWithNestedEnums } from './schemas/$ModelWithNestedEnums'; -export { $ModelWithNestedProperties } from './schemas/$ModelWithNestedProperties'; -export { $ModelWithNullableString } from './schemas/$ModelWithNullableString'; -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 { $SimpleStringWithPattern } from './schemas/$SimpleStringWithPattern'; - -export { CollectionFormatService } from './services/CollectionFormatService'; -export { ComplexService } from './services/ComplexService'; -export { DefaultsService } from './services/DefaultsService'; -export { DuplicateService } from './services/DuplicateService'; -export { HeaderService } from './services/HeaderService'; -export { NoContentService } from './services/NoContentService'; -export { ParametersService } from './services/ParametersService'; -export { ResponseService } from './services/ResponseService'; -export { SimpleService } from './services/SimpleService'; -export { TypesService } from './services/TypesService'; +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export * from './core'; +export * from './models'; +export * from './schemas'; +export * from './services'; export { TestClient } from './client'; " `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ArrayWithArray.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -955,7 +422,8 @@ export type ArrayWithArray = Array>;" `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ArrayWithBooleans.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -966,7 +434,8 @@ export type ArrayWithBooleans = Array;" `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ArrayWithNumbers.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -977,7 +446,8 @@ export type ArrayWithNumbers = Array;" `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ArrayWithProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -991,7 +461,8 @@ export type ArrayWithProperties = Array<{ `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ArrayWithReferences.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1004,7 +475,8 @@ export type ArrayWithReferences = Array;" `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ArrayWithStrings.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1015,7 +487,8 @@ export type ArrayWithStrings = Array;" `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/Date.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1026,7 +499,8 @@ export type Date = string;" `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/DictionaryWithArray.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1039,7 +513,8 @@ export type DictionaryWithArray = Record>;" `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/DictionaryWithDictionary.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1050,7 +525,8 @@ export type DictionaryWithDictionary = Record>;" `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/DictionaryWithProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1064,7 +540,8 @@ export type DictionaryWithProperties = Record;" `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/DictionaryWithString.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1088,7 +566,8 @@ export type DictionaryWithString = Record;" `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/EnumFromDescription.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1103,7 +582,8 @@ export enum EnumFromDescription { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/EnumWithExtensions.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1127,7 +607,8 @@ export enum EnumWithExtensions { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/EnumWithNumbers.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1154,7 +635,8 @@ export enum EnumWithNumbers { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/EnumWithStrings.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1169,7 +651,8 @@ export enum EnumWithStrings { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelThatExtends.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1186,7 +669,8 @@ export type ModelThatExtends = (ModelWithString & { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelThatExtendsExtends.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1204,7 +688,8 @@ export type ModelThatExtendsExtends = (ModelWithString & ModelThatExtends & { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithArray.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1222,7 +707,8 @@ export type ModelWithArray = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithBoolean.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1239,7 +725,8 @@ export type ModelWithBoolean = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithCircularReference.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1253,7 +740,8 @@ export type ModelWithCircularReference = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithDictionary.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1267,7 +755,8 @@ export type ModelWithDictionary = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithDuplicateImports.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1285,7 +774,8 @@ export type ModelWithDuplicateImports = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithDuplicateProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1301,7 +791,8 @@ export type ModelWithDuplicateProperties = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithEnum.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1352,7 +843,8 @@ export namespace ModelWithEnum { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithEnumFromDescription.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1383,7 +875,8 @@ export namespace ModelWithEnumFromDescription { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithInteger.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1400,7 +893,8 @@ export type ModelWithInteger = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithNestedEnums.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1417,7 +911,8 @@ export type ModelWithNestedEnums = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithNestedProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1435,7 +930,8 @@ export type ModelWithNestedProperties = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithNullableString.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1456,7 +952,8 @@ export type ModelWithNullableString = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithOrderedProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1472,7 +969,8 @@ export type ModelWithOrderedProperties = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithPattern.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1491,7 +989,8 @@ export type ModelWithPattern = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1517,7 +1016,8 @@ export type ModelWithProperties = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithReference.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1533,7 +1033,8 @@ export type ModelWithReference = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithString.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1550,7 +1051,8 @@ export type ModelWithString = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/MultilineComment.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1564,7 +1066,8 @@ export type MultilineComment = number;" `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/SimpleBoolean.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1575,7 +1078,8 @@ export type SimpleBoolean = boolean;" `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/SimpleFile.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1586,7 +1090,8 @@ export type SimpleFile = Blob;" `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/SimpleInteger.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1597,7 +1102,8 @@ export type SimpleInteger = number;" `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/SimpleReference.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1610,7 +1116,8 @@ export type SimpleReference = ModelWithString;" `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/SimpleString.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1621,7 +1128,8 @@ export type SimpleString = string;" `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/SimpleStringWithPattern.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1631,8 +1139,59 @@ exports[`v2 should generate with exportClient: ./test/generated/v2_client/models export type SimpleStringWithPattern = string;" `; +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/index.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type { ArrayWithArray } from './ArrayWithArray'; +export type { ArrayWithBooleans } from './ArrayWithBooleans'; +export type { ArrayWithNumbers } from './ArrayWithNumbers'; +export type { ArrayWithProperties } from './ArrayWithProperties'; +export type { ArrayWithReferences } from './ArrayWithReferences'; +export type { ArrayWithStrings } from './ArrayWithStrings'; +export type { Date } from './Date'; +export type { DictionaryWithArray } from './DictionaryWithArray'; +export type { DictionaryWithDictionary } from './DictionaryWithDictionary'; +export type { DictionaryWithProperties } from './DictionaryWithProperties'; +export type { DictionaryWithReference } from './DictionaryWithReference'; +export type { DictionaryWithString } from './DictionaryWithString'; +export { EnumFromDescription } from './EnumFromDescription'; +export { EnumWithExtensions } from './EnumWithExtensions'; +export { EnumWithNumbers } from './EnumWithNumbers'; +export { EnumWithStrings } from './EnumWithStrings'; +export type { ModelThatExtends } from './ModelThatExtends'; +export type { ModelThatExtendsExtends } from './ModelThatExtendsExtends'; +export type { ModelWithArray } from './ModelWithArray'; +export type { ModelWithBoolean } from './ModelWithBoolean'; +export type { ModelWithCircularReference } from './ModelWithCircularReference'; +export type { ModelWithDictionary } from './ModelWithDictionary'; +export type { ModelWithDuplicateImports } from './ModelWithDuplicateImports'; +export type { ModelWithDuplicateProperties } from './ModelWithDuplicateProperties'; +export type { ModelWithEnum } from './ModelWithEnum'; +export type { ModelWithEnumFromDescription } from './ModelWithEnumFromDescription'; +export type { ModelWithInteger } from './ModelWithInteger'; +export type { ModelWithNestedEnums } from './ModelWithNestedEnums'; +export type { ModelWithNestedProperties } from './ModelWithNestedProperties'; +export type { ModelWithNullableString } from './ModelWithNullableString'; +export type { ModelWithOrderedProperties } from './ModelWithOrderedProperties'; +export type { ModelWithPattern } from './ModelWithPattern'; +export type { ModelWithProperties } from './ModelWithProperties'; +export type { ModelWithReference } from './ModelWithReference'; +export type { ModelWithString } from './ModelWithString'; +export type { MultilineComment } from './MultilineComment'; +export type { SimpleBoolean } from './SimpleBoolean'; +export type { SimpleFile } from './SimpleFile'; +export type { SimpleInteger } from './SimpleInteger'; +export type { SimpleReference } from './SimpleReference'; +export type { SimpleString } from './SimpleString'; +export type { SimpleStringWithPattern } from './SimpleStringWithPattern'; +" +`; + exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ArrayWithArray.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ArrayWithArray = { @@ -1647,7 +1206,8 @@ export const $ArrayWithArray = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ArrayWithBooleans.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ArrayWithBooleans = { @@ -1659,7 +1219,8 @@ export const $ArrayWithBooleans = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ArrayWithNumbers.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ArrayWithNumbers = { @@ -1671,7 +1232,8 @@ export const $ArrayWithNumbers = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ArrayWithProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ArrayWithProperties = { @@ -1690,7 +1252,8 @@ export const $ArrayWithProperties = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ArrayWithReferences.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ArrayWithReferences = { @@ -1702,7 +1265,8 @@ export const $ArrayWithReferences = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ArrayWithStrings.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ArrayWithStrings = { @@ -1714,7 +1278,8 @@ export const $ArrayWithStrings = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$Date.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $Date = { @@ -1723,7 +1288,8 @@ export const $Date = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$DictionaryWithArray.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $DictionaryWithArray = { @@ -1738,7 +1304,8 @@ export const $DictionaryWithArray = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$DictionaryWithDictionary.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $DictionaryWithDictionary = { @@ -1753,7 +1320,8 @@ export const $DictionaryWithDictionary = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$DictionaryWithProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $DictionaryWithProperties = { @@ -1772,7 +1340,8 @@ export const $DictionaryWithProperties = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$DictionaryWithReference.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $DictionaryWithReference = { @@ -1784,7 +1353,8 @@ export const $DictionaryWithReference = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$DictionaryWithString.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $DictionaryWithString = { @@ -1796,7 +1366,8 @@ export const $DictionaryWithString = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$EnumFromDescription.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $EnumFromDescription = { @@ -1805,7 +1376,8 @@ export const $EnumFromDescription = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$EnumWithExtensions.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $EnumWithExtensions = { @@ -1814,7 +1386,8 @@ export const $EnumWithExtensions = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$EnumWithNumbers.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $EnumWithNumbers = { @@ -1823,7 +1396,8 @@ export const $EnumWithNumbers = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$EnumWithStrings.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $EnumWithStrings = { @@ -1832,7 +1406,8 @@ export const $EnumWithStrings = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelThatExtends.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelThatExtends = { @@ -1853,7 +1428,8 @@ export const $ModelThatExtends = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelThatExtendsExtends.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelThatExtendsExtends = { @@ -1876,7 +1452,8 @@ export const $ModelThatExtendsExtends = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithArray.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithArray = { @@ -1904,7 +1481,8 @@ export const $ModelWithArray = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithBoolean.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithBoolean = { @@ -1917,7 +1495,8 @@ export const $ModelWithBoolean = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithCircularReference.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithCircularReference = { @@ -1930,7 +1509,8 @@ export const $ModelWithCircularReference = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithDictionary.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithDictionary = { @@ -1946,7 +1526,8 @@ export const $ModelWithDictionary = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithDuplicateImports.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithDuplicateImports = { @@ -1965,7 +1546,8 @@ export const $ModelWithDuplicateImports = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithDuplicateProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithDuplicateProperties = { @@ -1978,7 +1560,8 @@ export const $ModelWithDuplicateProperties = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithEnum.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithEnum = { @@ -1997,7 +1580,8 @@ export const $ModelWithEnum = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithEnumFromDescription.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithEnumFromDescription = { @@ -2010,7 +1594,8 @@ export const $ModelWithEnumFromDescription = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithInteger.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithInteger = { @@ -2023,7 +1608,8 @@ export const $ModelWithInteger = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithNestedEnums.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithNestedEnums = { @@ -2057,7 +1643,8 @@ export const $ModelWithNestedEnums = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithNestedProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithNestedProperties = { @@ -2084,7 +1671,8 @@ export const $ModelWithNestedProperties = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithNullableString.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithNullableString = { @@ -2103,7 +1691,8 @@ export const $ModelWithNullableString = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithOrderedProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithOrderedProperties = { @@ -2122,7 +1711,8 @@ export const $ModelWithOrderedProperties = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithPattern.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithPattern = { @@ -2160,7 +1750,8 @@ export const $ModelWithPattern = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithProperties = { @@ -2208,7 +1799,8 @@ export const $ModelWithProperties = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithReference.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithReference = { @@ -2221,7 +1813,8 @@ export const $ModelWithReference = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithString.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithString = { @@ -2234,7 +1827,8 @@ export const $ModelWithString = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$MultilineComment.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $MultilineComment = { @@ -2243,7 +1837,8 @@ export const $MultilineComment = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$SimpleBoolean.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $SimpleBoolean = { @@ -2252,7 +1847,8 @@ export const $SimpleBoolean = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$SimpleFile.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $SimpleFile = { @@ -2261,7 +1857,8 @@ export const $SimpleFile = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$SimpleInteger.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $SimpleInteger = { @@ -2270,7 +1867,8 @@ export const $SimpleInteger = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$SimpleReference.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $SimpleReference = { @@ -2279,7 +1877,8 @@ export const $SimpleReference = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$SimpleString.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $SimpleString = { @@ -2288,7 +1887,8 @@ export const $SimpleString = { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$SimpleStringWithPattern.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $SimpleStringWithPattern = { @@ -2298,11 +1898,62 @@ export const $SimpleStringWithPattern = { };" `; +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/index.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export { $ArrayWithArray } from './$ArrayWithArray'; +export { $ArrayWithBooleans } from './$ArrayWithBooleans'; +export { $ArrayWithNumbers } from './$ArrayWithNumbers'; +export { $ArrayWithProperties } from './$ArrayWithProperties'; +export { $ArrayWithReferences } from './$ArrayWithReferences'; +export { $ArrayWithStrings } from './$ArrayWithStrings'; +export { $Date } from './$Date'; +export { $DictionaryWithArray } from './$DictionaryWithArray'; +export { $DictionaryWithDictionary } from './$DictionaryWithDictionary'; +export { $DictionaryWithProperties } from './$DictionaryWithProperties'; +export { $DictionaryWithReference } from './$DictionaryWithReference'; +export { $DictionaryWithString } from './$DictionaryWithString'; +export { $EnumFromDescription } from './$EnumFromDescription'; +export { $EnumWithExtensions } from './$EnumWithExtensions'; +export { $EnumWithNumbers } from './$EnumWithNumbers'; +export { $EnumWithStrings } from './$EnumWithStrings'; +export { $ModelThatExtends } from './$ModelThatExtends'; +export { $ModelThatExtendsExtends } from './$ModelThatExtendsExtends'; +export { $ModelWithArray } from './$ModelWithArray'; +export { $ModelWithBoolean } from './$ModelWithBoolean'; +export { $ModelWithCircularReference } from './$ModelWithCircularReference'; +export { $ModelWithDictionary } from './$ModelWithDictionary'; +export { $ModelWithDuplicateImports } from './$ModelWithDuplicateImports'; +export { $ModelWithDuplicateProperties } from './$ModelWithDuplicateProperties'; +export { $ModelWithEnum } from './$ModelWithEnum'; +export { $ModelWithEnumFromDescription } from './$ModelWithEnumFromDescription'; +export { $ModelWithInteger } from './$ModelWithInteger'; +export { $ModelWithNestedEnums } from './$ModelWithNestedEnums'; +export { $ModelWithNestedProperties } from './$ModelWithNestedProperties'; +export { $ModelWithNullableString } from './$ModelWithNullableString'; +export { $ModelWithOrderedProperties } from './$ModelWithOrderedProperties'; +export { $ModelWithPattern } from './$ModelWithPattern'; +export { $ModelWithProperties } from './$ModelWithProperties'; +export { $ModelWithReference } from './$ModelWithReference'; +export { $ModelWithString } from './$ModelWithString'; +export { $MultilineComment } from './$MultilineComment'; +export { $SimpleBoolean } from './$SimpleBoolean'; +export { $SimpleFile } from './$SimpleFile'; +export { $SimpleInteger } from './$SimpleInteger'; +export { $SimpleReference } from './$SimpleReference'; +export { $SimpleString } from './$SimpleString'; +export { $SimpleStringWithPattern } from './$SimpleStringWithPattern'; +" +`; + exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/CollectionFormatService.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { BaseHttpRequest } from '../core/BaseHttpRequest'; +import { BaseHttpRequest } from '../core'; export class CollectionFormatService { private httpRequest: BaseHttpRequest; @@ -2344,11 +1995,14 @@ export class CollectionFormatService { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/ComplexService.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ModelWithString } from '../models/ModelWithString'; -import { BaseHttpRequest } from '../core/BaseHttpRequest'; +import type { + ModelWithString, +} from '../models'; +import { BaseHttpRequest } from '../core'; export class ComplexService { private httpRequest: BaseHttpRequest; @@ -2392,11 +2046,14 @@ export class ComplexService { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/DefaultsService.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ModelWithString } from '../models/ModelWithString'; -import { BaseHttpRequest } from '../core/BaseHttpRequest'; +import type { + ModelWithString, +} from '../models'; +import { BaseHttpRequest } from '../core'; export class DefaultsService { private httpRequest: BaseHttpRequest; @@ -2503,10 +2160,11 @@ export class DefaultsService { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/DuplicateService.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { BaseHttpRequest } from '../core/BaseHttpRequest'; +import { BaseHttpRequest } from '../core'; export class DuplicateService { private httpRequest: BaseHttpRequest; @@ -2563,10 +2221,11 @@ export class DuplicateService { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/HeaderService.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { BaseHttpRequest } from '../core/BaseHttpRequest'; +import { BaseHttpRequest } from '../core'; export class HeaderService { private httpRequest: BaseHttpRequest; @@ -2596,10 +2255,11 @@ export class HeaderService { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/NoContentService.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { BaseHttpRequest } from '../core/BaseHttpRequest'; +import { BaseHttpRequest } from '../core'; export class NoContentService { private httpRequest: BaseHttpRequest; @@ -2624,10 +2284,11 @@ export class NoContentService { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/ParametersService.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { BaseHttpRequest } from '../core/BaseHttpRequest'; +import { BaseHttpRequest } from '../core'; export class ParametersService { private httpRequest: BaseHttpRequest; @@ -2711,13 +2372,16 @@ export class ParametersService { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/ResponseService.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ModelThatExtends } from '../models/ModelThatExtends'; -import type { ModelThatExtendsExtends } from '../models/ModelThatExtendsExtends'; -import type { ModelWithString } from '../models/ModelWithString'; -import { BaseHttpRequest } from '../core/BaseHttpRequest'; +import type { + ModelThatExtends, + ModelThatExtendsExtends, + ModelWithString, +} from '../models'; +import { BaseHttpRequest } from '../core'; export class ResponseService { private httpRequest: BaseHttpRequest; @@ -2783,10 +2447,11 @@ export class ResponseService { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/SimpleService.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { BaseHttpRequest } from '../core/BaseHttpRequest'; +import { BaseHttpRequest } from '../core'; export class SimpleService { private httpRequest: BaseHttpRequest; @@ -2876,10 +2541,11 @@ export class SimpleService { `; exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/TypesService.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { BaseHttpRequest } from '../core/BaseHttpRequest'; +import { BaseHttpRequest } from '../core'; export class TypesService { private httpRequest: BaseHttpRequest; @@ -2932,26 +2598,46 @@ export class TypesService { }" `; +exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/index.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export { CollectionFormatService } from './CollectionFormatService'; +export { ComplexService } from './ComplexService'; +export { DefaultsService } from './DefaultsService'; +export { DuplicateService } from './DuplicateService'; +export { HeaderService } from './HeaderService'; +export { NoContentService } from './NoContentService'; +export { ParametersService } from './ParametersService'; +export { ResponseService } from './ResponseService'; +export { SimpleService } from './SimpleService'; +export { TypesService } from './TypesService'; +" +`; + exports[`v3 should generate with exportClient: ./test/generated/v3_client/client.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -import { BaseHttpRequest } from './core/BaseHttpRequest'; -import type { OpenAPIConfig } from './core/OpenAPI'; -import { FetchHttpRequest } from './core/FetchHttpRequest'; -import { CollectionFormatService } from './services/CollectionFormatService'; -import { ComplexService } from './services/ComplexService'; -import { DefaultsService } from './services/DefaultsService'; -import { DuplicateService } from './services/DuplicateService'; -import { HeaderService } from './services/HeaderService'; -import { MultipartService } from './services/MultipartService'; -import { NoContentService } from './services/NoContentService'; -import { ParametersService } from './services/ParametersService'; -import { RequestBodyService } from './services/RequestBodyService'; -import { ResponseService } from './services/ResponseService'; -import { SimpleService } from './services/SimpleService'; -import { TypesService } from './services/TypesService'; -import { UploadService } from './services/UploadService'; +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import { BaseHttpRequest, FetchHttpRequest } from './core'; +import type { OpenAPIConfig } from './core'; +import { + CollectionFormatService, + ComplexService, + DefaultsService, + DuplicateService, + HeaderService, + MultipartService, + NoContentService, + ParametersService, + RequestBodyService, + ResponseService, + SimpleService, + TypesService, + UploadService, +} from './services'; export class TestClient { readonly collectionformat: CollectionFormatService; @@ -2997,7 +2683,8 @@ export class TestClient { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/core/ApiError.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ import type { ApiResult } from './ApiResult'; @@ -3020,7 +2707,8 @@ export class ApiError extends Error { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/core/ApiRequestOptions.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export type ApiRequestOptions = { @@ -3038,7 +2726,8 @@ export type ApiRequestOptions = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/core/ApiResult.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export type ApiResult = { @@ -3051,254 +2740,32 @@ export type ApiResult = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/core/BaseHttpRequest.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -import type { ApiRequestOptions } from './ApiRequestOptions'; -import type { ApiResult } from './ApiResult'; -import type { OpenAPIConfig } from './OpenAPI'; - -export class BaseHttpRequest { - readonly openApiConfig: OpenAPIConfig; - - constructor(openApiConfig: OpenAPIConfig) { - this.openApiConfig = openApiConfig; - } - - async request(options: ApiRequestOptions): Promise { - throw new Error('Not Implemented'); - } -}" -`; - -exports[`v3 should generate with exportClient: ./test/generated/v3_client/core/FetchHttpRequest.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { ApiError } from './ApiError'; import type { ApiRequestOptions } from './ApiRequestOptions'; import type { ApiResult } from './ApiResult'; import type { OpenAPIConfig } from './OpenAPI'; -import { BaseHttpRequest } from './BaseHttpRequest'; - -function isDefined(value: T | null | undefined): value is Exclude { - return value !== undefined && value !== null; -} - -function isString(value: any): value is string { - return typeof value === 'string'; -} - -function isStringWithValue(value: any): value is string { - return isString(value) && value !== ''; -} - -function isBlob(value: any): value is Blob { - return value instanceof Blob; -} - -function getQueryString(params: Record): string { - const qs: string[] = []; - Object.keys(params).forEach(key => { - const value = params[key]; - if (isDefined(value)) { - 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 ''; -} - -function getUrl(options: ApiRequestOptions, config: OpenAPIConfig): string { - const path = options.path.replace(/[:]/g, '_'); - const url = \`\${config.BASE}\${path}\`; - - if (options.query) { - return \`\${url}\${getQueryString(options.query)}\`; - } - return url; -} - -function getFormData(params: Record): FormData { - const formData = new FormData(); - Object.keys(params).forEach(key => { - const value = params[key]; - if (isDefined(value)) { - formData.append(key, value); - } - }); - return formData; -} - -type Resolver = (options: ApiRequestOptions) => Promise; - -async function resolve(options: ApiRequestOptions, resolver?: T | Resolver): Promise { - if (typeof resolver === 'function') { - return (resolver as Resolver)(options); - } - return resolver; -} - -async function getHeaders(options: ApiRequestOptions, config: OpenAPIConfig): Promise { - const token = await resolve(options, config.TOKEN); - const username = await resolve(options, config.USERNAME); - const password = await resolve(options, config.PASSWORD); - const defaultHeaders = await resolve(options, config.HEADERS); - - const headers = new Headers({ - Accept: 'application/json', - ...defaultHeaders, - ...options.headers, - }); - - if (isStringWithValue(token)) { - headers.append('Authorization', \`Bearer \${token}\`); - } - - if (isStringWithValue(username) && isStringWithValue(password)) { - const credentials = btoa(\`\${username}:\${password}\`); - headers.append('Authorization', \`Basic \${credentials}\`); - } - - if (options.body) { - if (options.mediaType) { - headers.append('Content-Type', options.mediaType); - } else if (isBlob(options.body)) { - headers.append('Content-Type', options.body.type || 'application/octet-stream'); - } else if (isString(options.body)) { - headers.append('Content-Type', 'text/plain'); - } else { - headers.append('Content-Type', 'application/json'); - } - } - return headers; -} - -function getRequestBody(options: ApiRequestOptions): BodyInit | undefined { - if (options.formData) { - return getFormData(options.formData); - } - if (options.body) { - if (options.mediaType?.includes('/json')) { - return JSON.stringify(options.body) - } else if (isString(options.body) || isBlob(options.body)) { - return options.body; - } else { - return JSON.stringify(options.body); - } - } - return undefined; -} - -async function sendRequest(options: ApiRequestOptions, config: OpenAPIConfig, url: string): Promise { - const request: RequestInit = { - method: options.method, - headers: await getHeaders(options, config), - body: getRequestBody(options), - }; - if (config.WITH_CREDENTIALS) { - request.credentials = 'include'; - } - return await fetch(url, request); -} - -function getResponseHeader(response: Response, responseHeader?: string): string | null { - if (responseHeader) { - const content = response.headers.get(responseHeader); - if (isString(content)) { - return content; - } - } - return null; -} - -async function getResponseBody(response: Response): Promise { - try { - const contentType = response.headers.get('Content-Type'); - if (contentType) { - const isJSON = contentType.toLowerCase().startsWith('application/json'); - if (isJSON) { - return await response.json(); - } else { - return await response.text(); - } - } - } catch (error) { - console.error(error); - } - return null; -} - -function catchErrors(options: ApiRequestOptions, result: ApiResult): void { - const errors: Record = { - 400: 'Bad Request', - 401: 'Unauthorized', - 403: 'Forbidden', - 404: 'Not Found', - 500: 'Internal Server Error', - 502: 'Bad Gateway', - 503: 'Service Unavailable', - ...options.errors, - } - - const error = errors[result.status]; - if (error) { - throw new ApiError(result, error); - } - if (!result.ok) { - throw new ApiError(result, 'Generic Error'); - } -} +export class BaseHttpRequest { + readonly openApiConfig: OpenAPIConfig; -export class FetchHttpRequest extends BaseHttpRequest { constructor(openApiConfig: OpenAPIConfig) { - super(openApiConfig); + this.openApiConfig = openApiConfig; } - /** - * Request using fetch client - * @param options The request options from the the service - * @returns ApiResult - * @throws ApiError - */ async request(options: ApiRequestOptions): Promise { - const url = getUrl(options, this.openApiConfig); - const response = await sendRequest(options, this.openApiConfig, url); - const responseBody = await getResponseBody(response); - const responseHeader = getResponseHeader(response, options.responseHeader); - - const result: ApiResult = { - url, - ok: response.ok, - status: response.status, - statusText: response.statusText, - body: responseHeader || responseBody, - }; - - catchErrors(options, result); - return result; + throw new Error('Not Implemented'); } -} -" +}" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/core/NodeHttpRequest.ts 1`] = ` -"/* istanbul ignore file */ +exports[`v3 should generate with exportClient: ./test/generated/v3_client/core/FetchHttpRequest.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import FormData from 'form-data'; -import fetch, { BodyInit, Headers, RequestInit, Response } from 'node-fetch'; -import { types } from 'util'; - import { ApiError } from './ApiError'; import type { ApiRequestOptions } from './ApiRequestOptions'; import type { ApiResult } from './ApiResult'; @@ -3317,11 +2784,8 @@ function isStringWithValue(value: any): value is string { return isString(value) && value !== ''; } -function isBinary(value: any): value is Buffer | ArrayBuffer | ArrayBufferView { - const isBuffer = Buffer.isBuffer(value); - const isArrayBuffer = types.isArrayBuffer(value); - const isArrayBufferView = types.isArrayBufferView(value); - return isBuffer || isArrayBuffer || isArrayBufferView; +function isBlob(value: any): value is Blob { + return value instanceof Blob; } function getQueryString(params: Record): string { @@ -3391,15 +2855,15 @@ async function getHeaders(options: ApiRequestOptions, config: OpenAPIConfig): Pr } if (isStringWithValue(username) && isStringWithValue(password)) { - const credentials = Buffer.from(\`\${username}:\${password}\`).toString('base64'); + const credentials = btoa(\`\${username}:\${password}\`); headers.append('Authorization', \`Basic \${credentials}\`); } if (options.body) { if (options.mediaType) { headers.append('Content-Type', options.mediaType); - } else if (isBinary(options.body)) { - headers.append('Content-Type', 'application/octet-stream'); + } else if (isBlob(options.body)) { + headers.append('Content-Type', options.body.type || 'application/octet-stream'); } else if (isString(options.body)) { headers.append('Content-Type', 'text/plain'); } else { @@ -3416,7 +2880,7 @@ function getRequestBody(options: ApiRequestOptions): BodyInit | undefined { if (options.body) { if (options.mediaType?.includes('/json')) { return JSON.stringify(options.body) - } else if (isString(options.body) || isBinary(options.body)) { + } else if (isString(options.body) || isBlob(options.body)) { return options.body; } else { return JSON.stringify(options.body); @@ -3431,6 +2895,9 @@ async function sendRequest(options: ApiRequestOptions, config: OpenAPIConfig, ur headers: await getHeaders(options, config), body: getRequestBody(options), }; + if (config.WITH_CREDENTIALS) { + request.credentials = 'include'; + } return await fetch(url, request); } @@ -3483,13 +2950,13 @@ function catchErrors(options: ApiRequestOptions, result: ApiResult): void { } } -export class NodeHttpRequest extends BaseHttpRequest { +export class FetchHttpRequest extends BaseHttpRequest { constructor(openApiConfig: OpenAPIConfig) { super(openApiConfig); } /** - * Request using node-fetch client + * Request using fetch client * @param options The request options from the the service * @returns ApiResult * @throws ApiError @@ -3516,7 +2983,8 @@ export class NodeHttpRequest extends BaseHttpRequest { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/core/OpenAPI.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ import type { ApiRequestOptions } from './ApiRequestOptions'; @@ -3536,367 +3004,37 @@ export type OpenAPIConfig = { " `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/core/XhrHttpRequest.ts 1`] = ` -"/* istanbul ignore file */ +exports[`v3 should generate with exportClient: ./test/generated/v3_client/core/index.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { ApiError } from './ApiError'; -import type { ApiRequestOptions } from './ApiRequestOptions'; -import type { ApiResult } from './ApiResult'; -import type { OpenAPIConfig } from './OpenAPI'; -import { BaseHttpRequest } from './BaseHttpRequest'; - - -function isDefined(value: T | null | undefined): value is Exclude { - return value !== undefined && value !== null; -} - -function isString(value: any): value is string { - return typeof value === 'string'; -} - -function isStringWithValue(value: any): value is string { - return isString(value) && value !== ''; -} - -function isBlob(value: any): value is Blob { - return value instanceof Blob; -} - -function isSuccess(status: number): boolean { - return status >= 200 && status < 300; -} - -function getQueryString(params: Record): string { - const qs: string[] = []; - Object.keys(params).forEach(key => { - const value = params[key]; - if (isDefined(value)) { - 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 ''; -} - -function getUrl(options: ApiRequestOptions, config: OpenAPIConfig): string { - const path = options.path.replace(/[:]/g, '_'); - const url = \`\${config.BASE}\${path}\`; - - if (options.query) { - return \`\${url}\${getQueryString(options.query)}\`; - } - return url; -} - -function getFormData(params: Record): FormData { - const formData = new FormData(); - Object.keys(params).forEach(key => { - const value = params[key]; - if (isDefined(value)) { - formData.append(key, value); - } - }); - return formData; -} - -type Resolver = (options: ApiRequestOptions) => Promise; - -async function resolve(options: ApiRequestOptions, resolver?: T | Resolver): Promise { - if (typeof resolver === 'function') { - return (resolver as Resolver)(options); - } - return resolver; -} - -async function getHeaders(options: ApiRequestOptions, config: OpenAPIConfig): Promise { - const token = await resolve(options, config.TOKEN); - const username = await resolve(options, config.USERNAME); - const password = await resolve(options, config.PASSWORD); - const defaultHeaders = await resolve(options, config.HEADERS); - - const headers = new Headers({ - Accept: 'application/json', - ...defaultHeaders, - ...options.headers, - }); - - if (isStringWithValue(token)) { - headers.append('Authorization', \`Bearer \${token}\`); - } - - if (isStringWithValue(username) && isStringWithValue(password)) { - const credentials = btoa(\`\${username}:\${password}\`); - headers.append('Authorization', \`Basic \${credentials}\`); - } - - if (options.body) { - if (options.mediaType) { - headers.append('Content-Type', options.mediaType); - } else if (isBlob(options.body)) { - headers.append('Content-Type', options.body.type || 'application/octet-stream'); - } else if (isString(options.body)) { - headers.append('Content-Type', 'text/plain'); - } else { - headers.append('Content-Type', 'application/json'); - } - } - return headers; -} - -function getRequestBody(options: ApiRequestOptions): any { - if (options.formData) { - return getFormData(options.formData); - } - if (options.body) { - if (options.mediaType?.includes('/json')) { - return JSON.stringify(options.body) - } else if (isString(options.body) || isBlob(options.body)) { - return options.body; - } else { - return JSON.stringify(options.body); - } - } - return undefined; -} - -async function sendRequest(options: ApiRequestOptions, config: OpenAPIConfig, url: string): Promise { - - const xhr = new XMLHttpRequest(); - xhr.open(options.method, url, true); - xhr.withCredentials = config.WITH_CREDENTIALS ?? false; - - const headers = await getHeaders(options, config); - headers.forEach((value: string, key: string) => { - xhr.setRequestHeader(key, value); - }); - - return new Promise(resolve => { - xhr.onreadystatechange = () => { - if (xhr.readyState === XMLHttpRequest.DONE) { - resolve(xhr); - } - }; - xhr.send(getRequestBody(options)); - }); -} - -function getResponseHeader(xhr: XMLHttpRequest, responseHeader?: string): string | null { - if (responseHeader) { - const content = xhr.getResponseHeader(responseHeader); - if (isString(content)) { - return content; - } - } - return null; -} - -function getResponseBody(xhr: XMLHttpRequest): any { - try { - const contentType = xhr.getResponseHeader('Content-Type'); - if (contentType) { - const isJSON = contentType.toLowerCase().startsWith('application/json'); - if (isJSON) { - return JSON.parse(xhr.responseText); - } else { - return xhr.responseText; - } - } - } catch (error) { - console.error(error); - } - return null; -} - -function catchErrors(options: ApiRequestOptions, result: ApiResult): void { - const errors: Record = { - 400: 'Bad Request', - 401: 'Unauthorized', - 403: 'Forbidden', - 404: 'Not Found', - 500: 'Internal Server Error', - 502: 'Bad Gateway', - 503: 'Service Unavailable', - ...options.errors, - } - - const error = errors[result.status]; - if (error) { - throw new ApiError(result, error); - } - - if (!result.ok) { - throw new ApiError(result, 'Generic Error'); - } -} - -export class XhrHttpRequest extends BaseHttpRequest { - constructor(openApiConfig: OpenAPIConfig) { - super(openApiConfig); - } - - /** - * Request using XHR client - * @param options The request options from the the service - * @returns ApiResult - * @throws ApiError - */ - async request(options: ApiRequestOptions): Promise { - const url = getUrl(options, this.openApiConfig); - const response = await sendRequest(options, this.openApiConfig, url); - const responseBody = getResponseBody(response); - const responseHeader = getResponseHeader(response, options.responseHeader); - - const result: ApiResult = { - url, - ok: isSuccess(response.status), - status: response.status, - statusText: response.statusText, - body: responseHeader || responseBody, - }; - - catchErrors(options, result); - return result; - } -} +export { ApiError } from './ApiError'; +export type { ApiRequestOptions } from './ApiRequestOptions'; +export type { ApiResult } from './ApiResult'; +export { BaseHttpRequest } from './BaseHttpRequest'; +export { FetchHttpRequest } from './FetchHttpRequest'; +export type { OpenAPIConfig } from './OpenAPI'; " `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/index.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -export { ApiError } from './core/ApiError'; -export type { ApiRequestOptions } from './core/ApiRequestOptions'; -export type { ApiResult } from './core/ApiResult'; -export type { OpenAPIConfig } from './core/OpenAPI'; -export { BaseHttpRequest } from './core/BaseHttpRequest'; -export { FetchHttpRequest } from './core/FetchHttpRequest'; - -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 { CompositionWithAllOfAndNullable } from './models/CompositionWithAllOfAndNullable'; -export type { CompositionWithAnyOf } from './models/CompositionWithAnyOf'; -export type { CompositionWithAnyOfAndNullable } from './models/CompositionWithAnyOfAndNullable'; -export type { CompositionWithAnyOfAnonymous } from './models/CompositionWithAnyOfAnonymous'; -export type { CompositionWithOneOf } from './models/CompositionWithOneOf'; -export type { CompositionWithOneOfAndNullable } from './models/CompositionWithOneOfAndNullable'; -export type { CompositionWithOneOfAnonymous } from './models/CompositionWithOneOfAnonymous'; -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 { 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 { 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 type { SimpleStringWithPattern } from './models/SimpleStringWithPattern'; - -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 { $CompositionWithAllOfAndNullable } from './schemas/$CompositionWithAllOfAndNullable'; -export { $CompositionWithAnyOf } from './schemas/$CompositionWithAnyOf'; -export { $CompositionWithAnyOfAndNullable } from './schemas/$CompositionWithAnyOfAndNullable'; -export { $CompositionWithAnyOfAnonymous } from './schemas/$CompositionWithAnyOfAnonymous'; -export { $CompositionWithOneOf } from './schemas/$CompositionWithOneOf'; -export { $CompositionWithOneOfAndNullable } from './schemas/$CompositionWithOneOfAndNullable'; -export { $CompositionWithOneOfAnonymous } from './schemas/$CompositionWithOneOfAnonymous'; -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 { $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 { $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 { $SimpleStringWithPattern } from './schemas/$SimpleStringWithPattern'; - -export { CollectionFormatService } from './services/CollectionFormatService'; -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 { NoContentService } from './services/NoContentService'; -export { ParametersService } from './services/ParametersService'; -export { RequestBodyService } from './services/RequestBodyService'; -export { ResponseService } from './services/ResponseService'; -export { SimpleService } from './services/SimpleService'; -export { TypesService } from './services/TypesService'; -export { UploadService } from './services/UploadService'; +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export * from './core'; +export * from './models'; +export * from './schemas'; +export * from './services'; export { TestClient } from './client'; " `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ArrayWithArray.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3909,7 +3047,8 @@ export type ArrayWithArray = Array>;" `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ArrayWithBooleans.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3920,7 +3059,8 @@ export type ArrayWithBooleans = Array;" `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ArrayWithNumbers.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3931,7 +3071,8 @@ export type ArrayWithNumbers = Array;" `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ArrayWithProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3945,7 +3086,8 @@ export type ArrayWithProperties = Array<{ `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ArrayWithReferences.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3958,7 +3100,8 @@ export type ArrayWithReferences = Array;" `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ArrayWithStrings.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3969,7 +3112,8 @@ export type ArrayWithStrings = Array;" `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/CompositionWithAllOfAndNullable.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3989,7 +3133,8 @@ export type CompositionWithAllOfAndNullable = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/CompositionWithAnyOf.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -4008,7 +3153,8 @@ export type CompositionWithAnyOf = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/CompositionWithAnyOfAndNullable.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -4028,7 +3174,8 @@ export type CompositionWithAnyOfAndNullable = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/CompositionWithAnyOfAnonymous.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -4044,7 +3191,8 @@ export type CompositionWithAnyOfAnonymous = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/CompositionWithOneOf.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -4063,7 +3211,8 @@ export type CompositionWithOneOf = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/CompositionWithOneOfAndNullable.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -4083,7 +3232,8 @@ export type CompositionWithOneOfAndNullable = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/CompositionWithOneOfAnonymous.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -4099,7 +3249,8 @@ export type CompositionWithOneOfAnonymous = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/DictionaryWithArray.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -4112,7 +3263,8 @@ export type DictionaryWithArray = Record>;" `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/DictionaryWithDictionary.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -4123,7 +3275,8 @@ export type DictionaryWithDictionary = Record>;" `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/DictionaryWithProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -4137,7 +3290,8 @@ export type DictionaryWithProperties = Record;" `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/DictionaryWithString.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -4161,7 +3316,8 @@ export type DictionaryWithString = Record;" `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/EnumFromDescription.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -4176,7 +3332,8 @@ export enum EnumFromDescription { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/EnumWithExtensions.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -4200,7 +3357,8 @@ export enum EnumWithExtensions { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/EnumWithNumbers.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -4227,7 +3385,8 @@ export enum EnumWithNumbers { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/EnumWithStrings.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -4242,7 +3401,8 @@ export enum EnumWithStrings { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelThatExtends.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -4259,7 +3419,8 @@ export type ModelThatExtends = (ModelWithString & { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelThatExtendsExtends.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -4277,7 +3438,8 @@ export type ModelThatExtendsExtends = (ModelWithString & ModelThatExtends & { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithArray.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -4295,7 +3457,8 @@ export type ModelWithArray = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithBoolean.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -4312,7 +3475,8 @@ export type ModelWithBoolean = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithCircularReference.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -4326,7 +3490,8 @@ export type ModelWithCircularReference = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithDictionary.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -4340,7 +3505,8 @@ export type ModelWithDictionary = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithDuplicateImports.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -4358,7 +3524,8 @@ export type ModelWithDuplicateImports = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithDuplicateProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -4374,7 +3541,8 @@ export type ModelWithDuplicateProperties = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithEnum.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -4425,7 +3593,8 @@ export namespace ModelWithEnum { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithEnumFromDescription.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -4456,7 +3625,8 @@ export namespace ModelWithEnumFromDescription { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithInteger.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -4473,7 +3643,8 @@ export type ModelWithInteger = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithNestedEnums.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -4490,7 +3661,8 @@ export type ModelWithNestedEnums = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithNestedProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -4508,7 +3680,8 @@ export type ModelWithNestedProperties = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithOrderedProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -4524,7 +3697,8 @@ export type ModelWithOrderedProperties = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithPattern.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -4543,7 +3717,8 @@ export type ModelWithPattern = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -4570,7 +3745,8 @@ export type ModelWithProperties = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithReference.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -4586,7 +3762,8 @@ export type ModelWithReference = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithString.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -4603,7 +3780,8 @@ export type ModelWithString = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/MultilineComment.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -4617,7 +3795,8 @@ export type MultilineComment = number;" `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/SimpleBoolean.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -4628,7 +3807,8 @@ export type SimpleBoolean = boolean;" `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/SimpleFile.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -4639,7 +3819,8 @@ export type SimpleFile = Blob;" `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/SimpleInteger.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -4650,7 +3831,8 @@ export type SimpleInteger = number;" `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/SimpleReference.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -4663,7 +3845,8 @@ export type SimpleReference = ModelWithString;" `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/SimpleString.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -4674,7 +3857,8 @@ export type SimpleString = string;" `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/SimpleStringWithPattern.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -4684,8 +3868,64 @@ exports[`v3 should generate with exportClient: ./test/generated/v3_client/models export type SimpleStringWithPattern = string | null;" `; +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/index.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type { ArrayWithArray } from './ArrayWithArray'; +export type { ArrayWithBooleans } from './ArrayWithBooleans'; +export type { ArrayWithNumbers } from './ArrayWithNumbers'; +export type { ArrayWithProperties } from './ArrayWithProperties'; +export type { ArrayWithReferences } from './ArrayWithReferences'; +export type { ArrayWithStrings } from './ArrayWithStrings'; +export type { CompositionWithAllOfAndNullable } from './CompositionWithAllOfAndNullable'; +export type { CompositionWithAnyOf } from './CompositionWithAnyOf'; +export type { CompositionWithAnyOfAndNullable } from './CompositionWithAnyOfAndNullable'; +export type { CompositionWithAnyOfAnonymous } from './CompositionWithAnyOfAnonymous'; +export type { CompositionWithOneOf } from './CompositionWithOneOf'; +export type { CompositionWithOneOfAndNullable } from './CompositionWithOneOfAndNullable'; +export type { CompositionWithOneOfAnonymous } from './CompositionWithOneOfAnonymous'; +export type { DictionaryWithArray } from './DictionaryWithArray'; +export type { DictionaryWithDictionary } from './DictionaryWithDictionary'; +export type { DictionaryWithProperties } from './DictionaryWithProperties'; +export type { DictionaryWithReference } from './DictionaryWithReference'; +export type { DictionaryWithString } from './DictionaryWithString'; +export { EnumFromDescription } from './EnumFromDescription'; +export { EnumWithExtensions } from './EnumWithExtensions'; +export { EnumWithNumbers } from './EnumWithNumbers'; +export { EnumWithStrings } from './EnumWithStrings'; +export type { ModelThatExtends } from './ModelThatExtends'; +export type { ModelThatExtendsExtends } from './ModelThatExtendsExtends'; +export type { ModelWithArray } from './ModelWithArray'; +export type { ModelWithBoolean } from './ModelWithBoolean'; +export type { ModelWithCircularReference } from './ModelWithCircularReference'; +export type { ModelWithDictionary } from './ModelWithDictionary'; +export type { ModelWithDuplicateImports } from './ModelWithDuplicateImports'; +export type { ModelWithDuplicateProperties } from './ModelWithDuplicateProperties'; +export type { ModelWithEnum } from './ModelWithEnum'; +export type { ModelWithEnumFromDescription } from './ModelWithEnumFromDescription'; +export type { ModelWithInteger } from './ModelWithInteger'; +export type { ModelWithNestedEnums } from './ModelWithNestedEnums'; +export type { ModelWithNestedProperties } from './ModelWithNestedProperties'; +export type { ModelWithOrderedProperties } from './ModelWithOrderedProperties'; +export type { ModelWithPattern } from './ModelWithPattern'; +export type { ModelWithProperties } from './ModelWithProperties'; +export type { ModelWithReference } from './ModelWithReference'; +export type { ModelWithString } from './ModelWithString'; +export type { MultilineComment } from './MultilineComment'; +export type { SimpleBoolean } from './SimpleBoolean'; +export type { SimpleFile } from './SimpleFile'; +export type { SimpleInteger } from './SimpleInteger'; +export type { SimpleReference } from './SimpleReference'; +export type { SimpleString } from './SimpleString'; +export type { SimpleStringWithPattern } from './SimpleStringWithPattern'; +" +`; + exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ArrayWithArray.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ArrayWithArray = { @@ -4700,7 +3940,8 @@ export const $ArrayWithArray = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ArrayWithBooleans.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ArrayWithBooleans = { @@ -4712,7 +3953,8 @@ export const $ArrayWithBooleans = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ArrayWithNumbers.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ArrayWithNumbers = { @@ -4724,7 +3966,8 @@ export const $ArrayWithNumbers = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ArrayWithProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ArrayWithProperties = { @@ -4743,7 +3986,8 @@ export const $ArrayWithProperties = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ArrayWithReferences.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ArrayWithReferences = { @@ -4755,7 +3999,8 @@ export const $ArrayWithReferences = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ArrayWithStrings.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ArrayWithStrings = { @@ -4767,7 +4012,8 @@ export const $ArrayWithStrings = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$CompositionWithAllOfAndNullable.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $CompositionWithAllOfAndNullable = { @@ -4794,7 +4040,8 @@ export const $CompositionWithAllOfAndNullable = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$CompositionWithAnyOf.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $CompositionWithAnyOf = { @@ -4816,7 +4063,8 @@ export const $CompositionWithAnyOf = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$CompositionWithAnyOfAndNullable.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $CompositionWithAnyOfAndNullable = { @@ -4843,7 +4091,8 @@ export const $CompositionWithAnyOfAndNullable = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$CompositionWithAnyOfAnonymous.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $CompositionWithAnyOfAnonymous = { @@ -4868,7 +4117,8 @@ export const $CompositionWithAnyOfAnonymous = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$CompositionWithOneOf.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $CompositionWithOneOf = { @@ -4890,7 +4140,8 @@ export const $CompositionWithOneOf = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$CompositionWithOneOfAndNullable.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $CompositionWithOneOfAndNullable = { @@ -4917,7 +4168,8 @@ export const $CompositionWithOneOfAndNullable = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$CompositionWithOneOfAnonymous.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $CompositionWithOneOfAnonymous = { @@ -4942,7 +4194,8 @@ export const $CompositionWithOneOfAnonymous = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$DictionaryWithArray.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $DictionaryWithArray = { @@ -4957,7 +4210,8 @@ export const $DictionaryWithArray = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$DictionaryWithDictionary.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $DictionaryWithDictionary = { @@ -4972,7 +4226,8 @@ export const $DictionaryWithDictionary = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$DictionaryWithProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $DictionaryWithProperties = { @@ -4991,7 +4246,8 @@ export const $DictionaryWithProperties = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$DictionaryWithReference.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $DictionaryWithReference = { @@ -5003,7 +4259,8 @@ export const $DictionaryWithReference = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$DictionaryWithString.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $DictionaryWithString = { @@ -5015,7 +4272,8 @@ export const $DictionaryWithString = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$EnumFromDescription.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $EnumFromDescription = { @@ -5024,7 +4282,8 @@ export const $EnumFromDescription = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$EnumWithExtensions.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $EnumWithExtensions = { @@ -5033,7 +4292,8 @@ export const $EnumWithExtensions = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$EnumWithNumbers.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $EnumWithNumbers = { @@ -5042,7 +4302,8 @@ export const $EnumWithNumbers = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$EnumWithStrings.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $EnumWithStrings = { @@ -5051,7 +4312,8 @@ export const $EnumWithStrings = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelThatExtends.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelThatExtends = { @@ -5072,7 +4334,8 @@ export const $ModelThatExtends = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelThatExtendsExtends.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelThatExtendsExtends = { @@ -5095,7 +4358,8 @@ export const $ModelThatExtendsExtends = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithArray.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithArray = { @@ -5123,7 +4387,8 @@ export const $ModelWithArray = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithBoolean.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithBoolean = { @@ -5136,7 +4401,8 @@ export const $ModelWithBoolean = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithCircularReference.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithCircularReference = { @@ -5149,7 +4415,8 @@ export const $ModelWithCircularReference = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithDictionary.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithDictionary = { @@ -5165,7 +4432,8 @@ export const $ModelWithDictionary = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithDuplicateImports.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithDuplicateImports = { @@ -5184,7 +4452,8 @@ export const $ModelWithDuplicateImports = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithDuplicateProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithDuplicateProperties = { @@ -5197,7 +4466,8 @@ export const $ModelWithDuplicateProperties = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithEnum.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithEnum = { @@ -5216,7 +4486,8 @@ export const $ModelWithEnum = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithEnumFromDescription.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithEnumFromDescription = { @@ -5229,7 +4500,8 @@ export const $ModelWithEnumFromDescription = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithInteger.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithInteger = { @@ -5242,7 +4514,8 @@ export const $ModelWithInteger = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithNestedEnums.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithNestedEnums = { @@ -5276,7 +4549,8 @@ export const $ModelWithNestedEnums = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithNestedProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithNestedProperties = { @@ -5306,7 +4580,8 @@ export const $ModelWithNestedProperties = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithOrderedProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithOrderedProperties = { @@ -5325,7 +4600,8 @@ export const $ModelWithOrderedProperties = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithPattern.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithPattern = { @@ -5363,7 +4639,8 @@ export const $ModelWithPattern = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithProperties = { @@ -5416,7 +4693,8 @@ export const $ModelWithProperties = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithReference.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithReference = { @@ -5429,7 +4707,8 @@ export const $ModelWithReference = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithString.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithString = { @@ -5442,7 +4721,8 @@ export const $ModelWithString = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$MultilineComment.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $MultilineComment = { @@ -5451,7 +4731,8 @@ export const $MultilineComment = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$SimpleBoolean.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $SimpleBoolean = { @@ -5460,7 +4741,8 @@ export const $SimpleBoolean = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$SimpleFile.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $SimpleFile = { @@ -5469,7 +4751,8 @@ export const $SimpleFile = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$SimpleInteger.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $SimpleInteger = { @@ -5478,7 +4761,8 @@ export const $SimpleInteger = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$SimpleReference.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $SimpleReference = { @@ -5487,7 +4771,8 @@ export const $SimpleReference = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$SimpleString.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $SimpleString = { @@ -5496,7 +4781,8 @@ export const $SimpleString = { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$SimpleStringWithPattern.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $SimpleStringWithPattern = { @@ -5507,11 +4793,67 @@ export const $SimpleStringWithPattern = { };" `; +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/index.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export { $ArrayWithArray } from './$ArrayWithArray'; +export { $ArrayWithBooleans } from './$ArrayWithBooleans'; +export { $ArrayWithNumbers } from './$ArrayWithNumbers'; +export { $ArrayWithProperties } from './$ArrayWithProperties'; +export { $ArrayWithReferences } from './$ArrayWithReferences'; +export { $ArrayWithStrings } from './$ArrayWithStrings'; +export { $CompositionWithAllOfAndNullable } from './$CompositionWithAllOfAndNullable'; +export { $CompositionWithAnyOf } from './$CompositionWithAnyOf'; +export { $CompositionWithAnyOfAndNullable } from './$CompositionWithAnyOfAndNullable'; +export { $CompositionWithAnyOfAnonymous } from './$CompositionWithAnyOfAnonymous'; +export { $CompositionWithOneOf } from './$CompositionWithOneOf'; +export { $CompositionWithOneOfAndNullable } from './$CompositionWithOneOfAndNullable'; +export { $CompositionWithOneOfAnonymous } from './$CompositionWithOneOfAnonymous'; +export { $DictionaryWithArray } from './$DictionaryWithArray'; +export { $DictionaryWithDictionary } from './$DictionaryWithDictionary'; +export { $DictionaryWithProperties } from './$DictionaryWithProperties'; +export { $DictionaryWithReference } from './$DictionaryWithReference'; +export { $DictionaryWithString } from './$DictionaryWithString'; +export { $EnumFromDescription } from './$EnumFromDescription'; +export { $EnumWithExtensions } from './$EnumWithExtensions'; +export { $EnumWithNumbers } from './$EnumWithNumbers'; +export { $EnumWithStrings } from './$EnumWithStrings'; +export { $ModelThatExtends } from './$ModelThatExtends'; +export { $ModelThatExtendsExtends } from './$ModelThatExtendsExtends'; +export { $ModelWithArray } from './$ModelWithArray'; +export { $ModelWithBoolean } from './$ModelWithBoolean'; +export { $ModelWithCircularReference } from './$ModelWithCircularReference'; +export { $ModelWithDictionary } from './$ModelWithDictionary'; +export { $ModelWithDuplicateImports } from './$ModelWithDuplicateImports'; +export { $ModelWithDuplicateProperties } from './$ModelWithDuplicateProperties'; +export { $ModelWithEnum } from './$ModelWithEnum'; +export { $ModelWithEnumFromDescription } from './$ModelWithEnumFromDescription'; +export { $ModelWithInteger } from './$ModelWithInteger'; +export { $ModelWithNestedEnums } from './$ModelWithNestedEnums'; +export { $ModelWithNestedProperties } from './$ModelWithNestedProperties'; +export { $ModelWithOrderedProperties } from './$ModelWithOrderedProperties'; +export { $ModelWithPattern } from './$ModelWithPattern'; +export { $ModelWithProperties } from './$ModelWithProperties'; +export { $ModelWithReference } from './$ModelWithReference'; +export { $ModelWithString } from './$ModelWithString'; +export { $MultilineComment } from './$MultilineComment'; +export { $SimpleBoolean } from './$SimpleBoolean'; +export { $SimpleFile } from './$SimpleFile'; +export { $SimpleInteger } from './$SimpleInteger'; +export { $SimpleReference } from './$SimpleReference'; +export { $SimpleString } from './$SimpleString'; +export { $SimpleStringWithPattern } from './$SimpleStringWithPattern'; +" +`; + exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/CollectionFormatService.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { BaseHttpRequest } from '../core/BaseHttpRequest'; +import { BaseHttpRequest } from '../core'; export class CollectionFormatService { private httpRequest: BaseHttpRequest; @@ -5553,14 +4895,17 @@ export class CollectionFormatService { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/ComplexService.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ModelWithArray } from '../models/ModelWithArray'; -import type { ModelWithDictionary } from '../models/ModelWithDictionary'; -import type { ModelWithEnum } from '../models/ModelWithEnum'; -import type { ModelWithString } from '../models/ModelWithString'; -import { BaseHttpRequest } from '../core/BaseHttpRequest'; +import type { + ModelWithArray, + ModelWithDictionary, + ModelWithEnum, + ModelWithString, +} from '../models'; +import { BaseHttpRequest } from '../core'; export class ComplexService { private httpRequest: BaseHttpRequest; @@ -5635,11 +4980,14 @@ export class ComplexService { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/DefaultsService.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ModelWithString } from '../models/ModelWithString'; -import { BaseHttpRequest } from '../core/BaseHttpRequest'; +import type { + ModelWithString, +} from '../models'; +import { BaseHttpRequest } from '../core'; export class DefaultsService { private httpRequest: BaseHttpRequest; @@ -5746,10 +5094,11 @@ export class DefaultsService { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/DuplicateService.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { BaseHttpRequest } from '../core/BaseHttpRequest'; +import { BaseHttpRequest } from '../core'; export class DuplicateService { private httpRequest: BaseHttpRequest; @@ -5806,10 +5155,11 @@ export class DuplicateService { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/HeaderService.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { BaseHttpRequest } from '../core/BaseHttpRequest'; +import { BaseHttpRequest } from '../core'; export class HeaderService { private httpRequest: BaseHttpRequest; @@ -5839,10 +5189,11 @@ export class HeaderService { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/MultipartService.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { BaseHttpRequest } from '../core/BaseHttpRequest'; +import { BaseHttpRequest } from '../core'; export class MultipartService { private httpRequest: BaseHttpRequest; @@ -5873,10 +5224,11 @@ export class MultipartService { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/NoContentService.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { BaseHttpRequest } from '../core/BaseHttpRequest'; +import { BaseHttpRequest } from '../core'; export class NoContentService { private httpRequest: BaseHttpRequest; @@ -5901,11 +5253,14 @@ export class NoContentService { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/ParametersService.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ModelWithString } from '../models/ModelWithString'; -import { BaseHttpRequest } from '../core/BaseHttpRequest'; +import type { + ModelWithString, +} from '../models'; +import { BaseHttpRequest } from '../core'; export class ParametersService { private httpRequest: BaseHttpRequest; @@ -6043,11 +5398,14 @@ export class ParametersService { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/RequestBodyService.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ModelWithString } from '../models/ModelWithString'; -import { BaseHttpRequest } from '../core/BaseHttpRequest'; +import type { + ModelWithString, +} from '../models'; +import { BaseHttpRequest } from '../core'; export class RequestBodyService { private httpRequest: BaseHttpRequest; @@ -6076,13 +5434,16 @@ export class RequestBodyService { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/ResponseService.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ModelThatExtends } from '../models/ModelThatExtends'; -import type { ModelThatExtendsExtends } from '../models/ModelThatExtendsExtends'; -import type { ModelWithString } from '../models/ModelWithString'; -import { BaseHttpRequest } from '../core/BaseHttpRequest'; +import type { + ModelThatExtends, + ModelThatExtendsExtends, + ModelWithString, +} from '../models'; +import { BaseHttpRequest } from '../core'; export class ResponseService { private httpRequest: BaseHttpRequest; @@ -6148,10 +5509,11 @@ export class ResponseService { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/SimpleService.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { BaseHttpRequest } from '../core/BaseHttpRequest'; +import { BaseHttpRequest } from '../core'; export class SimpleService { private httpRequest: BaseHttpRequest; @@ -6241,10 +5603,11 @@ export class SimpleService { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/TypesService.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { BaseHttpRequest } from '../core/BaseHttpRequest'; +import { BaseHttpRequest } from '../core'; export class TypesService { private httpRequest: BaseHttpRequest; @@ -6298,10 +5661,11 @@ export class TypesService { `; exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/UploadService.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { BaseHttpRequest } from '../core/BaseHttpRequest'; +import { BaseHttpRequest } from '../core'; export class UploadService { private httpRequest: BaseHttpRequest; @@ -6330,3 +5694,24 @@ export class UploadService { }" `; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/index.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export { CollectionFormatService } from './CollectionFormatService'; +export { ComplexService } from './ComplexService'; +export { DefaultsService } from './DefaultsService'; +export { DuplicateService } from './DuplicateService'; +export { HeaderService } from './HeaderService'; +export { MultipartService } from './MultipartService'; +export { NoContentService } from './NoContentService'; +export { ParametersService } from './ParametersService'; +export { RequestBodyService } from './RequestBodyService'; +export { ResponseService } from './ResponseService'; +export { SimpleService } from './SimpleService'; +export { TypesService } from './TypesService'; +export { UploadService } from './UploadService'; +" +`; diff --git a/test/__snapshots__/index.spec.js.snap b/test/__snapshots__/index.spec.js.snap index 44da68af4..9b9b9d23d 100644 --- a/test/__snapshots__/index.spec.js.snap +++ b/test/__snapshots__/index.spec.js.snap @@ -1,7 +1,8 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`v2 should generate: ./test/generated/v2/core/ApiError.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ import type { ApiResult } from './ApiResult'; @@ -24,7 +25,8 @@ export class ApiError extends Error { `; exports[`v2 should generate: ./test/generated/v2/core/ApiRequestOptions.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export type ApiRequestOptions = { @@ -42,7 +44,8 @@ export type ApiRequestOptions = { `; exports[`v2 should generate: ./test/generated/v2/core/ApiResult.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export type ApiResult = { @@ -55,7 +58,8 @@ export type ApiResult = { `; exports[`v2 should generate: ./test/generated/v2/core/OpenAPI.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ import type { ApiRequestOptions } from './ApiRequestOptions'; @@ -84,8 +88,22 @@ export const OpenAPI: OpenAPIConfig = { " `; +exports[`v2 should generate: ./test/generated/v2/core/index.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export { ApiError } from './ApiError'; +export type { ApiRequestOptions } from './ApiRequestOptions'; +export type { ApiResult } from './ApiResult'; +export { OpenAPI } from './OpenAPI'; +export { request } from './request'; +" +`; + exports[`v2 should generate: ./test/generated/v2/core/request.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ import { ApiError } from './ApiError'; @@ -299,114 +317,21 @@ export async function request(options: ApiRequestOptions): Promise { `; exports[`v2 should generate: ./test/generated/v2/index.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -export { ApiError } from './core/ApiError'; -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 { Date } from './models/Date'; -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 { 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 { ModelWithNestedEnums } from './models/ModelWithNestedEnums'; -export type { ModelWithNestedProperties } from './models/ModelWithNestedProperties'; -export type { ModelWithNullableString } from './models/ModelWithNullableString'; -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 type { SimpleStringWithPattern } from './models/SimpleStringWithPattern'; - -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 { $Date } from './schemas/$Date'; -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 { $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 { $ModelWithNestedEnums } from './schemas/$ModelWithNestedEnums'; -export { $ModelWithNestedProperties } from './schemas/$ModelWithNestedProperties'; -export { $ModelWithNullableString } from './schemas/$ModelWithNullableString'; -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 { $SimpleStringWithPattern } from './schemas/$SimpleStringWithPattern'; - -export { CollectionFormatService } from './services/CollectionFormatService'; -export { ComplexService } from './services/ComplexService'; -export { DefaultsService } from './services/DefaultsService'; -export { DuplicateService } from './services/DuplicateService'; -export { HeaderService } from './services/HeaderService'; -export { NoContentService } from './services/NoContentService'; -export { ParametersService } from './services/ParametersService'; -export { ResponseService } from './services/ResponseService'; -export { SimpleService } from './services/SimpleService'; -export { TypesService } from './services/TypesService'; +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export * from './core'; +export * from './models'; +export * from './schemas'; +export * from './services'; " `; exports[`v2 should generate: ./test/generated/v2/models/ArrayWithArray.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -419,7 +344,8 @@ export type ArrayWithArray = Array>;" `; exports[`v2 should generate: ./test/generated/v2/models/ArrayWithBooleans.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -430,7 +356,8 @@ export type ArrayWithBooleans = Array;" `; exports[`v2 should generate: ./test/generated/v2/models/ArrayWithNumbers.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -441,7 +368,8 @@ export type ArrayWithNumbers = Array;" `; exports[`v2 should generate: ./test/generated/v2/models/ArrayWithProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -455,7 +383,8 @@ export type ArrayWithProperties = Array<{ `; exports[`v2 should generate: ./test/generated/v2/models/ArrayWithReferences.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -468,7 +397,8 @@ export type ArrayWithReferences = Array;" `; exports[`v2 should generate: ./test/generated/v2/models/ArrayWithStrings.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -479,7 +409,8 @@ export type ArrayWithStrings = Array;" `; exports[`v2 should generate: ./test/generated/v2/models/Date.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -490,7 +421,8 @@ export type Date = string;" `; exports[`v2 should generate: ./test/generated/v2/models/DictionaryWithArray.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -503,7 +435,8 @@ export type DictionaryWithArray = Record>;" `; exports[`v2 should generate: ./test/generated/v2/models/DictionaryWithDictionary.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -514,7 +447,8 @@ export type DictionaryWithDictionary = Record>;" `; exports[`v2 should generate: ./test/generated/v2/models/DictionaryWithProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -528,7 +462,8 @@ export type DictionaryWithProperties = Record;" `; exports[`v2 should generate: ./test/generated/v2/models/DictionaryWithString.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -552,7 +488,8 @@ export type DictionaryWithString = Record;" `; exports[`v2 should generate: ./test/generated/v2/models/EnumFromDescription.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -567,7 +504,8 @@ export enum EnumFromDescription { `; exports[`v2 should generate: ./test/generated/v2/models/EnumWithExtensions.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -591,7 +529,8 @@ export enum EnumWithExtensions { `; exports[`v2 should generate: ./test/generated/v2/models/EnumWithNumbers.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -618,7 +557,8 @@ export enum EnumWithNumbers { `; exports[`v2 should generate: ./test/generated/v2/models/EnumWithStrings.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -633,7 +573,8 @@ export enum EnumWithStrings { `; exports[`v2 should generate: ./test/generated/v2/models/ModelThatExtends.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -650,7 +591,8 @@ export type ModelThatExtends = (ModelWithString & { `; exports[`v2 should generate: ./test/generated/v2/models/ModelThatExtendsExtends.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -668,7 +610,8 @@ export type ModelThatExtendsExtends = (ModelWithString & ModelThatExtends & { `; exports[`v2 should generate: ./test/generated/v2/models/ModelWithArray.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -686,7 +629,8 @@ export type ModelWithArray = { `; exports[`v2 should generate: ./test/generated/v2/models/ModelWithBoolean.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -703,7 +647,8 @@ export type ModelWithBoolean = { `; exports[`v2 should generate: ./test/generated/v2/models/ModelWithCircularReference.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -717,7 +662,8 @@ export type ModelWithCircularReference = { `; exports[`v2 should generate: ./test/generated/v2/models/ModelWithDictionary.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -731,7 +677,8 @@ export type ModelWithDictionary = { `; exports[`v2 should generate: ./test/generated/v2/models/ModelWithDuplicateImports.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -749,7 +696,8 @@ export type ModelWithDuplicateImports = { `; exports[`v2 should generate: ./test/generated/v2/models/ModelWithDuplicateProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -765,7 +713,8 @@ export type ModelWithDuplicateProperties = { `; exports[`v2 should generate: ./test/generated/v2/models/ModelWithEnum.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -816,7 +765,8 @@ export namespace ModelWithEnum { `; exports[`v2 should generate: ./test/generated/v2/models/ModelWithEnumFromDescription.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -847,7 +797,8 @@ export namespace ModelWithEnumFromDescription { `; exports[`v2 should generate: ./test/generated/v2/models/ModelWithInteger.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -864,7 +815,8 @@ export type ModelWithInteger = { `; exports[`v2 should generate: ./test/generated/v2/models/ModelWithNestedEnums.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -881,7 +833,8 @@ export type ModelWithNestedEnums = { `; exports[`v2 should generate: ./test/generated/v2/models/ModelWithNestedProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -899,7 +852,8 @@ export type ModelWithNestedProperties = { `; exports[`v2 should generate: ./test/generated/v2/models/ModelWithNullableString.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -920,7 +874,8 @@ export type ModelWithNullableString = { `; exports[`v2 should generate: ./test/generated/v2/models/ModelWithOrderedProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -936,7 +891,8 @@ export type ModelWithOrderedProperties = { `; exports[`v2 should generate: ./test/generated/v2/models/ModelWithPattern.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -955,7 +911,8 @@ export type ModelWithPattern = { `; exports[`v2 should generate: ./test/generated/v2/models/ModelWithProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -981,7 +938,8 @@ export type ModelWithProperties = { `; exports[`v2 should generate: ./test/generated/v2/models/ModelWithReference.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -997,7 +955,8 @@ export type ModelWithReference = { `; exports[`v2 should generate: ./test/generated/v2/models/ModelWithString.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1014,7 +973,8 @@ export type ModelWithString = { `; exports[`v2 should generate: ./test/generated/v2/models/MultilineComment.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1028,7 +988,8 @@ export type MultilineComment = number;" `; exports[`v2 should generate: ./test/generated/v2/models/SimpleBoolean.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1039,7 +1000,8 @@ export type SimpleBoolean = boolean;" `; exports[`v2 should generate: ./test/generated/v2/models/SimpleFile.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1050,7 +1012,8 @@ export type SimpleFile = Blob;" `; exports[`v2 should generate: ./test/generated/v2/models/SimpleInteger.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1061,7 +1024,8 @@ export type SimpleInteger = number;" `; exports[`v2 should generate: ./test/generated/v2/models/SimpleReference.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1074,7 +1038,8 @@ export type SimpleReference = ModelWithString;" `; exports[`v2 should generate: ./test/generated/v2/models/SimpleString.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1085,7 +1050,8 @@ export type SimpleString = string;" `; exports[`v2 should generate: ./test/generated/v2/models/SimpleStringWithPattern.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1095,8 +1061,59 @@ exports[`v2 should generate: ./test/generated/v2/models/SimpleStringWithPattern. export type SimpleStringWithPattern = string;" `; +exports[`v2 should generate: ./test/generated/v2/models/index.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type { ArrayWithArray } from './ArrayWithArray'; +export type { ArrayWithBooleans } from './ArrayWithBooleans'; +export type { ArrayWithNumbers } from './ArrayWithNumbers'; +export type { ArrayWithProperties } from './ArrayWithProperties'; +export type { ArrayWithReferences } from './ArrayWithReferences'; +export type { ArrayWithStrings } from './ArrayWithStrings'; +export type { Date } from './Date'; +export type { DictionaryWithArray } from './DictionaryWithArray'; +export type { DictionaryWithDictionary } from './DictionaryWithDictionary'; +export type { DictionaryWithProperties } from './DictionaryWithProperties'; +export type { DictionaryWithReference } from './DictionaryWithReference'; +export type { DictionaryWithString } from './DictionaryWithString'; +export { EnumFromDescription } from './EnumFromDescription'; +export { EnumWithExtensions } from './EnumWithExtensions'; +export { EnumWithNumbers } from './EnumWithNumbers'; +export { EnumWithStrings } from './EnumWithStrings'; +export type { ModelThatExtends } from './ModelThatExtends'; +export type { ModelThatExtendsExtends } from './ModelThatExtendsExtends'; +export type { ModelWithArray } from './ModelWithArray'; +export type { ModelWithBoolean } from './ModelWithBoolean'; +export type { ModelWithCircularReference } from './ModelWithCircularReference'; +export type { ModelWithDictionary } from './ModelWithDictionary'; +export type { ModelWithDuplicateImports } from './ModelWithDuplicateImports'; +export type { ModelWithDuplicateProperties } from './ModelWithDuplicateProperties'; +export type { ModelWithEnum } from './ModelWithEnum'; +export type { ModelWithEnumFromDescription } from './ModelWithEnumFromDescription'; +export type { ModelWithInteger } from './ModelWithInteger'; +export type { ModelWithNestedEnums } from './ModelWithNestedEnums'; +export type { ModelWithNestedProperties } from './ModelWithNestedProperties'; +export type { ModelWithNullableString } from './ModelWithNullableString'; +export type { ModelWithOrderedProperties } from './ModelWithOrderedProperties'; +export type { ModelWithPattern } from './ModelWithPattern'; +export type { ModelWithProperties } from './ModelWithProperties'; +export type { ModelWithReference } from './ModelWithReference'; +export type { ModelWithString } from './ModelWithString'; +export type { MultilineComment } from './MultilineComment'; +export type { SimpleBoolean } from './SimpleBoolean'; +export type { SimpleFile } from './SimpleFile'; +export type { SimpleInteger } from './SimpleInteger'; +export type { SimpleReference } from './SimpleReference'; +export type { SimpleString } from './SimpleString'; +export type { SimpleStringWithPattern } from './SimpleStringWithPattern'; +" +`; + exports[`v2 should generate: ./test/generated/v2/schemas/$ArrayWithArray.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ArrayWithArray = { @@ -1111,7 +1128,8 @@ export const $ArrayWithArray = { `; exports[`v2 should generate: ./test/generated/v2/schemas/$ArrayWithBooleans.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ArrayWithBooleans = { @@ -1123,7 +1141,8 @@ export const $ArrayWithBooleans = { `; exports[`v2 should generate: ./test/generated/v2/schemas/$ArrayWithNumbers.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ArrayWithNumbers = { @@ -1135,7 +1154,8 @@ export const $ArrayWithNumbers = { `; exports[`v2 should generate: ./test/generated/v2/schemas/$ArrayWithProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ArrayWithProperties = { @@ -1154,7 +1174,8 @@ export const $ArrayWithProperties = { `; exports[`v2 should generate: ./test/generated/v2/schemas/$ArrayWithReferences.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ArrayWithReferences = { @@ -1166,7 +1187,8 @@ export const $ArrayWithReferences = { `; exports[`v2 should generate: ./test/generated/v2/schemas/$ArrayWithStrings.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ArrayWithStrings = { @@ -1178,7 +1200,8 @@ export const $ArrayWithStrings = { `; exports[`v2 should generate: ./test/generated/v2/schemas/$Date.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $Date = { @@ -1187,7 +1210,8 @@ export const $Date = { `; exports[`v2 should generate: ./test/generated/v2/schemas/$DictionaryWithArray.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $DictionaryWithArray = { @@ -1202,7 +1226,8 @@ export const $DictionaryWithArray = { `; exports[`v2 should generate: ./test/generated/v2/schemas/$DictionaryWithDictionary.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $DictionaryWithDictionary = { @@ -1217,7 +1242,8 @@ export const $DictionaryWithDictionary = { `; exports[`v2 should generate: ./test/generated/v2/schemas/$DictionaryWithProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $DictionaryWithProperties = { @@ -1236,7 +1262,8 @@ export const $DictionaryWithProperties = { `; exports[`v2 should generate: ./test/generated/v2/schemas/$DictionaryWithReference.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $DictionaryWithReference = { @@ -1248,7 +1275,8 @@ export const $DictionaryWithReference = { `; exports[`v2 should generate: ./test/generated/v2/schemas/$DictionaryWithString.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $DictionaryWithString = { @@ -1260,7 +1288,8 @@ export const $DictionaryWithString = { `; exports[`v2 should generate: ./test/generated/v2/schemas/$EnumFromDescription.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $EnumFromDescription = { @@ -1269,7 +1298,8 @@ export const $EnumFromDescription = { `; exports[`v2 should generate: ./test/generated/v2/schemas/$EnumWithExtensions.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $EnumWithExtensions = { @@ -1278,7 +1308,8 @@ export const $EnumWithExtensions = { `; exports[`v2 should generate: ./test/generated/v2/schemas/$EnumWithNumbers.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $EnumWithNumbers = { @@ -1287,7 +1318,8 @@ export const $EnumWithNumbers = { `; exports[`v2 should generate: ./test/generated/v2/schemas/$EnumWithStrings.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $EnumWithStrings = { @@ -1296,7 +1328,8 @@ export const $EnumWithStrings = { `; exports[`v2 should generate: ./test/generated/v2/schemas/$ModelThatExtends.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelThatExtends = { @@ -1317,7 +1350,8 @@ export const $ModelThatExtends = { `; exports[`v2 should generate: ./test/generated/v2/schemas/$ModelThatExtendsExtends.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelThatExtendsExtends = { @@ -1340,7 +1374,8 @@ export const $ModelThatExtendsExtends = { `; exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithArray.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithArray = { @@ -1368,7 +1403,8 @@ export const $ModelWithArray = { `; exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithBoolean.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithBoolean = { @@ -1381,7 +1417,8 @@ export const $ModelWithBoolean = { `; exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithCircularReference.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithCircularReference = { @@ -1394,7 +1431,8 @@ export const $ModelWithCircularReference = { `; exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithDictionary.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithDictionary = { @@ -1410,7 +1448,8 @@ export const $ModelWithDictionary = { `; exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithDuplicateImports.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithDuplicateImports = { @@ -1429,7 +1468,8 @@ export const $ModelWithDuplicateImports = { `; exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithDuplicateProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithDuplicateProperties = { @@ -1442,7 +1482,8 @@ export const $ModelWithDuplicateProperties = { `; exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithEnum.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithEnum = { @@ -1461,7 +1502,8 @@ export const $ModelWithEnum = { `; exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithEnumFromDescription.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithEnumFromDescription = { @@ -1474,7 +1516,8 @@ export const $ModelWithEnumFromDescription = { `; exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithInteger.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithInteger = { @@ -1487,7 +1530,8 @@ export const $ModelWithInteger = { `; exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithNestedEnums.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithNestedEnums = { @@ -1521,7 +1565,8 @@ export const $ModelWithNestedEnums = { `; exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithNestedProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithNestedProperties = { @@ -1548,7 +1593,8 @@ export const $ModelWithNestedProperties = { `; exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithNullableString.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithNullableString = { @@ -1567,7 +1613,8 @@ export const $ModelWithNullableString = { `; exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithOrderedProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithOrderedProperties = { @@ -1586,7 +1633,8 @@ export const $ModelWithOrderedProperties = { `; exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithPattern.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithPattern = { @@ -1624,7 +1672,8 @@ export const $ModelWithPattern = { `; exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithProperties = { @@ -1672,7 +1721,8 @@ export const $ModelWithProperties = { `; exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithReference.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithReference = { @@ -1685,7 +1735,8 @@ export const $ModelWithReference = { `; exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithString.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithString = { @@ -1698,7 +1749,8 @@ export const $ModelWithString = { `; exports[`v2 should generate: ./test/generated/v2/schemas/$MultilineComment.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $MultilineComment = { @@ -1707,7 +1759,8 @@ export const $MultilineComment = { `; exports[`v2 should generate: ./test/generated/v2/schemas/$SimpleBoolean.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $SimpleBoolean = { @@ -1716,7 +1769,8 @@ export const $SimpleBoolean = { `; exports[`v2 should generate: ./test/generated/v2/schemas/$SimpleFile.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $SimpleFile = { @@ -1725,7 +1779,8 @@ export const $SimpleFile = { `; exports[`v2 should generate: ./test/generated/v2/schemas/$SimpleInteger.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $SimpleInteger = { @@ -1734,7 +1789,8 @@ export const $SimpleInteger = { `; exports[`v2 should generate: ./test/generated/v2/schemas/$SimpleReference.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $SimpleReference = { @@ -1743,7 +1799,8 @@ export const $SimpleReference = { `; exports[`v2 should generate: ./test/generated/v2/schemas/$SimpleString.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $SimpleString = { @@ -1752,7 +1809,8 @@ export const $SimpleString = { `; exports[`v2 should generate: ./test/generated/v2/schemas/$SimpleStringWithPattern.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $SimpleStringWithPattern = { @@ -1762,12 +1820,65 @@ export const $SimpleStringWithPattern = { };" `; +exports[`v2 should generate: ./test/generated/v2/schemas/index.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export { $ArrayWithArray } from './$ArrayWithArray'; +export { $ArrayWithBooleans } from './$ArrayWithBooleans'; +export { $ArrayWithNumbers } from './$ArrayWithNumbers'; +export { $ArrayWithProperties } from './$ArrayWithProperties'; +export { $ArrayWithReferences } from './$ArrayWithReferences'; +export { $ArrayWithStrings } from './$ArrayWithStrings'; +export { $Date } from './$Date'; +export { $DictionaryWithArray } from './$DictionaryWithArray'; +export { $DictionaryWithDictionary } from './$DictionaryWithDictionary'; +export { $DictionaryWithProperties } from './$DictionaryWithProperties'; +export { $DictionaryWithReference } from './$DictionaryWithReference'; +export { $DictionaryWithString } from './$DictionaryWithString'; +export { $EnumFromDescription } from './$EnumFromDescription'; +export { $EnumWithExtensions } from './$EnumWithExtensions'; +export { $EnumWithNumbers } from './$EnumWithNumbers'; +export { $EnumWithStrings } from './$EnumWithStrings'; +export { $ModelThatExtends } from './$ModelThatExtends'; +export { $ModelThatExtendsExtends } from './$ModelThatExtendsExtends'; +export { $ModelWithArray } from './$ModelWithArray'; +export { $ModelWithBoolean } from './$ModelWithBoolean'; +export { $ModelWithCircularReference } from './$ModelWithCircularReference'; +export { $ModelWithDictionary } from './$ModelWithDictionary'; +export { $ModelWithDuplicateImports } from './$ModelWithDuplicateImports'; +export { $ModelWithDuplicateProperties } from './$ModelWithDuplicateProperties'; +export { $ModelWithEnum } from './$ModelWithEnum'; +export { $ModelWithEnumFromDescription } from './$ModelWithEnumFromDescription'; +export { $ModelWithInteger } from './$ModelWithInteger'; +export { $ModelWithNestedEnums } from './$ModelWithNestedEnums'; +export { $ModelWithNestedProperties } from './$ModelWithNestedProperties'; +export { $ModelWithNullableString } from './$ModelWithNullableString'; +export { $ModelWithOrderedProperties } from './$ModelWithOrderedProperties'; +export { $ModelWithPattern } from './$ModelWithPattern'; +export { $ModelWithProperties } from './$ModelWithProperties'; +export { $ModelWithReference } from './$ModelWithReference'; +export { $ModelWithString } from './$ModelWithString'; +export { $MultilineComment } from './$MultilineComment'; +export { $SimpleBoolean } from './$SimpleBoolean'; +export { $SimpleFile } from './$SimpleFile'; +export { $SimpleInteger } from './$SimpleInteger'; +export { $SimpleReference } from './$SimpleReference'; +export { $SimpleString } from './$SimpleString'; +export { $SimpleStringWithPattern } from './$SimpleStringWithPattern'; +" +`; + exports[`v2 should generate: ./test/generated/v2/services/CollectionFormatService.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; +import { + request as __request, + OpenAPI, +} from '../core'; export class CollectionFormatService { @@ -1804,12 +1915,17 @@ export class CollectionFormatService { `; exports[`v2 should generate: ./test/generated/v2/services/ComplexService.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ModelWithString } from '../models/ModelWithString'; -import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; +import type { + ModelWithString, +} from '../models'; +import { + request as __request, + OpenAPI, +} from '../core'; export class ComplexService { @@ -1848,12 +1964,17 @@ export class ComplexService { `; exports[`v2 should generate: ./test/generated/v2/services/DefaultsService.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ModelWithString } from '../models/ModelWithString'; -import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; +import type { + ModelWithString, +} from '../models'; +import { + request as __request, + OpenAPI, +} from '../core'; export class DefaultsService { @@ -1955,11 +2076,14 @@ export class DefaultsService { `; exports[`v2 should generate: ./test/generated/v2/services/DuplicateService.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; +import { + request as __request, + OpenAPI, +} from '../core'; export class DuplicateService { @@ -2011,11 +2135,14 @@ export class DuplicateService { `; exports[`v2 should generate: ./test/generated/v2/services/HeaderService.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; +import { + request as __request, + OpenAPI, +} from '../core'; export class HeaderService { @@ -2040,11 +2167,14 @@ export class HeaderService { `; exports[`v2 should generate: ./test/generated/v2/services/NoContentService.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; +import { + request as __request, + OpenAPI, +} from '../core'; export class NoContentService { @@ -2064,11 +2194,14 @@ export class NoContentService { `; exports[`v2 should generate: ./test/generated/v2/services/ParametersService.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; +import { + request as __request, + OpenAPI, +} from '../core'; export class ParametersService { @@ -2147,14 +2280,19 @@ export class ParametersService { `; exports[`v2 should generate: ./test/generated/v2/services/ResponseService.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ModelThatExtends } from '../models/ModelThatExtends'; -import type { ModelThatExtendsExtends } from '../models/ModelThatExtendsExtends'; -import type { ModelWithString } from '../models/ModelWithString'; -import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; +import type { + ModelThatExtends, + ModelThatExtendsExtends, + ModelWithString, +} from '../models'; +import { + request as __request, + OpenAPI, +} from '../core'; export class ResponseService { @@ -2215,11 +2353,14 @@ export class ResponseService { `; exports[`v2 should generate: ./test/generated/v2/services/SimpleService.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; +import { + request as __request, + OpenAPI, +} from '../core'; export class SimpleService { @@ -2304,11 +2445,14 @@ export class SimpleService { `; exports[`v2 should generate: ./test/generated/v2/services/TypesService.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; +import { + request as __request, + OpenAPI, +} from '../core'; export class TypesService { @@ -2356,8 +2500,27 @@ export class TypesService { }" `; +exports[`v2 should generate: ./test/generated/v2/services/index.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export { CollectionFormatService } from './CollectionFormatService'; +export { ComplexService } from './ComplexService'; +export { DefaultsService } from './DefaultsService'; +export { DuplicateService } from './DuplicateService'; +export { HeaderService } from './HeaderService'; +export { NoContentService } from './NoContentService'; +export { ParametersService } from './ParametersService'; +export { ResponseService } from './ResponseService'; +export { SimpleService } from './SimpleService'; +export { TypesService } from './TypesService'; +" +`; + exports[`v3 should generate: ./test/generated/v3/core/ApiError.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ import type { ApiResult } from './ApiResult'; @@ -2380,7 +2543,8 @@ export class ApiError extends Error { `; exports[`v3 should generate: ./test/generated/v3/core/ApiRequestOptions.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export type ApiRequestOptions = { @@ -2398,7 +2562,8 @@ export type ApiRequestOptions = { `; exports[`v3 should generate: ./test/generated/v3/core/ApiResult.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export type ApiResult = { @@ -2411,7 +2576,8 @@ export type ApiResult = { `; exports[`v3 should generate: ./test/generated/v3/core/OpenAPI.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ import type { ApiRequestOptions } from './ApiRequestOptions'; @@ -2440,8 +2606,22 @@ export const OpenAPI: OpenAPIConfig = { " `; +exports[`v3 should generate: ./test/generated/v3/core/index.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export { ApiError } from './ApiError'; +export type { ApiRequestOptions } from './ApiRequestOptions'; +export type { ApiResult } from './ApiResult'; +export { OpenAPI } from './OpenAPI'; +export { request } from './request'; +" +`; + exports[`v3 should generate: ./test/generated/v3/core/request.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ import { ApiError } from './ApiError'; @@ -2655,127 +2835,21 @@ export async function request(options: ApiRequestOptions): Promise { `; exports[`v3 should generate: ./test/generated/v3/index.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -export { ApiError } from './core/ApiError'; -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 { CompositionWithAllOfAndNullable } from './models/CompositionWithAllOfAndNullable'; -export type { CompositionWithAnyOf } from './models/CompositionWithAnyOf'; -export type { CompositionWithAnyOfAndNullable } from './models/CompositionWithAnyOfAndNullable'; -export type { CompositionWithAnyOfAnonymous } from './models/CompositionWithAnyOfAnonymous'; -export type { CompositionWithOneOf } from './models/CompositionWithOneOf'; -export type { CompositionWithOneOfAndNullable } from './models/CompositionWithOneOfAndNullable'; -export type { CompositionWithOneOfAnonymous } from './models/CompositionWithOneOfAnonymous'; -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 { 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 { 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 type { SimpleStringWithPattern } from './models/SimpleStringWithPattern'; - -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 { $CompositionWithAllOfAndNullable } from './schemas/$CompositionWithAllOfAndNullable'; -export { $CompositionWithAnyOf } from './schemas/$CompositionWithAnyOf'; -export { $CompositionWithAnyOfAndNullable } from './schemas/$CompositionWithAnyOfAndNullable'; -export { $CompositionWithAnyOfAnonymous } from './schemas/$CompositionWithAnyOfAnonymous'; -export { $CompositionWithOneOf } from './schemas/$CompositionWithOneOf'; -export { $CompositionWithOneOfAndNullable } from './schemas/$CompositionWithOneOfAndNullable'; -export { $CompositionWithOneOfAnonymous } from './schemas/$CompositionWithOneOfAnonymous'; -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 { $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 { $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 { $SimpleStringWithPattern } from './schemas/$SimpleStringWithPattern'; - -export { CollectionFormatService } from './services/CollectionFormatService'; -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 { NoContentService } from './services/NoContentService'; -export { ParametersService } from './services/ParametersService'; -export { RequestBodyService } from './services/RequestBodyService'; -export { ResponseService } from './services/ResponseService'; -export { SimpleService } from './services/SimpleService'; -export { TypesService } from './services/TypesService'; -export { UploadService } from './services/UploadService'; +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export * from './core'; +export * from './models'; +export * from './schemas'; +export * from './services'; " `; exports[`v3 should generate: ./test/generated/v3/models/ArrayWithArray.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -2788,7 +2862,8 @@ export type ArrayWithArray = Array>;" `; exports[`v3 should generate: ./test/generated/v3/models/ArrayWithBooleans.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -2799,7 +2874,8 @@ export type ArrayWithBooleans = Array;" `; exports[`v3 should generate: ./test/generated/v3/models/ArrayWithNumbers.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -2810,7 +2886,8 @@ export type ArrayWithNumbers = Array;" `; exports[`v3 should generate: ./test/generated/v3/models/ArrayWithProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -2824,7 +2901,8 @@ export type ArrayWithProperties = Array<{ `; exports[`v3 should generate: ./test/generated/v3/models/ArrayWithReferences.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -2837,7 +2915,8 @@ export type ArrayWithReferences = Array;" `; exports[`v3 should generate: ./test/generated/v3/models/ArrayWithStrings.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -2848,7 +2927,8 @@ export type ArrayWithStrings = Array;" `; exports[`v3 should generate: ./test/generated/v3/models/CompositionWithAllOfAndNullable.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -2868,7 +2948,8 @@ export type CompositionWithAllOfAndNullable = { `; exports[`v3 should generate: ./test/generated/v3/models/CompositionWithAnyOf.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -2887,7 +2968,8 @@ export type CompositionWithAnyOf = { `; exports[`v3 should generate: ./test/generated/v3/models/CompositionWithAnyOfAndNullable.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -2907,7 +2989,8 @@ export type CompositionWithAnyOfAndNullable = { `; exports[`v3 should generate: ./test/generated/v3/models/CompositionWithAnyOfAnonymous.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -2923,7 +3006,8 @@ export type CompositionWithAnyOfAnonymous = { `; exports[`v3 should generate: ./test/generated/v3/models/CompositionWithOneOf.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -2942,7 +3026,8 @@ export type CompositionWithOneOf = { `; exports[`v3 should generate: ./test/generated/v3/models/CompositionWithOneOfAndNullable.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -2962,7 +3047,8 @@ export type CompositionWithOneOfAndNullable = { `; exports[`v3 should generate: ./test/generated/v3/models/CompositionWithOneOfAnonymous.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -2978,7 +3064,8 @@ export type CompositionWithOneOfAnonymous = { `; exports[`v3 should generate: ./test/generated/v3/models/DictionaryWithArray.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -2991,7 +3078,8 @@ export type DictionaryWithArray = Record>;" `; exports[`v3 should generate: ./test/generated/v3/models/DictionaryWithDictionary.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3002,7 +3090,8 @@ export type DictionaryWithDictionary = Record>;" `; exports[`v3 should generate: ./test/generated/v3/models/DictionaryWithProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3016,7 +3105,8 @@ export type DictionaryWithProperties = Record;" `; exports[`v3 should generate: ./test/generated/v3/models/DictionaryWithString.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3040,7 +3131,8 @@ export type DictionaryWithString = Record;" `; exports[`v3 should generate: ./test/generated/v3/models/EnumFromDescription.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3055,7 +3147,8 @@ export enum EnumFromDescription { `; exports[`v3 should generate: ./test/generated/v3/models/EnumWithExtensions.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3079,7 +3172,8 @@ export enum EnumWithExtensions { `; exports[`v3 should generate: ./test/generated/v3/models/EnumWithNumbers.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3106,7 +3200,8 @@ export enum EnumWithNumbers { `; exports[`v3 should generate: ./test/generated/v3/models/EnumWithStrings.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3121,7 +3216,8 @@ export enum EnumWithStrings { `; exports[`v3 should generate: ./test/generated/v3/models/ModelThatExtends.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3138,7 +3234,8 @@ export type ModelThatExtends = (ModelWithString & { `; exports[`v3 should generate: ./test/generated/v3/models/ModelThatExtendsExtends.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3156,7 +3253,8 @@ export type ModelThatExtendsExtends = (ModelWithString & ModelThatExtends & { `; exports[`v3 should generate: ./test/generated/v3/models/ModelWithArray.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3174,7 +3272,8 @@ export type ModelWithArray = { `; exports[`v3 should generate: ./test/generated/v3/models/ModelWithBoolean.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3191,7 +3290,8 @@ export type ModelWithBoolean = { `; exports[`v3 should generate: ./test/generated/v3/models/ModelWithCircularReference.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3205,7 +3305,8 @@ export type ModelWithCircularReference = { `; exports[`v3 should generate: ./test/generated/v3/models/ModelWithDictionary.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3219,7 +3320,8 @@ export type ModelWithDictionary = { `; exports[`v3 should generate: ./test/generated/v3/models/ModelWithDuplicateImports.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3237,7 +3339,8 @@ export type ModelWithDuplicateImports = { `; exports[`v3 should generate: ./test/generated/v3/models/ModelWithDuplicateProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3253,7 +3356,8 @@ export type ModelWithDuplicateProperties = { `; exports[`v3 should generate: ./test/generated/v3/models/ModelWithEnum.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3304,7 +3408,8 @@ export namespace ModelWithEnum { `; exports[`v3 should generate: ./test/generated/v3/models/ModelWithEnumFromDescription.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3335,7 +3440,8 @@ export namespace ModelWithEnumFromDescription { `; exports[`v3 should generate: ./test/generated/v3/models/ModelWithInteger.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3352,7 +3458,8 @@ export type ModelWithInteger = { `; exports[`v3 should generate: ./test/generated/v3/models/ModelWithNestedEnums.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3369,7 +3476,8 @@ export type ModelWithNestedEnums = { `; exports[`v3 should generate: ./test/generated/v3/models/ModelWithNestedProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3387,7 +3495,8 @@ export type ModelWithNestedProperties = { `; exports[`v3 should generate: ./test/generated/v3/models/ModelWithOrderedProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3403,7 +3512,8 @@ export type ModelWithOrderedProperties = { `; exports[`v3 should generate: ./test/generated/v3/models/ModelWithPattern.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3422,7 +3532,8 @@ export type ModelWithPattern = { `; exports[`v3 should generate: ./test/generated/v3/models/ModelWithProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3449,7 +3560,8 @@ export type ModelWithProperties = { `; exports[`v3 should generate: ./test/generated/v3/models/ModelWithReference.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3465,7 +3577,8 @@ export type ModelWithReference = { `; exports[`v3 should generate: ./test/generated/v3/models/ModelWithString.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3482,7 +3595,8 @@ export type ModelWithString = { `; exports[`v3 should generate: ./test/generated/v3/models/MultilineComment.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3496,7 +3610,8 @@ export type MultilineComment = number;" `; exports[`v3 should generate: ./test/generated/v3/models/SimpleBoolean.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3507,7 +3622,8 @@ export type SimpleBoolean = boolean;" `; exports[`v3 should generate: ./test/generated/v3/models/SimpleFile.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3518,7 +3634,8 @@ export type SimpleFile = Blob;" `; exports[`v3 should generate: ./test/generated/v3/models/SimpleInteger.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3529,7 +3646,8 @@ export type SimpleInteger = number;" `; exports[`v3 should generate: ./test/generated/v3/models/SimpleReference.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3542,7 +3660,8 @@ export type SimpleReference = ModelWithString;" `; exports[`v3 should generate: ./test/generated/v3/models/SimpleString.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3553,7 +3672,8 @@ export type SimpleString = string;" `; exports[`v3 should generate: ./test/generated/v3/models/SimpleStringWithPattern.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3563,8 +3683,64 @@ exports[`v3 should generate: ./test/generated/v3/models/SimpleStringWithPattern. export type SimpleStringWithPattern = string | null;" `; +exports[`v3 should generate: ./test/generated/v3/models/index.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type { ArrayWithArray } from './ArrayWithArray'; +export type { ArrayWithBooleans } from './ArrayWithBooleans'; +export type { ArrayWithNumbers } from './ArrayWithNumbers'; +export type { ArrayWithProperties } from './ArrayWithProperties'; +export type { ArrayWithReferences } from './ArrayWithReferences'; +export type { ArrayWithStrings } from './ArrayWithStrings'; +export type { CompositionWithAllOfAndNullable } from './CompositionWithAllOfAndNullable'; +export type { CompositionWithAnyOf } from './CompositionWithAnyOf'; +export type { CompositionWithAnyOfAndNullable } from './CompositionWithAnyOfAndNullable'; +export type { CompositionWithAnyOfAnonymous } from './CompositionWithAnyOfAnonymous'; +export type { CompositionWithOneOf } from './CompositionWithOneOf'; +export type { CompositionWithOneOfAndNullable } from './CompositionWithOneOfAndNullable'; +export type { CompositionWithOneOfAnonymous } from './CompositionWithOneOfAnonymous'; +export type { DictionaryWithArray } from './DictionaryWithArray'; +export type { DictionaryWithDictionary } from './DictionaryWithDictionary'; +export type { DictionaryWithProperties } from './DictionaryWithProperties'; +export type { DictionaryWithReference } from './DictionaryWithReference'; +export type { DictionaryWithString } from './DictionaryWithString'; +export { EnumFromDescription } from './EnumFromDescription'; +export { EnumWithExtensions } from './EnumWithExtensions'; +export { EnumWithNumbers } from './EnumWithNumbers'; +export { EnumWithStrings } from './EnumWithStrings'; +export type { ModelThatExtends } from './ModelThatExtends'; +export type { ModelThatExtendsExtends } from './ModelThatExtendsExtends'; +export type { ModelWithArray } from './ModelWithArray'; +export type { ModelWithBoolean } from './ModelWithBoolean'; +export type { ModelWithCircularReference } from './ModelWithCircularReference'; +export type { ModelWithDictionary } from './ModelWithDictionary'; +export type { ModelWithDuplicateImports } from './ModelWithDuplicateImports'; +export type { ModelWithDuplicateProperties } from './ModelWithDuplicateProperties'; +export type { ModelWithEnum } from './ModelWithEnum'; +export type { ModelWithEnumFromDescription } from './ModelWithEnumFromDescription'; +export type { ModelWithInteger } from './ModelWithInteger'; +export type { ModelWithNestedEnums } from './ModelWithNestedEnums'; +export type { ModelWithNestedProperties } from './ModelWithNestedProperties'; +export type { ModelWithOrderedProperties } from './ModelWithOrderedProperties'; +export type { ModelWithPattern } from './ModelWithPattern'; +export type { ModelWithProperties } from './ModelWithProperties'; +export type { ModelWithReference } from './ModelWithReference'; +export type { ModelWithString } from './ModelWithString'; +export type { MultilineComment } from './MultilineComment'; +export type { SimpleBoolean } from './SimpleBoolean'; +export type { SimpleFile } from './SimpleFile'; +export type { SimpleInteger } from './SimpleInteger'; +export type { SimpleReference } from './SimpleReference'; +export type { SimpleString } from './SimpleString'; +export type { SimpleStringWithPattern } from './SimpleStringWithPattern'; +" +`; + exports[`v3 should generate: ./test/generated/v3/schemas/$ArrayWithArray.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ArrayWithArray = { @@ -3579,7 +3755,8 @@ export const $ArrayWithArray = { `; exports[`v3 should generate: ./test/generated/v3/schemas/$ArrayWithBooleans.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ArrayWithBooleans = { @@ -3591,7 +3768,8 @@ export const $ArrayWithBooleans = { `; exports[`v3 should generate: ./test/generated/v3/schemas/$ArrayWithNumbers.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ArrayWithNumbers = { @@ -3603,7 +3781,8 @@ export const $ArrayWithNumbers = { `; exports[`v3 should generate: ./test/generated/v3/schemas/$ArrayWithProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ArrayWithProperties = { @@ -3622,7 +3801,8 @@ export const $ArrayWithProperties = { `; exports[`v3 should generate: ./test/generated/v3/schemas/$ArrayWithReferences.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ArrayWithReferences = { @@ -3634,7 +3814,8 @@ export const $ArrayWithReferences = { `; exports[`v3 should generate: ./test/generated/v3/schemas/$ArrayWithStrings.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ArrayWithStrings = { @@ -3646,7 +3827,8 @@ export const $ArrayWithStrings = { `; exports[`v3 should generate: ./test/generated/v3/schemas/$CompositionWithAllOfAndNullable.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $CompositionWithAllOfAndNullable = { @@ -3673,7 +3855,8 @@ export const $CompositionWithAllOfAndNullable = { `; exports[`v3 should generate: ./test/generated/v3/schemas/$CompositionWithAnyOf.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $CompositionWithAnyOf = { @@ -3695,7 +3878,8 @@ export const $CompositionWithAnyOf = { `; exports[`v3 should generate: ./test/generated/v3/schemas/$CompositionWithAnyOfAndNullable.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $CompositionWithAnyOfAndNullable = { @@ -3722,7 +3906,8 @@ export const $CompositionWithAnyOfAndNullable = { `; exports[`v3 should generate: ./test/generated/v3/schemas/$CompositionWithAnyOfAnonymous.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $CompositionWithAnyOfAnonymous = { @@ -3747,7 +3932,8 @@ export const $CompositionWithAnyOfAnonymous = { `; exports[`v3 should generate: ./test/generated/v3/schemas/$CompositionWithOneOf.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $CompositionWithOneOf = { @@ -3769,7 +3955,8 @@ export const $CompositionWithOneOf = { `; exports[`v3 should generate: ./test/generated/v3/schemas/$CompositionWithOneOfAndNullable.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $CompositionWithOneOfAndNullable = { @@ -3796,7 +3983,8 @@ export const $CompositionWithOneOfAndNullable = { `; exports[`v3 should generate: ./test/generated/v3/schemas/$CompositionWithOneOfAnonymous.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $CompositionWithOneOfAnonymous = { @@ -3821,7 +4009,8 @@ export const $CompositionWithOneOfAnonymous = { `; exports[`v3 should generate: ./test/generated/v3/schemas/$DictionaryWithArray.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $DictionaryWithArray = { @@ -3836,7 +4025,8 @@ export const $DictionaryWithArray = { `; exports[`v3 should generate: ./test/generated/v3/schemas/$DictionaryWithDictionary.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $DictionaryWithDictionary = { @@ -3851,7 +4041,8 @@ export const $DictionaryWithDictionary = { `; exports[`v3 should generate: ./test/generated/v3/schemas/$DictionaryWithProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $DictionaryWithProperties = { @@ -3870,7 +4061,8 @@ export const $DictionaryWithProperties = { `; exports[`v3 should generate: ./test/generated/v3/schemas/$DictionaryWithReference.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $DictionaryWithReference = { @@ -3882,7 +4074,8 @@ export const $DictionaryWithReference = { `; exports[`v3 should generate: ./test/generated/v3/schemas/$DictionaryWithString.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $DictionaryWithString = { @@ -3894,7 +4087,8 @@ export const $DictionaryWithString = { `; exports[`v3 should generate: ./test/generated/v3/schemas/$EnumFromDescription.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $EnumFromDescription = { @@ -3903,7 +4097,8 @@ export const $EnumFromDescription = { `; exports[`v3 should generate: ./test/generated/v3/schemas/$EnumWithExtensions.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $EnumWithExtensions = { @@ -3912,7 +4107,8 @@ export const $EnumWithExtensions = { `; exports[`v3 should generate: ./test/generated/v3/schemas/$EnumWithNumbers.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $EnumWithNumbers = { @@ -3921,7 +4117,8 @@ export const $EnumWithNumbers = { `; exports[`v3 should generate: ./test/generated/v3/schemas/$EnumWithStrings.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $EnumWithStrings = { @@ -3930,7 +4127,8 @@ export const $EnumWithStrings = { `; exports[`v3 should generate: ./test/generated/v3/schemas/$ModelThatExtends.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelThatExtends = { @@ -3951,7 +4149,8 @@ export const $ModelThatExtends = { `; exports[`v3 should generate: ./test/generated/v3/schemas/$ModelThatExtendsExtends.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelThatExtendsExtends = { @@ -3974,7 +4173,8 @@ export const $ModelThatExtendsExtends = { `; exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithArray.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithArray = { @@ -4002,7 +4202,8 @@ export const $ModelWithArray = { `; exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithBoolean.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithBoolean = { @@ -4015,7 +4216,8 @@ export const $ModelWithBoolean = { `; exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithCircularReference.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithCircularReference = { @@ -4028,7 +4230,8 @@ export const $ModelWithCircularReference = { `; exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithDictionary.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithDictionary = { @@ -4044,7 +4247,8 @@ export const $ModelWithDictionary = { `; exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithDuplicateImports.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithDuplicateImports = { @@ -4063,7 +4267,8 @@ export const $ModelWithDuplicateImports = { `; exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithDuplicateProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithDuplicateProperties = { @@ -4076,7 +4281,8 @@ export const $ModelWithDuplicateProperties = { `; exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithEnum.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithEnum = { @@ -4095,7 +4301,8 @@ export const $ModelWithEnum = { `; exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithEnumFromDescription.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithEnumFromDescription = { @@ -4108,7 +4315,8 @@ export const $ModelWithEnumFromDescription = { `; exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithInteger.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithInteger = { @@ -4121,7 +4329,8 @@ export const $ModelWithInteger = { `; exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithNestedEnums.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithNestedEnums = { @@ -4155,7 +4364,8 @@ export const $ModelWithNestedEnums = { `; exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithNestedProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithNestedProperties = { @@ -4185,7 +4395,8 @@ export const $ModelWithNestedProperties = { `; exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithOrderedProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithOrderedProperties = { @@ -4204,7 +4415,8 @@ export const $ModelWithOrderedProperties = { `; exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithPattern.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithPattern = { @@ -4242,7 +4454,8 @@ export const $ModelWithPattern = { `; exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithProperties.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithProperties = { @@ -4295,7 +4508,8 @@ export const $ModelWithProperties = { `; exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithReference.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithReference = { @@ -4308,7 +4522,8 @@ export const $ModelWithReference = { `; exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithString.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $ModelWithString = { @@ -4321,7 +4536,8 @@ export const $ModelWithString = { `; exports[`v3 should generate: ./test/generated/v3/schemas/$MultilineComment.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $MultilineComment = { @@ -4330,7 +4546,8 @@ export const $MultilineComment = { `; exports[`v3 should generate: ./test/generated/v3/schemas/$SimpleBoolean.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $SimpleBoolean = { @@ -4339,7 +4556,8 @@ export const $SimpleBoolean = { `; exports[`v3 should generate: ./test/generated/v3/schemas/$SimpleFile.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $SimpleFile = { @@ -4348,7 +4566,8 @@ export const $SimpleFile = { `; exports[`v3 should generate: ./test/generated/v3/schemas/$SimpleInteger.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $SimpleInteger = { @@ -4357,7 +4576,8 @@ export const $SimpleInteger = { `; exports[`v3 should generate: ./test/generated/v3/schemas/$SimpleReference.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $SimpleReference = { @@ -4366,7 +4586,8 @@ export const $SimpleReference = { `; exports[`v3 should generate: ./test/generated/v3/schemas/$SimpleString.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $SimpleString = { @@ -4375,7 +4596,8 @@ export const $SimpleString = { `; exports[`v3 should generate: ./test/generated/v3/schemas/$SimpleStringWithPattern.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ export const $SimpleStringWithPattern = { @@ -4386,12 +4608,70 @@ export const $SimpleStringWithPattern = { };" `; +exports[`v3 should generate: ./test/generated/v3/schemas/index.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export { $ArrayWithArray } from './$ArrayWithArray'; +export { $ArrayWithBooleans } from './$ArrayWithBooleans'; +export { $ArrayWithNumbers } from './$ArrayWithNumbers'; +export { $ArrayWithProperties } from './$ArrayWithProperties'; +export { $ArrayWithReferences } from './$ArrayWithReferences'; +export { $ArrayWithStrings } from './$ArrayWithStrings'; +export { $CompositionWithAllOfAndNullable } from './$CompositionWithAllOfAndNullable'; +export { $CompositionWithAnyOf } from './$CompositionWithAnyOf'; +export { $CompositionWithAnyOfAndNullable } from './$CompositionWithAnyOfAndNullable'; +export { $CompositionWithAnyOfAnonymous } from './$CompositionWithAnyOfAnonymous'; +export { $CompositionWithOneOf } from './$CompositionWithOneOf'; +export { $CompositionWithOneOfAndNullable } from './$CompositionWithOneOfAndNullable'; +export { $CompositionWithOneOfAnonymous } from './$CompositionWithOneOfAnonymous'; +export { $DictionaryWithArray } from './$DictionaryWithArray'; +export { $DictionaryWithDictionary } from './$DictionaryWithDictionary'; +export { $DictionaryWithProperties } from './$DictionaryWithProperties'; +export { $DictionaryWithReference } from './$DictionaryWithReference'; +export { $DictionaryWithString } from './$DictionaryWithString'; +export { $EnumFromDescription } from './$EnumFromDescription'; +export { $EnumWithExtensions } from './$EnumWithExtensions'; +export { $EnumWithNumbers } from './$EnumWithNumbers'; +export { $EnumWithStrings } from './$EnumWithStrings'; +export { $ModelThatExtends } from './$ModelThatExtends'; +export { $ModelThatExtendsExtends } from './$ModelThatExtendsExtends'; +export { $ModelWithArray } from './$ModelWithArray'; +export { $ModelWithBoolean } from './$ModelWithBoolean'; +export { $ModelWithCircularReference } from './$ModelWithCircularReference'; +export { $ModelWithDictionary } from './$ModelWithDictionary'; +export { $ModelWithDuplicateImports } from './$ModelWithDuplicateImports'; +export { $ModelWithDuplicateProperties } from './$ModelWithDuplicateProperties'; +export { $ModelWithEnum } from './$ModelWithEnum'; +export { $ModelWithEnumFromDescription } from './$ModelWithEnumFromDescription'; +export { $ModelWithInteger } from './$ModelWithInteger'; +export { $ModelWithNestedEnums } from './$ModelWithNestedEnums'; +export { $ModelWithNestedProperties } from './$ModelWithNestedProperties'; +export { $ModelWithOrderedProperties } from './$ModelWithOrderedProperties'; +export { $ModelWithPattern } from './$ModelWithPattern'; +export { $ModelWithProperties } from './$ModelWithProperties'; +export { $ModelWithReference } from './$ModelWithReference'; +export { $ModelWithString } from './$ModelWithString'; +export { $MultilineComment } from './$MultilineComment'; +export { $SimpleBoolean } from './$SimpleBoolean'; +export { $SimpleFile } from './$SimpleFile'; +export { $SimpleInteger } from './$SimpleInteger'; +export { $SimpleReference } from './$SimpleReference'; +export { $SimpleString } from './$SimpleString'; +export { $SimpleStringWithPattern } from './$SimpleStringWithPattern'; +" +`; + exports[`v3 should generate: ./test/generated/v3/services/CollectionFormatService.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; +import { + request as __request, + OpenAPI, +} from '../core'; export class CollectionFormatService { @@ -4428,15 +4708,20 @@ export class CollectionFormatService { `; exports[`v3 should generate: ./test/generated/v3/services/ComplexService.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ModelWithArray } from '../models/ModelWithArray'; -import type { ModelWithDictionary } from '../models/ModelWithDictionary'; -import type { ModelWithEnum } from '../models/ModelWithEnum'; -import type { ModelWithString } from '../models/ModelWithString'; -import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; +import type { + ModelWithArray, + ModelWithDictionary, + ModelWithEnum, + ModelWithString, +} from '../models'; +import { + request as __request, + OpenAPI, +} from '../core'; export class ComplexService { @@ -4506,12 +4791,17 @@ export class ComplexService { `; exports[`v3 should generate: ./test/generated/v3/services/DefaultsService.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ModelWithString } from '../models/ModelWithString'; -import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; +import type { + ModelWithString, +} from '../models'; +import { + request as __request, + OpenAPI, +} from '../core'; export class DefaultsService { @@ -4613,11 +4903,14 @@ export class DefaultsService { `; exports[`v3 should generate: ./test/generated/v3/services/DuplicateService.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; +import { + request as __request, + OpenAPI, +} from '../core'; export class DuplicateService { @@ -4669,11 +4962,14 @@ export class DuplicateService { `; exports[`v3 should generate: ./test/generated/v3/services/HeaderService.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; +import { + request as __request, + OpenAPI, +} from '../core'; export class HeaderService { @@ -4698,11 +4994,14 @@ export class HeaderService { `; exports[`v3 should generate: ./test/generated/v3/services/MultipartService.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; +import { + request as __request, + OpenAPI, +} from '../core'; export class MultipartService { @@ -4728,11 +5027,14 @@ export class MultipartService { `; exports[`v3 should generate: ./test/generated/v3/services/NoContentService.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; +import { + request as __request, + OpenAPI, +} from '../core'; export class NoContentService { @@ -4752,12 +5054,17 @@ export class NoContentService { `; exports[`v3 should generate: ./test/generated/v3/services/ParametersService.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ModelWithString } from '../models/ModelWithString'; -import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; +import type { + ModelWithString, +} from '../models'; +import { + request as __request, + OpenAPI, +} from '../core'; export class ParametersService { @@ -4890,12 +5197,17 @@ export class ParametersService { `; exports[`v3 should generate: ./test/generated/v3/services/RequestBodyService.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ModelWithString } from '../models/ModelWithString'; -import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; +import type { + ModelWithString, +} from '../models'; +import { + request as __request, + OpenAPI, +} from '../core'; export class RequestBodyService { @@ -4919,14 +5231,19 @@ export class RequestBodyService { `; exports[`v3 should generate: ./test/generated/v3/services/ResponseService.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ModelThatExtends } from '../models/ModelThatExtends'; -import type { ModelThatExtendsExtends } from '../models/ModelThatExtendsExtends'; -import type { ModelWithString } from '../models/ModelWithString'; -import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; +import type { + ModelThatExtends, + ModelThatExtendsExtends, + ModelWithString, +} from '../models'; +import { + request as __request, + OpenAPI, +} from '../core'; export class ResponseService { @@ -4987,11 +5304,14 @@ export class ResponseService { `; exports[`v3 should generate: ./test/generated/v3/services/SimpleService.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; +import { + request as __request, + OpenAPI, +} from '../core'; export class SimpleService { @@ -5076,11 +5396,14 @@ export class SimpleService { `; exports[`v3 should generate: ./test/generated/v3/services/TypesService.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; +import { + request as __request, + OpenAPI, +} from '../core'; export class TypesService { @@ -5129,11 +5452,14 @@ export class TypesService { `; exports[`v3 should generate: ./test/generated/v3/services/UploadService.ts 1`] = ` -"/* istanbul ignore file */ +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; +import { + request as __request, + OpenAPI, +} from '../core'; export class UploadService { @@ -5157,3 +5483,24 @@ export class UploadService { }" `; + +exports[`v3 should generate: ./test/generated/v3/services/index.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export { CollectionFormatService } from './CollectionFormatService'; +export { ComplexService } from './ComplexService'; +export { DefaultsService } from './DefaultsService'; +export { DuplicateService } from './DuplicateService'; +export { HeaderService } from './HeaderService'; +export { MultipartService } from './MultipartService'; +export { NoContentService } from './NoContentService'; +export { ParametersService } from './ParametersService'; +export { RequestBodyService } from './RequestBodyService'; +export { ResponseService } from './ResponseService'; +export { SimpleService } from './SimpleService'; +export { TypesService } from './TypesService'; +export { UploadService } from './UploadService'; +" +`; From 1ee631467d3d7bae9850b3c537bba3cd2ce1bbc5 Mon Sep 17 00:00:00 2001 From: lub0v-parsable Date: Tue, 24 Aug 2021 16:08:15 -0700 Subject: [PATCH 05/11] PE-2229 - rename OpenApi properties, remove config from http client, add config to request --- package.json | 2 +- src/templates/core/ApiResult.hbs | 4 +- src/templates/core/BaseHttpRequest.hbs | 16 +- src/templates/core/OpenAPI.hbs | 28 +- src/templates/core/fetch/getHeaders.hbs | 8 +- src/templates/core/fetch/request.hbs | 20 +- src/templates/core/fetch/sendRequest.hbs | 2 +- src/templates/core/functions/deepAssign.hbs | 19 + src/templates/core/functions/getUrl.hbs | 2 +- src/templates/core/index.hbs | 2 +- src/templates/core/node/getHeaders.hbs | 8 +- src/templates/core/node/request.hbs | 20 +- src/templates/core/xhr/getHeaders.hbs | 8 +- src/templates/core/xhr/request.hbs | 20 +- src/templates/core/xhr/sendRequest.hbs | 2 +- src/templates/exportAppClient.hbs | 26 +- src/templates/partials/parameters.hbs | 5 +- src/templates/services/exportService.hbs | 17 +- src/utils/postProcessServiceOperations.ts | 2 +- src/utils/registerHandlebarTemplates.ts | 2 + src/utils/writeClientServices.ts | 2 +- test/__snapshots__/index.client.spec.js.snap | 1019 ++++++++++-------- test/__snapshots__/index.spec.js.snap | 610 ++++++----- test/e2e/v2.babel.spec.js | 10 +- test/e2e/v2.fetch.spec.js | 12 +- test/e2e/v2.node.spec.js | 12 +- test/e2e/v2.xhr.spec.js | 12 +- test/e2e/v3.babel.spec.js | 28 +- test/e2e/v3.fetch.spec.js | 28 +- test/e2e/v3.node.spec.js | 28 +- test/e2e/v3.xhr.spec.js | 26 +- 31 files changed, 1104 insertions(+), 896 deletions(-) create mode 100644 src/templates/core/functions/deepAssign.hbs diff --git a/package.json b/package.json index 5c6ac00c3..cf4db830d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@parsable/openapi-typescript-codegen", - "version": "0.0.2-alpha-4", + "version": "0.0.2-alpha-5", "description": "Library that generates Typescript clients based on the OpenAPI specification.", "author": "Ferdi Koomen", "homepage": "https://github.com/ferdikoomen/openapi-typescript-codegen", diff --git a/src/templates/core/ApiResult.hbs b/src/templates/core/ApiResult.hbs index b5c3c9594..7837bfcaf 100644 --- a/src/templates/core/ApiResult.hbs +++ b/src/templates/core/ApiResult.hbs @@ -1,9 +1,9 @@ {{>header}} -export type ApiResult = { +export type ApiResult = { readonly url: string; readonly ok: boolean; readonly status: number; readonly statusText: string; - readonly body: any; + readonly body: T; } diff --git a/src/templates/core/BaseHttpRequest.hbs b/src/templates/core/BaseHttpRequest.hbs index ad6636a32..77310d3d8 100644 --- a/src/templates/core/BaseHttpRequest.hbs +++ b/src/templates/core/BaseHttpRequest.hbs @@ -4,14 +4,10 @@ import type { ApiRequestOptions } from './ApiRequestOptions'; import type { ApiResult } from './ApiResult'; import type { OpenAPIConfig } from './OpenAPI'; -export class BaseHttpRequest { - readonly openApiConfig: OpenAPIConfig; - - constructor(openApiConfig: OpenAPIConfig) { - this.openApiConfig = openApiConfig; - } - - async request(options: ApiRequestOptions): Promise { - throw new Error('Not Implemented'); - } +export interface BaseHttpRequest { + request( + options: ApiRequestOptions, + config: OpenAPIConfig, + mergeConfig?: OpenAPIConfig + ): Promise; } diff --git a/src/templates/core/OpenAPI.hbs b/src/templates/core/OpenAPI.hbs index 6ddd59fd8..cc49407e8 100644 --- a/src/templates/core/OpenAPI.hbs +++ b/src/templates/core/OpenAPI.hbs @@ -6,22 +6,22 @@ type Resolver = (options: ApiRequestOptions) => Promise; type Headers = Record; export type OpenAPIConfig = { - BASE?: string; - VERSION?: string; - WITH_CREDENTIALS?: boolean; - TOKEN?: string | Resolver; - USERNAME?: string | Resolver; - PASSWORD?: string | Resolver; - HEADERS?: Headers | Resolver; + baseUrl?: string; + version?: string; + withCredentials?: boolean; + token?: string | Resolver; + username?: string | Resolver; + password?: string | Resolver; + headers?: Headers | Resolver; } {{#unless @root.exportClient}} export const OpenAPI: OpenAPIConfig = { - BASE: '{{{server}}}', - VERSION: '{{{version}}}', - WITH_CREDENTIALS: false, - TOKEN: undefined, - USERNAME: undefined, - PASSWORD: undefined, - HEADERS: undefined, + baseUrl: '{{{server}}}', + version: '{{{version}}}', + withCredentials: false, + token: undefined, + username: undefined, + password: undefined, + headers: undefined, }; {{/unless}} diff --git a/src/templates/core/fetch/getHeaders.hbs b/src/templates/core/fetch/getHeaders.hbs index 1ef2301f0..062a2689f 100644 --- a/src/templates/core/fetch/getHeaders.hbs +++ b/src/templates/core/fetch/getHeaders.hbs @@ -1,8 +1,8 @@ async function getHeaders(options: ApiRequestOptions, config: OpenAPIConfig): Promise { - const token = await resolve(options, config.TOKEN); - const username = await resolve(options, config.USERNAME); - const password = await resolve(options, config.PASSWORD); - const defaultHeaders = await resolve(options, config.HEADERS); + const token = await resolve(options, config.token); + const username = await resolve(options, config.username); + const password = await resolve(options, config.password); + const defaultHeaders = await resolve(options, config.headers); const headers = new Headers({ Accept: 'application/json', diff --git a/src/templates/core/fetch/request.hbs b/src/templates/core/fetch/request.hbs index 1e34f4fbb..64746efe3 100644 --- a/src/templates/core/fetch/request.hbs +++ b/src/templates/core/fetch/request.hbs @@ -5,7 +5,7 @@ import type { ApiRequestOptions } from './ApiRequestOptions'; import type { ApiResult } from './ApiResult'; import type { OpenAPIConfig } from './OpenAPI'; {{#if @root.exportClient}} -import { BaseHttpRequest } from './BaseHttpRequest'; +import type { BaseHttpRequest } from './BaseHttpRequest'; {{else}} import { OpenAPI } from './OpenAPI'; {{/if}} @@ -16,6 +16,9 @@ import { OpenAPI } from './OpenAPI'; {{>functions/isString}} +{{>functions/deepAssign}} + + {{>functions/isStringWithValue}} @@ -53,20 +56,19 @@ import { OpenAPI } from './OpenAPI'; {{#if @root.exportClient}} -export class FetchHttpRequest extends BaseHttpRequest { - constructor(openApiConfig: OpenAPIConfig) { - super(openApiConfig); - } - +export class FetchHttpRequest implements BaseHttpRequest { /** * Request using fetch client * @param options The request options from the the service + * @param config The OpenAPI configuration + * @param [mergeConfig] Additional optional OpenAPI configuration that will be merged with the first one * @returns ApiResult * @throws ApiError */ - async request(options: ApiRequestOptions): Promise { - const url = getUrl(options, this.openApiConfig); - const response = await sendRequest(options, this.openApiConfig, url); + async request(options: ApiRequestOptions, config: OpenAPIConfig, mergeConfig?: OpenAPIConfig): Promise { + const conf = mergeConfig ? deepAssign(config, mergeConfig) : config; + const url = getUrl(options, conf); + const response = await sendRequest(options, conf, url); const responseBody = await getResponseBody(response); const responseHeader = getResponseHeader(response, options.responseHeader); diff --git a/src/templates/core/fetch/sendRequest.hbs b/src/templates/core/fetch/sendRequest.hbs index bdcf5b26f..ce67b0f45 100644 --- a/src/templates/core/fetch/sendRequest.hbs +++ b/src/templates/core/fetch/sendRequest.hbs @@ -4,7 +4,7 @@ async function sendRequest(options: ApiRequestOptions, config: OpenAPIConfig, ur headers: await getHeaders(options, config), body: getRequestBody(options), }; - if (config.WITH_CREDENTIALS) { + if (config.withCredentials) { request.credentials = 'include'; } return await fetch(url, request); diff --git a/src/templates/core/functions/deepAssign.hbs b/src/templates/core/functions/deepAssign.hbs new file mode 100644 index 000000000..b61fb11ae --- /dev/null +++ b/src/templates/core/functions/deepAssign.hbs @@ -0,0 +1,19 @@ +export function deepAssign( + target: Record, + source: Record, +): Record { + const keys = Object.keys(source); + for (const k of keys) { + const sourceValue: unknown = source[k]; + const targetValue: unknown = target[k]; + if (Object(sourceValue) === sourceValue && Object(targetValue) === targetValue) { + target[k] = deepAssign( + targetValue as Record, + sourceValue as Record, + ); + } else { + target[k] = source[k]; + } + } + return target; +} diff --git a/src/templates/core/functions/getUrl.hbs b/src/templates/core/functions/getUrl.hbs index 758ab7549..b255d7813 100644 --- a/src/templates/core/functions/getUrl.hbs +++ b/src/templates/core/functions/getUrl.hbs @@ -1,6 +1,6 @@ function getUrl(options: ApiRequestOptions, config: OpenAPIConfig): string { const path = options.path.replace(/[:]/g, '_'); - const url = `${config.BASE}${path}`; + const url = `${config.baseUrl}${path}`; if (options.query) { return `${url}${getQueryString(options.query)}`; diff --git a/src/templates/core/index.hbs b/src/templates/core/index.hbs index d04f13142..3bf1378d6 100644 --- a/src/templates/core/index.hbs +++ b/src/templates/core/index.hbs @@ -4,7 +4,7 @@ export { ApiError } from './ApiError'; export type { ApiRequestOptions } from './ApiRequestOptions'; export type { ApiResult } from './ApiResult'; {{#if @root.exportClient}} -export { BaseHttpRequest } from './BaseHttpRequest'; +export type { BaseHttpRequest } from './BaseHttpRequest'; export { {{{httpRequestName}}} } from './{{{httpRequestName}}}'; export type { OpenAPIConfig } from './OpenAPI'; {{else}} diff --git a/src/templates/core/node/getHeaders.hbs b/src/templates/core/node/getHeaders.hbs index 61f2e47ce..a29d296cb 100644 --- a/src/templates/core/node/getHeaders.hbs +++ b/src/templates/core/node/getHeaders.hbs @@ -1,8 +1,8 @@ async function getHeaders(options: ApiRequestOptions, config: OpenAPIConfig): Promise { - const token = await resolve(options, config.TOKEN); - const username = await resolve(options, config.USERNAME); - const password = await resolve(options, config.PASSWORD); - const defaultHeaders = await resolve(options, config.HEADERS); + const token = await resolve(options, config.token); + const username = await resolve(options, config.username); + const password = await resolve(options, config.password); + const defaultHeaders = await resolve(options, config.headers); const headers = new Headers({ Accept: 'application/json', diff --git a/src/templates/core/node/request.hbs b/src/templates/core/node/request.hbs index 229c02fdb..9f0b11d44 100644 --- a/src/templates/core/node/request.hbs +++ b/src/templates/core/node/request.hbs @@ -9,7 +9,7 @@ import type { ApiRequestOptions } from './ApiRequestOptions'; import type { ApiResult } from './ApiResult'; import type { OpenAPIConfig } from './OpenAPI'; {{#if @root.exportClient}} -import { BaseHttpRequest } from './BaseHttpRequest'; +import type { BaseHttpRequest } from './BaseHttpRequest'; {{else}} import { OpenAPI } from './OpenAPI'; {{/if}} @@ -20,6 +20,9 @@ import { OpenAPI } from './OpenAPI'; {{>functions/isString}} +{{>functions/deepAssign}} + + {{>functions/isStringWithValue}} @@ -57,20 +60,19 @@ import { OpenAPI } from './OpenAPI'; {{#if @root.exportClient}} -export class NodeHttpRequest extends BaseHttpRequest { - constructor(openApiConfig: OpenAPIConfig) { - super(openApiConfig); - } - +export class NodeHttpRequest implements BaseHttpRequest { /** * Request using node-fetch client * @param options The request options from the the service + * @param config The OpenAPI configuration + * @param [mergeConfig] Additional optional OpenAPI configuration that will be merged with the first one * @returns ApiResult * @throws ApiError */ - async request(options: ApiRequestOptions): Promise { - const url = getUrl(options, this.openApiConfig); - const response = await sendRequest(options, this.openApiConfig, url); + async request(options: ApiRequestOptions, config: OpenAPIConfig, mergeConfig?: OpenAPIConfig): Promise { + const conf = mergeConfig ? deepAssign(config, mergeConfig) : config; + const url = getUrl(options, conf); + const response = await sendRequest(options, conf, url); const responseBody = await getResponseBody(response); const responseHeader = getResponseHeader(response, options.responseHeader); diff --git a/src/templates/core/xhr/getHeaders.hbs b/src/templates/core/xhr/getHeaders.hbs index 1ef2301f0..062a2689f 100644 --- a/src/templates/core/xhr/getHeaders.hbs +++ b/src/templates/core/xhr/getHeaders.hbs @@ -1,8 +1,8 @@ async function getHeaders(options: ApiRequestOptions, config: OpenAPIConfig): Promise { - const token = await resolve(options, config.TOKEN); - const username = await resolve(options, config.USERNAME); - const password = await resolve(options, config.PASSWORD); - const defaultHeaders = await resolve(options, config.HEADERS); + const token = await resolve(options, config.token); + const username = await resolve(options, config.username); + const password = await resolve(options, config.password); + const defaultHeaders = await resolve(options, config.headers); const headers = new Headers({ Accept: 'application/json', diff --git a/src/templates/core/xhr/request.hbs b/src/templates/core/xhr/request.hbs index 7749c7e35..151f4c3c1 100644 --- a/src/templates/core/xhr/request.hbs +++ b/src/templates/core/xhr/request.hbs @@ -5,7 +5,7 @@ import type { ApiRequestOptions } from './ApiRequestOptions'; import type { ApiResult } from './ApiResult'; import type { OpenAPIConfig } from './OpenAPI'; {{#if @root.exportClient}} -import { BaseHttpRequest } from './BaseHttpRequest'; +import type { BaseHttpRequest } from './BaseHttpRequest'; {{else}} import { OpenAPI } from './OpenAPI'; {{/if}} @@ -17,6 +17,9 @@ import { OpenAPI } from './OpenAPI'; {{>functions/isString}} +{{>functions/deepAssign}} + + {{>functions/isStringWithValue}} @@ -57,20 +60,19 @@ import { OpenAPI } from './OpenAPI'; {{#if @root.exportClient}} -export class XhrHttpRequest extends BaseHttpRequest { - constructor(openApiConfig: OpenAPIConfig) { - super(openApiConfig); - } - +export class XhrHttpRequest implements BaseHttpRequest { /** * Request using XHR client * @param options The request options from the the service + * @param config The OpenAPI configuration + * @param [mergeConfig] Additional optional OpenAPI configuration that will be merged with the first one * @returns ApiResult * @throws ApiError */ - async request(options: ApiRequestOptions): Promise { - const url = getUrl(options, this.openApiConfig); - const response = await sendRequest(options, this.openApiConfig, url); + async request(options: ApiRequestOptions, config: OpenAPIConfig, mergeConfig?: OpenAPIConfig): Promise { + const conf = mergeConfig ? deepAssign(config, mergeConfig) : config; + const url = getUrl(options, conf); + const response = await sendRequest(options, conf, url); const responseBody = getResponseBody(response); const responseHeader = getResponseHeader(response, options.responseHeader); diff --git a/src/templates/core/xhr/sendRequest.hbs b/src/templates/core/xhr/sendRequest.hbs index 5c6d9bfd8..203d4e2dc 100644 --- a/src/templates/core/xhr/sendRequest.hbs +++ b/src/templates/core/xhr/sendRequest.hbs @@ -2,7 +2,7 @@ async function sendRequest(options: ApiRequestOptions, config: OpenAPIConfig, ur const xhr = new XMLHttpRequest(); xhr.open(options.method, url, true); - xhr.withCredentials = config.WITH_CREDENTIALS ?? false; + xhr.withCredentials = config.withCredentials ?? false; const headers = await getHeaders(options, config); headers.forEach((value: string, key: string) => { diff --git a/src/templates/exportAppClient.hbs b/src/templates/exportAppClient.hbs index c9ac6c9d2..722180122 100644 --- a/src/templates/exportAppClient.hbs +++ b/src/templates/exportAppClient.hbs @@ -1,6 +1,7 @@ {{>header}} -import { BaseHttpRequest, {{{httpClientRequest}}} } from './core'; +import type { BaseHttpRequest } from './core'; +import { {{{httpClientRequest}}} } from './core'; import type { OpenAPIConfig } from './core'; {{#if services}} import { @@ -14,20 +15,19 @@ export class {{{clientName}}} { {{#each services}} readonly {{{shortName}}}: {{{name}}}; {{/each}} - readonly request: BaseHttpRequest; - constructor(openApiConfig?: OpenAPIConfig, HttpRequest: new (config: OpenAPIConfig) => BaseHttpRequest = {{{httpClientRequest}}}) { - this.request = new HttpRequest({ - BASE: openApiConfig?.BASE ?? '{{{server}}}', - VERSION: openApiConfig?.VERSION ?? '{{{version}}}', - WITH_CREDENTIALS: openApiConfig?.WITH_CREDENTIALS ?? false, - TOKEN: openApiConfig?.TOKEN, - USERNAME: openApiConfig?.USERNAME, - PASSWORD: openApiConfig?.PASSWORD, - HEADERS: openApiConfig?.HEADERS, - }); + constructor(openApiConfig: OpenAPIConfig, httpClient: BaseHttpRequest = new {{{httpClientRequest}}}()) { + const config = { + baseUrl: openApiConfig?.baseUrl ?? '{{{server}}}', + version: openApiConfig?.version ?? '{{{version}}}', + withCredentials: openApiConfig?.withCredentials ?? false, + token: openApiConfig?.token, + username: openApiConfig?.username, + password: openApiConfig?.password, + headers: openApiConfig?.headers, + } {{#each services}} - this.{{{shortName}}} = new {{{name}}}(this.request); + this.{{{shortName}}} = new {{{name}}}(httpClient, config); {{/each}} } } diff --git a/src/templates/partials/parameters.hbs b/src/templates/partials/parameters.hbs index a911f3a42..495d16172 100644 --- a/src/templates/partials/parameters.hbs +++ b/src/templates/partials/parameters.hbs @@ -11,11 +11,12 @@ {{/if}} {{{name}}}{{>isRequired}}: {{>type}}, {{/each}} -} +}{{#if @root.exportClient}}, config?: OpenAPIConfig{{/if}} {{~else}} {{#each parameters}} {{{name}}}{{>isRequired}}: {{>type}}{{#if default}} = {{{default}}}{{/if}}, {{/each}} +{{#if @root.exportClient}}config?: OpenAPIConfig{{/if}} {{/if}} -{{/if}} +{{else}}{{#if @root.exportClient}}config?: OpenAPIConfig{{/if}}{{/if}} diff --git a/src/templates/services/exportService.hbs b/src/templates/services/exportService.hbs index 2eab5f787..99c6c9cd0 100644 --- a/src/templates/services/exportService.hbs +++ b/src/templates/services/exportService.hbs @@ -8,8 +8,9 @@ import type { } from '../models'; {{/if}} {{#if @root.exportClient}} -import { BaseHttpRequest } from '../core'; +import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; {{else}} +import type { ApiResult } from '../core'; import { request as __request, {{#if @root.useVersion}} @@ -20,10 +21,12 @@ import { export class {{{name}}} { {{#if @root.exportClient}} - private httpRequest: BaseHttpRequest; + private readonly httpRequest: BaseHttpRequest; + private readonly openApiConfig: OpenAPIConfig; - constructor(httpRequest: BaseHttpRequest) { + constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { this.httpRequest = httpRequest; + this.openApiConfig = openApiConfig; } {{/if}} @@ -45,13 +48,14 @@ export class {{{name}}} { {{/each}} {{/if}} {{/unless}} + {{#if @root.exportClient}}* @param [config] the optional OpenAPI config to use{{/if}} {{#each results}} * @returns {{{type}}} {{{description}}} {{/each}} * @throws ApiError */ - public{{#unless @root.exportClient}} static{{/unless}} async {{{name}}}({{>parameters}}): Promise<{{>result}}> { - const result = await {{#if @root.exportClient}}this.httpRequest.request{{else}}__request{{/if}}({ + public{{#unless @root.exportClient}} static{{/unless}} async {{{name}}}({{>parameters}}): Promiseresult}}>> { + return {{#if @root.exportClient}}this.httpRequest.request{{else}}__request{{/if}}({ method: '{{{method}}}', path: `{{{path}}}`, {{#if parametersCookie}} @@ -98,8 +102,7 @@ export class {{{name}}} { {{/each}} }, {{/if}} - }); - return result.body; + }{{#if @root.exportClient}}, this.openApiConfig, config{{/if}}); } {{/each}} diff --git a/src/utils/postProcessServiceOperations.ts b/src/utils/postProcessServiceOperations.ts index 759af5573..cd1dcc7ed 100644 --- a/src/utils/postProcessServiceOperations.ts +++ b/src/utils/postProcessServiceOperations.ts @@ -22,7 +22,7 @@ export function postProcessServiceOperations(service: Service, exportClient: boo names.set(name, index + 1); // Update the operation path with the dynamically injected version - clone.path = clone.path.replace('${apiVersion}', exportClient ? '${this.httpRequest.openApiConfig.VERSION}' : '${OpenAPI.VERSION}'); + clone.path = clone.path.replace('${apiVersion}', exportClient ? '${this.openApiConfig.version}' : '${OpenAPI.version}'); return clone; }); diff --git a/src/utils/registerHandlebarTemplates.ts b/src/utils/registerHandlebarTemplates.ts index e222709df..0363220bf 100644 --- a/src/utils/registerHandlebarTemplates.ts +++ b/src/utils/registerHandlebarTemplates.ts @@ -12,6 +12,7 @@ import fetchGetResponseHeader from '../templates/core/fetch/getResponseHeader.hb import fetchRequest from '../templates/core/fetch/request.hbs'; import fetchSendRequest from '../templates/core/fetch/sendRequest.hbs'; import functionCatchErrors from '../templates/core/functions/catchErrors.hbs'; +import functionDeepAssign from '../templates/core/functions/deepAssign.hbs'; import functionGetFormData from '../templates/core/functions/getFormData.hbs'; import functionGetQueryString from '../templates/core/functions/getQueryString.hbs'; import functionGetUrl from '../templates/core/functions/getUrl.hbs'; @@ -184,6 +185,7 @@ export function registerHandlebarTemplates(root: { httpClient: HttpClient; useOp Handlebars.registerPartial('functions/isString', Handlebars.template(functionIsString)); Handlebars.registerPartial('functions/isStringWithValue', Handlebars.template(functionIsStringWithValue)); Handlebars.registerPartial('functions/isSuccess', Handlebars.template(functionIsSuccess)); + Handlebars.registerPartial('functions/deepAssign', Handlebars.template(functionDeepAssign)); Handlebars.registerPartial('functions/resolve', Handlebars.template(functionResolve)); // Specific files for the fetch client implementation diff --git a/src/utils/writeClientServices.ts b/src/utils/writeClientServices.ts index 7732f5e2f..e901bcb3a 100644 --- a/src/utils/writeClientServices.ts +++ b/src/utils/writeClientServices.ts @@ -8,7 +8,7 @@ import { getHttpRequestName } from './getHttpRequestName'; import { Templates } from './registerHandlebarTemplates'; import { sortServicesByName } from './sortServicesByName'; -const VERSION_TEMPLATE_STRING = 'OpenAPI.VERSION'; +const VERSION_TEMPLATE_STRING = 'OpenAPI.version'; /** * Generate Services using the Handlebar template and write to disk. diff --git a/test/__snapshots__/index.client.spec.js.snap b/test/__snapshots__/index.client.spec.js.snap index e785f4fbb..e02b20233 100644 --- a/test/__snapshots__/index.client.spec.js.snap +++ b/test/__snapshots__/index.client.spec.js.snap @@ -5,7 +5,8 @@ exports[`v2 should generate with exportClient: ./test/generated/v2_client/client /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { BaseHttpRequest, FetchHttpRequest } from './core'; +import type { BaseHttpRequest } from './core'; +import { FetchHttpRequest } from './core'; import type { OpenAPIConfig } from './core'; import { CollectionFormatService, @@ -31,28 +32,27 @@ export class TestClient { readonly response: ResponseService; readonly simple: SimpleService; readonly types: TypesService; - readonly request: BaseHttpRequest; - - constructor(openApiConfig?: OpenAPIConfig, HttpRequest: new (config: OpenAPIConfig) => BaseHttpRequest = FetchHttpRequest) { - this.request = new HttpRequest({ - BASE: openApiConfig?.BASE ?? 'http://localhost:3000/base', - VERSION: openApiConfig?.VERSION ?? '1.0', - WITH_CREDENTIALS: openApiConfig?.WITH_CREDENTIALS ?? false, - TOKEN: openApiConfig?.TOKEN, - USERNAME: openApiConfig?.USERNAME, - PASSWORD: openApiConfig?.PASSWORD, - HEADERS: openApiConfig?.HEADERS, - }); - this.collectionformat = new CollectionFormatService(this.request); - this.complex = new ComplexService(this.request); - this.defaults = new DefaultsService(this.request); - this.duplicate = new DuplicateService(this.request); - this.header = new HeaderService(this.request); - this.nocontent = new NoContentService(this.request); - this.parameters = new ParametersService(this.request); - this.response = new ResponseService(this.request); - this.simple = new SimpleService(this.request); - this.types = new TypesService(this.request); + + constructor(openApiConfig: OpenAPIConfig, httpClient: BaseHttpRequest = new FetchHttpRequest()) { + const config = { + baseUrl: openApiConfig?.baseUrl ?? 'http://localhost:3000/base', + version: openApiConfig?.version ?? '1.0', + withCredentials: openApiConfig?.withCredentials ?? false, + token: openApiConfig?.token, + username: openApiConfig?.username, + password: openApiConfig?.password, + headers: openApiConfig?.headers, + } + this.collectionformat = new CollectionFormatService(httpClient, config); + this.complex = new ComplexService(httpClient, config); + this.defaults = new DefaultsService(httpClient, config); + this.duplicate = new DuplicateService(httpClient, config); + this.header = new HeaderService(httpClient, config); + this.nocontent = new NoContentService(httpClient, config); + this.parameters = new ParametersService(httpClient, config); + this.response = new ResponseService(httpClient, config); + this.simple = new SimpleService(httpClient, config); + this.types = new TypesService(httpClient, config); } }" `; @@ -105,12 +105,12 @@ exports[`v2 should generate with exportClient: ./test/generated/v2_client/core/A /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export type ApiResult = { +export type ApiResult = { readonly url: string; readonly ok: boolean; readonly status: number; readonly statusText: string; - readonly body: any; + readonly body: T; }" `; @@ -123,16 +123,12 @@ import type { ApiRequestOptions } from './ApiRequestOptions'; import type { ApiResult } from './ApiResult'; import type { OpenAPIConfig } from './OpenAPI'; -export class BaseHttpRequest { - readonly openApiConfig: OpenAPIConfig; - - constructor(openApiConfig: OpenAPIConfig) { - this.openApiConfig = openApiConfig; - } - - async request(options: ApiRequestOptions): Promise { - throw new Error('Not Implemented'); - } +export interface BaseHttpRequest { + request( + options: ApiRequestOptions, + config: OpenAPIConfig, + mergeConfig?: OpenAPIConfig + ): Promise; }" `; @@ -145,7 +141,7 @@ import { ApiError } from './ApiError'; import type { ApiRequestOptions } from './ApiRequestOptions'; import type { ApiResult } from './ApiResult'; import type { OpenAPIConfig } from './OpenAPI'; -import { BaseHttpRequest } from './BaseHttpRequest'; +import type { BaseHttpRequest } from './BaseHttpRequest'; function isDefined(value: T | null | undefined): value is Exclude { return value !== undefined && value !== null; @@ -155,6 +151,26 @@ function isString(value: any): value is string { return typeof value === 'string'; } +export function deepAssign( + target: Record, + source: Record, +): Record { + const keys = Object.keys(source); + for (const k of keys) { + const sourceValue: unknown = source[k]; + const targetValue: unknown = target[k]; + if (Object(sourceValue) === sourceValue && Object(targetValue) === targetValue) { + target[k] = deepAssign( + targetValue as Record, + sourceValue as Record, + ); + } else { + target[k] = source[k]; + } + } + return target; +} + function isStringWithValue(value: any): value is string { return isString(value) && value !== ''; } @@ -185,7 +201,7 @@ function getQueryString(params: Record): string { function getUrl(options: ApiRequestOptions, config: OpenAPIConfig): string { const path = options.path.replace(/[:]/g, '_'); - const url = \`\${config.BASE}\${path}\`; + const url = \`\${config.baseUrl}\${path}\`; if (options.query) { return \`\${url}\${getQueryString(options.query)}\`; @@ -214,10 +230,10 @@ async function resolve(options: ApiRequestOptions, resolver?: T | Resolver } async function getHeaders(options: ApiRequestOptions, config: OpenAPIConfig): Promise { - const token = await resolve(options, config.TOKEN); - const username = await resolve(options, config.USERNAME); - const password = await resolve(options, config.PASSWORD); - const defaultHeaders = await resolve(options, config.HEADERS); + const token = await resolve(options, config.token); + const username = await resolve(options, config.username); + const password = await resolve(options, config.password); + const defaultHeaders = await resolve(options, config.headers); const headers = new Headers({ Accept: 'application/json', @@ -270,7 +286,7 @@ async function sendRequest(options: ApiRequestOptions, config: OpenAPIConfig, ur headers: await getHeaders(options, config), body: getRequestBody(options), }; - if (config.WITH_CREDENTIALS) { + if (config.withCredentials) { request.credentials = 'include'; } return await fetch(url, request); @@ -325,20 +341,19 @@ function catchErrors(options: ApiRequestOptions, result: ApiResult): void { } } -export class FetchHttpRequest extends BaseHttpRequest { - constructor(openApiConfig: OpenAPIConfig) { - super(openApiConfig); - } - +export class FetchHttpRequest implements BaseHttpRequest { /** * Request using fetch client * @param options The request options from the the service + * @param config The OpenAPI configuration + * @param [mergeConfig] Additional optional OpenAPI configuration that will be merged with the first one * @returns ApiResult * @throws ApiError */ - async request(options: ApiRequestOptions): Promise { - const url = getUrl(options, this.openApiConfig); - const response = await sendRequest(options, this.openApiConfig, url); + async request(options: ApiRequestOptions, config: OpenAPIConfig, mergeConfig?: OpenAPIConfig): Promise { + const conf = mergeConfig ? deepAssign(config, mergeConfig) : config; + const url = getUrl(options, conf); + const response = await sendRequest(options, conf, url); const responseBody = await getResponseBody(response); const responseHeader = getResponseHeader(response, options.responseHeader); @@ -368,13 +383,13 @@ type Resolver = (options: ApiRequestOptions) => Promise; type Headers = Record; export type OpenAPIConfig = { - BASE?: string; - VERSION?: string; - WITH_CREDENTIALS?: boolean; - TOKEN?: string | Resolver; - USERNAME?: string | Resolver; - PASSWORD?: string | Resolver; - HEADERS?: Headers | Resolver; + baseUrl?: string; + version?: string; + withCredentials?: boolean; + token?: string | Resolver; + username?: string | Resolver; + password?: string | Resolver; + headers?: Headers | Resolver; } " `; @@ -387,7 +402,7 @@ exports[`v2 should generate with exportClient: ./test/generated/v2_client/core/i export { ApiError } from './ApiError'; export type { ApiRequestOptions } from './ApiRequestOptions'; export type { ApiResult } from './ApiResult'; -export { BaseHttpRequest } from './BaseHttpRequest'; +export type { BaseHttpRequest } from './BaseHttpRequest'; export { FetchHttpRequest } from './FetchHttpRequest'; export type { OpenAPIConfig } from './OpenAPI'; " @@ -1953,13 +1968,15 @@ exports[`v2 should generate with exportClient: ./test/generated/v2_client/servic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { BaseHttpRequest } from '../core'; +import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; export class CollectionFormatService { - private httpRequest: BaseHttpRequest; + private readonly httpRequest: BaseHttpRequest; + private readonly openApiConfig: OpenAPIConfig; - constructor(httpRequest: BaseHttpRequest) { + constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { this.httpRequest = httpRequest; + this.openApiConfig = openApiConfig; } /** @@ -1968,6 +1985,7 @@ export class CollectionFormatService { * @param parameterArrayTsv This is an array parameter that is send as tsv format (tab-separated values) * @param parameterArrayPipes This is an array parameter that is send as pipes format (pipe-separated values) * @param parameterArrayMulti This is an array parameter that is send as multi format (multiple parameter instances) + * @param [config] the optional OpenAPI config to use * @throws ApiError */ public async collectionFormat( @@ -1976,10 +1994,11 @@ export class CollectionFormatService { parameterArrayTsv: Array, parameterArrayPipes: Array, parameterArrayMulti: Array, - ): Promise { - const result = await this.httpRequest.request({ + config?: OpenAPIConfig + ): Promise> { + return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/collectionFormat\`, + path: \`/api/v\${this.openApiConfig.version}/collectionFormat\`, query: { 'parameterArrayCSV': parameterArrayCsv, 'parameterArraySSV': parameterArraySsv, @@ -1987,8 +2006,7 @@ export class CollectionFormatService { 'parameterArrayPipes': parameterArrayPipes, 'parameterArrayMulti': parameterArrayMulti, }, - }); - return result.body; + }, this.openApiConfig, config); } }" @@ -2002,18 +2020,21 @@ exports[`v2 should generate with exportClient: ./test/generated/v2_client/servic import type { ModelWithString, } from '../models'; -import { BaseHttpRequest } from '../core'; +import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; export class ComplexService { - private httpRequest: BaseHttpRequest; + private readonly httpRequest: BaseHttpRequest; + private readonly openApiConfig: OpenAPIConfig; - constructor(httpRequest: BaseHttpRequest) { + constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { this.httpRequest = httpRequest; + this.openApiConfig = openApiConfig; } /** * @param parameterObject Parameter containing object * @param parameterReference Parameter containing reference + * @param [config] the optional OpenAPI config to use * @returns ModelWithString Successful response * @throws ApiError */ @@ -2026,10 +2047,11 @@ export class ComplexService { }, }, parameterReference: ModelWithString, - ): Promise> { - const result = await this.httpRequest.request({ + config?: OpenAPIConfig + ): Promise>> { + return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/complex\`, + path: \`/api/v\${this.openApiConfig.version}/complex\`, query: { 'parameterObject': parameterObject, 'parameterReference': parameterReference, @@ -2038,8 +2060,7 @@ export class ComplexService { 400: \`400 server error\`, 500: \`500 server error\`, }, - }); - return result.body; + }, this.openApiConfig, config); } }" @@ -2053,13 +2074,15 @@ exports[`v2 should generate with exportClient: ./test/generated/v2_client/servic import type { ModelWithString, } from '../models'; -import { BaseHttpRequest } from '../core'; +import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; export class DefaultsService { - private httpRequest: BaseHttpRequest; + private readonly httpRequest: BaseHttpRequest; + private readonly openApiConfig: OpenAPIConfig; - constructor(httpRequest: BaseHttpRequest) { + constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { this.httpRequest = httpRequest; + this.openApiConfig = openApiConfig; } /** @@ -2068,6 +2091,7 @@ export class DefaultsService { * @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 + * @param [config] the optional OpenAPI config to use * @throws ApiError */ public async callWithDefaultParameters( @@ -2078,10 +2102,11 @@ export class DefaultsService { parameterModel: ModelWithString = { \\"prop\\": \\"Hello World!\\" }, - ): Promise { - const result = await this.httpRequest.request({ + config?: OpenAPIConfig + ): Promise> { + return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/defaults\`, + path: \`/api/v\${this.openApiConfig.version}/defaults\`, query: { 'parameterString': parameterString, 'parameterNumber': parameterNumber, @@ -2089,8 +2114,7 @@ export class DefaultsService { 'parameterEnum': parameterEnum, 'parameterModel': parameterModel, }, - }); - return result.body; + }, this.openApiConfig, config); } /** @@ -2099,6 +2123,7 @@ export class DefaultsService { * @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 + * @param [config] the optional OpenAPI config to use * @throws ApiError */ public async callWithDefaultOptionalParameters( @@ -2109,10 +2134,11 @@ export class DefaultsService { parameterModel: ModelWithString = { \\"prop\\": \\"Hello World!\\" }, - ): Promise { - const result = await this.httpRequest.request({ + config?: OpenAPIConfig + ): Promise> { + return this.httpRequest.request({ method: 'POST', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/defaults\`, + path: \`/api/v\${this.openApiConfig.version}/defaults\`, query: { 'parameterString': parameterString, 'parameterNumber': parameterNumber, @@ -2120,8 +2146,7 @@ export class DefaultsService { 'parameterEnum': parameterEnum, 'parameterModel': parameterModel, }, - }); - return result.body; + }, this.openApiConfig, config); } /** @@ -2131,6 +2156,7 @@ export class DefaultsService { * @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 + * @param [config] the optional OpenAPI config to use * @throws ApiError */ public async callToTestOrderOfParams( @@ -2140,10 +2166,11 @@ export class DefaultsService { parameterOptionalStringWithNoDefault?: string, parameterStringWithDefault: string = 'Hello World!', parameterStringWithEmptyDefault: string = '', - ): Promise { - const result = await this.httpRequest.request({ + config?: OpenAPIConfig + ): Promise> { + return this.httpRequest.request({ method: 'PUT', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/defaults\`, + path: \`/api/v\${this.openApiConfig.version}/defaults\`, query: { 'parameterStringWithNoDefault': parameterStringWithNoDefault, 'parameterOptionalStringWithDefault': parameterOptionalStringWithDefault, @@ -2152,8 +2179,7 @@ export class DefaultsService { 'parameterStringWithDefault': parameterStringWithDefault, 'parameterStringWithEmptyDefault': parameterStringWithEmptyDefault, }, - }); - return result.body; + }, this.openApiConfig, config); } }" @@ -2164,57 +2190,59 @@ exports[`v2 should generate with exportClient: ./test/generated/v2_client/servic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { BaseHttpRequest } from '../core'; +import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; export class DuplicateService { - private httpRequest: BaseHttpRequest; + private readonly httpRequest: BaseHttpRequest; + private readonly openApiConfig: OpenAPIConfig; - constructor(httpRequest: BaseHttpRequest) { + constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { this.httpRequest = httpRequest; + this.openApiConfig = openApiConfig; } /** + * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async duplicateName(): Promise { - const result = await this.httpRequest.request({ + public async duplicateName(config?: OpenAPIConfig): Promise> { + return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/duplicate\`, - }); - return result.body; + path: \`/api/v\${this.openApiConfig.version}/duplicate\`, + }, this.openApiConfig, config); } /** + * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async duplicateName1(): Promise { - const result = await this.httpRequest.request({ + public async duplicateName1(config?: OpenAPIConfig): Promise> { + return this.httpRequest.request({ method: 'POST', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/duplicate\`, - }); - return result.body; + path: \`/api/v\${this.openApiConfig.version}/duplicate\`, + }, this.openApiConfig, config); } /** + * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async duplicateName2(): Promise { - const result = await this.httpRequest.request({ + public async duplicateName2(config?: OpenAPIConfig): Promise> { + return this.httpRequest.request({ method: 'PUT', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/duplicate\`, - }); - return result.body; + path: \`/api/v\${this.openApiConfig.version}/duplicate\`, + }, this.openApiConfig, config); } /** + * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async duplicateName3(): Promise { - const result = await this.httpRequest.request({ + public async duplicateName3(config?: OpenAPIConfig): Promise> { + return this.httpRequest.request({ method: 'DELETE', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/duplicate\`, - }); - return result.body; + path: \`/api/v\${this.openApiConfig.version}/duplicate\`, + }, this.openApiConfig, config); } }" @@ -2225,30 +2253,32 @@ exports[`v2 should generate with exportClient: ./test/generated/v2_client/servic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { BaseHttpRequest } from '../core'; +import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; export class HeaderService { - private httpRequest: BaseHttpRequest; + private readonly httpRequest: BaseHttpRequest; + private readonly openApiConfig: OpenAPIConfig; - constructor(httpRequest: BaseHttpRequest) { + constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { this.httpRequest = httpRequest; + this.openApiConfig = openApiConfig; } /** + * @param [config] the optional OpenAPI config to use * @returns string Successful response * @throws ApiError */ - public async callWithResultFromHeader(): Promise { - const result = await this.httpRequest.request({ + public async callWithResultFromHeader(config?: OpenAPIConfig): Promise> { + return this.httpRequest.request({ method: 'POST', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/header\`, + path: \`/api/v\${this.openApiConfig.version}/header\`, responseHeader: 'operation-location', errors: { 400: \`400 server error\`, 500: \`500 server error\`, }, - }); - return result.body; + }, this.openApiConfig, config); } }" @@ -2259,25 +2289,27 @@ exports[`v2 should generate with exportClient: ./test/generated/v2_client/servic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { BaseHttpRequest } from '../core'; +import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; export class NoContentService { - private httpRequest: BaseHttpRequest; + private readonly httpRequest: BaseHttpRequest; + private readonly openApiConfig: OpenAPIConfig; - constructor(httpRequest: BaseHttpRequest) { + constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { this.httpRequest = httpRequest; + this.openApiConfig = openApiConfig; } /** + * @param [config] the optional OpenAPI config to use * @returns void * @throws ApiError */ - public async callWithNoContentResponse(): Promise { - const result = await this.httpRequest.request({ + public async callWithNoContentResponse(config?: OpenAPIConfig): Promise> { + return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/no-content\`, - }); - return result.body; + path: \`/api/v\${this.openApiConfig.version}/no-content\`, + }, this.openApiConfig, config); } }" @@ -2288,13 +2320,15 @@ exports[`v2 should generate with exportClient: ./test/generated/v2_client/servic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { BaseHttpRequest } from '../core'; +import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; export class ParametersService { - private httpRequest: BaseHttpRequest; + private readonly httpRequest: BaseHttpRequest; + private readonly openApiConfig: OpenAPIConfig; - constructor(httpRequest: BaseHttpRequest) { + constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { this.httpRequest = httpRequest; + this.openApiConfig = openApiConfig; } /** @@ -2303,6 +2337,7 @@ export class ParametersService { * @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 + * @param [config] the optional OpenAPI config to use * @throws ApiError */ public async callWithParameters( @@ -2311,10 +2346,11 @@ export class ParametersService { parameterForm: string, parameterBody: string, parameterPath: string, - ): Promise { - const result = await this.httpRequest.request({ + config?: OpenAPIConfig + ): Promise> { + return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/parameters/\${parameterPath}\`, + path: \`/api/v\${this.openApiConfig.version}/parameters/\${parameterPath}\`, headers: { 'parameterHeader': parameterHeader, }, @@ -2325,8 +2361,7 @@ export class ParametersService { 'parameterForm': parameterForm, }, body: parameterBody, - }); - return result.body; + }, this.openApiConfig, config); } /** @@ -2338,6 +2373,7 @@ export class ParametersService { * @param parameterPath2 This is the parameter that goes into the path * @param parameterPath3 This is the parameter that goes into the path * @param _default This is the parameter with a reserved keyword + * @param [config] the optional OpenAPI config to use * @throws ApiError */ public async callWithWeirdParameterNames( @@ -2349,10 +2385,11 @@ export class ParametersService { parameterPath2?: string, parameterPath3?: string, _default?: string, - ): Promise { - const result = await this.httpRequest.request({ + config?: OpenAPIConfig + ): Promise> { + return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/parameters/\${parameterPath1}/\${parameterPath2}/\${parameterPath3}\`, + path: \`/api/v\${this.openApiConfig.version}/parameters/\${parameterPath1}/\${parameterPath2}/\${parameterPath3}\`, headers: { 'parameter.header': parameterHeader, }, @@ -2364,8 +2401,7 @@ export class ParametersService { 'parameter_form': parameterForm, }, body: parameterBody, - }); - return result.body; + }, this.openApiConfig, config); } }" @@ -2381,66 +2417,68 @@ import type { ModelThatExtendsExtends, ModelWithString, } from '../models'; -import { BaseHttpRequest } from '../core'; +import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; export class ResponseService { - private httpRequest: BaseHttpRequest; + private readonly httpRequest: BaseHttpRequest; + private readonly openApiConfig: OpenAPIConfig; - constructor(httpRequest: BaseHttpRequest) { + constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { this.httpRequest = httpRequest; + this.openApiConfig = openApiConfig; } /** + * @param [config] the optional OpenAPI config to use * @returns ModelWithString Message for default response * @throws ApiError */ - public async callWithResponse(): Promise { - const result = await this.httpRequest.request({ + public async callWithResponse(config?: OpenAPIConfig): Promise> { + return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/response\`, - }); - return result.body; + path: \`/api/v\${this.openApiConfig.version}/response\`, + }, this.openApiConfig, config); } /** + * @param [config] the optional OpenAPI config to use * @returns ModelWithString Message for default response * @throws ApiError */ - public async callWithDuplicateResponses(): Promise { - const result = await this.httpRequest.request({ + public async callWithDuplicateResponses(config?: OpenAPIConfig): Promise> { + return this.httpRequest.request({ method: 'POST', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/response\`, + path: \`/api/v\${this.openApiConfig.version}/response\`, errors: { 500: \`Message for 500 error\`, 501: \`Message for 501 error\`, 502: \`Message for 502 error\`, }, - }); - return result.body; + }, this.openApiConfig, config); } /** + * @param [config] the optional OpenAPI config to use * @returns any Message for 200 response * @returns ModelWithString Message for default response * @returns ModelThatExtends Message for 201 response * @returns ModelThatExtendsExtends Message for 202 response * @throws ApiError */ - public async callWithResponses(): Promise<{ + public async callWithResponses(config?: OpenAPIConfig): Promise, - } | ModelWithString | ModelThatExtends | ModelThatExtendsExtends> { - const result = await this.httpRequest.request({ + } | ModelWithString | ModelThatExtends | ModelThatExtendsExtends>> { + return this.httpRequest.request({ method: 'PUT', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/response\`, + path: \`/api/v\${this.openApiConfig.version}/response\`, errors: { 500: \`Message for 500 error\`, 501: \`Message for 501 error\`, 502: \`Message for 502 error\`, }, - }); - return result.body; + }, this.openApiConfig, config); } }" @@ -2451,90 +2489,92 @@ exports[`v2 should generate with exportClient: ./test/generated/v2_client/servic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { BaseHttpRequest } from '../core'; +import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; export class SimpleService { - private httpRequest: BaseHttpRequest; + private readonly httpRequest: BaseHttpRequest; + private readonly openApiConfig: OpenAPIConfig; - constructor(httpRequest: BaseHttpRequest) { + constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { this.httpRequest = httpRequest; + this.openApiConfig = openApiConfig; } /** + * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async getCallWithoutParametersAndResponse(): Promise { - const result = await this.httpRequest.request({ + public async getCallWithoutParametersAndResponse(config?: OpenAPIConfig): Promise> { + return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/simple\`, - }); - return result.body; + path: \`/api/v\${this.openApiConfig.version}/simple\`, + }, this.openApiConfig, config); } /** + * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async putCallWithoutParametersAndResponse(): Promise { - const result = await this.httpRequest.request({ + public async putCallWithoutParametersAndResponse(config?: OpenAPIConfig): Promise> { + return this.httpRequest.request({ method: 'PUT', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/simple\`, - }); - return result.body; + path: \`/api/v\${this.openApiConfig.version}/simple\`, + }, this.openApiConfig, config); } /** + * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async postCallWithoutParametersAndResponse(): Promise { - const result = await this.httpRequest.request({ + public async postCallWithoutParametersAndResponse(config?: OpenAPIConfig): Promise> { + return this.httpRequest.request({ method: 'POST', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/simple\`, - }); - return result.body; + path: \`/api/v\${this.openApiConfig.version}/simple\`, + }, this.openApiConfig, config); } /** + * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async deleteCallWithoutParametersAndResponse(): Promise { - const result = await this.httpRequest.request({ + public async deleteCallWithoutParametersAndResponse(config?: OpenAPIConfig): Promise> { + return this.httpRequest.request({ method: 'DELETE', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/simple\`, - }); - return result.body; + path: \`/api/v\${this.openApiConfig.version}/simple\`, + }, this.openApiConfig, config); } /** + * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async optionsCallWithoutParametersAndResponse(): Promise { - const result = await this.httpRequest.request({ + public async optionsCallWithoutParametersAndResponse(config?: OpenAPIConfig): Promise> { + return this.httpRequest.request({ method: 'OPTIONS', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/simple\`, - }); - return result.body; + path: \`/api/v\${this.openApiConfig.version}/simple\`, + }, this.openApiConfig, config); } /** + * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async headCallWithoutParametersAndResponse(): Promise { - const result = await this.httpRequest.request({ + public async headCallWithoutParametersAndResponse(config?: OpenAPIConfig): Promise> { + return this.httpRequest.request({ method: 'HEAD', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/simple\`, - }); - return result.body; + path: \`/api/v\${this.openApiConfig.version}/simple\`, + }, this.openApiConfig, config); } /** + * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async patchCallWithoutParametersAndResponse(): Promise { - const result = await this.httpRequest.request({ + public async patchCallWithoutParametersAndResponse(config?: OpenAPIConfig): Promise> { + return this.httpRequest.request({ method: 'PATCH', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/simple\`, - }); - return result.body; + path: \`/api/v\${this.openApiConfig.version}/simple\`, + }, this.openApiConfig, config); } }" @@ -2545,13 +2585,15 @@ exports[`v2 should generate with exportClient: ./test/generated/v2_client/servic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { BaseHttpRequest } from '../core'; +import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; export class TypesService { - private httpRequest: BaseHttpRequest; + private readonly httpRequest: BaseHttpRequest; + private readonly openApiConfig: OpenAPIConfig; - constructor(httpRequest: BaseHttpRequest) { + constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { this.httpRequest = httpRequest; + this.openApiConfig = openApiConfig; } /** @@ -2563,6 +2605,7 @@ export class TypesService { * @param parameterBoolean This is a boolean parameter * @param parameterObject This is an object parameter * @param id This is a number parameter + * @param [config] the optional OpenAPI config to use * @returns number Response is a simple number * @returns string Response is a simple string * @returns boolean Response is a simple boolean @@ -2578,10 +2621,11 @@ export class TypesService { parameterBoolean: boolean = true, parameterObject: any = null, id?: number, - ): Promise { - const result = await this.httpRequest.request({ + config?: OpenAPIConfig + ): Promise> { + return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/types\`, + path: \`/api/v\${this.openApiConfig.version}/types\`, query: { 'parameterArray': parameterArray, 'parameterDictionary': parameterDictionary, @@ -2591,8 +2635,7 @@ export class TypesService { 'parameterBoolean': parameterBoolean, 'parameterObject': parameterObject, }, - }); - return result.body; + }, this.openApiConfig, config); } }" @@ -2621,7 +2664,8 @@ exports[`v3 should generate with exportClient: ./test/generated/v3_client/client /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { BaseHttpRequest, FetchHttpRequest } from './core'; +import type { BaseHttpRequest } from './core'; +import { FetchHttpRequest } from './core'; import type { OpenAPIConfig } from './core'; import { CollectionFormatService, @@ -2653,31 +2697,30 @@ export class TestClient { readonly simple: SimpleService; readonly types: TypesService; readonly upload: UploadService; - readonly request: BaseHttpRequest; - - constructor(openApiConfig?: OpenAPIConfig, HttpRequest: new (config: OpenAPIConfig) => BaseHttpRequest = FetchHttpRequest) { - this.request = new HttpRequest({ - BASE: openApiConfig?.BASE ?? 'http://localhost:3000/base', - VERSION: openApiConfig?.VERSION ?? '1.0', - WITH_CREDENTIALS: openApiConfig?.WITH_CREDENTIALS ?? false, - TOKEN: openApiConfig?.TOKEN, - USERNAME: openApiConfig?.USERNAME, - PASSWORD: openApiConfig?.PASSWORD, - HEADERS: openApiConfig?.HEADERS, - }); - this.collectionformat = new CollectionFormatService(this.request); - this.complex = new ComplexService(this.request); - this.defaults = new DefaultsService(this.request); - this.duplicate = new DuplicateService(this.request); - this.header = new HeaderService(this.request); - this.multipart = new MultipartService(this.request); - this.nocontent = new NoContentService(this.request); - this.parameters = new ParametersService(this.request); - this.requestbody = new RequestBodyService(this.request); - this.response = new ResponseService(this.request); - this.simple = new SimpleService(this.request); - this.types = new TypesService(this.request); - this.upload = new UploadService(this.request); + + constructor(openApiConfig: OpenAPIConfig, httpClient: BaseHttpRequest = new FetchHttpRequest()) { + const config = { + baseUrl: openApiConfig?.baseUrl ?? 'http://localhost:3000/base', + version: openApiConfig?.version ?? '1.0', + withCredentials: openApiConfig?.withCredentials ?? false, + token: openApiConfig?.token, + username: openApiConfig?.username, + password: openApiConfig?.password, + headers: openApiConfig?.headers, + } + this.collectionformat = new CollectionFormatService(httpClient, config); + this.complex = new ComplexService(httpClient, config); + this.defaults = new DefaultsService(httpClient, config); + this.duplicate = new DuplicateService(httpClient, config); + this.header = new HeaderService(httpClient, config); + this.multipart = new MultipartService(httpClient, config); + this.nocontent = new NoContentService(httpClient, config); + this.parameters = new ParametersService(httpClient, config); + this.requestbody = new RequestBodyService(httpClient, config); + this.response = new ResponseService(httpClient, config); + this.simple = new SimpleService(httpClient, config); + this.types = new TypesService(httpClient, config); + this.upload = new UploadService(httpClient, config); } }" `; @@ -2730,12 +2773,12 @@ exports[`v3 should generate with exportClient: ./test/generated/v3_client/core/A /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export type ApiResult = { +export type ApiResult = { readonly url: string; readonly ok: boolean; readonly status: number; readonly statusText: string; - readonly body: any; + readonly body: T; }" `; @@ -2748,16 +2791,12 @@ import type { ApiRequestOptions } from './ApiRequestOptions'; import type { ApiResult } from './ApiResult'; import type { OpenAPIConfig } from './OpenAPI'; -export class BaseHttpRequest { - readonly openApiConfig: OpenAPIConfig; - - constructor(openApiConfig: OpenAPIConfig) { - this.openApiConfig = openApiConfig; - } - - async request(options: ApiRequestOptions): Promise { - throw new Error('Not Implemented'); - } +export interface BaseHttpRequest { + request( + options: ApiRequestOptions, + config: OpenAPIConfig, + mergeConfig?: OpenAPIConfig + ): Promise; }" `; @@ -2770,7 +2809,7 @@ import { ApiError } from './ApiError'; import type { ApiRequestOptions } from './ApiRequestOptions'; import type { ApiResult } from './ApiResult'; import type { OpenAPIConfig } from './OpenAPI'; -import { BaseHttpRequest } from './BaseHttpRequest'; +import type { BaseHttpRequest } from './BaseHttpRequest'; function isDefined(value: T | null | undefined): value is Exclude { return value !== undefined && value !== null; @@ -2780,6 +2819,26 @@ function isString(value: any): value is string { return typeof value === 'string'; } +export function deepAssign( + target: Record, + source: Record, +): Record { + const keys = Object.keys(source); + for (const k of keys) { + const sourceValue: unknown = source[k]; + const targetValue: unknown = target[k]; + if (Object(sourceValue) === sourceValue && Object(targetValue) === targetValue) { + target[k] = deepAssign( + targetValue as Record, + sourceValue as Record, + ); + } else { + target[k] = source[k]; + } + } + return target; +} + function isStringWithValue(value: any): value is string { return isString(value) && value !== ''; } @@ -2810,7 +2869,7 @@ function getQueryString(params: Record): string { function getUrl(options: ApiRequestOptions, config: OpenAPIConfig): string { const path = options.path.replace(/[:]/g, '_'); - const url = \`\${config.BASE}\${path}\`; + const url = \`\${config.baseUrl}\${path}\`; if (options.query) { return \`\${url}\${getQueryString(options.query)}\`; @@ -2839,10 +2898,10 @@ async function resolve(options: ApiRequestOptions, resolver?: T | Resolver } async function getHeaders(options: ApiRequestOptions, config: OpenAPIConfig): Promise { - const token = await resolve(options, config.TOKEN); - const username = await resolve(options, config.USERNAME); - const password = await resolve(options, config.PASSWORD); - const defaultHeaders = await resolve(options, config.HEADERS); + const token = await resolve(options, config.token); + const username = await resolve(options, config.username); + const password = await resolve(options, config.password); + const defaultHeaders = await resolve(options, config.headers); const headers = new Headers({ Accept: 'application/json', @@ -2895,7 +2954,7 @@ async function sendRequest(options: ApiRequestOptions, config: OpenAPIConfig, ur headers: await getHeaders(options, config), body: getRequestBody(options), }; - if (config.WITH_CREDENTIALS) { + if (config.withCredentials) { request.credentials = 'include'; } return await fetch(url, request); @@ -2950,20 +3009,19 @@ function catchErrors(options: ApiRequestOptions, result: ApiResult): void { } } -export class FetchHttpRequest extends BaseHttpRequest { - constructor(openApiConfig: OpenAPIConfig) { - super(openApiConfig); - } - +export class FetchHttpRequest implements BaseHttpRequest { /** * Request using fetch client * @param options The request options from the the service + * @param config The OpenAPI configuration + * @param [mergeConfig] Additional optional OpenAPI configuration that will be merged with the first one * @returns ApiResult * @throws ApiError */ - async request(options: ApiRequestOptions): Promise { - const url = getUrl(options, this.openApiConfig); - const response = await sendRequest(options, this.openApiConfig, url); + async request(options: ApiRequestOptions, config: OpenAPIConfig, mergeConfig?: OpenAPIConfig): Promise { + const conf = mergeConfig ? deepAssign(config, mergeConfig) : config; + const url = getUrl(options, conf); + const response = await sendRequest(options, conf, url); const responseBody = await getResponseBody(response); const responseHeader = getResponseHeader(response, options.responseHeader); @@ -2993,13 +3051,13 @@ type Resolver = (options: ApiRequestOptions) => Promise; type Headers = Record; export type OpenAPIConfig = { - BASE?: string; - VERSION?: string; - WITH_CREDENTIALS?: boolean; - TOKEN?: string | Resolver; - USERNAME?: string | Resolver; - PASSWORD?: string | Resolver; - HEADERS?: Headers | Resolver; + baseUrl?: string; + version?: string; + withCredentials?: boolean; + token?: string | Resolver; + username?: string | Resolver; + password?: string | Resolver; + headers?: Headers | Resolver; } " `; @@ -3012,7 +3070,7 @@ exports[`v3 should generate with exportClient: ./test/generated/v3_client/core/i export { ApiError } from './ApiError'; export type { ApiRequestOptions } from './ApiRequestOptions'; export type { ApiResult } from './ApiResult'; -export { BaseHttpRequest } from './BaseHttpRequest'; +export type { BaseHttpRequest } from './BaseHttpRequest'; export { FetchHttpRequest } from './FetchHttpRequest'; export type { OpenAPIConfig } from './OpenAPI'; " @@ -4853,13 +4911,15 @@ exports[`v3 should generate with exportClient: ./test/generated/v3_client/servic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { BaseHttpRequest } from '../core'; +import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; export class CollectionFormatService { - private httpRequest: BaseHttpRequest; + private readonly httpRequest: BaseHttpRequest; + private readonly openApiConfig: OpenAPIConfig; - constructor(httpRequest: BaseHttpRequest) { + constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { this.httpRequest = httpRequest; + this.openApiConfig = openApiConfig; } /** @@ -4868,6 +4928,7 @@ export class CollectionFormatService { * @param parameterArrayTsv This is an array parameter that is send as tsv format (tab-separated values) * @param parameterArrayPipes This is an array parameter that is send as pipes format (pipe-separated values) * @param parameterArrayMulti This is an array parameter that is send as multi format (multiple parameter instances) + * @param [config] the optional OpenAPI config to use * @throws ApiError */ public async collectionFormat( @@ -4876,10 +4937,11 @@ export class CollectionFormatService { parameterArrayTsv: Array | null, parameterArrayPipes: Array | null, parameterArrayMulti: Array | null, - ): Promise { - const result = await this.httpRequest.request({ + config?: OpenAPIConfig + ): Promise> { + return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/collectionFormat\`, + path: \`/api/v\${this.openApiConfig.version}/collectionFormat\`, query: { 'parameterArrayCSV': parameterArrayCsv, 'parameterArraySSV': parameterArraySsv, @@ -4887,8 +4949,7 @@ export class CollectionFormatService { 'parameterArrayPipes': parameterArrayPipes, 'parameterArrayMulti': parameterArrayMulti, }, - }); - return result.body; + }, this.openApiConfig, config); } }" @@ -4905,18 +4966,21 @@ import type { ModelWithEnum, ModelWithString, } from '../models'; -import { BaseHttpRequest } from '../core'; +import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; export class ComplexService { - private httpRequest: BaseHttpRequest; + private readonly httpRequest: BaseHttpRequest; + private readonly openApiConfig: OpenAPIConfig; - constructor(httpRequest: BaseHttpRequest) { + constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { this.httpRequest = httpRequest; + this.openApiConfig = openApiConfig; } /** * @param parameterObject Parameter containing object * @param parameterReference Parameter containing reference + * @param [config] the optional OpenAPI config to use * @returns ModelWithString Successful response * @throws ApiError */ @@ -4929,10 +4993,11 @@ export class ComplexService { }, }, parameterReference: ModelWithString, - ): Promise> { - const result = await this.httpRequest.request({ + config?: OpenAPIConfig + ): Promise>> { + return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/complex\`, + path: \`/api/v\${this.openApiConfig.version}/complex\`, query: { 'parameterObject': parameterObject, 'parameterReference': parameterReference, @@ -4941,13 +5006,13 @@ export class ComplexService { 400: \`400 server error\`, 500: \`500 server error\`, }, - }); - return result.body; + }, this.openApiConfig, config); } /** * @param id * @param requestBody + * @param [config] the optional OpenAPI config to use * @returns ModelWithString Success * @throws ApiError */ @@ -4966,14 +5031,14 @@ export class ComplexService { readonly name?: string | null, }, }, - ): Promise { - const result = await this.httpRequest.request({ + config?: OpenAPIConfig + ): Promise> { + return this.httpRequest.request({ method: 'PUT', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/complex/\${id}\`, + path: \`/api/v\${this.openApiConfig.version}/complex/\${id}\`, body: requestBody, mediaType: 'application/json-patch+json', - }); - return result.body; + }, this.openApiConfig, config); } }" @@ -4987,13 +5052,15 @@ exports[`v3 should generate with exportClient: ./test/generated/v3_client/servic import type { ModelWithString, } from '../models'; -import { BaseHttpRequest } from '../core'; +import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; export class DefaultsService { - private httpRequest: BaseHttpRequest; + private readonly httpRequest: BaseHttpRequest; + private readonly openApiConfig: OpenAPIConfig; - constructor(httpRequest: BaseHttpRequest) { + constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { this.httpRequest = httpRequest; + this.openApiConfig = openApiConfig; } /** @@ -5002,6 +5069,7 @@ export class DefaultsService { * @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 + * @param [config] the optional OpenAPI config to use * @throws ApiError */ public async callWithDefaultParameters( @@ -5012,10 +5080,11 @@ export class DefaultsService { parameterModel: ModelWithString | null = { \\"prop\\": \\"Hello World!\\" }, - ): Promise { - const result = await this.httpRequest.request({ + config?: OpenAPIConfig + ): Promise> { + return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/defaults\`, + path: \`/api/v\${this.openApiConfig.version}/defaults\`, query: { 'parameterString': parameterString, 'parameterNumber': parameterNumber, @@ -5023,8 +5092,7 @@ export class DefaultsService { 'parameterEnum': parameterEnum, 'parameterModel': parameterModel, }, - }); - return result.body; + }, this.openApiConfig, config); } /** @@ -5033,6 +5101,7 @@ export class DefaultsService { * @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 + * @param [config] the optional OpenAPI config to use * @throws ApiError */ public async callWithDefaultOptionalParameters( @@ -5043,10 +5112,11 @@ export class DefaultsService { parameterModel: ModelWithString = { \\"prop\\": \\"Hello World!\\" }, - ): Promise { - const result = await this.httpRequest.request({ + config?: OpenAPIConfig + ): Promise> { + return this.httpRequest.request({ method: 'POST', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/defaults\`, + path: \`/api/v\${this.openApiConfig.version}/defaults\`, query: { 'parameterString': parameterString, 'parameterNumber': parameterNumber, @@ -5054,8 +5124,7 @@ export class DefaultsService { 'parameterEnum': parameterEnum, 'parameterModel': parameterModel, }, - }); - return result.body; + }, this.openApiConfig, config); } /** @@ -5065,6 +5134,7 @@ export class DefaultsService { * @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 + * @param [config] the optional OpenAPI config to use * @throws ApiError */ public async callToTestOrderOfParams( @@ -5074,10 +5144,11 @@ export class DefaultsService { parameterOptionalStringWithNoDefault?: string, parameterStringWithDefault: string = 'Hello World!', parameterStringWithEmptyDefault: string = '', - ): Promise { - const result = await this.httpRequest.request({ + config?: OpenAPIConfig + ): Promise> { + return this.httpRequest.request({ method: 'PUT', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/defaults\`, + path: \`/api/v\${this.openApiConfig.version}/defaults\`, query: { 'parameterStringWithNoDefault': parameterStringWithNoDefault, 'parameterOptionalStringWithDefault': parameterOptionalStringWithDefault, @@ -5086,8 +5157,7 @@ export class DefaultsService { 'parameterStringWithDefault': parameterStringWithDefault, 'parameterStringWithEmptyDefault': parameterStringWithEmptyDefault, }, - }); - return result.body; + }, this.openApiConfig, config); } }" @@ -5098,57 +5168,59 @@ exports[`v3 should generate with exportClient: ./test/generated/v3_client/servic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { BaseHttpRequest } from '../core'; +import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; export class DuplicateService { - private httpRequest: BaseHttpRequest; + private readonly httpRequest: BaseHttpRequest; + private readonly openApiConfig: OpenAPIConfig; - constructor(httpRequest: BaseHttpRequest) { + constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { this.httpRequest = httpRequest; + this.openApiConfig = openApiConfig; } /** + * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async duplicateName(): Promise { - const result = await this.httpRequest.request({ + public async duplicateName(config?: OpenAPIConfig): Promise> { + return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/duplicate\`, - }); - return result.body; + path: \`/api/v\${this.openApiConfig.version}/duplicate\`, + }, this.openApiConfig, config); } /** + * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async duplicateName1(): Promise { - const result = await this.httpRequest.request({ + public async duplicateName1(config?: OpenAPIConfig): Promise> { + return this.httpRequest.request({ method: 'POST', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/duplicate\`, - }); - return result.body; + path: \`/api/v\${this.openApiConfig.version}/duplicate\`, + }, this.openApiConfig, config); } /** + * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async duplicateName2(): Promise { - const result = await this.httpRequest.request({ + public async duplicateName2(config?: OpenAPIConfig): Promise> { + return this.httpRequest.request({ method: 'PUT', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/duplicate\`, - }); - return result.body; + path: \`/api/v\${this.openApiConfig.version}/duplicate\`, + }, this.openApiConfig, config); } /** + * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async duplicateName3(): Promise { - const result = await this.httpRequest.request({ + public async duplicateName3(config?: OpenAPIConfig): Promise> { + return this.httpRequest.request({ method: 'DELETE', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/duplicate\`, - }); - return result.body; + path: \`/api/v\${this.openApiConfig.version}/duplicate\`, + }, this.openApiConfig, config); } }" @@ -5159,30 +5231,32 @@ exports[`v3 should generate with exportClient: ./test/generated/v3_client/servic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { BaseHttpRequest } from '../core'; +import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; export class HeaderService { - private httpRequest: BaseHttpRequest; + private readonly httpRequest: BaseHttpRequest; + private readonly openApiConfig: OpenAPIConfig; - constructor(httpRequest: BaseHttpRequest) { + constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { this.httpRequest = httpRequest; + this.openApiConfig = openApiConfig; } /** + * @param [config] the optional OpenAPI config to use * @returns string Successful response * @throws ApiError */ - public async callWithResultFromHeader(): Promise { - const result = await this.httpRequest.request({ + public async callWithResultFromHeader(config?: OpenAPIConfig): Promise> { + return this.httpRequest.request({ method: 'POST', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/header\`, + path: \`/api/v\${this.openApiConfig.version}/header\`, responseHeader: 'operation-location', errors: { 400: \`400 server error\`, 500: \`500 server error\`, }, - }); - return result.body; + }, this.openApiConfig, config); } }" @@ -5193,31 +5267,33 @@ exports[`v3 should generate with exportClient: ./test/generated/v3_client/servic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { BaseHttpRequest } from '../core'; +import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; export class MultipartService { - private httpRequest: BaseHttpRequest; + private readonly httpRequest: BaseHttpRequest; + private readonly openApiConfig: OpenAPIConfig; - constructor(httpRequest: BaseHttpRequest) { + constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { this.httpRequest = httpRequest; + this.openApiConfig = openApiConfig; } /** + * @param [config] the optional OpenAPI config to use * @returns any OK * @throws ApiError */ - public async multipartResponse(): Promise<{ + public async multipartResponse(config?: OpenAPIConfig): Promise { - const result = await this.httpRequest.request({ + }>> { + return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/multipart\`, - }); - return result.body; + path: \`/api/v\${this.openApiConfig.version}/multipart\`, + }, this.openApiConfig, config); } }" @@ -5228,25 +5304,27 @@ exports[`v3 should generate with exportClient: ./test/generated/v3_client/servic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { BaseHttpRequest } from '../core'; +import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; export class NoContentService { - private httpRequest: BaseHttpRequest; + private readonly httpRequest: BaseHttpRequest; + private readonly openApiConfig: OpenAPIConfig; - constructor(httpRequest: BaseHttpRequest) { + constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { this.httpRequest = httpRequest; + this.openApiConfig = openApiConfig; } /** + * @param [config] the optional OpenAPI config to use * @returns void * @throws ApiError */ - public async callWithNoContentResponse(): Promise { - const result = await this.httpRequest.request({ + public async callWithNoContentResponse(config?: OpenAPIConfig): Promise> { + return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/no-content\`, - }); - return result.body; + path: \`/api/v\${this.openApiConfig.version}/no-content\`, + }, this.openApiConfig, config); } }" @@ -5260,13 +5338,15 @@ exports[`v3 should generate with exportClient: ./test/generated/v3_client/servic import type { ModelWithString, } from '../models'; -import { BaseHttpRequest } from '../core'; +import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; export class ParametersService { - private httpRequest: BaseHttpRequest; + private readonly httpRequest: BaseHttpRequest; + private readonly openApiConfig: OpenAPIConfig; - constructor(httpRequest: BaseHttpRequest) { + constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { this.httpRequest = httpRequest; + this.openApiConfig = openApiConfig; } /** @@ -5276,6 +5356,7 @@ export class ParametersService { * @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 + * @param [config] the optional OpenAPI config to use * @throws ApiError */ public async callWithParameters( @@ -5285,10 +5366,11 @@ export class ParametersService { parameterCookie: string | null, parameterPath: string | null, requestBody: ModelWithString | null, - ): Promise { - const result = await this.httpRequest.request({ + config?: OpenAPIConfig + ): Promise> { + return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/parameters/\${parameterPath}\`, + path: \`/api/v\${this.openApiConfig.version}/parameters/\${parameterPath}\`, cookies: { 'parameterCookie': parameterCookie, }, @@ -5303,8 +5385,7 @@ export class ParametersService { }, body: requestBody, mediaType: 'application/json', - }); - return result.body; + }, this.openApiConfig, config); } /** @@ -5317,6 +5398,7 @@ export class ParametersService { * @param parameterPath2 This is the parameter that goes into the path * @param parameterPath3 This is the parameter that goes into the path * @param _default This is the parameter with a reserved keyword + * @param [config] the optional OpenAPI config to use * @throws ApiError */ public async callWithWeirdParameterNames( @@ -5329,10 +5411,11 @@ export class ParametersService { parameterPath2?: string, parameterPath3?: string, _default?: string, - ): Promise { - const result = await this.httpRequest.request({ + config?: OpenAPIConfig + ): Promise> { + return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/parameters/\${parameterPath1}/\${parameterPath2}/\${parameterPath3}\`, + path: \`/api/v\${this.openApiConfig.version}/parameters/\${parameterPath1}/\${parameterPath2}/\${parameterPath3}\`, cookies: { 'PARAMETER-COOKIE': parameterCookie, }, @@ -5348,50 +5431,51 @@ export class ParametersService { }, body: requestBody, mediaType: 'application/json', - }); - return result.body; + }, this.openApiConfig, config); } /** * @param requestBody This is a required parameter * @param parameter This is an optional parameter + * @param [config] the optional OpenAPI config to use * @throws ApiError */ public async getCallWithOptionalParam( requestBody: ModelWithString, parameter?: string, - ): Promise { - const result = await this.httpRequest.request({ + config?: OpenAPIConfig + ): Promise> { + return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/parameters/\`, + path: \`/api/v\${this.openApiConfig.version}/parameters/\`, query: { 'parameter': parameter, }, body: requestBody, mediaType: 'application/json', - }); - return result.body; + }, this.openApiConfig, config); } /** * @param parameter This is a required parameter * @param requestBody This is an optional parameter + * @param [config] the optional OpenAPI config to use * @throws ApiError */ public async postCallWithOptionalParam( parameter: string, requestBody?: ModelWithString, - ): Promise { - const result = await this.httpRequest.request({ + config?: OpenAPIConfig + ): Promise> { + return this.httpRequest.request({ method: 'POST', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/parameters/\`, + path: \`/api/v\${this.openApiConfig.version}/parameters/\`, query: { 'parameter': parameter, }, body: requestBody, mediaType: 'application/json', - }); - return result.body; + }, this.openApiConfig, config); } }" @@ -5405,29 +5489,32 @@ exports[`v3 should generate with exportClient: ./test/generated/v3_client/servic import type { ModelWithString, } from '../models'; -import { BaseHttpRequest } from '../core'; +import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; export class RequestBodyService { - private httpRequest: BaseHttpRequest; + private readonly httpRequest: BaseHttpRequest; + private readonly openApiConfig: OpenAPIConfig; - constructor(httpRequest: BaseHttpRequest) { + constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { this.httpRequest = httpRequest; + this.openApiConfig = openApiConfig; } /** * @param requestBody A reusable request body + * @param [config] the optional OpenAPI config to use * @throws ApiError */ public async postRequestBodyService( requestBody?: ModelWithString, - ): Promise { - const result = await this.httpRequest.request({ + config?: OpenAPIConfig + ): Promise> { + return this.httpRequest.request({ method: 'POST', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/requestBody/\`, + path: \`/api/v\${this.openApiConfig.version}/requestBody/\`, body: requestBody, mediaType: 'application/json', - }); - return result.body; + }, this.openApiConfig, config); } }" @@ -5443,66 +5530,68 @@ import type { ModelThatExtendsExtends, ModelWithString, } from '../models'; -import { BaseHttpRequest } from '../core'; +import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; export class ResponseService { - private httpRequest: BaseHttpRequest; + private readonly httpRequest: BaseHttpRequest; + private readonly openApiConfig: OpenAPIConfig; - constructor(httpRequest: BaseHttpRequest) { + constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { this.httpRequest = httpRequest; + this.openApiConfig = openApiConfig; } /** + * @param [config] the optional OpenAPI config to use * @returns ModelWithString * @throws ApiError */ - public async callWithResponse(): Promise { - const result = await this.httpRequest.request({ + public async callWithResponse(config?: OpenAPIConfig): Promise> { + return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/response\`, - }); - return result.body; + path: \`/api/v\${this.openApiConfig.version}/response\`, + }, this.openApiConfig, config); } /** + * @param [config] the optional OpenAPI config to use * @returns ModelWithString Message for default response * @throws ApiError */ - public async callWithDuplicateResponses(): Promise { - const result = await this.httpRequest.request({ + public async callWithDuplicateResponses(config?: OpenAPIConfig): Promise> { + return this.httpRequest.request({ method: 'POST', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/response\`, + path: \`/api/v\${this.openApiConfig.version}/response\`, errors: { 500: \`Message for 500 error\`, 501: \`Message for 501 error\`, 502: \`Message for 502 error\`, }, - }); - return result.body; + }, this.openApiConfig, config); } /** + * @param [config] the optional OpenAPI config to use * @returns any Message for 200 response * @returns ModelWithString Message for default response * @returns ModelThatExtends Message for 201 response * @returns ModelThatExtendsExtends Message for 202 response * @throws ApiError */ - public async callWithResponses(): Promise<{ + public async callWithResponses(config?: OpenAPIConfig): Promise, - } | ModelWithString | ModelThatExtends | ModelThatExtendsExtends> { - const result = await this.httpRequest.request({ + } | ModelWithString | ModelThatExtends | ModelThatExtendsExtends>> { + return this.httpRequest.request({ method: 'PUT', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/response\`, + path: \`/api/v\${this.openApiConfig.version}/response\`, errors: { 500: \`Message for 500 error\`, 501: \`Message for 501 error\`, 502: \`Message for 502 error\`, }, - }); - return result.body; + }, this.openApiConfig, config); } }" @@ -5513,90 +5602,92 @@ exports[`v3 should generate with exportClient: ./test/generated/v3_client/servic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { BaseHttpRequest } from '../core'; +import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; export class SimpleService { - private httpRequest: BaseHttpRequest; + private readonly httpRequest: BaseHttpRequest; + private readonly openApiConfig: OpenAPIConfig; - constructor(httpRequest: BaseHttpRequest) { + constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { this.httpRequest = httpRequest; + this.openApiConfig = openApiConfig; } /** + * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async getCallWithoutParametersAndResponse(): Promise { - const result = await this.httpRequest.request({ + public async getCallWithoutParametersAndResponse(config?: OpenAPIConfig): Promise> { + return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/simple\`, - }); - return result.body; + path: \`/api/v\${this.openApiConfig.version}/simple\`, + }, this.openApiConfig, config); } /** + * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async putCallWithoutParametersAndResponse(): Promise { - const result = await this.httpRequest.request({ + public async putCallWithoutParametersAndResponse(config?: OpenAPIConfig): Promise> { + return this.httpRequest.request({ method: 'PUT', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/simple\`, - }); - return result.body; + path: \`/api/v\${this.openApiConfig.version}/simple\`, + }, this.openApiConfig, config); } /** + * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async postCallWithoutParametersAndResponse(): Promise { - const result = await this.httpRequest.request({ + public async postCallWithoutParametersAndResponse(config?: OpenAPIConfig): Promise> { + return this.httpRequest.request({ method: 'POST', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/simple\`, - }); - return result.body; + path: \`/api/v\${this.openApiConfig.version}/simple\`, + }, this.openApiConfig, config); } /** + * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async deleteCallWithoutParametersAndResponse(): Promise { - const result = await this.httpRequest.request({ + public async deleteCallWithoutParametersAndResponse(config?: OpenAPIConfig): Promise> { + return this.httpRequest.request({ method: 'DELETE', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/simple\`, - }); - return result.body; + path: \`/api/v\${this.openApiConfig.version}/simple\`, + }, this.openApiConfig, config); } /** + * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async optionsCallWithoutParametersAndResponse(): Promise { - const result = await this.httpRequest.request({ + public async optionsCallWithoutParametersAndResponse(config?: OpenAPIConfig): Promise> { + return this.httpRequest.request({ method: 'OPTIONS', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/simple\`, - }); - return result.body; + path: \`/api/v\${this.openApiConfig.version}/simple\`, + }, this.openApiConfig, config); } /** + * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async headCallWithoutParametersAndResponse(): Promise { - const result = await this.httpRequest.request({ + public async headCallWithoutParametersAndResponse(config?: OpenAPIConfig): Promise> { + return this.httpRequest.request({ method: 'HEAD', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/simple\`, - }); - return result.body; + path: \`/api/v\${this.openApiConfig.version}/simple\`, + }, this.openApiConfig, config); } /** + * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async patchCallWithoutParametersAndResponse(): Promise { - const result = await this.httpRequest.request({ + public async patchCallWithoutParametersAndResponse(config?: OpenAPIConfig): Promise> { + return this.httpRequest.request({ method: 'PATCH', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/simple\`, - }); - return result.body; + path: \`/api/v\${this.openApiConfig.version}/simple\`, + }, this.openApiConfig, config); } }" @@ -5607,13 +5698,15 @@ exports[`v3 should generate with exportClient: ./test/generated/v3_client/servic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { BaseHttpRequest } from '../core'; +import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; export class TypesService { - private httpRequest: BaseHttpRequest; + private readonly httpRequest: BaseHttpRequest; + private readonly openApiConfig: OpenAPIConfig; - constructor(httpRequest: BaseHttpRequest) { + constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { this.httpRequest = httpRequest; + this.openApiConfig = openApiConfig; } /** @@ -5625,6 +5718,7 @@ export class TypesService { * @param parameterBoolean This is a boolean parameter * @param parameterObject This is an object parameter * @param id This is a number parameter + * @param [config] the optional OpenAPI config to use * @returns number Response is a simple number * @returns string Response is a simple string * @returns boolean Response is a simple boolean @@ -5640,10 +5734,11 @@ export class TypesService { parameterBoolean: boolean | null = true, parameterObject: any = null, id?: number, - ): Promise { - const result = await this.httpRequest.request({ + config?: OpenAPIConfig + ): Promise> { + return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/types\`, + path: \`/api/v\${this.openApiConfig.version}/types\`, query: { 'parameterArray': parameterArray, 'parameterDictionary': parameterDictionary, @@ -5653,8 +5748,7 @@ export class TypesService { 'parameterBoolean': parameterBoolean, 'parameterObject': parameterObject, }, - }); - return result.body; + }, this.openApiConfig, config); } }" @@ -5665,31 +5759,34 @@ exports[`v3 should generate with exportClient: ./test/generated/v3_client/servic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { BaseHttpRequest } from '../core'; +import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; export class UploadService { - private httpRequest: BaseHttpRequest; + private readonly httpRequest: BaseHttpRequest; + private readonly openApiConfig: OpenAPIConfig; - constructor(httpRequest: BaseHttpRequest) { + constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { this.httpRequest = httpRequest; + this.openApiConfig = openApiConfig; } /** * @param file Supply a file reference for upload + * @param [config] the optional OpenAPI config to use * @returns boolean * @throws ApiError */ public async uploadFile( file: Blob, - ): Promise { - const result = await this.httpRequest.request({ + config?: OpenAPIConfig + ): Promise> { + return this.httpRequest.request({ method: 'POST', - path: \`/api/v\${this.httpRequest.openApiConfig.VERSION}/upload\`, + path: \`/api/v\${this.openApiConfig.version}/upload\`, formData: { 'file': file, }, - }); - return result.body; + }, this.openApiConfig, config); } }" diff --git a/test/__snapshots__/index.spec.js.snap b/test/__snapshots__/index.spec.js.snap index 9b9b9d23d..4eb63f9cc 100644 --- a/test/__snapshots__/index.spec.js.snap +++ b/test/__snapshots__/index.spec.js.snap @@ -48,12 +48,12 @@ exports[`v2 should generate: ./test/generated/v2/core/ApiResult.ts 1`] = ` /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export type ApiResult = { +export type ApiResult = { readonly url: string; readonly ok: boolean; readonly status: number; readonly statusText: string; - readonly body: any; + readonly body: T; }" `; @@ -68,22 +68,22 @@ type Resolver = (options: ApiRequestOptions) => Promise; type Headers = Record; export type OpenAPIConfig = { - BASE?: string; - VERSION?: string; - WITH_CREDENTIALS?: boolean; - TOKEN?: string | Resolver; - USERNAME?: string | Resolver; - PASSWORD?: string | Resolver; - HEADERS?: Headers | Resolver; + baseUrl?: string; + version?: string; + withCredentials?: boolean; + token?: string | Resolver; + username?: string | Resolver; + password?: string | Resolver; + headers?: Headers | Resolver; } export const OpenAPI: OpenAPIConfig = { - BASE: 'http://localhost:3000/base', - VERSION: '1.0', - WITH_CREDENTIALS: false, - TOKEN: undefined, - USERNAME: undefined, - PASSWORD: undefined, - HEADERS: undefined, + baseUrl: 'http://localhost:3000/base', + version: '1.0', + withCredentials: false, + token: undefined, + username: undefined, + password: undefined, + headers: undefined, }; " `; @@ -120,6 +120,26 @@ function isString(value: any): value is string { return typeof value === 'string'; } +export function deepAssign( + target: Record, + source: Record, +): Record { + const keys = Object.keys(source); + for (const k of keys) { + const sourceValue: unknown = source[k]; + const targetValue: unknown = target[k]; + if (Object(sourceValue) === sourceValue && Object(targetValue) === targetValue) { + target[k] = deepAssign( + targetValue as Record, + sourceValue as Record, + ); + } else { + target[k] = source[k]; + } + } + return target; +} + function isStringWithValue(value: any): value is string { return isString(value) && value !== ''; } @@ -150,7 +170,7 @@ function getQueryString(params: Record): string { function getUrl(options: ApiRequestOptions, config: OpenAPIConfig): string { const path = options.path.replace(/[:]/g, '_'); - const url = \`\${config.BASE}\${path}\`; + const url = \`\${config.baseUrl}\${path}\`; if (options.query) { return \`\${url}\${getQueryString(options.query)}\`; @@ -179,10 +199,10 @@ async function resolve(options: ApiRequestOptions, resolver?: T | Resolver } async function getHeaders(options: ApiRequestOptions, config: OpenAPIConfig): Promise { - const token = await resolve(options, config.TOKEN); - const username = await resolve(options, config.USERNAME); - const password = await resolve(options, config.PASSWORD); - const defaultHeaders = await resolve(options, config.HEADERS); + const token = await resolve(options, config.token); + const username = await resolve(options, config.username); + const password = await resolve(options, config.password); + const defaultHeaders = await resolve(options, config.headers); const headers = new Headers({ Accept: 'application/json', @@ -235,7 +255,7 @@ async function sendRequest(options: ApiRequestOptions, config: OpenAPIConfig, ur headers: await getHeaders(options, config), body: getRequestBody(options), }; - if (config.WITH_CREDENTIALS) { + if (config.withCredentials) { request.credentials = 'include'; } return await fetch(url, request); @@ -1875,6 +1895,7 @@ exports[`v2 should generate: ./test/generated/v2/services/CollectionFormatServic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { ApiResult } from '../core'; import { request as __request, OpenAPI, @@ -1888,6 +1909,7 @@ export class CollectionFormatService { * @param parameterArrayTsv This is an array parameter that is send as tsv format (tab-separated values) * @param parameterArrayPipes This is an array parameter that is send as pipes format (pipe-separated values) * @param parameterArrayMulti This is an array parameter that is send as multi format (multiple parameter instances) + * @throws ApiError */ public static async collectionFormat( @@ -1896,10 +1918,11 @@ export class CollectionFormatService { parameterArrayTsv: Array, parameterArrayPipes: Array, parameterArrayMulti: Array, - ): Promise { - const result = await __request({ + + ): Promise> { + return __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/collectionFormat\`, + path: \`/api/v\${OpenAPI.version}/collectionFormat\`, query: { 'parameterArrayCSV': parameterArrayCsv, 'parameterArraySSV': parameterArraySsv, @@ -1908,7 +1931,6 @@ export class CollectionFormatService { 'parameterArrayMulti': parameterArrayMulti, }, }); - return result.body; } }" @@ -1922,6 +1944,7 @@ exports[`v2 should generate: ./test/generated/v2/services/ComplexService.ts 1`] import type { ModelWithString, } from '../models'; +import type { ApiResult } from '../core'; import { request as __request, OpenAPI, @@ -1932,6 +1955,7 @@ export class ComplexService { /** * @param parameterObject Parameter containing object * @param parameterReference Parameter containing reference + * @returns ModelWithString Successful response * @throws ApiError */ @@ -1944,10 +1968,11 @@ export class ComplexService { }, }, parameterReference: ModelWithString, - ): Promise> { - const result = await __request({ + + ): Promise>> { + return __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/complex\`, + path: \`/api/v\${OpenAPI.version}/complex\`, query: { 'parameterObject': parameterObject, 'parameterReference': parameterReference, @@ -1957,7 +1982,6 @@ export class ComplexService { 500: \`500 server error\`, }, }); - return result.body; } }" @@ -1971,6 +1995,7 @@ exports[`v2 should generate: ./test/generated/v2/services/DefaultsService.ts 1`] import type { ModelWithString, } from '../models'; +import type { ApiResult } from '../core'; import { request as __request, OpenAPI, @@ -1984,6 +2009,7 @@ export class DefaultsService { * @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( @@ -1994,10 +2020,11 @@ export class DefaultsService { parameterModel: ModelWithString = { \\"prop\\": \\"Hello World!\\" }, - ): Promise { - const result = await __request({ + + ): Promise> { + return __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/defaults\`, + path: \`/api/v\${OpenAPI.version}/defaults\`, query: { 'parameterString': parameterString, 'parameterNumber': parameterNumber, @@ -2006,7 +2033,6 @@ export class DefaultsService { 'parameterModel': parameterModel, }, }); - return result.body; } /** @@ -2015,6 +2041,7 @@ export class DefaultsService { * @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( @@ -2025,10 +2052,11 @@ export class DefaultsService { parameterModel: ModelWithString = { \\"prop\\": \\"Hello World!\\" }, - ): Promise { - const result = await __request({ + + ): Promise> { + return __request({ method: 'POST', - path: \`/api/v\${OpenAPI.VERSION}/defaults\`, + path: \`/api/v\${OpenAPI.version}/defaults\`, query: { 'parameterString': parameterString, 'parameterNumber': parameterNumber, @@ -2037,7 +2065,6 @@ export class DefaultsService { 'parameterModel': parameterModel, }, }); - return result.body; } /** @@ -2047,6 +2074,7 @@ export class DefaultsService { * @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( @@ -2056,10 +2084,11 @@ export class DefaultsService { parameterOptionalStringWithNoDefault?: string, parameterStringWithDefault: string = 'Hello World!', parameterStringWithEmptyDefault: string = '', - ): Promise { - const result = await __request({ + + ): Promise> { + return __request({ method: 'PUT', - path: \`/api/v\${OpenAPI.VERSION}/defaults\`, + path: \`/api/v\${OpenAPI.version}/defaults\`, query: { 'parameterStringWithNoDefault': parameterStringWithNoDefault, 'parameterOptionalStringWithDefault': parameterOptionalStringWithDefault, @@ -2069,7 +2098,6 @@ export class DefaultsService { 'parameterStringWithEmptyDefault': parameterStringWithEmptyDefault, }, }); - return result.body; } }" @@ -2080,6 +2108,7 @@ exports[`v2 should generate: ./test/generated/v2/services/DuplicateService.ts 1` /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { ApiResult } from '../core'; import { request as __request, OpenAPI, @@ -2088,47 +2117,47 @@ import { export class DuplicateService { /** + * @throws ApiError */ - public static async duplicateName(): Promise { - const result = await __request({ + public static async duplicateName(): Promise> { + return __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/duplicate\`, + path: \`/api/v\${OpenAPI.version}/duplicate\`, }); - return result.body; } /** + * @throws ApiError */ - public static async duplicateName1(): Promise { - const result = await __request({ + public static async duplicateName1(): Promise> { + return __request({ method: 'POST', - path: \`/api/v\${OpenAPI.VERSION}/duplicate\`, + path: \`/api/v\${OpenAPI.version}/duplicate\`, }); - return result.body; } /** + * @throws ApiError */ - public static async duplicateName2(): Promise { - const result = await __request({ + public static async duplicateName2(): Promise> { + return __request({ method: 'PUT', - path: \`/api/v\${OpenAPI.VERSION}/duplicate\`, + path: \`/api/v\${OpenAPI.version}/duplicate\`, }); - return result.body; } /** + * @throws ApiError */ - public static async duplicateName3(): Promise { - const result = await __request({ + public static async duplicateName3(): Promise> { + return __request({ method: 'DELETE', - path: \`/api/v\${OpenAPI.VERSION}/duplicate\`, + path: \`/api/v\${OpenAPI.version}/duplicate\`, }); - return result.body; } }" @@ -2139,6 +2168,7 @@ exports[`v2 should generate: ./test/generated/v2/services/HeaderService.ts 1`] = /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { ApiResult } from '../core'; import { request as __request, OpenAPI, @@ -2147,20 +2177,20 @@ import { export class HeaderService { /** + * @returns string Successful response * @throws ApiError */ - public static async callWithResultFromHeader(): Promise { - const result = await __request({ + public static async callWithResultFromHeader(): Promise> { + return __request({ method: 'POST', - path: \`/api/v\${OpenAPI.VERSION}/header\`, + path: \`/api/v\${OpenAPI.version}/header\`, responseHeader: 'operation-location', errors: { 400: \`400 server error\`, 500: \`500 server error\`, }, }); - return result.body; } }" @@ -2171,6 +2201,7 @@ exports[`v2 should generate: ./test/generated/v2/services/NoContentService.ts 1` /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { ApiResult } from '../core'; import { request as __request, OpenAPI, @@ -2179,15 +2210,15 @@ import { export class NoContentService { /** + * @returns void * @throws ApiError */ - public static async callWithNoContentResponse(): Promise { - const result = await __request({ + public static async callWithNoContentResponse(): Promise> { + return __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/no-content\`, + path: \`/api/v\${OpenAPI.version}/no-content\`, }); - return result.body; } }" @@ -2198,6 +2229,7 @@ exports[`v2 should generate: ./test/generated/v2/services/ParametersService.ts 1 /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { ApiResult } from '../core'; import { request as __request, OpenAPI, @@ -2211,6 +2243,7 @@ export class ParametersService { * @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( @@ -2219,10 +2252,11 @@ export class ParametersService { parameterForm: string, parameterBody: string, parameterPath: string, - ): Promise { - const result = await __request({ + + ): Promise> { + return __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/parameters/\${parameterPath}\`, + path: \`/api/v\${OpenAPI.version}/parameters/\${parameterPath}\`, headers: { 'parameterHeader': parameterHeader, }, @@ -2234,7 +2268,6 @@ export class ParametersService { }, body: parameterBody, }); - return result.body; } /** @@ -2246,6 +2279,7 @@ export class ParametersService { * @param parameterPath2 This is the parameter that goes into the path * @param parameterPath3 This is the parameter that goes into the path * @param _default This is the parameter with a reserved keyword + * @throws ApiError */ public static async callWithWeirdParameterNames( @@ -2257,10 +2291,11 @@ export class ParametersService { parameterPath2?: string, parameterPath3?: string, _default?: string, - ): Promise { - const result = await __request({ + + ): Promise> { + return __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/parameters/\${parameterPath1}/\${parameterPath2}/\${parameterPath3}\`, + path: \`/api/v\${OpenAPI.version}/parameters/\${parameterPath1}/\${parameterPath2}/\${parameterPath3}\`, headers: { 'parameter.header': parameterHeader, }, @@ -2273,7 +2308,6 @@ export class ParametersService { }, body: parameterBody, }); - return result.body; } }" @@ -2289,6 +2323,7 @@ import type { ModelThatExtendsExtends, ModelWithString, } from '../models'; +import type { ApiResult } from '../core'; import { request as __request, OpenAPI, @@ -2297,56 +2332,56 @@ import { export class ResponseService { /** + * @returns ModelWithString Message for default response * @throws ApiError */ - public static async callWithResponse(): Promise { - const result = await __request({ + public static async callWithResponse(): Promise> { + return __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/response\`, + path: \`/api/v\${OpenAPI.version}/response\`, }); - return result.body; } /** + * @returns ModelWithString Message for default response * @throws ApiError */ - public static async callWithDuplicateResponses(): Promise { - const result = await __request({ + public static async callWithDuplicateResponses(): Promise> { + return __request({ method: 'POST', - path: \`/api/v\${OpenAPI.VERSION}/response\`, + path: \`/api/v\${OpenAPI.version}/response\`, errors: { 500: \`Message for 500 error\`, 501: \`Message for 501 error\`, 502: \`Message for 502 error\`, }, }); - return result.body; } /** + * @returns any Message for 200 response * @returns ModelWithString Message for default response * @returns ModelThatExtends Message for 201 response * @returns ModelThatExtendsExtends Message for 202 response * @throws ApiError */ - public static async callWithResponses(): Promise<{ + public static async callWithResponses(): Promise, - } | ModelWithString | ModelThatExtends | ModelThatExtendsExtends> { - const result = await __request({ + } | ModelWithString | ModelThatExtends | ModelThatExtendsExtends>> { + return __request({ method: 'PUT', - path: \`/api/v\${OpenAPI.VERSION}/response\`, + path: \`/api/v\${OpenAPI.version}/response\`, errors: { 500: \`Message for 500 error\`, 501: \`Message for 501 error\`, 502: \`Message for 502 error\`, }, }); - return result.body; } }" @@ -2357,6 +2392,7 @@ exports[`v2 should generate: ./test/generated/v2/services/SimpleService.ts 1`] = /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { ApiResult } from '../core'; import { request as __request, OpenAPI, @@ -2365,80 +2401,80 @@ import { export class SimpleService { /** + * @throws ApiError */ - public static async getCallWithoutParametersAndResponse(): Promise { - const result = await __request({ + public static async getCallWithoutParametersAndResponse(): Promise> { + return __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/simple\`, + path: \`/api/v\${OpenAPI.version}/simple\`, }); - return result.body; } /** + * @throws ApiError */ - public static async putCallWithoutParametersAndResponse(): Promise { - const result = await __request({ + public static async putCallWithoutParametersAndResponse(): Promise> { + return __request({ method: 'PUT', - path: \`/api/v\${OpenAPI.VERSION}/simple\`, + path: \`/api/v\${OpenAPI.version}/simple\`, }); - return result.body; } /** + * @throws ApiError */ - public static async postCallWithoutParametersAndResponse(): Promise { - const result = await __request({ + public static async postCallWithoutParametersAndResponse(): Promise> { + return __request({ method: 'POST', - path: \`/api/v\${OpenAPI.VERSION}/simple\`, + path: \`/api/v\${OpenAPI.version}/simple\`, }); - return result.body; } /** + * @throws ApiError */ - public static async deleteCallWithoutParametersAndResponse(): Promise { - const result = await __request({ + public static async deleteCallWithoutParametersAndResponse(): Promise> { + return __request({ method: 'DELETE', - path: \`/api/v\${OpenAPI.VERSION}/simple\`, + path: \`/api/v\${OpenAPI.version}/simple\`, }); - return result.body; } /** + * @throws ApiError */ - public static async optionsCallWithoutParametersAndResponse(): Promise { - const result = await __request({ + public static async optionsCallWithoutParametersAndResponse(): Promise> { + return __request({ method: 'OPTIONS', - path: \`/api/v\${OpenAPI.VERSION}/simple\`, + path: \`/api/v\${OpenAPI.version}/simple\`, }); - return result.body; } /** + * @throws ApiError */ - public static async headCallWithoutParametersAndResponse(): Promise { - const result = await __request({ + public static async headCallWithoutParametersAndResponse(): Promise> { + return __request({ method: 'HEAD', - path: \`/api/v\${OpenAPI.VERSION}/simple\`, + path: \`/api/v\${OpenAPI.version}/simple\`, }); - return result.body; } /** + * @throws ApiError */ - public static async patchCallWithoutParametersAndResponse(): Promise { - const result = await __request({ + public static async patchCallWithoutParametersAndResponse(): Promise> { + return __request({ method: 'PATCH', - path: \`/api/v\${OpenAPI.VERSION}/simple\`, + path: \`/api/v\${OpenAPI.version}/simple\`, }); - return result.body; } }" @@ -2449,6 +2485,7 @@ exports[`v2 should generate: ./test/generated/v2/services/TypesService.ts 1`] = /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { ApiResult } from '../core'; import { request as __request, OpenAPI, @@ -2465,6 +2502,7 @@ export class TypesService { * @param parameterBoolean This is a boolean parameter * @param parameterObject This is an object parameter * @param id This is a number parameter + * @returns number Response is a simple number * @returns string Response is a simple string * @returns boolean Response is a simple boolean @@ -2480,10 +2518,11 @@ export class TypesService { parameterBoolean: boolean = true, parameterObject: any = null, id?: number, - ): Promise { - const result = await __request({ + + ): Promise> { + return __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/types\`, + path: \`/api/v\${OpenAPI.version}/types\`, query: { 'parameterArray': parameterArray, 'parameterDictionary': parameterDictionary, @@ -2494,7 +2533,6 @@ export class TypesService { 'parameterObject': parameterObject, }, }); - return result.body; } }" @@ -2566,12 +2604,12 @@ exports[`v3 should generate: ./test/generated/v3/core/ApiResult.ts 1`] = ` /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export type ApiResult = { +export type ApiResult = { readonly url: string; readonly ok: boolean; readonly status: number; readonly statusText: string; - readonly body: any; + readonly body: T; }" `; @@ -2586,22 +2624,22 @@ type Resolver = (options: ApiRequestOptions) => Promise; type Headers = Record; export type OpenAPIConfig = { - BASE?: string; - VERSION?: string; - WITH_CREDENTIALS?: boolean; - TOKEN?: string | Resolver; - USERNAME?: string | Resolver; - PASSWORD?: string | Resolver; - HEADERS?: Headers | Resolver; + baseUrl?: string; + version?: string; + withCredentials?: boolean; + token?: string | Resolver; + username?: string | Resolver; + password?: string | Resolver; + headers?: Headers | Resolver; } export const OpenAPI: OpenAPIConfig = { - BASE: 'http://localhost:3000/base', - VERSION: '1.0', - WITH_CREDENTIALS: false, - TOKEN: undefined, - USERNAME: undefined, - PASSWORD: undefined, - HEADERS: undefined, + baseUrl: 'http://localhost:3000/base', + version: '1.0', + withCredentials: false, + token: undefined, + username: undefined, + password: undefined, + headers: undefined, }; " `; @@ -2638,6 +2676,26 @@ function isString(value: any): value is string { return typeof value === 'string'; } +export function deepAssign( + target: Record, + source: Record, +): Record { + const keys = Object.keys(source); + for (const k of keys) { + const sourceValue: unknown = source[k]; + const targetValue: unknown = target[k]; + if (Object(sourceValue) === sourceValue && Object(targetValue) === targetValue) { + target[k] = deepAssign( + targetValue as Record, + sourceValue as Record, + ); + } else { + target[k] = source[k]; + } + } + return target; +} + function isStringWithValue(value: any): value is string { return isString(value) && value !== ''; } @@ -2668,7 +2726,7 @@ function getQueryString(params: Record): string { function getUrl(options: ApiRequestOptions, config: OpenAPIConfig): string { const path = options.path.replace(/[:]/g, '_'); - const url = \`\${config.BASE}\${path}\`; + const url = \`\${config.baseUrl}\${path}\`; if (options.query) { return \`\${url}\${getQueryString(options.query)}\`; @@ -2697,10 +2755,10 @@ async function resolve(options: ApiRequestOptions, resolver?: T | Resolver } async function getHeaders(options: ApiRequestOptions, config: OpenAPIConfig): Promise { - const token = await resolve(options, config.TOKEN); - const username = await resolve(options, config.USERNAME); - const password = await resolve(options, config.PASSWORD); - const defaultHeaders = await resolve(options, config.HEADERS); + const token = await resolve(options, config.token); + const username = await resolve(options, config.username); + const password = await resolve(options, config.password); + const defaultHeaders = await resolve(options, config.headers); const headers = new Headers({ Accept: 'application/json', @@ -2753,7 +2811,7 @@ async function sendRequest(options: ApiRequestOptions, config: OpenAPIConfig, ur headers: await getHeaders(options, config), body: getRequestBody(options), }; - if (config.WITH_CREDENTIALS) { + if (config.withCredentials) { request.credentials = 'include'; } return await fetch(url, request); @@ -4668,6 +4726,7 @@ exports[`v3 should generate: ./test/generated/v3/services/CollectionFormatServic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { ApiResult } from '../core'; import { request as __request, OpenAPI, @@ -4681,6 +4740,7 @@ export class CollectionFormatService { * @param parameterArrayTsv This is an array parameter that is send as tsv format (tab-separated values) * @param parameterArrayPipes This is an array parameter that is send as pipes format (pipe-separated values) * @param parameterArrayMulti This is an array parameter that is send as multi format (multiple parameter instances) + * @throws ApiError */ public static async collectionFormat( @@ -4689,10 +4749,11 @@ export class CollectionFormatService { parameterArrayTsv: Array | null, parameterArrayPipes: Array | null, parameterArrayMulti: Array | null, - ): Promise { - const result = await __request({ + + ): Promise> { + return __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/collectionFormat\`, + path: \`/api/v\${OpenAPI.version}/collectionFormat\`, query: { 'parameterArrayCSV': parameterArrayCsv, 'parameterArraySSV': parameterArraySsv, @@ -4701,7 +4762,6 @@ export class CollectionFormatService { 'parameterArrayMulti': parameterArrayMulti, }, }); - return result.body; } }" @@ -4718,6 +4778,7 @@ import type { ModelWithEnum, ModelWithString, } from '../models'; +import type { ApiResult } from '../core'; import { request as __request, OpenAPI, @@ -4728,6 +4789,7 @@ export class ComplexService { /** * @param parameterObject Parameter containing object * @param parameterReference Parameter containing reference + * @returns ModelWithString Successful response * @throws ApiError */ @@ -4740,10 +4802,11 @@ export class ComplexService { }, }, parameterReference: ModelWithString, - ): Promise> { - const result = await __request({ + + ): Promise>> { + return __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/complex\`, + path: \`/api/v\${OpenAPI.version}/complex\`, query: { 'parameterObject': parameterObject, 'parameterReference': parameterReference, @@ -4753,12 +4816,12 @@ export class ComplexService { 500: \`500 server error\`, }, }); - return result.body; } /** * @param id * @param requestBody + * @returns ModelWithString Success * @throws ApiError */ @@ -4777,14 +4840,14 @@ export class ComplexService { readonly name?: string | null, }, }, - ): Promise { - const result = await __request({ + + ): Promise> { + return __request({ method: 'PUT', - path: \`/api/v\${OpenAPI.VERSION}/complex/\${id}\`, + path: \`/api/v\${OpenAPI.version}/complex/\${id}\`, body: requestBody, mediaType: 'application/json-patch+json', }); - return result.body; } }" @@ -4798,6 +4861,7 @@ exports[`v3 should generate: ./test/generated/v3/services/DefaultsService.ts 1`] import type { ModelWithString, } from '../models'; +import type { ApiResult } from '../core'; import { request as __request, OpenAPI, @@ -4811,6 +4875,7 @@ export class DefaultsService { * @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( @@ -4821,10 +4886,11 @@ export class DefaultsService { parameterModel: ModelWithString | null = { \\"prop\\": \\"Hello World!\\" }, - ): Promise { - const result = await __request({ + + ): Promise> { + return __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/defaults\`, + path: \`/api/v\${OpenAPI.version}/defaults\`, query: { 'parameterString': parameterString, 'parameterNumber': parameterNumber, @@ -4833,7 +4899,6 @@ export class DefaultsService { 'parameterModel': parameterModel, }, }); - return result.body; } /** @@ -4842,6 +4907,7 @@ export class DefaultsService { * @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( @@ -4852,10 +4918,11 @@ export class DefaultsService { parameterModel: ModelWithString = { \\"prop\\": \\"Hello World!\\" }, - ): Promise { - const result = await __request({ + + ): Promise> { + return __request({ method: 'POST', - path: \`/api/v\${OpenAPI.VERSION}/defaults\`, + path: \`/api/v\${OpenAPI.version}/defaults\`, query: { 'parameterString': parameterString, 'parameterNumber': parameterNumber, @@ -4864,7 +4931,6 @@ export class DefaultsService { 'parameterModel': parameterModel, }, }); - return result.body; } /** @@ -4874,6 +4940,7 @@ export class DefaultsService { * @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( @@ -4883,10 +4950,11 @@ export class DefaultsService { parameterOptionalStringWithNoDefault?: string, parameterStringWithDefault: string = 'Hello World!', parameterStringWithEmptyDefault: string = '', - ): Promise { - const result = await __request({ + + ): Promise> { + return __request({ method: 'PUT', - path: \`/api/v\${OpenAPI.VERSION}/defaults\`, + path: \`/api/v\${OpenAPI.version}/defaults\`, query: { 'parameterStringWithNoDefault': parameterStringWithNoDefault, 'parameterOptionalStringWithDefault': parameterOptionalStringWithDefault, @@ -4896,7 +4964,6 @@ export class DefaultsService { 'parameterStringWithEmptyDefault': parameterStringWithEmptyDefault, }, }); - return result.body; } }" @@ -4907,6 +4974,7 @@ exports[`v3 should generate: ./test/generated/v3/services/DuplicateService.ts 1` /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { ApiResult } from '../core'; import { request as __request, OpenAPI, @@ -4915,47 +4983,47 @@ import { export class DuplicateService { /** + * @throws ApiError */ - public static async duplicateName(): Promise { - const result = await __request({ + public static async duplicateName(): Promise> { + return __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/duplicate\`, + path: \`/api/v\${OpenAPI.version}/duplicate\`, }); - return result.body; } /** + * @throws ApiError */ - public static async duplicateName1(): Promise { - const result = await __request({ + public static async duplicateName1(): Promise> { + return __request({ method: 'POST', - path: \`/api/v\${OpenAPI.VERSION}/duplicate\`, + path: \`/api/v\${OpenAPI.version}/duplicate\`, }); - return result.body; } /** + * @throws ApiError */ - public static async duplicateName2(): Promise { - const result = await __request({ + public static async duplicateName2(): Promise> { + return __request({ method: 'PUT', - path: \`/api/v\${OpenAPI.VERSION}/duplicate\`, + path: \`/api/v\${OpenAPI.version}/duplicate\`, }); - return result.body; } /** + * @throws ApiError */ - public static async duplicateName3(): Promise { - const result = await __request({ + public static async duplicateName3(): Promise> { + return __request({ method: 'DELETE', - path: \`/api/v\${OpenAPI.VERSION}/duplicate\`, + path: \`/api/v\${OpenAPI.version}/duplicate\`, }); - return result.body; } }" @@ -4966,6 +5034,7 @@ exports[`v3 should generate: ./test/generated/v3/services/HeaderService.ts 1`] = /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { ApiResult } from '../core'; import { request as __request, OpenAPI, @@ -4974,20 +5043,20 @@ import { export class HeaderService { /** + * @returns string Successful response * @throws ApiError */ - public static async callWithResultFromHeader(): Promise { - const result = await __request({ + public static async callWithResultFromHeader(): Promise> { + return __request({ method: 'POST', - path: \`/api/v\${OpenAPI.VERSION}/header\`, + path: \`/api/v\${OpenAPI.version}/header\`, responseHeader: 'operation-location', errors: { 400: \`400 server error\`, 500: \`500 server error\`, }, }); - return result.body; } }" @@ -4998,6 +5067,7 @@ exports[`v3 should generate: ./test/generated/v3/services/MultipartService.ts 1` /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { ApiResult } from '../core'; import { request as __request, OpenAPI, @@ -5006,21 +5076,21 @@ import { export class MultipartService { /** + * @returns any OK * @throws ApiError */ - public static async multipartResponse(): Promise<{ + public static async multipartResponse(): Promise { - const result = await __request({ + }>> { + return __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/multipart\`, + path: \`/api/v\${OpenAPI.version}/multipart\`, }); - return result.body; } }" @@ -5031,6 +5101,7 @@ exports[`v3 should generate: ./test/generated/v3/services/NoContentService.ts 1` /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { ApiResult } from '../core'; import { request as __request, OpenAPI, @@ -5039,15 +5110,15 @@ import { export class NoContentService { /** + * @returns void * @throws ApiError */ - public static async callWithNoContentResponse(): Promise { - const result = await __request({ + public static async callWithNoContentResponse(): Promise> { + return __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/no-content\`, + path: \`/api/v\${OpenAPI.version}/no-content\`, }); - return result.body; } }" @@ -5061,6 +5132,7 @@ exports[`v3 should generate: ./test/generated/v3/services/ParametersService.ts 1 import type { ModelWithString, } from '../models'; +import type { ApiResult } from '../core'; import { request as __request, OpenAPI, @@ -5075,6 +5147,7 @@ export class ParametersService { * @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( @@ -5084,10 +5157,11 @@ export class ParametersService { parameterCookie: string | null, parameterPath: string | null, requestBody: ModelWithString | null, - ): Promise { - const result = await __request({ + + ): Promise> { + return __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/parameters/\${parameterPath}\`, + path: \`/api/v\${OpenAPI.version}/parameters/\${parameterPath}\`, cookies: { 'parameterCookie': parameterCookie, }, @@ -5103,7 +5177,6 @@ export class ParametersService { body: requestBody, mediaType: 'application/json', }); - return result.body; } /** @@ -5116,6 +5189,7 @@ export class ParametersService { * @param parameterPath2 This is the parameter that goes into the path * @param parameterPath3 This is the parameter that goes into the path * @param _default This is the parameter with a reserved keyword + * @throws ApiError */ public static async callWithWeirdParameterNames( @@ -5128,10 +5202,11 @@ export class ParametersService { parameterPath2?: string, parameterPath3?: string, _default?: string, - ): Promise { - const result = await __request({ + + ): Promise> { + return __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/parameters/\${parameterPath1}/\${parameterPath2}/\${parameterPath3}\`, + path: \`/api/v\${OpenAPI.version}/parameters/\${parameterPath1}/\${parameterPath2}/\${parameterPath3}\`, cookies: { 'PARAMETER-COOKIE': parameterCookie, }, @@ -5148,49 +5223,50 @@ export class ParametersService { body: requestBody, mediaType: 'application/json', }); - 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({ + + ): Promise> { + return __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/parameters/\`, + path: \`/api/v\${OpenAPI.version}/parameters/\`, query: { 'parameter': parameter, }, body: requestBody, mediaType: 'application/json', }); - 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({ + + ): Promise> { + return __request({ method: 'POST', - path: \`/api/v\${OpenAPI.VERSION}/parameters/\`, + path: \`/api/v\${OpenAPI.version}/parameters/\`, query: { 'parameter': parameter, }, body: requestBody, mediaType: 'application/json', }); - return result.body; } }" @@ -5204,6 +5280,7 @@ exports[`v3 should generate: ./test/generated/v3/services/RequestBodyService.ts import type { ModelWithString, } from '../models'; +import type { ApiResult } from '../core'; import { request as __request, OpenAPI, @@ -5213,18 +5290,19 @@ export class RequestBodyService { /** * @param requestBody A reusable request body + * @throws ApiError */ public static async postRequestBodyService( requestBody?: ModelWithString, - ): Promise { - const result = await __request({ + + ): Promise> { + return __request({ method: 'POST', - path: \`/api/v\${OpenAPI.VERSION}/requestBody/\`, + path: \`/api/v\${OpenAPI.version}/requestBody/\`, body: requestBody, mediaType: 'application/json', }); - return result.body; } }" @@ -5240,6 +5318,7 @@ import type { ModelThatExtendsExtends, ModelWithString, } from '../models'; +import type { ApiResult } from '../core'; import { request as __request, OpenAPI, @@ -5248,56 +5327,56 @@ import { export class ResponseService { /** + * @returns ModelWithString * @throws ApiError */ - public static async callWithResponse(): Promise { - const result = await __request({ + public static async callWithResponse(): Promise> { + return __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/response\`, + path: \`/api/v\${OpenAPI.version}/response\`, }); - return result.body; } /** + * @returns ModelWithString Message for default response * @throws ApiError */ - public static async callWithDuplicateResponses(): Promise { - const result = await __request({ + public static async callWithDuplicateResponses(): Promise> { + return __request({ method: 'POST', - path: \`/api/v\${OpenAPI.VERSION}/response\`, + path: \`/api/v\${OpenAPI.version}/response\`, errors: { 500: \`Message for 500 error\`, 501: \`Message for 501 error\`, 502: \`Message for 502 error\`, }, }); - return result.body; } /** + * @returns any Message for 200 response * @returns ModelWithString Message for default response * @returns ModelThatExtends Message for 201 response * @returns ModelThatExtendsExtends Message for 202 response * @throws ApiError */ - public static async callWithResponses(): Promise<{ + public static async callWithResponses(): Promise, - } | ModelWithString | ModelThatExtends | ModelThatExtendsExtends> { - const result = await __request({ + } | ModelWithString | ModelThatExtends | ModelThatExtendsExtends>> { + return __request({ method: 'PUT', - path: \`/api/v\${OpenAPI.VERSION}/response\`, + path: \`/api/v\${OpenAPI.version}/response\`, errors: { 500: \`Message for 500 error\`, 501: \`Message for 501 error\`, 502: \`Message for 502 error\`, }, }); - return result.body; } }" @@ -5308,6 +5387,7 @@ exports[`v3 should generate: ./test/generated/v3/services/SimpleService.ts 1`] = /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { ApiResult } from '../core'; import { request as __request, OpenAPI, @@ -5316,80 +5396,80 @@ import { export class SimpleService { /** + * @throws ApiError */ - public static async getCallWithoutParametersAndResponse(): Promise { - const result = await __request({ + public static async getCallWithoutParametersAndResponse(): Promise> { + return __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/simple\`, + path: \`/api/v\${OpenAPI.version}/simple\`, }); - return result.body; } /** + * @throws ApiError */ - public static async putCallWithoutParametersAndResponse(): Promise { - const result = await __request({ + public static async putCallWithoutParametersAndResponse(): Promise> { + return __request({ method: 'PUT', - path: \`/api/v\${OpenAPI.VERSION}/simple\`, + path: \`/api/v\${OpenAPI.version}/simple\`, }); - return result.body; } /** + * @throws ApiError */ - public static async postCallWithoutParametersAndResponse(): Promise { - const result = await __request({ + public static async postCallWithoutParametersAndResponse(): Promise> { + return __request({ method: 'POST', - path: \`/api/v\${OpenAPI.VERSION}/simple\`, + path: \`/api/v\${OpenAPI.version}/simple\`, }); - return result.body; } /** + * @throws ApiError */ - public static async deleteCallWithoutParametersAndResponse(): Promise { - const result = await __request({ + public static async deleteCallWithoutParametersAndResponse(): Promise> { + return __request({ method: 'DELETE', - path: \`/api/v\${OpenAPI.VERSION}/simple\`, + path: \`/api/v\${OpenAPI.version}/simple\`, }); - return result.body; } /** + * @throws ApiError */ - public static async optionsCallWithoutParametersAndResponse(): Promise { - const result = await __request({ + public static async optionsCallWithoutParametersAndResponse(): Promise> { + return __request({ method: 'OPTIONS', - path: \`/api/v\${OpenAPI.VERSION}/simple\`, + path: \`/api/v\${OpenAPI.version}/simple\`, }); - return result.body; } /** + * @throws ApiError */ - public static async headCallWithoutParametersAndResponse(): Promise { - const result = await __request({ + public static async headCallWithoutParametersAndResponse(): Promise> { + return __request({ method: 'HEAD', - path: \`/api/v\${OpenAPI.VERSION}/simple\`, + path: \`/api/v\${OpenAPI.version}/simple\`, }); - return result.body; } /** + * @throws ApiError */ - public static async patchCallWithoutParametersAndResponse(): Promise { - const result = await __request({ + public static async patchCallWithoutParametersAndResponse(): Promise> { + return __request({ method: 'PATCH', - path: \`/api/v\${OpenAPI.VERSION}/simple\`, + path: \`/api/v\${OpenAPI.version}/simple\`, }); - return result.body; } }" @@ -5400,6 +5480,7 @@ exports[`v3 should generate: ./test/generated/v3/services/TypesService.ts 1`] = /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { ApiResult } from '../core'; import { request as __request, OpenAPI, @@ -5416,6 +5497,7 @@ export class TypesService { * @param parameterBoolean This is a boolean parameter * @param parameterObject This is an object parameter * @param id This is a number parameter + * @returns number Response is a simple number * @returns string Response is a simple string * @returns boolean Response is a simple boolean @@ -5431,10 +5513,11 @@ export class TypesService { parameterBoolean: boolean | null = true, parameterObject: any = null, id?: number, - ): Promise { - const result = await __request({ + + ): Promise> { + return __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/types\`, + path: \`/api/v\${OpenAPI.version}/types\`, query: { 'parameterArray': parameterArray, 'parameterDictionary': parameterDictionary, @@ -5445,7 +5528,6 @@ export class TypesService { 'parameterObject': parameterObject, }, }); - return result.body; } }" @@ -5456,6 +5538,7 @@ exports[`v3 should generate: ./test/generated/v3/services/UploadService.ts 1`] = /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { ApiResult } from '../core'; import { request as __request, OpenAPI, @@ -5465,20 +5548,21 @@ export class UploadService { /** * @param file Supply a file reference for upload + * @returns boolean * @throws ApiError */ public static async uploadFile( file: Blob, - ): Promise { - const result = await __request({ + + ): Promise> { + return __request({ method: 'POST', - path: \`/api/v\${OpenAPI.VERSION}/upload\`, + path: \`/api/v\${OpenAPI.version}/upload\`, formData: { 'file': file, }, }); - return result.body; } }" diff --git a/test/e2e/v2.babel.spec.js b/test/e2e/v2.babel.spec.js index ca3bd1925..d81b86acd 100644 --- a/test/e2e/v2.babel.spec.js +++ b/test/e2e/v2.babel.spec.js @@ -24,10 +24,10 @@ describe('v2.fetch', () => { await browser.exposeFunction('tokenRequest', jest.fn().mockResolvedValue('MY_TOKEN')); const result = await browser.evaluate(async () => { const { OpenAPI, SimpleService } = window.api; - OpenAPI.TOKEN = window.tokenRequest; + OpenAPI.token = window.tokenRequest; return await SimpleService.getCallWithoutParametersAndResponse(); }); - expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); + expect(result.body.headers.authorization).toBe('Bearer MY_TOKEN'); }); it('complexService', async () => { @@ -63,10 +63,10 @@ describe('v2.fetch with client', () => { await browser.exposeFunction('tokenRequest', jest.fn().mockResolvedValue('MY_TOKEN')); const result = await browser.evaluate(async () => { const { AppClient } = window.api; - const client = new AppClient({ TOKEN: window.tokenRequest }); + const client = new AppClient({ token: window.tokenRequest }); return await client.simple.getCallWithoutParametersAndResponse(); }); - expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); + expect(result.body.headers.authorization).toBe('Bearer MY_TOKEN'); }); it('complexService', async () => { @@ -81,6 +81,6 @@ describe('v2.fetch with client', () => { }, }); }); - expect(result).toBeDefined(); + expect(result.body).toBeDefined(); }); }); diff --git a/test/e2e/v2.fetch.spec.js b/test/e2e/v2.fetch.spec.js index 412392577..f881686cd 100644 --- a/test/e2e/v2.fetch.spec.js +++ b/test/e2e/v2.fetch.spec.js @@ -24,10 +24,10 @@ describe('v2.fetch', () => { await browser.exposeFunction('tokenRequest', jest.fn().mockResolvedValue('MY_TOKEN')); const result = await browser.evaluate(async () => { const { OpenAPI, SimpleService } = window.api; - OpenAPI.TOKEN = window.tokenRequest; + OpenAPI.token = window.tokenRequest; return await SimpleService.getCallWithoutParametersAndResponse(); }); - expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); + expect(result.body.headers.authorization).toBe('Bearer MY_TOKEN'); }); it('complexService', async () => { @@ -41,7 +41,7 @@ describe('v2.fetch', () => { }, }); }); - expect(result).toBeDefined(); + expect(result.body).toBeDefined(); }); }); @@ -63,10 +63,10 @@ describe('v2.fetch with client', () => { await browser.exposeFunction('tokenRequest', jest.fn().mockResolvedValue('MY_TOKEN')); const result = await browser.evaluate(async () => { const { AppClient } = window.api; - const client = new AppClient({ TOKEN: window.tokenRequest }); + const client = new AppClient({ token: window.tokenRequest }); return await client.simple.getCallWithoutParametersAndResponse(); }); - expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); + expect(result.body.headers.authorization).toBe('Bearer MY_TOKEN'); }); it('complexService', async () => { @@ -81,6 +81,6 @@ describe('v2.fetch with client', () => { }, }); }); - expect(result).toBeDefined(); + expect(result.body).toBeDefined(); }); }); diff --git a/test/e2e/v2.node.spec.js b/test/e2e/v2.node.spec.js index c3cab8f5f..d30aba312 100644 --- a/test/e2e/v2.node.spec.js +++ b/test/e2e/v2.node.spec.js @@ -18,10 +18,10 @@ describe('v2.node', () => { it('requests token', async () => { const { OpenAPI, SimpleService } = require('./generated/v2/node/index.js'); const tokenRequest = jest.fn().mockResolvedValue('MY_TOKEN'); - OpenAPI.TOKEN = tokenRequest; + OpenAPI.token = tokenRequest; const result = await SimpleService.getCallWithoutParametersAndResponse(); expect(tokenRequest.mock.calls.length).toBe(1); - expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); + expect(result.body.headers.authorization).toBe('Bearer MY_TOKEN'); }); it('complexService', async () => { @@ -33,7 +33,7 @@ describe('v2.node', () => { }, }, }); - expect(result).toBeDefined(); + expect(result.body).toBeDefined(); }); }); @@ -51,10 +51,10 @@ describe('v2.node with client', () => { it('requests token', async () => { const tokenRequest = jest.fn().mockResolvedValue('MY_TOKEN'); const { AppClient } = require('./generated/v2/node_client/index.js'); - const client = new AppClient({ TOKEN: tokenRequest }); + const client = new AppClient({ token: tokenRequest }); const result = await client.simple.getCallWithoutParametersAndResponse(); expect(tokenRequest.mock.calls.length).toBe(1); - expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); + expect(result.body.headers.authorization).toBe('Bearer MY_TOKEN'); }); it('complexService', async () => { @@ -67,6 +67,6 @@ describe('v2.node with client', () => { }, }, }); - expect(result).toBeDefined(); + expect(result.body).toBeDefined(); }); }); diff --git a/test/e2e/v2.xhr.spec.js b/test/e2e/v2.xhr.spec.js index 09b1c219b..a4262a6a9 100644 --- a/test/e2e/v2.xhr.spec.js +++ b/test/e2e/v2.xhr.spec.js @@ -24,10 +24,10 @@ describe('v2.xhr', () => { await browser.exposeFunction('tokenRequest', jest.fn().mockResolvedValue('MY_TOKEN')); const result = await browser.evaluate(async () => { const { OpenAPI, SimpleService } = window.api; - OpenAPI.TOKEN = window.tokenRequest; + OpenAPI.token = window.tokenRequest; return await SimpleService.getCallWithoutParametersAndResponse(); }); - expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); + expect(result.body.headers.authorization).toBe('Bearer MY_TOKEN'); }); it('complexService', async () => { @@ -41,7 +41,7 @@ describe('v2.xhr', () => { }, }); }); - expect(result).toBeDefined(); + expect(result.body).toBeDefined(); }); }); @@ -63,10 +63,10 @@ describe('v2.xhr with client', () => { await browser.exposeFunction('tokenRequest', jest.fn().mockResolvedValue('MY_TOKEN')); const result = await browser.evaluate(async () => { const { AppClient } = window.api; - const client = new AppClient({ TOKEN: window.tokenRequest }); + const client = new AppClient({ token: window.tokenRequest }); return await client.simple.getCallWithoutParametersAndResponse(); }); - expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); + expect(result.body.headers.authorization).toBe('Bearer MY_TOKEN'); }); it('complexService', async () => { @@ -81,6 +81,6 @@ describe('v2.xhr with client', () => { }, }); }); - expect(result).toBeDefined(); + expect(result.body).toBeDefined(); }); }); diff --git a/test/e2e/v3.babel.spec.js b/test/e2e/v3.babel.spec.js index 3a5a9c538..d43a08d9e 100644 --- a/test/e2e/v3.babel.spec.js +++ b/test/e2e/v3.babel.spec.js @@ -24,23 +24,23 @@ describe('v3.fetch', () => { await browser.exposeFunction('tokenRequest', jest.fn().mockResolvedValue('MY_TOKEN')); const result = await browser.evaluate(async () => { const { OpenAPI, SimpleService } = window.api; - OpenAPI.TOKEN = window.tokenRequest; - OpenAPI.USERNAME = undefined; - OpenAPI.PASSWORD = undefined; + OpenAPI.token = window.tokenRequest; + OpenAPI.username = undefined; + OpenAPI.password = undefined; return await SimpleService.getCallWithoutParametersAndResponse(); }); - expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); + expect(result.body.headers.authorization).toBe('Bearer MY_TOKEN'); }); it('uses credentials', async () => { const result = await browser.evaluate(async () => { const { OpenAPI, SimpleService } = window.api; - OpenAPI.TOKEN = undefined; - OpenAPI.USERNAME = 'username'; - OpenAPI.PASSWORD = 'password'; + OpenAPI.token = undefined; + OpenAPI.username = 'username'; + OpenAPI.password = 'password'; return await SimpleService.getCallWithoutParametersAndResponse(); }); - expect(result.headers.authorization).toBe('Basic dXNlcm5hbWU6cGFzc3dvcmQ='); + expect(result.body.headers.authorization).toBe('Basic dXNlcm5hbWU6cGFzc3dvcmQ='); }); it('complexService', async () => { @@ -54,7 +54,7 @@ describe('v3.fetch', () => { }, }); }); - expect(result).toBeDefined(); + expect(result.body).toBeDefined(); }); }); @@ -76,19 +76,19 @@ describe('v3.fetch with client', () => { await browser.exposeFunction('tokenRequest', jest.fn().mockResolvedValue('MY_TOKEN')); const result = await browser.evaluate(async () => { const { AppClient } = window.api; - const client = new AppClient({ TOKEN: window.tokenRequest, USERNAME: undefined, PASSWORD: undefined }); + const client = new AppClient({ token: window.tokenRequest, username: undefined, password: undefined }); return await client.simple.getCallWithoutParametersAndResponse(); }); - expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); + expect(result.body.headers.authorization).toBe('Bearer MY_TOKEN'); }); it('uses credentials', async () => { const result = await browser.evaluate(async () => { const { AppClient } = window.api; - const client = new AppClient({ TOKEN: undefined, USERNAME: 'username', PASSWORD: 'password' }); + const client = new AppClient({ token: undefined, username: 'username', password: 'password' }); return await client.simple.getCallWithoutParametersAndResponse(); }); - expect(result.headers.authorization).toBe('Basic dXNlcm5hbWU6cGFzc3dvcmQ='); + expect(result.body.headers.authorization).toBe('Basic dXNlcm5hbWU6cGFzc3dvcmQ='); }); it('complexService', async () => { @@ -103,6 +103,6 @@ describe('v3.fetch with client', () => { }, }); }); - expect(result).toBeDefined(); + expect(result.body).toBeDefined(); }); }); diff --git a/test/e2e/v3.fetch.spec.js b/test/e2e/v3.fetch.spec.js index cd2a1996a..dd821ceaf 100644 --- a/test/e2e/v3.fetch.spec.js +++ b/test/e2e/v3.fetch.spec.js @@ -24,23 +24,23 @@ describe('v3.fetch', () => { await browser.exposeFunction('tokenRequest', jest.fn().mockResolvedValue('MY_TOKEN')); const result = await browser.evaluate(async () => { const { OpenAPI, SimpleService } = window.api; - OpenAPI.TOKEN = window.tokenRequest; - OpenAPI.USERNAME = undefined; - OpenAPI.PASSWORD = undefined; + OpenAPI.token = window.tokenRequest; + OpenAPI.username = undefined; + OpenAPI.password = undefined; return await SimpleService.getCallWithoutParametersAndResponse(); }); - expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); + expect(result.body.headers.authorization).toBe('Bearer MY_TOKEN'); }); it('uses credentials', async () => { const result = await browser.evaluate(async () => { const { OpenAPI, SimpleService } = window.api; - OpenAPI.TOKEN = undefined; - OpenAPI.USERNAME = 'username'; - OpenAPI.PASSWORD = 'password'; + OpenAPI.token = undefined; + OpenAPI.username = 'username'; + OpenAPI.password = 'password'; return await SimpleService.getCallWithoutParametersAndResponse(); }); - expect(result.headers.authorization).toBe('Basic dXNlcm5hbWU6cGFzc3dvcmQ='); + expect(result.body.headers.authorization).toBe('Basic dXNlcm5hbWU6cGFzc3dvcmQ='); }); it('complexService', async () => { @@ -54,7 +54,7 @@ describe('v3.fetch', () => { }, }); }); - expect(result).toBeDefined(); + expect(result.body).toBeDefined(); }); }); @@ -76,19 +76,19 @@ describe('v3.fetch with client', () => { await browser.exposeFunction('tokenRequest', jest.fn().mockResolvedValue('MY_TOKEN')); const result = await browser.evaluate(async () => { const { AppClient } = window.api; - const client = new AppClient({ TOKEN: window.tokenRequest, USERNAME: undefined, PASSWORD: undefined }); + const client = new AppClient({ token: window.tokenRequest, username: undefined, password: undefined }); return await client.simple.getCallWithoutParametersAndResponse(); }); - expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); + expect(result.body.headers.authorization).toBe('Bearer MY_TOKEN'); }); it('uses credentials', async () => { const result = await browser.evaluate(async () => { const { AppClient } = window.api; - const client = new AppClient({ TOKEN: undefined, USERNAME: 'username', PASSWORD: 'password' }); + const client = new AppClient({ token: undefined, username: 'username', password: 'password' }); return await client.simple.getCallWithoutParametersAndResponse(); }); - expect(result.headers.authorization).toBe('Basic dXNlcm5hbWU6cGFzc3dvcmQ='); + expect(result.body.headers.authorization).toBe('Basic dXNlcm5hbWU6cGFzc3dvcmQ='); }); it('complexService', async () => { @@ -103,6 +103,6 @@ describe('v3.fetch with client', () => { }, }); }); - expect(result).toBeDefined(); + expect(result.body).toBeDefined(); }); }); diff --git a/test/e2e/v3.node.spec.js b/test/e2e/v3.node.spec.js index 42ac11acc..5e338351e 100644 --- a/test/e2e/v3.node.spec.js +++ b/test/e2e/v3.node.spec.js @@ -18,21 +18,21 @@ describe('v3.node', () => { it('requests token', async () => { const { OpenAPI, SimpleService } = require('./generated/v3/node/index.js'); const tokenRequest = jest.fn().mockResolvedValue('MY_TOKEN'); - OpenAPI.TOKEN = tokenRequest; - OpenAPI.USERNAME = undefined; - OpenAPI.PASSWORD = undefined; + OpenAPI.token = tokenRequest; + OpenAPI.username = undefined; + OpenAPI.password = undefined; const result = await SimpleService.getCallWithoutParametersAndResponse(); expect(tokenRequest.mock.calls.length).toBe(1); - expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); + expect(result.body.headers.authorization).toBe('Bearer MY_TOKEN'); }); it('uses credentials', async () => { const { OpenAPI, SimpleService } = require('./generated/v3/node/index.js'); - OpenAPI.TOKEN = undefined; - OpenAPI.USERNAME = 'username'; - OpenAPI.PASSWORD = 'password'; + OpenAPI.token = undefined; + OpenAPI.username = 'username'; + OpenAPI.password = 'password'; const result = await SimpleService.getCallWithoutParametersAndResponse(); - expect(result.headers.authorization).toBe('Basic dXNlcm5hbWU6cGFzc3dvcmQ='); + expect(result.body.headers.authorization).toBe('Basic dXNlcm5hbWU6cGFzc3dvcmQ='); }); it('complexService', async () => { @@ -44,7 +44,7 @@ describe('v3.node', () => { }, }, }); - expect(result).toBeDefined(); + expect(result.body).toBeDefined(); }); }); @@ -62,17 +62,17 @@ describe('v3.node with client', () => { it('requests token', async () => { const { AppClient } = require('./generated/v3/node_client/index.js'); const tokenRequest = jest.fn().mockResolvedValue('MY_TOKEN'); - const client = new AppClient({ TOKEN: tokenRequest, username: undefined, password: undefined }); + const client = new AppClient({ token: tokenRequest, username: undefined, password: undefined }); const result = await client.simple.getCallWithoutParametersAndResponse(); expect(tokenRequest.mock.calls.length).toBe(1); - expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); + expect(result.body.headers.authorization).toBe('Bearer MY_TOKEN'); }); it('uses credentials', async () => { const { AppClient } = require('./generated/v3/node_client/index.js'); - const client = new AppClient({ TOKEN: undefined, USERNAME: 'username', PASSWORD: 'password' }); + const client = new AppClient({ token: undefined, username: 'username', password: 'password' }); const result = await client.simple.getCallWithoutParametersAndResponse(); - expect(result.headers.authorization).toBe('Basic dXNlcm5hbWU6cGFzc3dvcmQ='); + expect(result.body.headers.authorization).toBe('Basic dXNlcm5hbWU6cGFzc3dvcmQ='); }); it('complexService', async () => { @@ -85,6 +85,6 @@ describe('v3.node with client', () => { }, }, }); - expect(result).toBeDefined(); + expect(result.body).toBeDefined(); }); }); diff --git a/test/e2e/v3.xhr.spec.js b/test/e2e/v3.xhr.spec.js index 4bcdabf60..57c64ae58 100644 --- a/test/e2e/v3.xhr.spec.js +++ b/test/e2e/v3.xhr.spec.js @@ -24,23 +24,23 @@ describe('v3.xhr', () => { await browser.exposeFunction('tokenRequest', jest.fn().mockResolvedValue('MY_TOKEN')); const result = await browser.evaluate(async () => { const { OpenAPI, SimpleService } = window.api; - OpenAPI.TOKEN = window.tokenRequest; - OpenAPI.USERNAME = undefined; - OpenAPI.PASSWORD = undefined; + OpenAPI.token = window.tokenRequest; + OpenAPI.username = undefined; + OpenAPI.password = undefined; return await SimpleService.getCallWithoutParametersAndResponse(); }); - expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); + expect(result.body.headers.authorization).toBe('Bearer MY_TOKEN'); }); it('uses credentials', async () => { const result = await browser.evaluate(async () => { const { OpenAPI, SimpleService } = window.api; - OpenAPI.TOKEN = undefined; - OpenAPI.USERNAME = 'username'; - OpenAPI.PASSWORD = 'password'; + OpenAPI.token = undefined; + OpenAPI.username = 'username'; + OpenAPI.password = 'password'; return await SimpleService.getCallWithoutParametersAndResponse(); }); - expect(result.headers.authorization).toBe('Basic dXNlcm5hbWU6cGFzc3dvcmQ='); + expect(result.body.headers.authorization).toBe('Basic dXNlcm5hbWU6cGFzc3dvcmQ='); }); it('complexService', async () => { @@ -76,19 +76,19 @@ describe('v3.xhr with client', () => { await browser.exposeFunction('tokenRequest', jest.fn().mockResolvedValue('MY_TOKEN')); const result = await browser.evaluate(async () => { const { AppClient } = window.api; - const client = new AppClient({ TOKEN: window.tokenRequest, USERNAME: undefined, PASSWORD: undefined }); + const client = new AppClient({ token: window.tokenRequest, username: undefined, password: undefined }); return await client.simple.getCallWithoutParametersAndResponse(); }); - expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); + expect(result.body.headers.authorization).toBe('Bearer MY_TOKEN'); }); it('uses credentials', async () => { const result = await browser.evaluate(async () => { const { AppClient } = window.api; - const client = new AppClient({ TOKEN: undefined, USERNAME: 'username', PASSWORD: 'password' }); + const client = new AppClient({ token: undefined, username: 'username', password: 'password' }); return await client.simple.getCallWithoutParametersAndResponse(); }); - expect(result.headers.authorization).toBe('Basic dXNlcm5hbWU6cGFzc3dvcmQ='); + expect(result.body.headers.authorization).toBe('Basic dXNlcm5hbWU6cGFzc3dvcmQ='); }); it('complexService', async () => { @@ -103,6 +103,6 @@ describe('v3.xhr with client', () => { }, }); }); - expect(result).toBeDefined(); + expect(result.body).toBeDefined(); }); }); From 5e6a10a91a275366045c87b79fabffa4eb32d9c5 Mon Sep 17 00:00:00 2001 From: lub0v-parsable Date: Thu, 26 Aug 2021 12:26:54 -0700 Subject: [PATCH 06/11] PE-2229 - add type to BaseHttpRequest --- src/templates/core/BaseHttpRequest.hbs | 6 +++--- test/__snapshots__/index.client.spec.js.snap | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/templates/core/BaseHttpRequest.hbs b/src/templates/core/BaseHttpRequest.hbs index 77310d3d8..aaaa564e3 100644 --- a/src/templates/core/BaseHttpRequest.hbs +++ b/src/templates/core/BaseHttpRequest.hbs @@ -4,10 +4,10 @@ import type { ApiRequestOptions } from './ApiRequestOptions'; import type { ApiResult } from './ApiResult'; import type { OpenAPIConfig } from './OpenAPI'; -export interface BaseHttpRequest { - request( +export interface BaseHttpRequest { + request( options: ApiRequestOptions, config: OpenAPIConfig, mergeConfig?: OpenAPIConfig - ): Promise; + ): Promise>; } diff --git a/test/__snapshots__/index.client.spec.js.snap b/test/__snapshots__/index.client.spec.js.snap index e02b20233..ef9c72962 100644 --- a/test/__snapshots__/index.client.spec.js.snap +++ b/test/__snapshots__/index.client.spec.js.snap @@ -123,12 +123,12 @@ import type { ApiRequestOptions } from './ApiRequestOptions'; import type { ApiResult } from './ApiResult'; import type { OpenAPIConfig } from './OpenAPI'; -export interface BaseHttpRequest { - request( +export interface BaseHttpRequest { + request( options: ApiRequestOptions, config: OpenAPIConfig, mergeConfig?: OpenAPIConfig - ): Promise; + ): Promise>; }" `; @@ -2791,12 +2791,12 @@ import type { ApiRequestOptions } from './ApiRequestOptions'; import type { ApiResult } from './ApiResult'; import type { OpenAPIConfig } from './OpenAPI'; -export interface BaseHttpRequest { - request( +export interface BaseHttpRequest { + request( options: ApiRequestOptions, config: OpenAPIConfig, mergeConfig?: OpenAPIConfig - ): Promise; + ): Promise>; }" `; From 8dee0780e0d6db3605c5b3dc83db79b2ec7cec9e Mon Sep 17 00:00:00 2001 From: lub0v-parsable Date: Thu, 26 Aug 2021 13:38:40 -0700 Subject: [PATCH 07/11] PE-2229 - rename to ClientConfig --- src/templates/core/BaseHttpRequest.hbs | 6 +- src/templates/core/OpenAPI.hbs | 4 +- src/templates/core/fetch/getHeaders.hbs | 2 +- src/templates/core/fetch/request.hbs | 4 +- src/templates/core/fetch/sendRequest.hbs | 2 +- src/templates/core/functions/getUrl.hbs | 2 +- src/templates/core/index.hbs | 2 +- src/templates/core/node/getHeaders.hbs | 2 +- src/templates/core/node/request.hbs | 4 +- src/templates/core/node/sendRequest.hbs | 2 +- src/templates/core/xhr/getHeaders.hbs | 2 +- src/templates/core/xhr/request.hbs | 4 +- src/templates/core/xhr/sendRequest.hbs | 2 +- src/templates/exportAppClient.hbs | 18 +- src/templates/partials/parameters.hbs | 6 +- src/templates/services/exportService.hbs | 10 +- src/utils/postProcessServiceOperations.ts | 2 +- test/__snapshots__/index.client.spec.js.snap | 584 +++++++++---------- test/__snapshots__/index.spec.js.snap | 24 +- 19 files changed, 341 insertions(+), 341 deletions(-) diff --git a/src/templates/core/BaseHttpRequest.hbs b/src/templates/core/BaseHttpRequest.hbs index aaaa564e3..a20419eca 100644 --- a/src/templates/core/BaseHttpRequest.hbs +++ b/src/templates/core/BaseHttpRequest.hbs @@ -2,12 +2,12 @@ import type { ApiRequestOptions } from './ApiRequestOptions'; import type { ApiResult } from './ApiResult'; -import type { OpenAPIConfig } from './OpenAPI'; +import type { ClientConfig } from './OpenAPI'; export interface BaseHttpRequest { request( options: ApiRequestOptions, - config: OpenAPIConfig, - mergeConfig?: OpenAPIConfig + config: ClientConfig, + mergeConfig?: ClientConfig ): Promise>; } diff --git a/src/templates/core/OpenAPI.hbs b/src/templates/core/OpenAPI.hbs index cc49407e8..9c2678508 100644 --- a/src/templates/core/OpenAPI.hbs +++ b/src/templates/core/OpenAPI.hbs @@ -5,7 +5,7 @@ import type { ApiRequestOptions } from './ApiRequestOptions'; type Resolver = (options: ApiRequestOptions) => Promise; type Headers = Record; -export type OpenAPIConfig = { +export type ClientConfig = { baseUrl?: string; version?: string; withCredentials?: boolean; @@ -15,7 +15,7 @@ export type OpenAPIConfig = { headers?: Headers | Resolver; } {{#unless @root.exportClient}} -export const OpenAPI: OpenAPIConfig = { +export const OpenAPI: ClientConfig = { baseUrl: '{{{server}}}', version: '{{{version}}}', withCredentials: false, diff --git a/src/templates/core/fetch/getHeaders.hbs b/src/templates/core/fetch/getHeaders.hbs index 062a2689f..82676f4c9 100644 --- a/src/templates/core/fetch/getHeaders.hbs +++ b/src/templates/core/fetch/getHeaders.hbs @@ -1,4 +1,4 @@ -async function getHeaders(options: ApiRequestOptions, config: OpenAPIConfig): Promise { +async function getHeaders(options: ApiRequestOptions, config: ClientConfig): Promise { const token = await resolve(options, config.token); const username = await resolve(options, config.username); const password = await resolve(options, config.password); diff --git a/src/templates/core/fetch/request.hbs b/src/templates/core/fetch/request.hbs index 64746efe3..980f4d3a3 100644 --- a/src/templates/core/fetch/request.hbs +++ b/src/templates/core/fetch/request.hbs @@ -3,7 +3,7 @@ import { ApiError } from './ApiError'; import type { ApiRequestOptions } from './ApiRequestOptions'; import type { ApiResult } from './ApiResult'; -import type { OpenAPIConfig } from './OpenAPI'; +import type { ClientConfig } from './OpenAPI'; {{#if @root.exportClient}} import type { BaseHttpRequest } from './BaseHttpRequest'; {{else}} @@ -65,7 +65,7 @@ export class FetchHttpRequest implements BaseHttpRequest { * @returns ApiResult * @throws ApiError */ - async request(options: ApiRequestOptions, config: OpenAPIConfig, mergeConfig?: OpenAPIConfig): Promise { + async request(options: ApiRequestOptions, config: ClientConfig, mergeConfig?: ClientConfig): Promise { const conf = mergeConfig ? deepAssign(config, mergeConfig) : config; const url = getUrl(options, conf); const response = await sendRequest(options, conf, url); diff --git a/src/templates/core/fetch/sendRequest.hbs b/src/templates/core/fetch/sendRequest.hbs index ce67b0f45..5bb9ae4f4 100644 --- a/src/templates/core/fetch/sendRequest.hbs +++ b/src/templates/core/fetch/sendRequest.hbs @@ -1,4 +1,4 @@ -async function sendRequest(options: ApiRequestOptions, config: OpenAPIConfig, url: string): Promise { +async function sendRequest(options: ApiRequestOptions, config: ClientConfig, url: string): Promise { const request: RequestInit = { method: options.method, headers: await getHeaders(options, config), diff --git a/src/templates/core/functions/getUrl.hbs b/src/templates/core/functions/getUrl.hbs index b255d7813..848e3fc8b 100644 --- a/src/templates/core/functions/getUrl.hbs +++ b/src/templates/core/functions/getUrl.hbs @@ -1,4 +1,4 @@ -function getUrl(options: ApiRequestOptions, config: OpenAPIConfig): string { +function getUrl(options: ApiRequestOptions, config: ClientConfig): string { const path = options.path.replace(/[:]/g, '_'); const url = `${config.baseUrl}${path}`; diff --git a/src/templates/core/index.hbs b/src/templates/core/index.hbs index 3bf1378d6..ff17398b6 100644 --- a/src/templates/core/index.hbs +++ b/src/templates/core/index.hbs @@ -6,7 +6,7 @@ export type { ApiResult } from './ApiResult'; {{#if @root.exportClient}} export type { BaseHttpRequest } from './BaseHttpRequest'; export { {{{httpRequestName}}} } from './{{{httpRequestName}}}'; -export type { OpenAPIConfig } from './OpenAPI'; +export type { ClientConfig } from './OpenAPI'; {{else}} export { OpenAPI } from './OpenAPI'; export { request } from './request'; diff --git a/src/templates/core/node/getHeaders.hbs b/src/templates/core/node/getHeaders.hbs index a29d296cb..8711afe80 100644 --- a/src/templates/core/node/getHeaders.hbs +++ b/src/templates/core/node/getHeaders.hbs @@ -1,4 +1,4 @@ -async function getHeaders(options: ApiRequestOptions, config: OpenAPIConfig): Promise { +async function getHeaders(options: ApiRequestOptions, config: ClientConfig): Promise { const token = await resolve(options, config.token); const username = await resolve(options, config.username); const password = await resolve(options, config.password); diff --git a/src/templates/core/node/request.hbs b/src/templates/core/node/request.hbs index 9f0b11d44..b17cfb324 100644 --- a/src/templates/core/node/request.hbs +++ b/src/templates/core/node/request.hbs @@ -7,7 +7,7 @@ import { types } from 'util'; import { ApiError } from './ApiError'; import type { ApiRequestOptions } from './ApiRequestOptions'; import type { ApiResult } from './ApiResult'; -import type { OpenAPIConfig } from './OpenAPI'; +import type { ClientConfig } from './OpenAPI'; {{#if @root.exportClient}} import type { BaseHttpRequest } from './BaseHttpRequest'; {{else}} @@ -69,7 +69,7 @@ export class NodeHttpRequest implements BaseHttpRequest { * @returns ApiResult * @throws ApiError */ - async request(options: ApiRequestOptions, config: OpenAPIConfig, mergeConfig?: OpenAPIConfig): Promise { + async request(options: ApiRequestOptions, config: ClientConfig, mergeConfig?: ClientConfig): Promise { const conf = mergeConfig ? deepAssign(config, mergeConfig) : config; const url = getUrl(options, conf); const response = await sendRequest(options, conf, url); diff --git a/src/templates/core/node/sendRequest.hbs b/src/templates/core/node/sendRequest.hbs index 9ef53752f..0eba4e8dc 100644 --- a/src/templates/core/node/sendRequest.hbs +++ b/src/templates/core/node/sendRequest.hbs @@ -1,4 +1,4 @@ -async function sendRequest(options: ApiRequestOptions, config: OpenAPIConfig, url: string): Promise { +async function sendRequest(options: ApiRequestOptions, config: ClientConfig, url: string): Promise { const request: RequestInit = { method: options.method, headers: await getHeaders(options, config), diff --git a/src/templates/core/xhr/getHeaders.hbs b/src/templates/core/xhr/getHeaders.hbs index 062a2689f..82676f4c9 100644 --- a/src/templates/core/xhr/getHeaders.hbs +++ b/src/templates/core/xhr/getHeaders.hbs @@ -1,4 +1,4 @@ -async function getHeaders(options: ApiRequestOptions, config: OpenAPIConfig): Promise { +async function getHeaders(options: ApiRequestOptions, config: ClientConfig): Promise { const token = await resolve(options, config.token); const username = await resolve(options, config.username); const password = await resolve(options, config.password); diff --git a/src/templates/core/xhr/request.hbs b/src/templates/core/xhr/request.hbs index 151f4c3c1..832b964dd 100644 --- a/src/templates/core/xhr/request.hbs +++ b/src/templates/core/xhr/request.hbs @@ -3,7 +3,7 @@ import { ApiError } from './ApiError'; import type { ApiRequestOptions } from './ApiRequestOptions'; import type { ApiResult } from './ApiResult'; -import type { OpenAPIConfig } from './OpenAPI'; +import type { ClientConfig } from './OpenAPI'; {{#if @root.exportClient}} import type { BaseHttpRequest } from './BaseHttpRequest'; {{else}} @@ -69,7 +69,7 @@ export class XhrHttpRequest implements BaseHttpRequest { * @returns ApiResult * @throws ApiError */ - async request(options: ApiRequestOptions, config: OpenAPIConfig, mergeConfig?: OpenAPIConfig): Promise { + async request(options: ApiRequestOptions, config: ClientConfig, mergeConfig?: ClientConfig): Promise { const conf = mergeConfig ? deepAssign(config, mergeConfig) : config; const url = getUrl(options, conf); const response = await sendRequest(options, conf, url); diff --git a/src/templates/core/xhr/sendRequest.hbs b/src/templates/core/xhr/sendRequest.hbs index 203d4e2dc..687c9fff6 100644 --- a/src/templates/core/xhr/sendRequest.hbs +++ b/src/templates/core/xhr/sendRequest.hbs @@ -1,4 +1,4 @@ -async function sendRequest(options: ApiRequestOptions, config: OpenAPIConfig, url: string): Promise { +async function sendRequest(options: ApiRequestOptions, config: ClientConfig, url: string): Promise { const xhr = new XMLHttpRequest(); xhr.open(options.method, url, true); diff --git a/src/templates/exportAppClient.hbs b/src/templates/exportAppClient.hbs index 722180122..6412a7074 100644 --- a/src/templates/exportAppClient.hbs +++ b/src/templates/exportAppClient.hbs @@ -2,7 +2,7 @@ import type { BaseHttpRequest } from './core'; import { {{{httpClientRequest}}} } from './core'; -import type { OpenAPIConfig } from './core'; +import type { ClientConfig } from './core'; {{#if services}} import { {{#each services}} @@ -16,15 +16,15 @@ export class {{{clientName}}} { readonly {{{shortName}}}: {{{name}}}; {{/each}} - constructor(openApiConfig: OpenAPIConfig, httpClient: BaseHttpRequest = new {{{httpClientRequest}}}()) { + constructor(ClientConfig: ClientConfig, httpClient: BaseHttpRequest = new {{{httpClientRequest}}}()) { const config = { - baseUrl: openApiConfig?.baseUrl ?? '{{{server}}}', - version: openApiConfig?.version ?? '{{{version}}}', - withCredentials: openApiConfig?.withCredentials ?? false, - token: openApiConfig?.token, - username: openApiConfig?.username, - password: openApiConfig?.password, - headers: openApiConfig?.headers, + baseUrl: ClientConfig?.baseUrl ?? '{{{server}}}', + version: ClientConfig?.version ?? '{{{version}}}', + withCredentials: ClientConfig?.withCredentials ?? false, + token: ClientConfig?.token, + username: ClientConfig?.username, + password: ClientConfig?.password, + headers: ClientConfig?.headers, } {{#each services}} this.{{{shortName}}} = new {{{name}}}(httpClient, config); diff --git a/src/templates/partials/parameters.hbs b/src/templates/partials/parameters.hbs index 495d16172..24f3c81db 100644 --- a/src/templates/partials/parameters.hbs +++ b/src/templates/partials/parameters.hbs @@ -11,12 +11,12 @@ {{/if}} {{{name}}}{{>isRequired}}: {{>type}}, {{/each}} -}{{#if @root.exportClient}}, config?: OpenAPIConfig{{/if}} +}{{#if @root.exportClient}}, config?: ClientConfig{{/if}} {{~else}} {{#each parameters}} {{{name}}}{{>isRequired}}: {{>type}}{{#if default}} = {{{default}}}{{/if}}, {{/each}} -{{#if @root.exportClient}}config?: OpenAPIConfig{{/if}} +{{#if @root.exportClient}}config?: ClientConfig{{/if}} {{/if}} -{{else}}{{#if @root.exportClient}}config?: OpenAPIConfig{{/if}}{{/if}} +{{else}}{{#if @root.exportClient}}config?: ClientConfig{{/if}}{{/if}} diff --git a/src/templates/services/exportService.hbs b/src/templates/services/exportService.hbs index 99c6c9cd0..201c092e1 100644 --- a/src/templates/services/exportService.hbs +++ b/src/templates/services/exportService.hbs @@ -8,7 +8,7 @@ import type { } from '../models'; {{/if}} {{#if @root.exportClient}} -import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; {{else}} import type { ApiResult } from '../core'; import { @@ -22,11 +22,11 @@ import { export class {{{name}}} { {{#if @root.exportClient}} private readonly httpRequest: BaseHttpRequest; - private readonly openApiConfig: OpenAPIConfig; + private readonly ClientConfig: ClientConfig; - constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { + constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.openApiConfig = openApiConfig; + this.ClientConfig = ClientConfig; } {{/if}} @@ -102,7 +102,7 @@ export class {{{name}}} { {{/each}} }, {{/if}} - }{{#if @root.exportClient}}, this.openApiConfig, config{{/if}}); + }{{#if @root.exportClient}}, this.ClientConfig, config{{/if}}); } {{/each}} diff --git a/src/utils/postProcessServiceOperations.ts b/src/utils/postProcessServiceOperations.ts index cd1dcc7ed..33c9a88a2 100644 --- a/src/utils/postProcessServiceOperations.ts +++ b/src/utils/postProcessServiceOperations.ts @@ -22,7 +22,7 @@ export function postProcessServiceOperations(service: Service, exportClient: boo names.set(name, index + 1); // Update the operation path with the dynamically injected version - clone.path = clone.path.replace('${apiVersion}', exportClient ? '${this.openApiConfig.version}' : '${OpenAPI.version}'); + clone.path = clone.path.replace('${apiVersion}', exportClient ? '${this.ClientConfig.version}' : '${OpenAPI.version}'); return clone; }); diff --git a/test/__snapshots__/index.client.spec.js.snap b/test/__snapshots__/index.client.spec.js.snap index ef9c72962..88da3bab8 100644 --- a/test/__snapshots__/index.client.spec.js.snap +++ b/test/__snapshots__/index.client.spec.js.snap @@ -7,7 +7,7 @@ exports[`v2 should generate with exportClient: ./test/generated/v2_client/client /* eslint-disable */ import type { BaseHttpRequest } from './core'; import { FetchHttpRequest } from './core'; -import type { OpenAPIConfig } from './core'; +import type { ClientConfig } from './core'; import { CollectionFormatService, ComplexService, @@ -33,15 +33,15 @@ export class TestClient { readonly simple: SimpleService; readonly types: TypesService; - constructor(openApiConfig: OpenAPIConfig, httpClient: BaseHttpRequest = new FetchHttpRequest()) { + constructor(ClientConfig: ClientConfig, httpClient: BaseHttpRequest = new FetchHttpRequest()) { const config = { - baseUrl: openApiConfig?.baseUrl ?? 'http://localhost:3000/base', - version: openApiConfig?.version ?? '1.0', - withCredentials: openApiConfig?.withCredentials ?? false, - token: openApiConfig?.token, - username: openApiConfig?.username, - password: openApiConfig?.password, - headers: openApiConfig?.headers, + baseUrl: ClientConfig?.baseUrl ?? 'http://localhost:3000/base', + version: ClientConfig?.version ?? '1.0', + withCredentials: ClientConfig?.withCredentials ?? false, + token: ClientConfig?.token, + username: ClientConfig?.username, + password: ClientConfig?.password, + headers: ClientConfig?.headers, } this.collectionformat = new CollectionFormatService(httpClient, config); this.complex = new ComplexService(httpClient, config); @@ -121,13 +121,13 @@ exports[`v2 should generate with exportClient: ./test/generated/v2_client/core/B /* eslint-disable */ import type { ApiRequestOptions } from './ApiRequestOptions'; import type { ApiResult } from './ApiResult'; -import type { OpenAPIConfig } from './OpenAPI'; +import type { ClientConfig } from './OpenAPI'; export interface BaseHttpRequest { request( options: ApiRequestOptions, - config: OpenAPIConfig, - mergeConfig?: OpenAPIConfig + config: ClientConfig, + mergeConfig?: ClientConfig ): Promise>; }" `; @@ -140,7 +140,7 @@ exports[`v2 should generate with exportClient: ./test/generated/v2_client/core/F import { ApiError } from './ApiError'; import type { ApiRequestOptions } from './ApiRequestOptions'; import type { ApiResult } from './ApiResult'; -import type { OpenAPIConfig } from './OpenAPI'; +import type { ClientConfig } from './OpenAPI'; import type { BaseHttpRequest } from './BaseHttpRequest'; function isDefined(value: T | null | undefined): value is Exclude { @@ -199,7 +199,7 @@ function getQueryString(params: Record): string { return ''; } -function getUrl(options: ApiRequestOptions, config: OpenAPIConfig): string { +function getUrl(options: ApiRequestOptions, config: ClientConfig): string { const path = options.path.replace(/[:]/g, '_'); const url = \`\${config.baseUrl}\${path}\`; @@ -229,7 +229,7 @@ async function resolve(options: ApiRequestOptions, resolver?: T | Resolver return resolver; } -async function getHeaders(options: ApiRequestOptions, config: OpenAPIConfig): Promise { +async function getHeaders(options: ApiRequestOptions, config: ClientConfig): Promise { const token = await resolve(options, config.token); const username = await resolve(options, config.username); const password = await resolve(options, config.password); @@ -280,7 +280,7 @@ function getRequestBody(options: ApiRequestOptions): BodyInit | undefined { return undefined; } -async function sendRequest(options: ApiRequestOptions, config: OpenAPIConfig, url: string): Promise { +async function sendRequest(options: ApiRequestOptions, config: ClientConfig, url: string): Promise { const request: RequestInit = { method: options.method, headers: await getHeaders(options, config), @@ -350,7 +350,7 @@ export class FetchHttpRequest implements BaseHttpRequest { * @returns ApiResult * @throws ApiError */ - async request(options: ApiRequestOptions, config: OpenAPIConfig, mergeConfig?: OpenAPIConfig): Promise { + async request(options: ApiRequestOptions, config: ClientConfig, mergeConfig?: ClientConfig): Promise { const conf = mergeConfig ? deepAssign(config, mergeConfig) : config; const url = getUrl(options, conf); const response = await sendRequest(options, conf, url); @@ -382,7 +382,7 @@ import type { ApiRequestOptions } from './ApiRequestOptions'; type Resolver = (options: ApiRequestOptions) => Promise; type Headers = Record; -export type OpenAPIConfig = { +export type ClientConfig = { baseUrl?: string; version?: string; withCredentials?: boolean; @@ -404,7 +404,7 @@ export type { ApiRequestOptions } from './ApiRequestOptions'; export type { ApiResult } from './ApiResult'; export type { BaseHttpRequest } from './BaseHttpRequest'; export { FetchHttpRequest } from './FetchHttpRequest'; -export type { OpenAPIConfig } from './OpenAPI'; +export type { ClientConfig } from './OpenAPI'; " `; @@ -1968,15 +1968,15 @@ exports[`v2 should generate with exportClient: ./test/generated/v2_client/servic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; export class CollectionFormatService { private readonly httpRequest: BaseHttpRequest; - private readonly openApiConfig: OpenAPIConfig; + private readonly ClientConfig: ClientConfig; - constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { + constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.openApiConfig = openApiConfig; + this.ClientConfig = ClientConfig; } /** @@ -1994,11 +1994,11 @@ export class CollectionFormatService { parameterArrayTsv: Array, parameterArrayPipes: Array, parameterArrayMulti: Array, - config?: OpenAPIConfig + config?: ClientConfig ): Promise> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.openApiConfig.version}/collectionFormat\`, + path: \`/api/v\${this.ClientConfig.version}/collectionFormat\`, query: { 'parameterArrayCSV': parameterArrayCsv, 'parameterArraySSV': parameterArraySsv, @@ -2006,7 +2006,7 @@ export class CollectionFormatService { 'parameterArrayPipes': parameterArrayPipes, 'parameterArrayMulti': parameterArrayMulti, }, - }, this.openApiConfig, config); + }, this.ClientConfig, config); } }" @@ -2020,15 +2020,15 @@ exports[`v2 should generate with exportClient: ./test/generated/v2_client/servic import type { ModelWithString, } from '../models'; -import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; export class ComplexService { private readonly httpRequest: BaseHttpRequest; - private readonly openApiConfig: OpenAPIConfig; + private readonly ClientConfig: ClientConfig; - constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { + constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.openApiConfig = openApiConfig; + this.ClientConfig = ClientConfig; } /** @@ -2047,11 +2047,11 @@ export class ComplexService { }, }, parameterReference: ModelWithString, - config?: OpenAPIConfig + config?: ClientConfig ): Promise>> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.openApiConfig.version}/complex\`, + path: \`/api/v\${this.ClientConfig.version}/complex\`, query: { 'parameterObject': parameterObject, 'parameterReference': parameterReference, @@ -2060,7 +2060,7 @@ export class ComplexService { 400: \`400 server error\`, 500: \`500 server error\`, }, - }, this.openApiConfig, config); + }, this.ClientConfig, config); } }" @@ -2074,15 +2074,15 @@ exports[`v2 should generate with exportClient: ./test/generated/v2_client/servic import type { ModelWithString, } from '../models'; -import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; export class DefaultsService { private readonly httpRequest: BaseHttpRequest; - private readonly openApiConfig: OpenAPIConfig; + private readonly ClientConfig: ClientConfig; - constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { + constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.openApiConfig = openApiConfig; + this.ClientConfig = ClientConfig; } /** @@ -2102,11 +2102,11 @@ export class DefaultsService { parameterModel: ModelWithString = { \\"prop\\": \\"Hello World!\\" }, - config?: OpenAPIConfig + config?: ClientConfig ): Promise> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.openApiConfig.version}/defaults\`, + path: \`/api/v\${this.ClientConfig.version}/defaults\`, query: { 'parameterString': parameterString, 'parameterNumber': parameterNumber, @@ -2114,7 +2114,7 @@ export class DefaultsService { 'parameterEnum': parameterEnum, 'parameterModel': parameterModel, }, - }, this.openApiConfig, config); + }, this.ClientConfig, config); } /** @@ -2134,11 +2134,11 @@ export class DefaultsService { parameterModel: ModelWithString = { \\"prop\\": \\"Hello World!\\" }, - config?: OpenAPIConfig + config?: ClientConfig ): Promise> { return this.httpRequest.request({ method: 'POST', - path: \`/api/v\${this.openApiConfig.version}/defaults\`, + path: \`/api/v\${this.ClientConfig.version}/defaults\`, query: { 'parameterString': parameterString, 'parameterNumber': parameterNumber, @@ -2146,7 +2146,7 @@ export class DefaultsService { 'parameterEnum': parameterEnum, 'parameterModel': parameterModel, }, - }, this.openApiConfig, config); + }, this.ClientConfig, config); } /** @@ -2166,11 +2166,11 @@ export class DefaultsService { parameterOptionalStringWithNoDefault?: string, parameterStringWithDefault: string = 'Hello World!', parameterStringWithEmptyDefault: string = '', - config?: OpenAPIConfig + config?: ClientConfig ): Promise> { return this.httpRequest.request({ method: 'PUT', - path: \`/api/v\${this.openApiConfig.version}/defaults\`, + path: \`/api/v\${this.ClientConfig.version}/defaults\`, query: { 'parameterStringWithNoDefault': parameterStringWithNoDefault, 'parameterOptionalStringWithDefault': parameterOptionalStringWithDefault, @@ -2179,7 +2179,7 @@ export class DefaultsService { 'parameterStringWithDefault': parameterStringWithDefault, 'parameterStringWithEmptyDefault': parameterStringWithEmptyDefault, }, - }, this.openApiConfig, config); + }, this.ClientConfig, config); } }" @@ -2190,59 +2190,59 @@ exports[`v2 should generate with exportClient: ./test/generated/v2_client/servic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; export class DuplicateService { private readonly httpRequest: BaseHttpRequest; - private readonly openApiConfig: OpenAPIConfig; + private readonly ClientConfig: ClientConfig; - constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { + constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.openApiConfig = openApiConfig; + this.ClientConfig = ClientConfig; } /** * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async duplicateName(config?: OpenAPIConfig): Promise> { + public async duplicateName(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.openApiConfig.version}/duplicate\`, - }, this.openApiConfig, config); + path: \`/api/v\${this.ClientConfig.version}/duplicate\`, + }, this.ClientConfig, config); } /** * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async duplicateName1(config?: OpenAPIConfig): Promise> { + public async duplicateName1(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'POST', - path: \`/api/v\${this.openApiConfig.version}/duplicate\`, - }, this.openApiConfig, config); + path: \`/api/v\${this.ClientConfig.version}/duplicate\`, + }, this.ClientConfig, config); } /** * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async duplicateName2(config?: OpenAPIConfig): Promise> { + public async duplicateName2(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'PUT', - path: \`/api/v\${this.openApiConfig.version}/duplicate\`, - }, this.openApiConfig, config); + path: \`/api/v\${this.ClientConfig.version}/duplicate\`, + }, this.ClientConfig, config); } /** * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async duplicateName3(config?: OpenAPIConfig): Promise> { + public async duplicateName3(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'DELETE', - path: \`/api/v\${this.openApiConfig.version}/duplicate\`, - }, this.openApiConfig, config); + path: \`/api/v\${this.ClientConfig.version}/duplicate\`, + }, this.ClientConfig, config); } }" @@ -2253,15 +2253,15 @@ exports[`v2 should generate with exportClient: ./test/generated/v2_client/servic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; export class HeaderService { private readonly httpRequest: BaseHttpRequest; - private readonly openApiConfig: OpenAPIConfig; + private readonly ClientConfig: ClientConfig; - constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { + constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.openApiConfig = openApiConfig; + this.ClientConfig = ClientConfig; } /** @@ -2269,16 +2269,16 @@ export class HeaderService { * @returns string Successful response * @throws ApiError */ - public async callWithResultFromHeader(config?: OpenAPIConfig): Promise> { + public async callWithResultFromHeader(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'POST', - path: \`/api/v\${this.openApiConfig.version}/header\`, + path: \`/api/v\${this.ClientConfig.version}/header\`, responseHeader: 'operation-location', errors: { 400: \`400 server error\`, 500: \`500 server error\`, }, - }, this.openApiConfig, config); + }, this.ClientConfig, config); } }" @@ -2289,15 +2289,15 @@ exports[`v2 should generate with exportClient: ./test/generated/v2_client/servic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; export class NoContentService { private readonly httpRequest: BaseHttpRequest; - private readonly openApiConfig: OpenAPIConfig; + private readonly ClientConfig: ClientConfig; - constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { + constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.openApiConfig = openApiConfig; + this.ClientConfig = ClientConfig; } /** @@ -2305,11 +2305,11 @@ export class NoContentService { * @returns void * @throws ApiError */ - public async callWithNoContentResponse(config?: OpenAPIConfig): Promise> { + public async callWithNoContentResponse(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.openApiConfig.version}/no-content\`, - }, this.openApiConfig, config); + path: \`/api/v\${this.ClientConfig.version}/no-content\`, + }, this.ClientConfig, config); } }" @@ -2320,15 +2320,15 @@ exports[`v2 should generate with exportClient: ./test/generated/v2_client/servic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; export class ParametersService { private readonly httpRequest: BaseHttpRequest; - private readonly openApiConfig: OpenAPIConfig; + private readonly ClientConfig: ClientConfig; - constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { + constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.openApiConfig = openApiConfig; + this.ClientConfig = ClientConfig; } /** @@ -2346,11 +2346,11 @@ export class ParametersService { parameterForm: string, parameterBody: string, parameterPath: string, - config?: OpenAPIConfig + config?: ClientConfig ): Promise> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.openApiConfig.version}/parameters/\${parameterPath}\`, + path: \`/api/v\${this.ClientConfig.version}/parameters/\${parameterPath}\`, headers: { 'parameterHeader': parameterHeader, }, @@ -2361,7 +2361,7 @@ export class ParametersService { 'parameterForm': parameterForm, }, body: parameterBody, - }, this.openApiConfig, config); + }, this.ClientConfig, config); } /** @@ -2385,11 +2385,11 @@ export class ParametersService { parameterPath2?: string, parameterPath3?: string, _default?: string, - config?: OpenAPIConfig + config?: ClientConfig ): Promise> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.openApiConfig.version}/parameters/\${parameterPath1}/\${parameterPath2}/\${parameterPath3}\`, + path: \`/api/v\${this.ClientConfig.version}/parameters/\${parameterPath1}/\${parameterPath2}/\${parameterPath3}\`, headers: { 'parameter.header': parameterHeader, }, @@ -2401,7 +2401,7 @@ export class ParametersService { 'parameter_form': parameterForm, }, body: parameterBody, - }, this.openApiConfig, config); + }, this.ClientConfig, config); } }" @@ -2417,15 +2417,15 @@ import type { ModelThatExtendsExtends, ModelWithString, } from '../models'; -import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; export class ResponseService { private readonly httpRequest: BaseHttpRequest; - private readonly openApiConfig: OpenAPIConfig; + private readonly ClientConfig: ClientConfig; - constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { + constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.openApiConfig = openApiConfig; + this.ClientConfig = ClientConfig; } /** @@ -2433,11 +2433,11 @@ export class ResponseService { * @returns ModelWithString Message for default response * @throws ApiError */ - public async callWithResponse(config?: OpenAPIConfig): Promise> { + public async callWithResponse(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.openApiConfig.version}/response\`, - }, this.openApiConfig, config); + path: \`/api/v\${this.ClientConfig.version}/response\`, + }, this.ClientConfig, config); } /** @@ -2445,16 +2445,16 @@ export class ResponseService { * @returns ModelWithString Message for default response * @throws ApiError */ - public async callWithDuplicateResponses(config?: OpenAPIConfig): Promise> { + public async callWithDuplicateResponses(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'POST', - path: \`/api/v\${this.openApiConfig.version}/response\`, + path: \`/api/v\${this.ClientConfig.version}/response\`, errors: { 500: \`Message for 500 error\`, 501: \`Message for 501 error\`, 502: \`Message for 502 error\`, }, - }, this.openApiConfig, config); + }, this.ClientConfig, config); } /** @@ -2465,20 +2465,20 @@ export class ResponseService { * @returns ModelThatExtendsExtends Message for 202 response * @throws ApiError */ - public async callWithResponses(config?: OpenAPIConfig): Promise, } | ModelWithString | ModelThatExtends | ModelThatExtendsExtends>> { return this.httpRequest.request({ method: 'PUT', - path: \`/api/v\${this.openApiConfig.version}/response\`, + path: \`/api/v\${this.ClientConfig.version}/response\`, errors: { 500: \`Message for 500 error\`, 501: \`Message for 501 error\`, 502: \`Message for 502 error\`, }, - }, this.openApiConfig, config); + }, this.ClientConfig, config); } }" @@ -2489,92 +2489,92 @@ exports[`v2 should generate with exportClient: ./test/generated/v2_client/servic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; export class SimpleService { private readonly httpRequest: BaseHttpRequest; - private readonly openApiConfig: OpenAPIConfig; + private readonly ClientConfig: ClientConfig; - constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { + constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.openApiConfig = openApiConfig; + this.ClientConfig = ClientConfig; } /** * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async getCallWithoutParametersAndResponse(config?: OpenAPIConfig): Promise> { + public async getCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.openApiConfig.version}/simple\`, - }, this.openApiConfig, config); + path: \`/api/v\${this.ClientConfig.version}/simple\`, + }, this.ClientConfig, config); } /** * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async putCallWithoutParametersAndResponse(config?: OpenAPIConfig): Promise> { + public async putCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'PUT', - path: \`/api/v\${this.openApiConfig.version}/simple\`, - }, this.openApiConfig, config); + path: \`/api/v\${this.ClientConfig.version}/simple\`, + }, this.ClientConfig, config); } /** * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async postCallWithoutParametersAndResponse(config?: OpenAPIConfig): Promise> { + public async postCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'POST', - path: \`/api/v\${this.openApiConfig.version}/simple\`, - }, this.openApiConfig, config); + path: \`/api/v\${this.ClientConfig.version}/simple\`, + }, this.ClientConfig, config); } /** * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async deleteCallWithoutParametersAndResponse(config?: OpenAPIConfig): Promise> { + public async deleteCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'DELETE', - path: \`/api/v\${this.openApiConfig.version}/simple\`, - }, this.openApiConfig, config); + path: \`/api/v\${this.ClientConfig.version}/simple\`, + }, this.ClientConfig, config); } /** * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async optionsCallWithoutParametersAndResponse(config?: OpenAPIConfig): Promise> { + public async optionsCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'OPTIONS', - path: \`/api/v\${this.openApiConfig.version}/simple\`, - }, this.openApiConfig, config); + path: \`/api/v\${this.ClientConfig.version}/simple\`, + }, this.ClientConfig, config); } /** * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async headCallWithoutParametersAndResponse(config?: OpenAPIConfig): Promise> { + public async headCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'HEAD', - path: \`/api/v\${this.openApiConfig.version}/simple\`, - }, this.openApiConfig, config); + path: \`/api/v\${this.ClientConfig.version}/simple\`, + }, this.ClientConfig, config); } /** * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async patchCallWithoutParametersAndResponse(config?: OpenAPIConfig): Promise> { + public async patchCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'PATCH', - path: \`/api/v\${this.openApiConfig.version}/simple\`, - }, this.openApiConfig, config); + path: \`/api/v\${this.ClientConfig.version}/simple\`, + }, this.ClientConfig, config); } }" @@ -2585,15 +2585,15 @@ exports[`v2 should generate with exportClient: ./test/generated/v2_client/servic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; export class TypesService { private readonly httpRequest: BaseHttpRequest; - private readonly openApiConfig: OpenAPIConfig; + private readonly ClientConfig: ClientConfig; - constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { + constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.openApiConfig = openApiConfig; + this.ClientConfig = ClientConfig; } /** @@ -2621,11 +2621,11 @@ export class TypesService { parameterBoolean: boolean = true, parameterObject: any = null, id?: number, - config?: OpenAPIConfig + config?: ClientConfig ): Promise> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.openApiConfig.version}/types\`, + path: \`/api/v\${this.ClientConfig.version}/types\`, query: { 'parameterArray': parameterArray, 'parameterDictionary': parameterDictionary, @@ -2635,7 +2635,7 @@ export class TypesService { 'parameterBoolean': parameterBoolean, 'parameterObject': parameterObject, }, - }, this.openApiConfig, config); + }, this.ClientConfig, config); } }" @@ -2666,7 +2666,7 @@ exports[`v3 should generate with exportClient: ./test/generated/v3_client/client /* eslint-disable */ import type { BaseHttpRequest } from './core'; import { FetchHttpRequest } from './core'; -import type { OpenAPIConfig } from './core'; +import type { ClientConfig } from './core'; import { CollectionFormatService, ComplexService, @@ -2698,15 +2698,15 @@ export class TestClient { readonly types: TypesService; readonly upload: UploadService; - constructor(openApiConfig: OpenAPIConfig, httpClient: BaseHttpRequest = new FetchHttpRequest()) { + constructor(ClientConfig: ClientConfig, httpClient: BaseHttpRequest = new FetchHttpRequest()) { const config = { - baseUrl: openApiConfig?.baseUrl ?? 'http://localhost:3000/base', - version: openApiConfig?.version ?? '1.0', - withCredentials: openApiConfig?.withCredentials ?? false, - token: openApiConfig?.token, - username: openApiConfig?.username, - password: openApiConfig?.password, - headers: openApiConfig?.headers, + baseUrl: ClientConfig?.baseUrl ?? 'http://localhost:3000/base', + version: ClientConfig?.version ?? '1.0', + withCredentials: ClientConfig?.withCredentials ?? false, + token: ClientConfig?.token, + username: ClientConfig?.username, + password: ClientConfig?.password, + headers: ClientConfig?.headers, } this.collectionformat = new CollectionFormatService(httpClient, config); this.complex = new ComplexService(httpClient, config); @@ -2789,13 +2789,13 @@ exports[`v3 should generate with exportClient: ./test/generated/v3_client/core/B /* eslint-disable */ import type { ApiRequestOptions } from './ApiRequestOptions'; import type { ApiResult } from './ApiResult'; -import type { OpenAPIConfig } from './OpenAPI'; +import type { ClientConfig } from './OpenAPI'; export interface BaseHttpRequest { request( options: ApiRequestOptions, - config: OpenAPIConfig, - mergeConfig?: OpenAPIConfig + config: ClientConfig, + mergeConfig?: ClientConfig ): Promise>; }" `; @@ -2808,7 +2808,7 @@ exports[`v3 should generate with exportClient: ./test/generated/v3_client/core/F import { ApiError } from './ApiError'; import type { ApiRequestOptions } from './ApiRequestOptions'; import type { ApiResult } from './ApiResult'; -import type { OpenAPIConfig } from './OpenAPI'; +import type { ClientConfig } from './OpenAPI'; import type { BaseHttpRequest } from './BaseHttpRequest'; function isDefined(value: T | null | undefined): value is Exclude { @@ -2867,7 +2867,7 @@ function getQueryString(params: Record): string { return ''; } -function getUrl(options: ApiRequestOptions, config: OpenAPIConfig): string { +function getUrl(options: ApiRequestOptions, config: ClientConfig): string { const path = options.path.replace(/[:]/g, '_'); const url = \`\${config.baseUrl}\${path}\`; @@ -2897,7 +2897,7 @@ async function resolve(options: ApiRequestOptions, resolver?: T | Resolver return resolver; } -async function getHeaders(options: ApiRequestOptions, config: OpenAPIConfig): Promise { +async function getHeaders(options: ApiRequestOptions, config: ClientConfig): Promise { const token = await resolve(options, config.token); const username = await resolve(options, config.username); const password = await resolve(options, config.password); @@ -2948,7 +2948,7 @@ function getRequestBody(options: ApiRequestOptions): BodyInit | undefined { return undefined; } -async function sendRequest(options: ApiRequestOptions, config: OpenAPIConfig, url: string): Promise { +async function sendRequest(options: ApiRequestOptions, config: ClientConfig, url: string): Promise { const request: RequestInit = { method: options.method, headers: await getHeaders(options, config), @@ -3018,7 +3018,7 @@ export class FetchHttpRequest implements BaseHttpRequest { * @returns ApiResult * @throws ApiError */ - async request(options: ApiRequestOptions, config: OpenAPIConfig, mergeConfig?: OpenAPIConfig): Promise { + async request(options: ApiRequestOptions, config: ClientConfig, mergeConfig?: ClientConfig): Promise { const conf = mergeConfig ? deepAssign(config, mergeConfig) : config; const url = getUrl(options, conf); const response = await sendRequest(options, conf, url); @@ -3050,7 +3050,7 @@ import type { ApiRequestOptions } from './ApiRequestOptions'; type Resolver = (options: ApiRequestOptions) => Promise; type Headers = Record; -export type OpenAPIConfig = { +export type ClientConfig = { baseUrl?: string; version?: string; withCredentials?: boolean; @@ -3072,7 +3072,7 @@ export type { ApiRequestOptions } from './ApiRequestOptions'; export type { ApiResult } from './ApiResult'; export type { BaseHttpRequest } from './BaseHttpRequest'; export { FetchHttpRequest } from './FetchHttpRequest'; -export type { OpenAPIConfig } from './OpenAPI'; +export type { ClientConfig } from './OpenAPI'; " `; @@ -4911,15 +4911,15 @@ exports[`v3 should generate with exportClient: ./test/generated/v3_client/servic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; export class CollectionFormatService { private readonly httpRequest: BaseHttpRequest; - private readonly openApiConfig: OpenAPIConfig; + private readonly ClientConfig: ClientConfig; - constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { + constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.openApiConfig = openApiConfig; + this.ClientConfig = ClientConfig; } /** @@ -4937,11 +4937,11 @@ export class CollectionFormatService { parameterArrayTsv: Array | null, parameterArrayPipes: Array | null, parameterArrayMulti: Array | null, - config?: OpenAPIConfig + config?: ClientConfig ): Promise> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.openApiConfig.version}/collectionFormat\`, + path: \`/api/v\${this.ClientConfig.version}/collectionFormat\`, query: { 'parameterArrayCSV': parameterArrayCsv, 'parameterArraySSV': parameterArraySsv, @@ -4949,7 +4949,7 @@ export class CollectionFormatService { 'parameterArrayPipes': parameterArrayPipes, 'parameterArrayMulti': parameterArrayMulti, }, - }, this.openApiConfig, config); + }, this.ClientConfig, config); } }" @@ -4966,15 +4966,15 @@ import type { ModelWithEnum, ModelWithString, } from '../models'; -import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; export class ComplexService { private readonly httpRequest: BaseHttpRequest; - private readonly openApiConfig: OpenAPIConfig; + private readonly ClientConfig: ClientConfig; - constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { + constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.openApiConfig = openApiConfig; + this.ClientConfig = ClientConfig; } /** @@ -4993,11 +4993,11 @@ export class ComplexService { }, }, parameterReference: ModelWithString, - config?: OpenAPIConfig + config?: ClientConfig ): Promise>> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.openApiConfig.version}/complex\`, + path: \`/api/v\${this.ClientConfig.version}/complex\`, query: { 'parameterObject': parameterObject, 'parameterReference': parameterReference, @@ -5006,7 +5006,7 @@ export class ComplexService { 400: \`400 server error\`, 500: \`500 server error\`, }, - }, this.openApiConfig, config); + }, this.ClientConfig, config); } /** @@ -5031,14 +5031,14 @@ export class ComplexService { readonly name?: string | null, }, }, - config?: OpenAPIConfig + config?: ClientConfig ): Promise> { return this.httpRequest.request({ method: 'PUT', - path: \`/api/v\${this.openApiConfig.version}/complex/\${id}\`, + path: \`/api/v\${this.ClientConfig.version}/complex/\${id}\`, body: requestBody, mediaType: 'application/json-patch+json', - }, this.openApiConfig, config); + }, this.ClientConfig, config); } }" @@ -5052,15 +5052,15 @@ exports[`v3 should generate with exportClient: ./test/generated/v3_client/servic import type { ModelWithString, } from '../models'; -import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; export class DefaultsService { private readonly httpRequest: BaseHttpRequest; - private readonly openApiConfig: OpenAPIConfig; + private readonly ClientConfig: ClientConfig; - constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { + constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.openApiConfig = openApiConfig; + this.ClientConfig = ClientConfig; } /** @@ -5080,11 +5080,11 @@ export class DefaultsService { parameterModel: ModelWithString | null = { \\"prop\\": \\"Hello World!\\" }, - config?: OpenAPIConfig + config?: ClientConfig ): Promise> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.openApiConfig.version}/defaults\`, + path: \`/api/v\${this.ClientConfig.version}/defaults\`, query: { 'parameterString': parameterString, 'parameterNumber': parameterNumber, @@ -5092,7 +5092,7 @@ export class DefaultsService { 'parameterEnum': parameterEnum, 'parameterModel': parameterModel, }, - }, this.openApiConfig, config); + }, this.ClientConfig, config); } /** @@ -5112,11 +5112,11 @@ export class DefaultsService { parameterModel: ModelWithString = { \\"prop\\": \\"Hello World!\\" }, - config?: OpenAPIConfig + config?: ClientConfig ): Promise> { return this.httpRequest.request({ method: 'POST', - path: \`/api/v\${this.openApiConfig.version}/defaults\`, + path: \`/api/v\${this.ClientConfig.version}/defaults\`, query: { 'parameterString': parameterString, 'parameterNumber': parameterNumber, @@ -5124,7 +5124,7 @@ export class DefaultsService { 'parameterEnum': parameterEnum, 'parameterModel': parameterModel, }, - }, this.openApiConfig, config); + }, this.ClientConfig, config); } /** @@ -5144,11 +5144,11 @@ export class DefaultsService { parameterOptionalStringWithNoDefault?: string, parameterStringWithDefault: string = 'Hello World!', parameterStringWithEmptyDefault: string = '', - config?: OpenAPIConfig + config?: ClientConfig ): Promise> { return this.httpRequest.request({ method: 'PUT', - path: \`/api/v\${this.openApiConfig.version}/defaults\`, + path: \`/api/v\${this.ClientConfig.version}/defaults\`, query: { 'parameterStringWithNoDefault': parameterStringWithNoDefault, 'parameterOptionalStringWithDefault': parameterOptionalStringWithDefault, @@ -5157,7 +5157,7 @@ export class DefaultsService { 'parameterStringWithDefault': parameterStringWithDefault, 'parameterStringWithEmptyDefault': parameterStringWithEmptyDefault, }, - }, this.openApiConfig, config); + }, this.ClientConfig, config); } }" @@ -5168,59 +5168,59 @@ exports[`v3 should generate with exportClient: ./test/generated/v3_client/servic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; export class DuplicateService { private readonly httpRequest: BaseHttpRequest; - private readonly openApiConfig: OpenAPIConfig; + private readonly ClientConfig: ClientConfig; - constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { + constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.openApiConfig = openApiConfig; + this.ClientConfig = ClientConfig; } /** * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async duplicateName(config?: OpenAPIConfig): Promise> { + public async duplicateName(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.openApiConfig.version}/duplicate\`, - }, this.openApiConfig, config); + path: \`/api/v\${this.ClientConfig.version}/duplicate\`, + }, this.ClientConfig, config); } /** * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async duplicateName1(config?: OpenAPIConfig): Promise> { + public async duplicateName1(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'POST', - path: \`/api/v\${this.openApiConfig.version}/duplicate\`, - }, this.openApiConfig, config); + path: \`/api/v\${this.ClientConfig.version}/duplicate\`, + }, this.ClientConfig, config); } /** * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async duplicateName2(config?: OpenAPIConfig): Promise> { + public async duplicateName2(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'PUT', - path: \`/api/v\${this.openApiConfig.version}/duplicate\`, - }, this.openApiConfig, config); + path: \`/api/v\${this.ClientConfig.version}/duplicate\`, + }, this.ClientConfig, config); } /** * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async duplicateName3(config?: OpenAPIConfig): Promise> { + public async duplicateName3(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'DELETE', - path: \`/api/v\${this.openApiConfig.version}/duplicate\`, - }, this.openApiConfig, config); + path: \`/api/v\${this.ClientConfig.version}/duplicate\`, + }, this.ClientConfig, config); } }" @@ -5231,15 +5231,15 @@ exports[`v3 should generate with exportClient: ./test/generated/v3_client/servic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; export class HeaderService { private readonly httpRequest: BaseHttpRequest; - private readonly openApiConfig: OpenAPIConfig; + private readonly ClientConfig: ClientConfig; - constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { + constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.openApiConfig = openApiConfig; + this.ClientConfig = ClientConfig; } /** @@ -5247,16 +5247,16 @@ export class HeaderService { * @returns string Successful response * @throws ApiError */ - public async callWithResultFromHeader(config?: OpenAPIConfig): Promise> { + public async callWithResultFromHeader(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'POST', - path: \`/api/v\${this.openApiConfig.version}/header\`, + path: \`/api/v\${this.ClientConfig.version}/header\`, responseHeader: 'operation-location', errors: { 400: \`400 server error\`, 500: \`500 server error\`, }, - }, this.openApiConfig, config); + }, this.ClientConfig, config); } }" @@ -5267,15 +5267,15 @@ exports[`v3 should generate with exportClient: ./test/generated/v3_client/servic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; export class MultipartService { private readonly httpRequest: BaseHttpRequest; - private readonly openApiConfig: OpenAPIConfig; + private readonly ClientConfig: ClientConfig; - constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { + constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.openApiConfig = openApiConfig; + this.ClientConfig = ClientConfig; } /** @@ -5283,7 +5283,7 @@ export class MultipartService { * @returns any OK * @throws ApiError */ - public async multipartResponse(config?: OpenAPIConfig): Promise> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.openApiConfig.version}/multipart\`, - }, this.openApiConfig, config); + path: \`/api/v\${this.ClientConfig.version}/multipart\`, + }, this.ClientConfig, config); } }" @@ -5304,15 +5304,15 @@ exports[`v3 should generate with exportClient: ./test/generated/v3_client/servic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; export class NoContentService { private readonly httpRequest: BaseHttpRequest; - private readonly openApiConfig: OpenAPIConfig; + private readonly ClientConfig: ClientConfig; - constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { + constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.openApiConfig = openApiConfig; + this.ClientConfig = ClientConfig; } /** @@ -5320,11 +5320,11 @@ export class NoContentService { * @returns void * @throws ApiError */ - public async callWithNoContentResponse(config?: OpenAPIConfig): Promise> { + public async callWithNoContentResponse(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.openApiConfig.version}/no-content\`, - }, this.openApiConfig, config); + path: \`/api/v\${this.ClientConfig.version}/no-content\`, + }, this.ClientConfig, config); } }" @@ -5338,15 +5338,15 @@ exports[`v3 should generate with exportClient: ./test/generated/v3_client/servic import type { ModelWithString, } from '../models'; -import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; export class ParametersService { private readonly httpRequest: BaseHttpRequest; - private readonly openApiConfig: OpenAPIConfig; + private readonly ClientConfig: ClientConfig; - constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { + constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.openApiConfig = openApiConfig; + this.ClientConfig = ClientConfig; } /** @@ -5366,11 +5366,11 @@ export class ParametersService { parameterCookie: string | null, parameterPath: string | null, requestBody: ModelWithString | null, - config?: OpenAPIConfig + config?: ClientConfig ): Promise> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.openApiConfig.version}/parameters/\${parameterPath}\`, + path: \`/api/v\${this.ClientConfig.version}/parameters/\${parameterPath}\`, cookies: { 'parameterCookie': parameterCookie, }, @@ -5385,7 +5385,7 @@ export class ParametersService { }, body: requestBody, mediaType: 'application/json', - }, this.openApiConfig, config); + }, this.ClientConfig, config); } /** @@ -5411,11 +5411,11 @@ export class ParametersService { parameterPath2?: string, parameterPath3?: string, _default?: string, - config?: OpenAPIConfig + config?: ClientConfig ): Promise> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.openApiConfig.version}/parameters/\${parameterPath1}/\${parameterPath2}/\${parameterPath3}\`, + path: \`/api/v\${this.ClientConfig.version}/parameters/\${parameterPath1}/\${parameterPath2}/\${parameterPath3}\`, cookies: { 'PARAMETER-COOKIE': parameterCookie, }, @@ -5431,7 +5431,7 @@ export class ParametersService { }, body: requestBody, mediaType: 'application/json', - }, this.openApiConfig, config); + }, this.ClientConfig, config); } /** @@ -5443,17 +5443,17 @@ export class ParametersService { public async getCallWithOptionalParam( requestBody: ModelWithString, parameter?: string, - config?: OpenAPIConfig + config?: ClientConfig ): Promise> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.openApiConfig.version}/parameters/\`, + path: \`/api/v\${this.ClientConfig.version}/parameters/\`, query: { 'parameter': parameter, }, body: requestBody, mediaType: 'application/json', - }, this.openApiConfig, config); + }, this.ClientConfig, config); } /** @@ -5465,17 +5465,17 @@ export class ParametersService { public async postCallWithOptionalParam( parameter: string, requestBody?: ModelWithString, - config?: OpenAPIConfig + config?: ClientConfig ): Promise> { return this.httpRequest.request({ method: 'POST', - path: \`/api/v\${this.openApiConfig.version}/parameters/\`, + path: \`/api/v\${this.ClientConfig.version}/parameters/\`, query: { 'parameter': parameter, }, body: requestBody, mediaType: 'application/json', - }, this.openApiConfig, config); + }, this.ClientConfig, config); } }" @@ -5489,15 +5489,15 @@ exports[`v3 should generate with exportClient: ./test/generated/v3_client/servic import type { ModelWithString, } from '../models'; -import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; export class RequestBodyService { private readonly httpRequest: BaseHttpRequest; - private readonly openApiConfig: OpenAPIConfig; + private readonly ClientConfig: ClientConfig; - constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { + constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.openApiConfig = openApiConfig; + this.ClientConfig = ClientConfig; } /** @@ -5507,14 +5507,14 @@ export class RequestBodyService { */ public async postRequestBodyService( requestBody?: ModelWithString, - config?: OpenAPIConfig + config?: ClientConfig ): Promise> { return this.httpRequest.request({ method: 'POST', - path: \`/api/v\${this.openApiConfig.version}/requestBody/\`, + path: \`/api/v\${this.ClientConfig.version}/requestBody/\`, body: requestBody, mediaType: 'application/json', - }, this.openApiConfig, config); + }, this.ClientConfig, config); } }" @@ -5530,15 +5530,15 @@ import type { ModelThatExtendsExtends, ModelWithString, } from '../models'; -import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; export class ResponseService { private readonly httpRequest: BaseHttpRequest; - private readonly openApiConfig: OpenAPIConfig; + private readonly ClientConfig: ClientConfig; - constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { + constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.openApiConfig = openApiConfig; + this.ClientConfig = ClientConfig; } /** @@ -5546,11 +5546,11 @@ export class ResponseService { * @returns ModelWithString * @throws ApiError */ - public async callWithResponse(config?: OpenAPIConfig): Promise> { + public async callWithResponse(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.openApiConfig.version}/response\`, - }, this.openApiConfig, config); + path: \`/api/v\${this.ClientConfig.version}/response\`, + }, this.ClientConfig, config); } /** @@ -5558,16 +5558,16 @@ export class ResponseService { * @returns ModelWithString Message for default response * @throws ApiError */ - public async callWithDuplicateResponses(config?: OpenAPIConfig): Promise> { + public async callWithDuplicateResponses(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'POST', - path: \`/api/v\${this.openApiConfig.version}/response\`, + path: \`/api/v\${this.ClientConfig.version}/response\`, errors: { 500: \`Message for 500 error\`, 501: \`Message for 501 error\`, 502: \`Message for 502 error\`, }, - }, this.openApiConfig, config); + }, this.ClientConfig, config); } /** @@ -5578,20 +5578,20 @@ export class ResponseService { * @returns ModelThatExtendsExtends Message for 202 response * @throws ApiError */ - public async callWithResponses(config?: OpenAPIConfig): Promise, } | ModelWithString | ModelThatExtends | ModelThatExtendsExtends>> { return this.httpRequest.request({ method: 'PUT', - path: \`/api/v\${this.openApiConfig.version}/response\`, + path: \`/api/v\${this.ClientConfig.version}/response\`, errors: { 500: \`Message for 500 error\`, 501: \`Message for 501 error\`, 502: \`Message for 502 error\`, }, - }, this.openApiConfig, config); + }, this.ClientConfig, config); } }" @@ -5602,92 +5602,92 @@ exports[`v3 should generate with exportClient: ./test/generated/v3_client/servic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; export class SimpleService { private readonly httpRequest: BaseHttpRequest; - private readonly openApiConfig: OpenAPIConfig; + private readonly ClientConfig: ClientConfig; - constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { + constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.openApiConfig = openApiConfig; + this.ClientConfig = ClientConfig; } /** * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async getCallWithoutParametersAndResponse(config?: OpenAPIConfig): Promise> { + public async getCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.openApiConfig.version}/simple\`, - }, this.openApiConfig, config); + path: \`/api/v\${this.ClientConfig.version}/simple\`, + }, this.ClientConfig, config); } /** * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async putCallWithoutParametersAndResponse(config?: OpenAPIConfig): Promise> { + public async putCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'PUT', - path: \`/api/v\${this.openApiConfig.version}/simple\`, - }, this.openApiConfig, config); + path: \`/api/v\${this.ClientConfig.version}/simple\`, + }, this.ClientConfig, config); } /** * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async postCallWithoutParametersAndResponse(config?: OpenAPIConfig): Promise> { + public async postCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'POST', - path: \`/api/v\${this.openApiConfig.version}/simple\`, - }, this.openApiConfig, config); + path: \`/api/v\${this.ClientConfig.version}/simple\`, + }, this.ClientConfig, config); } /** * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async deleteCallWithoutParametersAndResponse(config?: OpenAPIConfig): Promise> { + public async deleteCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'DELETE', - path: \`/api/v\${this.openApiConfig.version}/simple\`, - }, this.openApiConfig, config); + path: \`/api/v\${this.ClientConfig.version}/simple\`, + }, this.ClientConfig, config); } /** * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async optionsCallWithoutParametersAndResponse(config?: OpenAPIConfig): Promise> { + public async optionsCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'OPTIONS', - path: \`/api/v\${this.openApiConfig.version}/simple\`, - }, this.openApiConfig, config); + path: \`/api/v\${this.ClientConfig.version}/simple\`, + }, this.ClientConfig, config); } /** * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async headCallWithoutParametersAndResponse(config?: OpenAPIConfig): Promise> { + public async headCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'HEAD', - path: \`/api/v\${this.openApiConfig.version}/simple\`, - }, this.openApiConfig, config); + path: \`/api/v\${this.ClientConfig.version}/simple\`, + }, this.ClientConfig, config); } /** * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async patchCallWithoutParametersAndResponse(config?: OpenAPIConfig): Promise> { + public async patchCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'PATCH', - path: \`/api/v\${this.openApiConfig.version}/simple\`, - }, this.openApiConfig, config); + path: \`/api/v\${this.ClientConfig.version}/simple\`, + }, this.ClientConfig, config); } }" @@ -5698,15 +5698,15 @@ exports[`v3 should generate with exportClient: ./test/generated/v3_client/servic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; export class TypesService { private readonly httpRequest: BaseHttpRequest; - private readonly openApiConfig: OpenAPIConfig; + private readonly ClientConfig: ClientConfig; - constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { + constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.openApiConfig = openApiConfig; + this.ClientConfig = ClientConfig; } /** @@ -5734,11 +5734,11 @@ export class TypesService { parameterBoolean: boolean | null = true, parameterObject: any = null, id?: number, - config?: OpenAPIConfig + config?: ClientConfig ): Promise> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.openApiConfig.version}/types\`, + path: \`/api/v\${this.ClientConfig.version}/types\`, query: { 'parameterArray': parameterArray, 'parameterDictionary': parameterDictionary, @@ -5748,7 +5748,7 @@ export class TypesService { 'parameterBoolean': parameterBoolean, 'parameterObject': parameterObject, }, - }, this.openApiConfig, config); + }, this.ClientConfig, config); } }" @@ -5759,15 +5759,15 @@ exports[`v3 should generate with exportClient: ./test/generated/v3_client/servic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ApiResult, BaseHttpRequest, OpenAPIConfig } from '../core'; +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; export class UploadService { private readonly httpRequest: BaseHttpRequest; - private readonly openApiConfig: OpenAPIConfig; + private readonly ClientConfig: ClientConfig; - constructor(httpRequest: BaseHttpRequest, openApiConfig: OpenAPIConfig) { + constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.openApiConfig = openApiConfig; + this.ClientConfig = ClientConfig; } /** @@ -5778,15 +5778,15 @@ export class UploadService { */ public async uploadFile( file: Blob, - config?: OpenAPIConfig + config?: ClientConfig ): Promise> { return this.httpRequest.request({ method: 'POST', - path: \`/api/v\${this.openApiConfig.version}/upload\`, + path: \`/api/v\${this.ClientConfig.version}/upload\`, formData: { 'file': file, }, - }, this.openApiConfig, config); + }, this.ClientConfig, config); } }" diff --git a/test/__snapshots__/index.spec.js.snap b/test/__snapshots__/index.spec.js.snap index 4eb63f9cc..2ac53f64f 100644 --- a/test/__snapshots__/index.spec.js.snap +++ b/test/__snapshots__/index.spec.js.snap @@ -67,7 +67,7 @@ import type { ApiRequestOptions } from './ApiRequestOptions'; type Resolver = (options: ApiRequestOptions) => Promise; type Headers = Record; -export type OpenAPIConfig = { +export type ClientConfig = { baseUrl?: string; version?: string; withCredentials?: boolean; @@ -76,7 +76,7 @@ export type OpenAPIConfig = { password?: string | Resolver; headers?: Headers | Resolver; } -export const OpenAPI: OpenAPIConfig = { +export const OpenAPI: ClientConfig = { baseUrl: 'http://localhost:3000/base', version: '1.0', withCredentials: false, @@ -109,7 +109,7 @@ exports[`v2 should generate: ./test/generated/v2/core/request.ts 1`] = ` import { ApiError } from './ApiError'; import type { ApiRequestOptions } from './ApiRequestOptions'; import type { ApiResult } from './ApiResult'; -import type { OpenAPIConfig } from './OpenAPI'; +import type { ClientConfig } from './OpenAPI'; import { OpenAPI } from './OpenAPI'; function isDefined(value: T | null | undefined): value is Exclude { @@ -168,7 +168,7 @@ function getQueryString(params: Record): string { return ''; } -function getUrl(options: ApiRequestOptions, config: OpenAPIConfig): string { +function getUrl(options: ApiRequestOptions, config: ClientConfig): string { const path = options.path.replace(/[:]/g, '_'); const url = \`\${config.baseUrl}\${path}\`; @@ -198,7 +198,7 @@ async function resolve(options: ApiRequestOptions, resolver?: T | Resolver return resolver; } -async function getHeaders(options: ApiRequestOptions, config: OpenAPIConfig): Promise { +async function getHeaders(options: ApiRequestOptions, config: ClientConfig): Promise { const token = await resolve(options, config.token); const username = await resolve(options, config.username); const password = await resolve(options, config.password); @@ -249,7 +249,7 @@ function getRequestBody(options: ApiRequestOptions): BodyInit | undefined { return undefined; } -async function sendRequest(options: ApiRequestOptions, config: OpenAPIConfig, url: string): Promise { +async function sendRequest(options: ApiRequestOptions, config: ClientConfig, url: string): Promise { const request: RequestInit = { method: options.method, headers: await getHeaders(options, config), @@ -2623,7 +2623,7 @@ import type { ApiRequestOptions } from './ApiRequestOptions'; type Resolver = (options: ApiRequestOptions) => Promise; type Headers = Record; -export type OpenAPIConfig = { +export type ClientConfig = { baseUrl?: string; version?: string; withCredentials?: boolean; @@ -2632,7 +2632,7 @@ export type OpenAPIConfig = { password?: string | Resolver; headers?: Headers | Resolver; } -export const OpenAPI: OpenAPIConfig = { +export const OpenAPI: ClientConfig = { baseUrl: 'http://localhost:3000/base', version: '1.0', withCredentials: false, @@ -2665,7 +2665,7 @@ exports[`v3 should generate: ./test/generated/v3/core/request.ts 1`] = ` import { ApiError } from './ApiError'; import type { ApiRequestOptions } from './ApiRequestOptions'; import type { ApiResult } from './ApiResult'; -import type { OpenAPIConfig } from './OpenAPI'; +import type { ClientConfig } from './OpenAPI'; import { OpenAPI } from './OpenAPI'; function isDefined(value: T | null | undefined): value is Exclude { @@ -2724,7 +2724,7 @@ function getQueryString(params: Record): string { return ''; } -function getUrl(options: ApiRequestOptions, config: OpenAPIConfig): string { +function getUrl(options: ApiRequestOptions, config: ClientConfig): string { const path = options.path.replace(/[:]/g, '_'); const url = \`\${config.baseUrl}\${path}\`; @@ -2754,7 +2754,7 @@ async function resolve(options: ApiRequestOptions, resolver?: T | Resolver return resolver; } -async function getHeaders(options: ApiRequestOptions, config: OpenAPIConfig): Promise { +async function getHeaders(options: ApiRequestOptions, config: ClientConfig): Promise { const token = await resolve(options, config.token); const username = await resolve(options, config.username); const password = await resolve(options, config.password); @@ -2805,7 +2805,7 @@ function getRequestBody(options: ApiRequestOptions): BodyInit | undefined { return undefined; } -async function sendRequest(options: ApiRequestOptions, config: OpenAPIConfig, url: string): Promise { +async function sendRequest(options: ApiRequestOptions, config: ClientConfig, url: string): Promise { const request: RequestInit = { method: options.method, headers: await getHeaders(options, config), From 93c0088de8c71272b24d018137c64663b4226e44 Mon Sep 17 00:00:00 2001 From: lub0v-parsable Date: Thu, 26 Aug 2021 16:30:34 -0700 Subject: [PATCH 08/11] PE-2229 - add full reference --- src/templates/partials/passParameters.hbs | 14 + src/templates/services/exportService.hbs | 77 +- src/templates/services/exportServiceFull.hbs | 109 ++ src/templates/services/index.hbs | 1 + src/utils/postProcessServiceOperations.ts | 2 +- src/utils/registerHandlebarTemplates.ts | 5 + src/utils/writeClientServices.spec.ts | 2 + src/utils/writeClientServices.ts | 12 + test/__snapshots__/index.client.spec.js.snap | 1852 +++++++++++++++--- test/__snapshots__/index.spec.js.snap | 1226 +++++++++++- test/e2e/v2.babel.spec.js | 6 +- test/e2e/v2.fetch.spec.js | 8 +- test/e2e/v2.node.spec.js | 8 +- test/e2e/v2.xhr.spec.js | 8 +- test/e2e/v3.babel.spec.js | 12 +- test/e2e/v3.fetch.spec.js | 12 +- test/e2e/v3.node.spec.js | 12 +- test/e2e/v3.xhr.spec.js | 10 +- 18 files changed, 2990 insertions(+), 386 deletions(-) create mode 100644 src/templates/partials/passParameters.hbs create mode 100644 src/templates/services/exportServiceFull.hbs diff --git a/src/templates/partials/passParameters.hbs b/src/templates/partials/passParameters.hbs new file mode 100644 index 000000000..6c90d4249 --- /dev/null +++ b/src/templates/partials/passParameters.hbs @@ -0,0 +1,14 @@ +{{#if parameters}} +{{#if @root.useOptions~}} +{ +{{#each parameters}} + {{{name}}}, +{{/each}} +}{{#if @root.exportClient}}, config{{/if}} +{{~else}} +{{#each parameters}} + {{{name}}}, +{{/each}} +{{#if @root.exportClient}}config{{/if}} +{{/if}} +{{else}}{{#if @root.exportClient}}config{{/if}}{{/if}} diff --git a/src/templates/services/exportService.hbs b/src/templates/services/exportService.hbs index 201c092e1..cb64e4627 100644 --- a/src/templates/services/exportService.hbs +++ b/src/templates/services/exportService.hbs @@ -3,30 +3,25 @@ {{#if imports}} import type { {{#each imports}} - {{{this}}}, +{{{this}}}, {{/each}} } from '../models'; {{/if}} {{#if @root.exportClient}} -import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; -{{else}} -import type { ApiResult } from '../core'; -import { - request as __request, -{{#if @root.useVersion}} - OpenAPI, -{{/if}} -} from '../core'; +import type { BaseHttpRequest, ClientConfig } from '../core'; {{/if}} +import { {{{name}}}Full } from './{{{name}}}Full'; export class {{{name}}} { {{#if @root.exportClient}} private readonly httpRequest: BaseHttpRequest; - private readonly ClientConfig: ClientConfig; + private readonly clientConfig: ClientConfig; + readonly full: {{{name}}}Full; - constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.ClientConfig = ClientConfig; + this.clientConfig = clientConfig; + this.full = new {{{name}}}Full(httpRequest, clientConfig); } {{/if}} @@ -54,56 +49,12 @@ export class {{{name}}} { {{/each}} * @throws ApiError */ - public{{#unless @root.exportClient}} static{{/unless}} async {{{name}}}({{>parameters}}): Promiseresult}}>> { - return {{#if @root.exportClient}}this.httpRequest.request{{else}}__request{{/if}}({ - method: '{{{method}}}', - path: `{{{path}}}`, - {{#if parametersCookie}} - cookies: { - {{#each parametersCookie}} - '{{{prop}}}': {{{name}}}, - {{/each}} - }, - {{/if}} - {{#if parametersHeader}} - headers: { - {{#each parametersHeader}} - '{{{prop}}}': {{{name}}}, - {{/each}} - }, - {{/if}} - {{#if parametersQuery}} - query: { - {{#each parametersQuery}} - '{{{prop}}}': {{{name}}}, - {{/each}} - }, - {{/if}} - {{#if parametersForm}} - formData: { - {{#each parametersForm}} - '{{{prop}}}': {{{name}}}, - {{/each}} - }, - {{/if}} - {{#if parametersBody}} - body: {{{parametersBody.name}}}, - {{#if parametersBody.mediaType}} - mediaType: '{{{parametersBody.mediaType}}}', - {{/if}} - {{/if}} - {{#if responseHeader}} - responseHeader: '{{{responseHeader}}}', - {{/if}} - {{#if errors}} - errors: { - {{#each errors}} - {{{code}}}: `{{{description}}}`, - {{/each}} - }, - {{/if}} - }{{#if @root.exportClient}}, this.ClientConfig, config{{/if}}); + public{{#unless @root.exportClient}} static{{/unless}} async {{{name}}}({{>parameters}}): Promise<{{>result}}> { + {{#if @root.exportClient}} + return (await this.full.{{{name}}}({{>passParameters}})).body; + {{else}} + return (await {{{@root.name}}}Full.{{{name}}}({{>passParameters}})).body; + {{/if}} } - {{/each}} } diff --git a/src/templates/services/exportServiceFull.hbs b/src/templates/services/exportServiceFull.hbs new file mode 100644 index 000000000..df742f3f5 --- /dev/null +++ b/src/templates/services/exportServiceFull.hbs @@ -0,0 +1,109 @@ +{{>header}} + +{{#if imports}} +import type { +{{#each imports}} + {{{this}}}, +{{/each}} +} from '../models'; +{{/if}} +{{#if @root.exportClient}} +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; +{{else}} +import type { ApiResult } from '../core'; +import { + request as __request, +{{#if @root.useVersion}} + OpenAPI, +{{/if}} +} from '../core'; +{{/if}} + +export class {{{name}}}Full { + {{#if @root.exportClient}} + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + } + {{/if}} + + {{#each operations}} + /** + {{#if deprecated}} + * @deprecated + {{/if}} + {{#if summary}} + * {{{summary}}} + {{/if}} + {{#if description}} + * {{{description}}} + {{/if}} + {{#unless @root.useOptions}} + {{#if parameters}} + {{#each parameters}} + * @param {{{name}}} {{{description}}} + {{/each}} + {{/if}} + {{/unless}} + {{#if @root.exportClient}}* @param [config] the optional OpenAPI config to use{{/if}} + {{#each results}} + * @returns {{{type}}} {{{description}}} + {{/each}} + * @throws ApiError + */ + public{{#unless @root.exportClient}} static{{/unless}} async {{{name}}}({{>parameters}}): Promiseresult}}>> { + return {{#if @root.exportClient}}this.httpRequest.request{{else}}__request{{/if}}({ + method: '{{{method}}}', + path: `{{{path}}}`, + {{#if parametersCookie}} + cookies: { + {{#each parametersCookie}} + '{{{prop}}}': {{{name}}}, + {{/each}} + }, + {{/if}} + {{#if parametersHeader}} + headers: { + {{#each parametersHeader}} + '{{{prop}}}': {{{name}}}, + {{/each}} + }, + {{/if}} + {{#if parametersQuery}} + query: { + {{#each parametersQuery}} + '{{{prop}}}': {{{name}}}, + {{/each}} + }, + {{/if}} + {{#if parametersForm}} + formData: { + {{#each parametersForm}} + '{{{prop}}}': {{{name}}}, + {{/each}} + }, + {{/if}} + {{#if parametersBody}} + body: {{{parametersBody.name}}}, + {{#if parametersBody.mediaType}} + mediaType: '{{{parametersBody.mediaType}}}', + {{/if}} + {{/if}} + {{#if responseHeader}} + responseHeader: '{{{responseHeader}}}', + {{/if}} + {{#if errors}} + errors: { + {{#each errors}} + {{{code}}}: `{{{description}}}`, + {{/each}} + }, + {{/if}} + }{{#if @root.exportClient}}, this.clientConfig, config{{/if}}); + } + + {{/each}} +} diff --git a/src/templates/services/index.hbs b/src/templates/services/index.hbs index 3b7b27a9e..4b5c22683 100644 --- a/src/templates/services/index.hbs +++ b/src/templates/services/index.hbs @@ -2,4 +2,5 @@ {{#each services}} export { {{{name}}} } from './{{{name}}}'; +export { {{{name}}}Full } from './{{{name}}}Full'; {{/each}} diff --git a/src/utils/postProcessServiceOperations.ts b/src/utils/postProcessServiceOperations.ts index 33c9a88a2..88c0e235b 100644 --- a/src/utils/postProcessServiceOperations.ts +++ b/src/utils/postProcessServiceOperations.ts @@ -22,7 +22,7 @@ export function postProcessServiceOperations(service: Service, exportClient: boo names.set(name, index + 1); // Update the operation path with the dynamically injected version - clone.path = clone.path.replace('${apiVersion}', exportClient ? '${this.ClientConfig.version}' : '${OpenAPI.version}'); + clone.path = clone.path.replace('${apiVersion}', exportClient ? '${this.clientConfig.version}' : '${OpenAPI.version}'); return clone; }); diff --git a/src/utils/registerHandlebarTemplates.ts b/src/utils/registerHandlebarTemplates.ts index 0363220bf..7de4c2daa 100644 --- a/src/utils/registerHandlebarTemplates.ts +++ b/src/utils/registerHandlebarTemplates.ts @@ -52,6 +52,7 @@ import partialIsNullable from '../templates/partials/isNullable.hbs'; import partialIsReadOnly from '../templates/partials/isReadOnly.hbs'; import partialIsRequired from '../templates/partials/isRequired.hbs'; import partialParameters from '../templates/partials/parameters.hbs'; +import partialPassParameters from '../templates/partials/passParameters.hbs'; import partialResult from '../templates/partials/result.hbs'; import partialSchema from '../templates/partials/schema.hbs'; import partialSchemaArray from '../templates/partials/schemaArray.hbs'; @@ -72,6 +73,7 @@ import partialTypeUnion from '../templates/partials/typeUnion.hbs'; import templateExportSchema from '../templates/schemas/exportSchema.hbs'; import templateExportSchemaIndex from '../templates/schemas/index.hbs'; import templateExportService from '../templates/services/exportService.hbs'; +import templateExportServiceFull from '../templates/services/exportServiceFull.hbs'; import templateExportServiceIndex from '../templates/services/index.hbs'; import { registerHandlebarHelpers } from './registerHandlebarHelpers'; @@ -84,6 +86,7 @@ export interface Templates { }; services: { service: Handlebars.TemplateDelegate; + serviceFull: Handlebars.TemplateDelegate; index: Handlebars.TemplateDelegate; }; schemas: { @@ -123,6 +126,7 @@ export function registerHandlebarTemplates(root: { httpClient: HttpClient; useOp }, services: { service: Handlebars.template(templateExportService), + serviceFull: Handlebars.template(templateExportServiceFull), index: Handlebars.template(templateExportServiceIndex), }, schemas: { @@ -155,6 +159,7 @@ export function registerHandlebarTemplates(root: { httpClient: HttpClient; useOp Handlebars.registerPartial('isReadOnly', Handlebars.template(partialIsReadOnly)); Handlebars.registerPartial('isRequired', Handlebars.template(partialIsRequired)); Handlebars.registerPartial('parameters', Handlebars.template(partialParameters)); + Handlebars.registerPartial('passParameters', Handlebars.template(partialPassParameters)); Handlebars.registerPartial('result', Handlebars.template(partialResult)); Handlebars.registerPartial('schema', Handlebars.template(partialSchema)); Handlebars.registerPartial('schemaArray', Handlebars.template(partialSchemaArray)); diff --git a/src/utils/writeClientServices.spec.ts b/src/utils/writeClientServices.spec.ts index 6e44dc2b7..d5eda3a31 100644 --- a/src/utils/writeClientServices.spec.ts +++ b/src/utils/writeClientServices.spec.ts @@ -25,6 +25,7 @@ describe('writeClientServices', () => { }, services: { service: () => 'service', + serviceFull: () => 'serviceFull', index: () => 'serviceIndex', }, schemas: { @@ -50,6 +51,7 @@ describe('writeClientServices', () => { await writeClientServices(services, templates, '/', HttpClient.FETCH, false, false, false); expect(writeFile).toBeCalledWith('/MyService.ts', 'service'); + expect(writeFile).toBeCalledWith('/MyServiceFull.ts', 'serviceFull'); expect(writeFile).toBeCalledWith('/index.ts', 'serviceIndex'); }); }); diff --git a/src/utils/writeClientServices.ts b/src/utils/writeClientServices.ts index e901bcb3a..79f2450de 100644 --- a/src/utils/writeClientServices.ts +++ b/src/utils/writeClientServices.ts @@ -42,6 +42,18 @@ export async function writeClientServices( httpClientRequest: getHttpRequestName(httpClient), }); await writeFile(file, format(templateResult)); + + const fileFull = resolve(outputPath, `${service.name}Full.ts`); + const templateFullResult = templates.services.serviceFull({ + ...service, + httpClient, + useUnionTypes, + useVersion, + useOptions, + exportClient, + httpClientRequest: getHttpRequestName(httpClient), + }); + await writeFile(fileFull, format(templateFullResult)); } await writeFile(resolve(outputPath, 'index.ts'), templates.services.index({ services: sortServicesByName(services) })); diff --git a/test/__snapshots__/index.client.spec.js.snap b/test/__snapshots__/index.client.spec.js.snap index 88da3bab8..a1e29d384 100644 --- a/test/__snapshots__/index.client.spec.js.snap +++ b/test/__snapshots__/index.client.spec.js.snap @@ -1968,15 +1968,62 @@ exports[`v2 should generate with exportClient: ./test/generated/v2_client/servic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; +import type { BaseHttpRequest, ClientConfig } from '../core'; +import { CollectionFormatServiceFull } from './CollectionFormatServiceFull'; export class CollectionFormatService { private readonly httpRequest: BaseHttpRequest; - private readonly ClientConfig: ClientConfig; + private readonly clientConfig: ClientConfig; + readonly full: CollectionFormatServiceFull; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + this.full = new CollectionFormatServiceFull(httpRequest, clientConfig); + } + + /** + * @param parameterArrayCsv This is an array parameter that is send as csv format (comma-separated values) + * @param parameterArraySsv This is an array parameter that is send as ssv format (space-separated values) + * @param parameterArrayTsv This is an array parameter that is send as tsv format (tab-separated values) + * @param parameterArrayPipes This is an array parameter that is send as pipes format (pipe-separated values) + * @param parameterArrayMulti This is an array parameter that is send as multi format (multiple parameter instances) + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async collectionFormat( + parameterArrayCsv: Array, + parameterArraySsv: Array, + parameterArrayTsv: Array, + parameterArrayPipes: Array, + parameterArrayMulti: Array, + config?: ClientConfig + ): Promise { + return (await this.full.collectionFormat( parameterArrayCsv, + parameterArraySsv, + parameterArrayTsv, + parameterArrayPipes, + parameterArrayMulti, + config + )).body; +} +}" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/CollectionFormatServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; + +export class CollectionFormatServiceFull { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; - constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.ClientConfig = ClientConfig; + this.clientConfig = clientConfig; } /** @@ -1998,7 +2045,7 @@ export class CollectionFormatService { ): Promise> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.ClientConfig.version}/collectionFormat\`, + path: \`/api/v\${this.clientConfig.version}/collectionFormat\`, query: { 'parameterArrayCSV': parameterArrayCsv, 'parameterArraySSV': parameterArraySsv, @@ -2006,7 +2053,7 @@ export class CollectionFormatService { 'parameterArrayPipes': parameterArrayPipes, 'parameterArrayMulti': parameterArrayMulti, }, - }, this.ClientConfig, config); + }, this.clientConfig, config); } }" @@ -2020,15 +2067,63 @@ exports[`v2 should generate with exportClient: ./test/generated/v2_client/servic import type { ModelWithString, } from '../models'; -import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; +import type { BaseHttpRequest, ClientConfig } from '../core'; +import { ComplexServiceFull } from './ComplexServiceFull'; export class ComplexService { private readonly httpRequest: BaseHttpRequest; - private readonly ClientConfig: ClientConfig; + private readonly clientConfig: ClientConfig; + readonly full: ComplexServiceFull; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + this.full = new ComplexServiceFull(httpRequest, clientConfig); + } + + /** + * @param parameterObject Parameter containing object + * @param parameterReference Parameter containing reference + * @param [config] the optional OpenAPI config to use + * @returns ModelWithString Successful response + * @throws ApiError + */ + public async complexTypes( + parameterObject: { + first?: { + second?: { + third?: string, + }, + }, + }, + parameterReference: ModelWithString, + config?: ClientConfig + ): Promise> { + return (await this.full.complexTypes( parameterObject, + parameterReference, + config + )).body; +} +}" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/ComplexServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { + ModelWithString, +} from '../models'; +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; + +export class ComplexServiceFull { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; - constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.ClientConfig = ClientConfig; + this.clientConfig = clientConfig; } /** @@ -2051,7 +2146,7 @@ export class ComplexService { ): Promise>> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.ClientConfig.version}/complex\`, + path: \`/api/v\${this.clientConfig.version}/complex\`, query: { 'parameterObject': parameterObject, 'parameterReference': parameterReference, @@ -2060,7 +2155,7 @@ export class ComplexService { 400: \`400 server error\`, 500: \`500 server error\`, }, - }, this.ClientConfig, config); + }, this.clientConfig, config); } }" @@ -2074,15 +2169,122 @@ exports[`v2 should generate with exportClient: ./test/generated/v2_client/servic import type { ModelWithString, } from '../models'; -import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; +import type { BaseHttpRequest, ClientConfig } from '../core'; +import { DefaultsServiceFull } from './DefaultsServiceFull'; export class DefaultsService { private readonly httpRequest: BaseHttpRequest; - private readonly ClientConfig: ClientConfig; + private readonly clientConfig: ClientConfig; + readonly full: DefaultsServiceFull; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + this.full = new DefaultsServiceFull(httpRequest, clientConfig); + } + + /** + * @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 + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async callWithDefaultParameters( + parameterString: string = 'Hello World!', + parameterNumber: number = 123, + parameterBoolean: boolean = true, + parameterEnum: 'Success' | 'Warning' | 'Error' = 'Success', + parameterModel: ModelWithString = { + \\"prop\\": \\"Hello World!\\" + }, + config?: ClientConfig + ): Promise { + return (await this.full.callWithDefaultParameters( parameterString, + parameterNumber, + parameterBoolean, + parameterEnum, + parameterModel, + config + )).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 + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ +public async callWithDefaultOptionalParameters( + parameterString: string = 'Hello World!', + parameterNumber: number = 123, + parameterBoolean: boolean = true, + parameterEnum: 'Success' | 'Warning' | 'Error' = 'Success', + parameterModel: ModelWithString = { + \\"prop\\": \\"Hello World!\\" + }, + config?: ClientConfig +): Promise { + return (await this.full.callWithDefaultOptionalParameters( parameterString, + parameterNumber, + parameterBoolean, + parameterEnum, + parameterModel, + config +)).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 + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ +public async callToTestOrderOfParams( + parameterStringWithNoDefault: string, + parameterOptionalStringWithDefault: string = 'Hello World!', + parameterOptionalStringWithEmptyDefault: string = '', + parameterOptionalStringWithNoDefault?: string, + parameterStringWithDefault: string = 'Hello World!', + parameterStringWithEmptyDefault: string = '', + config?: ClientConfig +): Promise { + return (await this.full.callToTestOrderOfParams( parameterStringWithNoDefault, + parameterOptionalStringWithDefault, + parameterOptionalStringWithEmptyDefault, + parameterOptionalStringWithNoDefault, + parameterStringWithDefault, + parameterStringWithEmptyDefault, + config +)).body; +} +}" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/DefaultsServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { + ModelWithString, +} from '../models'; +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; + +export class DefaultsServiceFull { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; - constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.ClientConfig = ClientConfig; + this.clientConfig = clientConfig; } /** @@ -2106,7 +2308,7 @@ export class DefaultsService { ): Promise> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.ClientConfig.version}/defaults\`, + path: \`/api/v\${this.clientConfig.version}/defaults\`, query: { 'parameterString': parameterString, 'parameterNumber': parameterNumber, @@ -2114,7 +2316,7 @@ export class DefaultsService { 'parameterEnum': parameterEnum, 'parameterModel': parameterModel, }, - }, this.ClientConfig, config); + }, this.clientConfig, config); } /** @@ -2138,7 +2340,7 @@ export class DefaultsService { ): Promise> { return this.httpRequest.request({ method: 'POST', - path: \`/api/v\${this.ClientConfig.version}/defaults\`, + path: \`/api/v\${this.clientConfig.version}/defaults\`, query: { 'parameterString': parameterString, 'parameterNumber': parameterNumber, @@ -2146,7 +2348,7 @@ export class DefaultsService { 'parameterEnum': parameterEnum, 'parameterModel': parameterModel, }, - }, this.ClientConfig, config); + }, this.clientConfig, config); } /** @@ -2170,7 +2372,7 @@ export class DefaultsService { ): Promise> { return this.httpRequest.request({ method: 'PUT', - path: \`/api/v\${this.ClientConfig.version}/defaults\`, + path: \`/api/v\${this.clientConfig.version}/defaults\`, query: { 'parameterStringWithNoDefault': parameterStringWithNoDefault, 'parameterOptionalStringWithDefault': parameterOptionalStringWithDefault, @@ -2179,7 +2381,7 @@ export class DefaultsService { 'parameterStringWithDefault': parameterStringWithDefault, 'parameterStringWithEmptyDefault': parameterStringWithEmptyDefault, }, - }, this.ClientConfig, config); + }, this.clientConfig, config); } }" @@ -2190,15 +2392,65 @@ exports[`v2 should generate with exportClient: ./test/generated/v2_client/servic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; +import type { BaseHttpRequest, ClientConfig } from '../core'; +import { DuplicateServiceFull } from './DuplicateServiceFull'; export class DuplicateService { private readonly httpRequest: BaseHttpRequest; - private readonly ClientConfig: ClientConfig; + private readonly clientConfig: ClientConfig; + readonly full: DuplicateServiceFull; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + this.full = new DuplicateServiceFull(httpRequest, clientConfig); + } + + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async duplicateName(config?: ClientConfig): Promise { + return (await this.full.duplicateName(config)).body; + } + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async duplicateName1(config?: ClientConfig): Promise { + return (await this.full.duplicateName1(config)).body; + } + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async duplicateName2(config?: ClientConfig): Promise { + return (await this.full.duplicateName2(config)).body; + } + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async duplicateName3(config?: ClientConfig): Promise { + return (await this.full.duplicateName3(config)).body; + } +}" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/DuplicateServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; + +export class DuplicateServiceFull { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; - constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.ClientConfig = ClientConfig; + this.clientConfig = clientConfig; } /** @@ -2208,8 +2460,8 @@ export class DuplicateService { public async duplicateName(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.ClientConfig.version}/duplicate\`, - }, this.ClientConfig, config); + path: \`/api/v\${this.clientConfig.version}/duplicate\`, + }, this.clientConfig, config); } /** @@ -2219,8 +2471,8 @@ export class DuplicateService { public async duplicateName1(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'POST', - path: \`/api/v\${this.ClientConfig.version}/duplicate\`, - }, this.ClientConfig, config); + path: \`/api/v\${this.clientConfig.version}/duplicate\`, + }, this.clientConfig, config); } /** @@ -2230,8 +2482,8 @@ export class DuplicateService { public async duplicateName2(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'PUT', - path: \`/api/v\${this.ClientConfig.version}/duplicate\`, - }, this.ClientConfig, config); + path: \`/api/v\${this.clientConfig.version}/duplicate\`, + }, this.clientConfig, config); } /** @@ -2241,8 +2493,8 @@ export class DuplicateService { public async duplicateName3(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'DELETE', - path: \`/api/v\${this.ClientConfig.version}/duplicate\`, - }, this.ClientConfig, config); + path: \`/api/v\${this.clientConfig.version}/duplicate\`, + }, this.clientConfig, config); } }" @@ -2253,15 +2505,45 @@ exports[`v2 should generate with exportClient: ./test/generated/v2_client/servic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; +import type { BaseHttpRequest, ClientConfig } from '../core'; +import { HeaderServiceFull } from './HeaderServiceFull'; export class HeaderService { private readonly httpRequest: BaseHttpRequest; - private readonly ClientConfig: ClientConfig; + private readonly clientConfig: ClientConfig; + readonly full: HeaderServiceFull; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + this.full = new HeaderServiceFull(httpRequest, clientConfig); + } + + /** + * @param [config] the optional OpenAPI config to use + * @returns string Successful response + * @throws ApiError + */ + public async callWithResultFromHeader(config?: ClientConfig): Promise { + return (await this.full.callWithResultFromHeader(config)).body; + } +}" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/HeaderServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; + +export class HeaderServiceFull { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; - constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.ClientConfig = ClientConfig; + this.clientConfig = clientConfig; } /** @@ -2272,13 +2554,13 @@ export class HeaderService { public async callWithResultFromHeader(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'POST', - path: \`/api/v\${this.ClientConfig.version}/header\`, + path: \`/api/v\${this.clientConfig.version}/header\`, responseHeader: 'operation-location', errors: { 400: \`400 server error\`, 500: \`500 server error\`, }, - }, this.ClientConfig, config); + }, this.clientConfig, config); } }" @@ -2289,15 +2571,45 @@ exports[`v2 should generate with exportClient: ./test/generated/v2_client/servic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; +import type { BaseHttpRequest, ClientConfig } from '../core'; +import { NoContentServiceFull } from './NoContentServiceFull'; export class NoContentService { private readonly httpRequest: BaseHttpRequest; - private readonly ClientConfig: ClientConfig; + private readonly clientConfig: ClientConfig; + readonly full: NoContentServiceFull; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + this.full = new NoContentServiceFull(httpRequest, clientConfig); + } + + /** + * @param [config] the optional OpenAPI config to use + * @returns void + * @throws ApiError + */ + public async callWithNoContentResponse(config?: ClientConfig): Promise { + return (await this.full.callWithNoContentResponse(config)).body; + } +}" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/NoContentServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; + +export class NoContentServiceFull { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; - constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.ClientConfig = ClientConfig; + this.clientConfig = clientConfig; } /** @@ -2308,8 +2620,8 @@ export class NoContentService { public async callWithNoContentResponse(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.ClientConfig.version}/no-content\`, - }, this.ClientConfig, config); + path: \`/api/v\${this.clientConfig.version}/no-content\`, + }, this.clientConfig, config); } }" @@ -2320,15 +2632,96 @@ exports[`v2 should generate with exportClient: ./test/generated/v2_client/servic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; +import type { BaseHttpRequest, ClientConfig } from '../core'; +import { ParametersServiceFull } from './ParametersServiceFull'; export class ParametersService { private readonly httpRequest: BaseHttpRequest; - private readonly ClientConfig: ClientConfig; + private readonly clientConfig: ClientConfig; + readonly full: ParametersServiceFull; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + this.full = new ParametersServiceFull(httpRequest, clientConfig); + } + + /** + * @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 + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async callWithParameters( + parameterHeader: string, + parameterQuery: string, + parameterForm: string, + parameterBody: string, + parameterPath: string, + config?: ClientConfig + ): Promise { + return (await this.full.callWithParameters( parameterHeader, + parameterQuery, + parameterForm, + parameterBody, + parameterPath, + config + )).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 + * @param _default This is the parameter with a reserved keyword + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ +public async callWithWeirdParameterNames( + parameterHeader: string, + parameterQuery: string, + parameterForm: string, + parameterBody: string, + parameterPath1?: string, + parameterPath2?: string, + parameterPath3?: string, + _default?: string, + config?: ClientConfig +): Promise { + return (await this.full.callWithWeirdParameterNames( parameterHeader, + parameterQuery, + parameterForm, + parameterBody, + parameterPath1, + parameterPath2, + parameterPath3, + _default, + config +)).body; +} +}" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/ParametersServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; + +export class ParametersServiceFull { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; - constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.ClientConfig = ClientConfig; + this.clientConfig = clientConfig; } /** @@ -2350,7 +2743,7 @@ export class ParametersService { ): Promise> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.ClientConfig.version}/parameters/\${parameterPath}\`, + path: \`/api/v\${this.clientConfig.version}/parameters/\${parameterPath}\`, headers: { 'parameterHeader': parameterHeader, }, @@ -2361,7 +2754,7 @@ export class ParametersService { 'parameterForm': parameterForm, }, body: parameterBody, - }, this.ClientConfig, config); + }, this.clientConfig, config); } /** @@ -2389,7 +2782,7 @@ export class ParametersService { ): Promise> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.ClientConfig.version}/parameters/\${parameterPath1}/\${parameterPath2}/\${parameterPath3}\`, + path: \`/api/v\${this.clientConfig.version}/parameters/\${parameterPath1}/\${parameterPath2}/\${parameterPath3}\`, headers: { 'parameter.header': parameterHeader, }, @@ -2401,7 +2794,7 @@ export class ParametersService { 'parameter_form': parameterForm, }, body: parameterBody, - }, this.ClientConfig, config); + }, this.clientConfig, config); } }" @@ -2417,15 +2810,18 @@ import type { ModelThatExtendsExtends, ModelWithString, } from '../models'; -import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; +import type { BaseHttpRequest, ClientConfig } from '../core'; +import { ResponseServiceFull } from './ResponseServiceFull'; export class ResponseService { private readonly httpRequest: BaseHttpRequest; - private readonly ClientConfig: ClientConfig; + private readonly clientConfig: ClientConfig; + readonly full: ResponseServiceFull; - constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.ClientConfig = ClientConfig; + this.clientConfig = clientConfig; + this.full = new ResponseServiceFull(httpRequest, clientConfig); } /** @@ -2433,30 +2829,17 @@ export class ResponseService { * @returns ModelWithString Message for default response * @throws ApiError */ - public async callWithResponse(config?: ClientConfig): Promise> { - return this.httpRequest.request({ - method: 'GET', - path: \`/api/v\${this.ClientConfig.version}/response\`, - }, this.ClientConfig, config); + public async callWithResponse(config?: ClientConfig): Promise { + return (await this.full.callWithResponse(config)).body; } - /** * @param [config] the optional OpenAPI config to use * @returns ModelWithString Message for default response * @throws ApiError */ - public async callWithDuplicateResponses(config?: ClientConfig): Promise> { - return this.httpRequest.request({ - method: 'POST', - path: \`/api/v\${this.ClientConfig.version}/response\`, - errors: { - 500: \`Message for 500 error\`, - 501: \`Message for 501 error\`, - 502: \`Message for 502 error\`, - }, - }, this.ClientConfig, config); + public async callWithDuplicateResponses(config?: ClientConfig): Promise { + return (await this.full.callWithDuplicateResponses(config)).body; } - /** * @param [config] the optional OpenAPI config to use * @returns any Message for 200 response @@ -2465,39 +2848,178 @@ export class ResponseService { * @returns ModelThatExtendsExtends Message for 202 response * @throws ApiError */ - public async callWithResponses(config?: ClientConfig): Promise, - } | ModelWithString | ModelThatExtends | ModelThatExtendsExtends>> { - return this.httpRequest.request({ - method: 'PUT', - path: \`/api/v\${this.ClientConfig.version}/response\`, - errors: { - 500: \`Message for 500 error\`, - 501: \`Message for 501 error\`, - 502: \`Message for 502 error\`, - }, - }, this.ClientConfig, config); + } | ModelWithString | ModelThatExtends | ModelThatExtendsExtends> { + return (await this.full.callWithResponses(config)).body; } - }" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/SimpleService.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/ResponseServiceFull.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { + ModelThatExtends, + ModelThatExtendsExtends, + ModelWithString, +} from '../models'; import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; -export class SimpleService { +export class ResponseServiceFull { private readonly httpRequest: BaseHttpRequest; - private readonly ClientConfig: ClientConfig; + private readonly clientConfig: ClientConfig; - constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.ClientConfig = ClientConfig; + this.clientConfig = clientConfig; + } + + /** + * @param [config] the optional OpenAPI config to use + * @returns ModelWithString Message for default response + * @throws ApiError + */ + public async callWithResponse(config?: ClientConfig): Promise> { + return this.httpRequest.request({ + method: 'GET', + path: \`/api/v\${this.clientConfig.version}/response\`, + }, this.clientConfig, config); + } + + /** + * @param [config] the optional OpenAPI config to use + * @returns ModelWithString Message for default response + * @throws ApiError + */ + public async callWithDuplicateResponses(config?: ClientConfig): Promise> { + return this.httpRequest.request({ + method: 'POST', + path: \`/api/v\${this.clientConfig.version}/response\`, + errors: { + 500: \`Message for 500 error\`, + 501: \`Message for 501 error\`, + 502: \`Message for 502 error\`, + }, + }, this.clientConfig, config); + } + + /** + * @param [config] the optional OpenAPI config to use + * @returns any Message for 200 response + * @returns ModelWithString Message for default response + * @returns ModelThatExtends Message for 201 response + * @returns ModelThatExtendsExtends Message for 202 response + * @throws ApiError + */ + public async callWithResponses(config?: ClientConfig): Promise, + } | ModelWithString | ModelThatExtends | ModelThatExtendsExtends>> { + return this.httpRequest.request({ + method: 'PUT', + path: \`/api/v\${this.clientConfig.version}/response\`, + errors: { + 500: \`Message for 500 error\`, + 501: \`Message for 501 error\`, + 502: \`Message for 502 error\`, + }, + }, this.clientConfig, config); + } + +}" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/SimpleService.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { BaseHttpRequest, ClientConfig } from '../core'; +import { SimpleServiceFull } from './SimpleServiceFull'; + +export class SimpleService { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; + readonly full: SimpleServiceFull; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + this.full = new SimpleServiceFull(httpRequest, clientConfig); + } + + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async getCallWithoutParametersAndResponse(config?: ClientConfig): Promise { + return (await this.full.getCallWithoutParametersAndResponse(config)).body; + } + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async putCallWithoutParametersAndResponse(config?: ClientConfig): Promise { + return (await this.full.putCallWithoutParametersAndResponse(config)).body; + } + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async postCallWithoutParametersAndResponse(config?: ClientConfig): Promise { + return (await this.full.postCallWithoutParametersAndResponse(config)).body; + } + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async deleteCallWithoutParametersAndResponse(config?: ClientConfig): Promise { + return (await this.full.deleteCallWithoutParametersAndResponse(config)).body; + } + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async optionsCallWithoutParametersAndResponse(config?: ClientConfig): Promise { + return (await this.full.optionsCallWithoutParametersAndResponse(config)).body; + } + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async headCallWithoutParametersAndResponse(config?: ClientConfig): Promise { + return (await this.full.headCallWithoutParametersAndResponse(config)).body; + } + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async patchCallWithoutParametersAndResponse(config?: ClientConfig): Promise { + return (await this.full.patchCallWithoutParametersAndResponse(config)).body; + } +}" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/SimpleServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; + +export class SimpleServiceFull { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; } /** @@ -2507,8 +3029,8 @@ export class SimpleService { public async getCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.ClientConfig.version}/simple\`, - }, this.ClientConfig, config); + path: \`/api/v\${this.clientConfig.version}/simple\`, + }, this.clientConfig, config); } /** @@ -2518,8 +3040,8 @@ export class SimpleService { public async putCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'PUT', - path: \`/api/v\${this.ClientConfig.version}/simple\`, - }, this.ClientConfig, config); + path: \`/api/v\${this.clientConfig.version}/simple\`, + }, this.clientConfig, config); } /** @@ -2529,8 +3051,8 @@ export class SimpleService { public async postCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'POST', - path: \`/api/v\${this.ClientConfig.version}/simple\`, - }, this.ClientConfig, config); + path: \`/api/v\${this.clientConfig.version}/simple\`, + }, this.clientConfig, config); } /** @@ -2540,8 +3062,8 @@ export class SimpleService { public async deleteCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'DELETE', - path: \`/api/v\${this.ClientConfig.version}/simple\`, - }, this.ClientConfig, config); + path: \`/api/v\${this.clientConfig.version}/simple\`, + }, this.clientConfig, config); } /** @@ -2551,8 +3073,8 @@ export class SimpleService { public async optionsCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'OPTIONS', - path: \`/api/v\${this.ClientConfig.version}/simple\`, - }, this.ClientConfig, config); + path: \`/api/v\${this.clientConfig.version}/simple\`, + }, this.clientConfig, config); } /** @@ -2562,8 +3084,8 @@ export class SimpleService { public async headCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'HEAD', - path: \`/api/v\${this.ClientConfig.version}/simple\`, - }, this.ClientConfig, config); + path: \`/api/v\${this.clientConfig.version}/simple\`, + }, this.clientConfig, config); } /** @@ -2573,8 +3095,8 @@ export class SimpleService { public async patchCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'PATCH', - path: \`/api/v\${this.ClientConfig.version}/simple\`, - }, this.ClientConfig, config); + path: \`/api/v\${this.clientConfig.version}/simple\`, + }, this.clientConfig, config); } }" @@ -2585,15 +3107,75 @@ exports[`v2 should generate with exportClient: ./test/generated/v2_client/servic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; +import type { BaseHttpRequest, ClientConfig } from '../core'; +import { TypesServiceFull } from './TypesServiceFull'; export class TypesService { private readonly httpRequest: BaseHttpRequest; - private readonly ClientConfig: ClientConfig; + private readonly clientConfig: ClientConfig; + readonly full: TypesServiceFull; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + this.full = new TypesServiceFull(httpRequest, clientConfig); + } + + /** + * @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 + * @param [config] the optional OpenAPI config to use + * @returns number Response is a simple number + * @returns string Response is a simple string + * @returns boolean Response is a simple boolean + * @returns any Response is a simple object + * @throws ApiError + */ + public async types( + parameterArray: Array, + parameterDictionary: Record, + parameterEnum: 'Success' | 'Warning' | 'Error', + parameterNumber: number = 123, + parameterString: string = 'default', + parameterBoolean: boolean = true, + parameterObject: any = null, + id?: number, + config?: ClientConfig + ): Promise { + return (await this.full.types( parameterArray, + parameterDictionary, + parameterEnum, + parameterNumber, + parameterString, + parameterBoolean, + parameterObject, + id, + config + )).body; +} +}" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/TypesServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; + +export class TypesServiceFull { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; - constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.ClientConfig = ClientConfig; + this.clientConfig = clientConfig; } /** @@ -2625,7 +3207,7 @@ export class TypesService { ): Promise> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.ClientConfig.version}/types\`, + path: \`/api/v\${this.clientConfig.version}/types\`, query: { 'parameterArray': parameterArray, 'parameterDictionary': parameterDictionary, @@ -2635,7 +3217,7 @@ export class TypesService { 'parameterBoolean': parameterBoolean, 'parameterObject': parameterObject, }, - }, this.ClientConfig, config); + }, this.clientConfig, config); } }" @@ -2647,15 +3229,25 @@ exports[`v2 should generate with exportClient: ./test/generated/v2_client/servic /* tslint:disable */ /* eslint-disable */ export { CollectionFormatService } from './CollectionFormatService'; +export { CollectionFormatServiceFull } from './CollectionFormatServiceFull'; export { ComplexService } from './ComplexService'; +export { ComplexServiceFull } from './ComplexServiceFull'; export { DefaultsService } from './DefaultsService'; +export { DefaultsServiceFull } from './DefaultsServiceFull'; export { DuplicateService } from './DuplicateService'; +export { DuplicateServiceFull } from './DuplicateServiceFull'; export { HeaderService } from './HeaderService'; +export { HeaderServiceFull } from './HeaderServiceFull'; export { NoContentService } from './NoContentService'; +export { NoContentServiceFull } from './NoContentServiceFull'; export { ParametersService } from './ParametersService'; +export { ParametersServiceFull } from './ParametersServiceFull'; export { ResponseService } from './ResponseService'; +export { ResponseServiceFull } from './ResponseServiceFull'; export { SimpleService } from './SimpleService'; +export { SimpleServiceFull } from './SimpleServiceFull'; export { TypesService } from './TypesService'; +export { TypesServiceFull } from './TypesServiceFull'; " `; @@ -4911,15 +5503,62 @@ exports[`v3 should generate with exportClient: ./test/generated/v3_client/servic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; +import type { BaseHttpRequest, ClientConfig } from '../core'; +import { CollectionFormatServiceFull } from './CollectionFormatServiceFull'; export class CollectionFormatService { private readonly httpRequest: BaseHttpRequest; - private readonly ClientConfig: ClientConfig; + private readonly clientConfig: ClientConfig; + readonly full: CollectionFormatServiceFull; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + this.full = new CollectionFormatServiceFull(httpRequest, clientConfig); + } + + /** + * @param parameterArrayCsv This is an array parameter that is send as csv format (comma-separated values) + * @param parameterArraySsv This is an array parameter that is send as ssv format (space-separated values) + * @param parameterArrayTsv This is an array parameter that is send as tsv format (tab-separated values) + * @param parameterArrayPipes This is an array parameter that is send as pipes format (pipe-separated values) + * @param parameterArrayMulti This is an array parameter that is send as multi format (multiple parameter instances) + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async collectionFormat( + parameterArrayCsv: Array | null, + parameterArraySsv: Array | null, + parameterArrayTsv: Array | null, + parameterArrayPipes: Array | null, + parameterArrayMulti: Array | null, + config?: ClientConfig + ): Promise { + return (await this.full.collectionFormat( parameterArrayCsv, + parameterArraySsv, + parameterArrayTsv, + parameterArrayPipes, + parameterArrayMulti, + config + )).body; +} +}" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/CollectionFormatServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; + +export class CollectionFormatServiceFull { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; - constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.ClientConfig = ClientConfig; + this.clientConfig = clientConfig; } /** @@ -4941,7 +5580,7 @@ export class CollectionFormatService { ): Promise> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.ClientConfig.version}/collectionFormat\`, + path: \`/api/v\${this.clientConfig.version}/collectionFormat\`, query: { 'parameterArrayCSV': parameterArrayCsv, 'parameterArraySSV': parameterArraySsv, @@ -4949,7 +5588,7 @@ export class CollectionFormatService { 'parameterArrayPipes': parameterArrayPipes, 'parameterArrayMulti': parameterArrayMulti, }, - }, this.ClientConfig, config); + }, this.clientConfig, config); } }" @@ -4966,15 +5605,95 @@ import type { ModelWithEnum, ModelWithString, } from '../models'; -import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; +import type { BaseHttpRequest, ClientConfig } from '../core'; +import { ComplexServiceFull } from './ComplexServiceFull'; export class ComplexService { private readonly httpRequest: BaseHttpRequest; - private readonly ClientConfig: ClientConfig; + private readonly clientConfig: ClientConfig; + readonly full: ComplexServiceFull; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + this.full = new ComplexServiceFull(httpRequest, clientConfig); + } + + /** + * @param parameterObject Parameter containing object + * @param parameterReference Parameter containing reference + * @param [config] the optional OpenAPI config to use + * @returns ModelWithString Successful response + * @throws ApiError + */ + public async complexTypes( + parameterObject: { + first?: { + second?: { + third?: string, + }, + }, + }, + parameterReference: ModelWithString, + config?: ClientConfig + ): Promise> { + return (await this.full.complexTypes( parameterObject, + parameterReference, + config + )).body; +} +/** + * @param id + * @param requestBody + * @param [config] the optional OpenAPI config to use + * @returns ModelWithString Success + * @throws ApiError + */ +public 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: (ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary), + readonly user?: { + readonly id?: number, + readonly name?: string | null, + }, + }, + config?: ClientConfig +): Promise { + return (await this.full.complexParams( id, + requestBody, + config +)).body; +} +}" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/ComplexServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { + ModelWithArray, + ModelWithDictionary, + ModelWithEnum, + ModelWithString, +} from '../models'; +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; + +export class ComplexServiceFull { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; - constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.ClientConfig = ClientConfig; + this.clientConfig = clientConfig; } /** @@ -4997,7 +5716,7 @@ export class ComplexService { ): Promise>> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.ClientConfig.version}/complex\`, + path: \`/api/v\${this.clientConfig.version}/complex\`, query: { 'parameterObject': parameterObject, 'parameterReference': parameterReference, @@ -5006,7 +5725,7 @@ export class ComplexService { 400: \`400 server error\`, 500: \`500 server error\`, }, - }, this.ClientConfig, config); + }, this.clientConfig, config); } /** @@ -5035,10 +5754,10 @@ export class ComplexService { ): Promise> { return this.httpRequest.request({ method: 'PUT', - path: \`/api/v\${this.ClientConfig.version}/complex/\${id}\`, + path: \`/api/v\${this.clientConfig.version}/complex/\${id}\`, body: requestBody, mediaType: 'application/json-patch+json', - }, this.ClientConfig, config); + }, this.clientConfig, config); } }" @@ -5052,15 +5771,18 @@ exports[`v3 should generate with exportClient: ./test/generated/v3_client/servic import type { ModelWithString, } from '../models'; -import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; +import type { BaseHttpRequest, ClientConfig } from '../core'; +import { DefaultsServiceFull } from './DefaultsServiceFull'; export class DefaultsService { private readonly httpRequest: BaseHttpRequest; - private readonly ClientConfig: ClientConfig; + private readonly clientConfig: ClientConfig; + readonly full: DefaultsServiceFull; - constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.ClientConfig = ClientConfig; + this.clientConfig = clientConfig; + this.full = new DefaultsServiceFull(httpRequest, clientConfig); } /** @@ -5081,26 +5803,130 @@ export class DefaultsService { \\"prop\\": \\"Hello World!\\" }, config?: ClientConfig - ): Promise> { - return this.httpRequest.request({ - method: 'GET', - path: \`/api/v\${this.ClientConfig.version}/defaults\`, - query: { - 'parameterString': parameterString, - 'parameterNumber': parameterNumber, - 'parameterBoolean': parameterBoolean, - 'parameterEnum': parameterEnum, - 'parameterModel': parameterModel, - }, - }, this.ClientConfig, config); - } + ): Promise { + return (await this.full.callWithDefaultParameters( parameterString, + parameterNumber, + parameterBoolean, + parameterEnum, + parameterModel, + config + )).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 + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ +public async callWithDefaultOptionalParameters( + parameterString: string = 'Hello World!', + parameterNumber: number = 123, + parameterBoolean: boolean = true, + parameterEnum: 'Success' | 'Warning' | 'Error' = 'Success', + parameterModel: ModelWithString = { + \\"prop\\": \\"Hello World!\\" + }, + config?: ClientConfig +): Promise { + return (await this.full.callWithDefaultOptionalParameters( parameterString, + parameterNumber, + parameterBoolean, + parameterEnum, + parameterModel, + config +)).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 + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ +public async callToTestOrderOfParams( + parameterStringWithNoDefault: string, + parameterOptionalStringWithDefault: string = 'Hello World!', + parameterOptionalStringWithEmptyDefault: string = '', + parameterOptionalStringWithNoDefault?: string, + parameterStringWithDefault: string = 'Hello World!', + parameterStringWithEmptyDefault: string = '', + config?: ClientConfig +): Promise { + return (await this.full.callToTestOrderOfParams( parameterStringWithNoDefault, + parameterOptionalStringWithDefault, + parameterOptionalStringWithEmptyDefault, + parameterOptionalStringWithNoDefault, + parameterStringWithDefault, + parameterStringWithEmptyDefault, + config +)).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 +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/DefaultsServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { + ModelWithString, +} from '../models'; +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; + +export class DefaultsServiceFull { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + } + + /** + * @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 + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public 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!\\" + }, + config?: ClientConfig + ): Promise> { + return this.httpRequest.request({ + method: 'GET', + path: \`/api/v\${this.clientConfig.version}/defaults\`, + query: { + 'parameterString': parameterString, + 'parameterNumber': parameterNumber, + 'parameterBoolean': parameterBoolean, + 'parameterEnum': parameterEnum, + 'parameterModel': parameterModel, + }, + }, this.clientConfig, config); + } + + /** + * @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 * @param [config] the optional OpenAPI config to use * @throws ApiError */ @@ -5116,7 +5942,7 @@ export class DefaultsService { ): Promise> { return this.httpRequest.request({ method: 'POST', - path: \`/api/v\${this.ClientConfig.version}/defaults\`, + path: \`/api/v\${this.clientConfig.version}/defaults\`, query: { 'parameterString': parameterString, 'parameterNumber': parameterNumber, @@ -5124,7 +5950,7 @@ export class DefaultsService { 'parameterEnum': parameterEnum, 'parameterModel': parameterModel, }, - }, this.ClientConfig, config); + }, this.clientConfig, config); } /** @@ -5148,7 +5974,7 @@ export class DefaultsService { ): Promise> { return this.httpRequest.request({ method: 'PUT', - path: \`/api/v\${this.ClientConfig.version}/defaults\`, + path: \`/api/v\${this.clientConfig.version}/defaults\`, query: { 'parameterStringWithNoDefault': parameterStringWithNoDefault, 'parameterOptionalStringWithDefault': parameterOptionalStringWithDefault, @@ -5157,7 +5983,7 @@ export class DefaultsService { 'parameterStringWithDefault': parameterStringWithDefault, 'parameterStringWithEmptyDefault': parameterStringWithEmptyDefault, }, - }, this.ClientConfig, config); + }, this.clientConfig, config); } }" @@ -5168,15 +5994,65 @@ exports[`v3 should generate with exportClient: ./test/generated/v3_client/servic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; +import type { BaseHttpRequest, ClientConfig } from '../core'; +import { DuplicateServiceFull } from './DuplicateServiceFull'; export class DuplicateService { private readonly httpRequest: BaseHttpRequest; - private readonly ClientConfig: ClientConfig; + private readonly clientConfig: ClientConfig; + readonly full: DuplicateServiceFull; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + this.full = new DuplicateServiceFull(httpRequest, clientConfig); + } + + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async duplicateName(config?: ClientConfig): Promise { + return (await this.full.duplicateName(config)).body; + } + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async duplicateName1(config?: ClientConfig): Promise { + return (await this.full.duplicateName1(config)).body; + } + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async duplicateName2(config?: ClientConfig): Promise { + return (await this.full.duplicateName2(config)).body; + } + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async duplicateName3(config?: ClientConfig): Promise { + return (await this.full.duplicateName3(config)).body; + } +}" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/DuplicateServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; + +export class DuplicateServiceFull { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; - constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.ClientConfig = ClientConfig; + this.clientConfig = clientConfig; } /** @@ -5186,8 +6062,8 @@ export class DuplicateService { public async duplicateName(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.ClientConfig.version}/duplicate\`, - }, this.ClientConfig, config); + path: \`/api/v\${this.clientConfig.version}/duplicate\`, + }, this.clientConfig, config); } /** @@ -5197,8 +6073,8 @@ export class DuplicateService { public async duplicateName1(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'POST', - path: \`/api/v\${this.ClientConfig.version}/duplicate\`, - }, this.ClientConfig, config); + path: \`/api/v\${this.clientConfig.version}/duplicate\`, + }, this.clientConfig, config); } /** @@ -5208,8 +6084,8 @@ export class DuplicateService { public async duplicateName2(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'PUT', - path: \`/api/v\${this.ClientConfig.version}/duplicate\`, - }, this.ClientConfig, config); + path: \`/api/v\${this.clientConfig.version}/duplicate\`, + }, this.clientConfig, config); } /** @@ -5219,8 +6095,8 @@ export class DuplicateService { public async duplicateName3(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'DELETE', - path: \`/api/v\${this.ClientConfig.version}/duplicate\`, - }, this.ClientConfig, config); + path: \`/api/v\${this.clientConfig.version}/duplicate\`, + }, this.clientConfig, config); } }" @@ -5231,15 +6107,45 @@ exports[`v3 should generate with exportClient: ./test/generated/v3_client/servic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; +import type { BaseHttpRequest, ClientConfig } from '../core'; +import { HeaderServiceFull } from './HeaderServiceFull'; export class HeaderService { private readonly httpRequest: BaseHttpRequest; - private readonly ClientConfig: ClientConfig; + private readonly clientConfig: ClientConfig; + readonly full: HeaderServiceFull; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + this.full = new HeaderServiceFull(httpRequest, clientConfig); + } + + /** + * @param [config] the optional OpenAPI config to use + * @returns string Successful response + * @throws ApiError + */ + public async callWithResultFromHeader(config?: ClientConfig): Promise { + return (await this.full.callWithResultFromHeader(config)).body; + } +}" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/HeaderServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; + +export class HeaderServiceFull { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; - constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.ClientConfig = ClientConfig; + this.clientConfig = clientConfig; } /** @@ -5250,13 +6156,13 @@ export class HeaderService { public async callWithResultFromHeader(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'POST', - path: \`/api/v\${this.ClientConfig.version}/header\`, + path: \`/api/v\${this.clientConfig.version}/header\`, responseHeader: 'operation-location', errors: { 400: \`400 server error\`, 500: \`500 server error\`, }, - }, this.ClientConfig, config); + }, this.clientConfig, config); } }" @@ -5267,15 +6173,51 @@ exports[`v3 should generate with exportClient: ./test/generated/v3_client/servic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; +import type { BaseHttpRequest, ClientConfig } from '../core'; +import { MultipartServiceFull } from './MultipartServiceFull'; export class MultipartService { private readonly httpRequest: BaseHttpRequest; - private readonly ClientConfig: ClientConfig; + private readonly clientConfig: ClientConfig; + readonly full: MultipartServiceFull; - constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.ClientConfig = ClientConfig; + this.clientConfig = clientConfig; + this.full = new MultipartServiceFull(httpRequest, clientConfig); + } + + /** + * @param [config] the optional OpenAPI config to use + * @returns any OK + * @throws ApiError + */ + public async multipartResponse(config?: ClientConfig): Promise<{ + file?: string, + metadata?: { + foo?: string, + bar?: string, + }, + }> { + return (await this.full.multipartResponse(config)).body; + } +}" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/MultipartServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; + +export class MultipartServiceFull { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; } /** @@ -5292,8 +6234,8 @@ export class MultipartService { }>> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.ClientConfig.version}/multipart\`, - }, this.ClientConfig, config); + path: \`/api/v\${this.clientConfig.version}/multipart\`, + }, this.clientConfig, config); } }" @@ -5304,15 +6246,45 @@ exports[`v3 should generate with exportClient: ./test/generated/v3_client/servic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; +import type { BaseHttpRequest, ClientConfig } from '../core'; +import { NoContentServiceFull } from './NoContentServiceFull'; export class NoContentService { private readonly httpRequest: BaseHttpRequest; - private readonly ClientConfig: ClientConfig; + private readonly clientConfig: ClientConfig; + readonly full: NoContentServiceFull; - constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.ClientConfig = ClientConfig; + this.clientConfig = clientConfig; + this.full = new NoContentServiceFull(httpRequest, clientConfig); + } + + /** + * @param [config] the optional OpenAPI config to use + * @returns void + * @throws ApiError + */ + public async callWithNoContentResponse(config?: ClientConfig): Promise { + return (await this.full.callWithNoContentResponse(config)).body; + } +}" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/NoContentServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; + +export class NoContentServiceFull { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; } /** @@ -5323,8 +6295,8 @@ export class NoContentService { public async callWithNoContentResponse(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.ClientConfig.version}/no-content\`, - }, this.ClientConfig, config); + path: \`/api/v\${this.clientConfig.version}/no-content\`, + }, this.clientConfig, config); } }" @@ -5338,15 +6310,137 @@ exports[`v3 should generate with exportClient: ./test/generated/v3_client/servic import type { ModelWithString, } from '../models'; -import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; +import type { BaseHttpRequest, ClientConfig } from '../core'; +import { ParametersServiceFull } from './ParametersServiceFull'; export class ParametersService { private readonly httpRequest: BaseHttpRequest; - private readonly ClientConfig: ClientConfig; + private readonly clientConfig: ClientConfig; + readonly full: ParametersServiceFull; - constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.ClientConfig = ClientConfig; + this.clientConfig = clientConfig; + this.full = new ParametersServiceFull(httpRequest, clientConfig); + } + + /** + * @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 + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async callWithParameters( + parameterHeader: string | null, + parameterQuery: string | null, + parameterForm: string | null, + parameterCookie: string | null, + parameterPath: string | null, + requestBody: ModelWithString | null, + config?: ClientConfig + ): Promise { + return (await this.full.callWithParameters( parameterHeader, + parameterQuery, + parameterForm, + parameterCookie, + parameterPath, + requestBody, + config + )).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 + * @param _default This is the parameter with a reserved keyword + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ +public async callWithWeirdParameterNames( + parameterHeader: string | null, + parameterQuery: string | null, + parameterForm: string | null, + parameterCookie: string | null, + requestBody: ModelWithString | null, + parameterPath1?: string, + parameterPath2?: string, + parameterPath3?: string, + _default?: string, + config?: ClientConfig +): Promise { + return (await this.full.callWithWeirdParameterNames( parameterHeader, + parameterQuery, + parameterForm, + parameterCookie, + requestBody, + parameterPath1, + parameterPath2, + parameterPath3, + _default, + config +)).body; +} +/** + * @param requestBody This is a required parameter + * @param parameter This is an optional parameter + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ +public async getCallWithOptionalParam( + requestBody: ModelWithString, + parameter?: string, + config?: ClientConfig +): Promise { + return (await this.full.getCallWithOptionalParam( requestBody, + parameter, + config +)).body; +} +/** + * @param parameter This is a required parameter + * @param requestBody This is an optional parameter + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ +public async postCallWithOptionalParam( + parameter: string, + requestBody?: ModelWithString, + config?: ClientConfig +): Promise { + return (await this.full.postCallWithOptionalParam( parameter, + requestBody, + config +)).body; +} +}" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/ParametersServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { + ModelWithString, +} from '../models'; +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; + +export class ParametersServiceFull { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; } /** @@ -5370,7 +6464,7 @@ export class ParametersService { ): Promise> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.ClientConfig.version}/parameters/\${parameterPath}\`, + path: \`/api/v\${this.clientConfig.version}/parameters/\${parameterPath}\`, cookies: { 'parameterCookie': parameterCookie, }, @@ -5385,7 +6479,7 @@ export class ParametersService { }, body: requestBody, mediaType: 'application/json', - }, this.ClientConfig, config); + }, this.clientConfig, config); } /** @@ -5415,7 +6509,7 @@ export class ParametersService { ): Promise> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.ClientConfig.version}/parameters/\${parameterPath1}/\${parameterPath2}/\${parameterPath3}\`, + path: \`/api/v\${this.clientConfig.version}/parameters/\${parameterPath1}/\${parameterPath2}/\${parameterPath3}\`, cookies: { 'PARAMETER-COOKIE': parameterCookie, }, @@ -5431,7 +6525,7 @@ export class ParametersService { }, body: requestBody, mediaType: 'application/json', - }, this.ClientConfig, config); + }, this.clientConfig, config); } /** @@ -5447,13 +6541,13 @@ export class ParametersService { ): Promise> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.ClientConfig.version}/parameters/\`, + path: \`/api/v\${this.clientConfig.version}/parameters/\`, query: { 'parameter': parameter, }, body: requestBody, mediaType: 'application/json', - }, this.ClientConfig, config); + }, this.clientConfig, config); } /** @@ -5469,13 +6563,13 @@ export class ParametersService { ): Promise> { return this.httpRequest.request({ method: 'POST', - path: \`/api/v\${this.ClientConfig.version}/parameters/\`, + path: \`/api/v\${this.clientConfig.version}/parameters/\`, query: { 'parameter': parameter, }, body: requestBody, mediaType: 'application/json', - }, this.ClientConfig, config); + }, this.clientConfig, config); } }" @@ -5489,15 +6583,53 @@ exports[`v3 should generate with exportClient: ./test/generated/v3_client/servic import type { ModelWithString, } from '../models'; -import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; +import type { BaseHttpRequest, ClientConfig } from '../core'; +import { RequestBodyServiceFull } from './RequestBodyServiceFull'; export class RequestBodyService { private readonly httpRequest: BaseHttpRequest; - private readonly ClientConfig: ClientConfig; + private readonly clientConfig: ClientConfig; + readonly full: RequestBodyServiceFull; - constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.ClientConfig = ClientConfig; + this.clientConfig = clientConfig; + this.full = new RequestBodyServiceFull(httpRequest, clientConfig); + } + + /** + * @param requestBody A reusable request body + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async postRequestBodyService( + requestBody?: ModelWithString, + config?: ClientConfig + ): Promise { + return (await this.full.postRequestBodyService( requestBody, + config + )).body; +} +}" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/RequestBodyServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { + ModelWithString, +} from '../models'; +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; + +export class RequestBodyServiceFull { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; } /** @@ -5511,10 +6643,10 @@ export class RequestBodyService { ): Promise> { return this.httpRequest.request({ method: 'POST', - path: \`/api/v\${this.ClientConfig.version}/requestBody/\`, + path: \`/api/v\${this.clientConfig.version}/requestBody/\`, body: requestBody, mediaType: 'application/json', - }, this.ClientConfig, config); + }, this.clientConfig, config); } }" @@ -5530,15 +6662,73 @@ import type { ModelThatExtendsExtends, ModelWithString, } from '../models'; -import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; +import type { BaseHttpRequest, ClientConfig } from '../core'; +import { ResponseServiceFull } from './ResponseServiceFull'; export class ResponseService { private readonly httpRequest: BaseHttpRequest; - private readonly ClientConfig: ClientConfig; + private readonly clientConfig: ClientConfig; + readonly full: ResponseServiceFull; - constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.ClientConfig = ClientConfig; + this.clientConfig = clientConfig; + this.full = new ResponseServiceFull(httpRequest, clientConfig); + } + + /** + * @param [config] the optional OpenAPI config to use + * @returns ModelWithString + * @throws ApiError + */ + public async callWithResponse(config?: ClientConfig): Promise { + return (await this.full.callWithResponse(config)).body; + } + /** + * @param [config] the optional OpenAPI config to use + * @returns ModelWithString Message for default response + * @throws ApiError + */ + public async callWithDuplicateResponses(config?: ClientConfig): Promise { + return (await this.full.callWithDuplicateResponses(config)).body; + } + /** + * @param [config] the optional OpenAPI config to use + * @returns any Message for 200 response + * @returns ModelWithString Message for default response + * @returns ModelThatExtends Message for 201 response + * @returns ModelThatExtendsExtends Message for 202 response + * @throws ApiError + */ + public async callWithResponses(config?: ClientConfig): Promise<{ + readonly '@namespace.string'?: string, + readonly '@namespace.integer'?: number, + readonly value?: Array, + } | ModelWithString | ModelThatExtends | ModelThatExtendsExtends> { + return (await this.full.callWithResponses(config)).body; + } +}" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/ResponseServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { + ModelThatExtends, + ModelThatExtendsExtends, + ModelWithString, +} from '../models'; +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; + +export class ResponseServiceFull { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; } /** @@ -5549,8 +6739,8 @@ export class ResponseService { public async callWithResponse(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.ClientConfig.version}/response\`, - }, this.ClientConfig, config); + path: \`/api/v\${this.clientConfig.version}/response\`, + }, this.clientConfig, config); } /** @@ -5561,13 +6751,13 @@ export class ResponseService { public async callWithDuplicateResponses(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'POST', - path: \`/api/v\${this.ClientConfig.version}/response\`, + path: \`/api/v\${this.clientConfig.version}/response\`, errors: { 500: \`Message for 500 error\`, 501: \`Message for 501 error\`, 502: \`Message for 502 error\`, }, - }, this.ClientConfig, config); + }, this.clientConfig, config); } /** @@ -5585,13 +6775,13 @@ export class ResponseService { } | ModelWithString | ModelThatExtends | ModelThatExtendsExtends>> { return this.httpRequest.request({ method: 'PUT', - path: \`/api/v\${this.ClientConfig.version}/response\`, + path: \`/api/v\${this.clientConfig.version}/response\`, errors: { 500: \`Message for 500 error\`, 501: \`Message for 501 error\`, 502: \`Message for 502 error\`, }, - }, this.ClientConfig, config); + }, this.clientConfig, config); } }" @@ -5602,15 +6792,86 @@ exports[`v3 should generate with exportClient: ./test/generated/v3_client/servic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; +import type { BaseHttpRequest, ClientConfig } from '../core'; +import { SimpleServiceFull } from './SimpleServiceFull'; export class SimpleService { private readonly httpRequest: BaseHttpRequest; - private readonly ClientConfig: ClientConfig; + private readonly clientConfig: ClientConfig; + readonly full: SimpleServiceFull; - constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.ClientConfig = ClientConfig; + this.clientConfig = clientConfig; + this.full = new SimpleServiceFull(httpRequest, clientConfig); + } + + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async getCallWithoutParametersAndResponse(config?: ClientConfig): Promise { + return (await this.full.getCallWithoutParametersAndResponse(config)).body; + } + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async putCallWithoutParametersAndResponse(config?: ClientConfig): Promise { + return (await this.full.putCallWithoutParametersAndResponse(config)).body; + } + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async postCallWithoutParametersAndResponse(config?: ClientConfig): Promise { + return (await this.full.postCallWithoutParametersAndResponse(config)).body; + } + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async deleteCallWithoutParametersAndResponse(config?: ClientConfig): Promise { + return (await this.full.deleteCallWithoutParametersAndResponse(config)).body; + } + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async optionsCallWithoutParametersAndResponse(config?: ClientConfig): Promise { + return (await this.full.optionsCallWithoutParametersAndResponse(config)).body; + } + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async headCallWithoutParametersAndResponse(config?: ClientConfig): Promise { + return (await this.full.headCallWithoutParametersAndResponse(config)).body; + } + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async patchCallWithoutParametersAndResponse(config?: ClientConfig): Promise { + return (await this.full.patchCallWithoutParametersAndResponse(config)).body; + } +}" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/SimpleServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; + +export class SimpleServiceFull { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; } /** @@ -5620,8 +6881,8 @@ export class SimpleService { public async getCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.ClientConfig.version}/simple\`, - }, this.ClientConfig, config); + path: \`/api/v\${this.clientConfig.version}/simple\`, + }, this.clientConfig, config); } /** @@ -5631,8 +6892,8 @@ export class SimpleService { public async putCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'PUT', - path: \`/api/v\${this.ClientConfig.version}/simple\`, - }, this.ClientConfig, config); + path: \`/api/v\${this.clientConfig.version}/simple\`, + }, this.clientConfig, config); } /** @@ -5642,8 +6903,8 @@ export class SimpleService { public async postCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'POST', - path: \`/api/v\${this.ClientConfig.version}/simple\`, - }, this.ClientConfig, config); + path: \`/api/v\${this.clientConfig.version}/simple\`, + }, this.clientConfig, config); } /** @@ -5653,8 +6914,8 @@ export class SimpleService { public async deleteCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'DELETE', - path: \`/api/v\${this.ClientConfig.version}/simple\`, - }, this.ClientConfig, config); + path: \`/api/v\${this.clientConfig.version}/simple\`, + }, this.clientConfig, config); } /** @@ -5664,8 +6925,8 @@ export class SimpleService { public async optionsCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'OPTIONS', - path: \`/api/v\${this.ClientConfig.version}/simple\`, - }, this.ClientConfig, config); + path: \`/api/v\${this.clientConfig.version}/simple\`, + }, this.clientConfig, config); } /** @@ -5675,8 +6936,8 @@ export class SimpleService { public async headCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'HEAD', - path: \`/api/v\${this.ClientConfig.version}/simple\`, - }, this.ClientConfig, config); + path: \`/api/v\${this.clientConfig.version}/simple\`, + }, this.clientConfig, config); } /** @@ -5686,8 +6947,8 @@ export class SimpleService { public async patchCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'PATCH', - path: \`/api/v\${this.ClientConfig.version}/simple\`, - }, this.ClientConfig, config); + path: \`/api/v\${this.clientConfig.version}/simple\`, + }, this.clientConfig, config); } }" @@ -5698,15 +6959,75 @@ exports[`v3 should generate with exportClient: ./test/generated/v3_client/servic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; +import type { BaseHttpRequest, ClientConfig } from '../core'; +import { TypesServiceFull } from './TypesServiceFull'; export class TypesService { private readonly httpRequest: BaseHttpRequest; - private readonly ClientConfig: ClientConfig; + private readonly clientConfig: ClientConfig; + readonly full: TypesServiceFull; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + this.full = new TypesServiceFull(httpRequest, clientConfig); + } + + /** + * @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 + * @param [config] the optional OpenAPI config to use + * @returns number Response is a simple number + * @returns string Response is a simple string + * @returns boolean Response is a simple boolean + * @returns any Response is a simple object + * @throws ApiError + */ + public 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, + config?: ClientConfig + ): Promise { + return (await this.full.types( parameterArray, + parameterDictionary, + parameterEnum, + parameterNumber, + parameterString, + parameterBoolean, + parameterObject, + id, + config + )).body; +} +}" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/TypesServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; + +export class TypesServiceFull { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; - constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.ClientConfig = ClientConfig; + this.clientConfig = clientConfig; } /** @@ -5738,7 +7059,7 @@ export class TypesService { ): Promise> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.ClientConfig.version}/types\`, + path: \`/api/v\${this.clientConfig.version}/types\`, query: { 'parameterArray': parameterArray, 'parameterDictionary': parameterDictionary, @@ -5748,7 +7069,7 @@ export class TypesService { 'parameterBoolean': parameterBoolean, 'parameterObject': parameterObject, }, - }, this.ClientConfig, config); + }, this.clientConfig, config); } }" @@ -5759,15 +7080,51 @@ exports[`v3 should generate with exportClient: ./test/generated/v3_client/servic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; +import type { BaseHttpRequest, ClientConfig } from '../core'; +import { UploadServiceFull } from './UploadServiceFull'; export class UploadService { private readonly httpRequest: BaseHttpRequest; - private readonly ClientConfig: ClientConfig; + private readonly clientConfig: ClientConfig; + readonly full: UploadServiceFull; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + this.full = new UploadServiceFull(httpRequest, clientConfig); + } + + /** + * @param file Supply a file reference for upload + * @param [config] the optional OpenAPI config to use + * @returns boolean + * @throws ApiError + */ + public async uploadFile( + file: Blob, + config?: ClientConfig + ): Promise { + return (await this.full.uploadFile( file, + config + )).body; +} +}" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/UploadServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; + +export class UploadServiceFull { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; - constructor(httpRequest: BaseHttpRequest, ClientConfig: ClientConfig) { + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { this.httpRequest = httpRequest; - this.ClientConfig = ClientConfig; + this.clientConfig = clientConfig; } /** @@ -5782,11 +7139,11 @@ export class UploadService { ): Promise> { return this.httpRequest.request({ method: 'POST', - path: \`/api/v\${this.ClientConfig.version}/upload\`, + path: \`/api/v\${this.clientConfig.version}/upload\`, formData: { 'file': file, }, - }, this.ClientConfig, config); + }, this.clientConfig, config); } }" @@ -5798,17 +7155,30 @@ exports[`v3 should generate with exportClient: ./test/generated/v3_client/servic /* tslint:disable */ /* eslint-disable */ export { CollectionFormatService } from './CollectionFormatService'; +export { CollectionFormatServiceFull } from './CollectionFormatServiceFull'; export { ComplexService } from './ComplexService'; +export { ComplexServiceFull } from './ComplexServiceFull'; export { DefaultsService } from './DefaultsService'; +export { DefaultsServiceFull } from './DefaultsServiceFull'; export { DuplicateService } from './DuplicateService'; +export { DuplicateServiceFull } from './DuplicateServiceFull'; export { HeaderService } from './HeaderService'; +export { HeaderServiceFull } from './HeaderServiceFull'; export { MultipartService } from './MultipartService'; +export { MultipartServiceFull } from './MultipartServiceFull'; export { NoContentService } from './NoContentService'; +export { NoContentServiceFull } from './NoContentServiceFull'; export { ParametersService } from './ParametersService'; +export { ParametersServiceFull } from './ParametersServiceFull'; export { RequestBodyService } from './RequestBodyService'; +export { RequestBodyServiceFull } from './RequestBodyServiceFull'; export { ResponseService } from './ResponseService'; +export { ResponseServiceFull } from './ResponseServiceFull'; export { SimpleService } from './SimpleService'; +export { SimpleServiceFull } from './SimpleServiceFull'; export { TypesService } from './TypesService'; +export { TypesServiceFull } from './TypesServiceFull'; export { UploadService } from './UploadService'; +export { UploadServiceFull } from './UploadServiceFull'; " `; diff --git a/test/__snapshots__/index.spec.js.snap b/test/__snapshots__/index.spec.js.snap index 2ac53f64f..4e7018161 100644 --- a/test/__snapshots__/index.spec.js.snap +++ b/test/__snapshots__/index.spec.js.snap @@ -1895,13 +1895,50 @@ exports[`v2 should generate: ./test/generated/v2/services/CollectionFormatServic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import { CollectionFormatServiceFull } from './CollectionFormatServiceFull'; + +export class CollectionFormatService { + + /** + * @param parameterArrayCsv This is an array parameter that is send as csv format (comma-separated values) + * @param parameterArraySsv This is an array parameter that is send as ssv format (space-separated values) + * @param parameterArrayTsv This is an array parameter that is send as tsv format (tab-separated values) + * @param parameterArrayPipes This is an array parameter that is send as pipes format (pipe-separated values) + * @param parameterArrayMulti This is an array parameter that is send as multi format (multiple parameter instances) + + * @throws ApiError + */ + public static async collectionFormat( + parameterArrayCsv: Array, + parameterArraySsv: Array, + parameterArrayTsv: Array, + parameterArrayPipes: Array, + parameterArrayMulti: Array, + + ): Promise { + return (await CollectionFormatServiceFull.collectionFormat( parameterArrayCsv, + parameterArraySsv, + parameterArrayTsv, + parameterArrayPipes, + parameterArrayMulti, + + )).body; +} +}" +`; + +exports[`v2 should generate: ./test/generated/v2/services/CollectionFormatServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ import type { ApiResult } from '../core'; import { request as __request, OpenAPI, } from '../core'; -export class CollectionFormatService { +export class CollectionFormatServiceFull { /** * @param parameterArrayCsv This is an array parameter that is send as csv format (comma-separated values) @@ -1944,13 +1981,51 @@ exports[`v2 should generate: ./test/generated/v2/services/ComplexService.ts 1`] import type { ModelWithString, } from '../models'; +import { ComplexServiceFull } from './ComplexServiceFull'; + +export class ComplexService { + + /** + * @param parameterObject Parameter containing object + * @param parameterReference Parameter containing reference + + * @returns ModelWithString Successful response + * @throws ApiError + */ + public static async complexTypes( + parameterObject: { + first?: { + second?: { + third?: string, + }, + }, + }, + parameterReference: ModelWithString, + + ): Promise> { + return (await ComplexServiceFull.complexTypes( parameterObject, + parameterReference, + + )).body; +} +}" +`; + +exports[`v2 should generate: ./test/generated/v2/services/ComplexServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { + ModelWithString, +} from '../models'; import type { ApiResult } from '../core'; import { request as __request, OpenAPI, } from '../core'; -export class ComplexService { +export class ComplexServiceFull { /** * @param parameterObject Parameter containing object @@ -1995,13 +2070,110 @@ exports[`v2 should generate: ./test/generated/v2/services/DefaultsService.ts 1`] import type { ModelWithString, } from '../models'; +import { DefaultsServiceFull } from './DefaultsServiceFull'; + +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 { + return (await DefaultsServiceFull.callWithDefaultParameters( parameterString, + parameterNumber, + parameterBoolean, + parameterEnum, + parameterModel, + + )).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 { + return (await DefaultsServiceFull.callWithDefaultOptionalParameters( parameterString, + parameterNumber, + parameterBoolean, + parameterEnum, + parameterModel, + +)).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 World!', + parameterStringWithEmptyDefault: string = '', + +): Promise { + return (await DefaultsServiceFull.callToTestOrderOfParams( parameterStringWithNoDefault, + parameterOptionalStringWithDefault, + parameterOptionalStringWithEmptyDefault, + parameterOptionalStringWithNoDefault, + parameterStringWithDefault, + parameterStringWithEmptyDefault, + +)).body; +} +}" +`; + +exports[`v2 should generate: ./test/generated/v2/services/DefaultsServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { + ModelWithString, +} from '../models'; import type { ApiResult } from '../core'; import { request as __request, OpenAPI, } from '../core'; -export class DefaultsService { +export class DefaultsServiceFull { /** * @param parameterString This is a simple string with default value @@ -2108,13 +2280,53 @@ exports[`v2 should generate: ./test/generated/v2/services/DuplicateService.ts 1` /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import { DuplicateServiceFull } from './DuplicateServiceFull'; + +export class DuplicateService { + + /** + + * @throws ApiError + */ + public static async duplicateName(): Promise { + return (await DuplicateServiceFull.duplicateName()).body; + } + /** + + * @throws ApiError + */ + public static async duplicateName1(): Promise { + return (await DuplicateServiceFull.duplicateName1()).body; + } + /** + + * @throws ApiError + */ + public static async duplicateName2(): Promise { + return (await DuplicateServiceFull.duplicateName2()).body; + } + /** + + * @throws ApiError + */ + public static async duplicateName3(): Promise { + return (await DuplicateServiceFull.duplicateName3()).body; + } +}" +`; + +exports[`v2 should generate: ./test/generated/v2/services/DuplicateServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ import type { ApiResult } from '../core'; import { request as __request, OpenAPI, } from '../core'; -export class DuplicateService { +export class DuplicateServiceFull { /** @@ -2168,13 +2380,33 @@ exports[`v2 should generate: ./test/generated/v2/services/HeaderService.ts 1`] = /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import { HeaderServiceFull } from './HeaderServiceFull'; + +export class HeaderService { + + /** + + * @returns string Successful response + * @throws ApiError + */ + public static async callWithResultFromHeader(): Promise { + return (await HeaderServiceFull.callWithResultFromHeader()).body; + } +}" +`; + +exports[`v2 should generate: ./test/generated/v2/services/HeaderServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ import type { ApiResult } from '../core'; import { request as __request, OpenAPI, } from '../core'; -export class HeaderService { +export class HeaderServiceFull { /** @@ -2201,13 +2433,33 @@ exports[`v2 should generate: ./test/generated/v2/services/NoContentService.ts 1` /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import { NoContentServiceFull } from './NoContentServiceFull'; + +export class NoContentService { + + /** + + * @returns void + * @throws ApiError + */ + public static async callWithNoContentResponse(): Promise { + return (await NoContentServiceFull.callWithNoContentResponse()).body; + } +}" +`; + +exports[`v2 should generate: ./test/generated/v2/services/NoContentServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ import type { ApiResult } from '../core'; import { request as __request, OpenAPI, } from '../core'; -export class NoContentService { +export class NoContentServiceFull { /** @@ -2229,13 +2481,84 @@ exports[`v2 should generate: ./test/generated/v2/services/ParametersService.ts 1 /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import { ParametersServiceFull } from './ParametersServiceFull'; + +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 { + return (await ParametersServiceFull.callWithParameters( parameterHeader, + parameterQuery, + parameterForm, + parameterBody, + parameterPath, + + )).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 + * @param _default This is the parameter with a reserved keyword + + * @throws ApiError + */ +public static async callWithWeirdParameterNames( + parameterHeader: string, + parameterQuery: string, + parameterForm: string, + parameterBody: string, + parameterPath1?: string, + parameterPath2?: string, + parameterPath3?: string, + _default?: string, + +): Promise { + return (await ParametersServiceFull.callWithWeirdParameterNames( parameterHeader, + parameterQuery, + parameterForm, + parameterBody, + parameterPath1, + parameterPath2, + parameterPath3, + _default, + +)).body; +} +}" +`; + +exports[`v2 should generate: ./test/generated/v2/services/ParametersServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ import type { ApiResult } from '../core'; import { request as __request, OpenAPI, } from '../core'; -export class ParametersService { +export class ParametersServiceFull { /** * @param parameterHeader This is the parameter that goes into the header @@ -2323,13 +2646,61 @@ import type { ModelThatExtendsExtends, ModelWithString, } from '../models'; +import { ResponseServiceFull } from './ResponseServiceFull'; + +export class ResponseService { + + /** + + * @returns ModelWithString Message for default response + * @throws ApiError + */ + public static async callWithResponse(): Promise { + return (await ResponseServiceFull.callWithResponse()).body; + } + /** + + * @returns ModelWithString Message for default response + * @throws ApiError + */ + public static async callWithDuplicateResponses(): Promise { + return (await ResponseServiceFull.callWithDuplicateResponses()).body; + } + /** + + * @returns any Message for 200 response + * @returns ModelWithString Message for default response + * @returns ModelThatExtends Message for 201 response + * @returns ModelThatExtendsExtends Message for 202 response + * @throws ApiError + */ + public static async callWithResponses(): Promise<{ + readonly '@namespace.string'?: string, + readonly '@namespace.integer'?: number, + readonly value?: Array, + } | ModelWithString | ModelThatExtends | ModelThatExtendsExtends> { + return (await ResponseServiceFull.callWithResponses()).body; + } +}" +`; + +exports[`v2 should generate: ./test/generated/v2/services/ResponseServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { + ModelThatExtends, + ModelThatExtendsExtends, + ModelWithString, +} from '../models'; import type { ApiResult } from '../core'; import { request as __request, OpenAPI, } from '../core'; -export class ResponseService { +export class ResponseServiceFull { /** @@ -2392,11 +2763,7 @@ exports[`v2 should generate: ./test/generated/v2/services/SimpleService.ts 1`] = /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ApiResult } from '../core'; -import { - request as __request, - OpenAPI, -} from '../core'; +import { SimpleServiceFull } from './SimpleServiceFull'; export class SimpleService { @@ -2404,9 +2771,74 @@ export class SimpleService { * @throws ApiError */ - public static async getCallWithoutParametersAndResponse(): Promise> { - return __request({ - method: 'GET', + public static async getCallWithoutParametersAndResponse(): Promise { + return (await SimpleServiceFull.getCallWithoutParametersAndResponse()).body; + } + /** + + * @throws ApiError + */ + public static async putCallWithoutParametersAndResponse(): Promise { + return (await SimpleServiceFull.putCallWithoutParametersAndResponse()).body; + } + /** + + * @throws ApiError + */ + public static async postCallWithoutParametersAndResponse(): Promise { + return (await SimpleServiceFull.postCallWithoutParametersAndResponse()).body; + } + /** + + * @throws ApiError + */ + public static async deleteCallWithoutParametersAndResponse(): Promise { + return (await SimpleServiceFull.deleteCallWithoutParametersAndResponse()).body; + } + /** + + * @throws ApiError + */ + public static async optionsCallWithoutParametersAndResponse(): Promise { + return (await SimpleServiceFull.optionsCallWithoutParametersAndResponse()).body; + } + /** + + * @throws ApiError + */ + public static async headCallWithoutParametersAndResponse(): Promise { + return (await SimpleServiceFull.headCallWithoutParametersAndResponse()).body; + } + /** + + * @throws ApiError + */ + public static async patchCallWithoutParametersAndResponse(): Promise { + return (await SimpleServiceFull.patchCallWithoutParametersAndResponse()).body; + } +}" +`; + +exports[`v2 should generate: ./test/generated/v2/services/SimpleServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ApiResult } from '../core'; +import { + request as __request, + OpenAPI, +} from '../core'; + +export class SimpleServiceFull { + + /** + + * @throws ApiError + */ + public static async getCallWithoutParametersAndResponse(): Promise> { + return __request({ + method: 'GET', path: \`/api/v\${OpenAPI.version}/simple\`, }); } @@ -2485,13 +2917,63 @@ exports[`v2 should generate: ./test/generated/v2/services/TypesService.ts 1`] = /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import { TypesServiceFull } from './TypesServiceFull'; + +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 + + * @returns number Response is a simple number + * @returns string Response is a simple string + * @returns boolean Response is a simple boolean + * @returns any Response is a simple object + * @throws ApiError + */ + public static async types( + parameterArray: Array, + parameterDictionary: Record, + parameterEnum: 'Success' | 'Warning' | 'Error', + parameterNumber: number = 123, + parameterString: string = 'default', + parameterBoolean: boolean = true, + parameterObject: any = null, + id?: number, + + ): Promise { + return (await TypesServiceFull.types( parameterArray, + parameterDictionary, + parameterEnum, + parameterNumber, + parameterString, + parameterBoolean, + parameterObject, + id, + + )).body; +} +}" +`; + +exports[`v2 should generate: ./test/generated/v2/services/TypesServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ import type { ApiResult } from '../core'; import { request as __request, OpenAPI, } from '../core'; -export class TypesService { +export class TypesServiceFull { /** * @param parameterArray This is an array parameter @@ -2544,15 +3026,25 @@ exports[`v2 should generate: ./test/generated/v2/services/index.ts 1`] = ` /* tslint:disable */ /* eslint-disable */ export { CollectionFormatService } from './CollectionFormatService'; +export { CollectionFormatServiceFull } from './CollectionFormatServiceFull'; export { ComplexService } from './ComplexService'; +export { ComplexServiceFull } from './ComplexServiceFull'; export { DefaultsService } from './DefaultsService'; +export { DefaultsServiceFull } from './DefaultsServiceFull'; export { DuplicateService } from './DuplicateService'; +export { DuplicateServiceFull } from './DuplicateServiceFull'; export { HeaderService } from './HeaderService'; +export { HeaderServiceFull } from './HeaderServiceFull'; export { NoContentService } from './NoContentService'; +export { NoContentServiceFull } from './NoContentServiceFull'; export { ParametersService } from './ParametersService'; +export { ParametersServiceFull } from './ParametersServiceFull'; export { ResponseService } from './ResponseService'; +export { ResponseServiceFull } from './ResponseServiceFull'; export { SimpleService } from './SimpleService'; +export { SimpleServiceFull } from './SimpleServiceFull'; export { TypesService } from './TypesService'; +export { TypesServiceFull } from './TypesServiceFull'; " `; @@ -4726,13 +5218,50 @@ exports[`v3 should generate: ./test/generated/v3/services/CollectionFormatServic /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import { CollectionFormatServiceFull } from './CollectionFormatServiceFull'; + +export class CollectionFormatService { + + /** + * @param parameterArrayCsv This is an array parameter that is send as csv format (comma-separated values) + * @param parameterArraySsv This is an array parameter that is send as ssv format (space-separated values) + * @param parameterArrayTsv This is an array parameter that is send as tsv format (tab-separated values) + * @param parameterArrayPipes This is an array parameter that is send as pipes format (pipe-separated values) + * @param parameterArrayMulti This is an array parameter that is send as multi format (multiple parameter instances) + + * @throws ApiError + */ + public static async collectionFormat( + parameterArrayCsv: Array | null, + parameterArraySsv: Array | null, + parameterArrayTsv: Array | null, + parameterArrayPipes: Array | null, + parameterArrayMulti: Array | null, + + ): Promise { + return (await CollectionFormatServiceFull.collectionFormat( parameterArrayCsv, + parameterArraySsv, + parameterArrayTsv, + parameterArrayPipes, + parameterArrayMulti, + + )).body; +} +}" +`; + +exports[`v3 should generate: ./test/generated/v3/services/CollectionFormatServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ import type { ApiResult } from '../core'; import { request as __request, OpenAPI, } from '../core'; -export class CollectionFormatService { +export class CollectionFormatServiceFull { /** * @param parameterArrayCsv This is an array parameter that is send as csv format (comma-separated values) @@ -4778,13 +5307,83 @@ import type { ModelWithEnum, ModelWithString, } from '../models'; +import { ComplexServiceFull } from './ComplexServiceFull'; + +export class ComplexService { + + /** + * @param parameterObject Parameter containing object + * @param parameterReference Parameter containing reference + + * @returns ModelWithString Successful response + * @throws ApiError + */ + public static async complexTypes( + parameterObject: { + first?: { + second?: { + third?: string, + }, + }, + }, + parameterReference: ModelWithString, + + ): Promise> { + return (await ComplexServiceFull.complexTypes( parameterObject, + parameterReference, + + )).body; +} +/** + * @param id + * @param requestBody + + * @returns 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: (ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary), + readonly user?: { + readonly id?: number, + readonly name?: string | null, + }, + }, + +): Promise { + return (await ComplexServiceFull.complexParams( id, + requestBody, + +)).body; +} +}" +`; + +exports[`v3 should generate: ./test/generated/v3/services/ComplexServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { + ModelWithArray, + ModelWithDictionary, + ModelWithEnum, + ModelWithString, +} from '../models'; import type { ApiResult } from '../core'; import { request as __request, OpenAPI, } from '../core'; -export class ComplexService { +export class ComplexServiceFull { /** * @param parameterObject Parameter containing object @@ -4861,13 +5460,110 @@ exports[`v3 should generate: ./test/generated/v3/services/DefaultsService.ts 1`] import type { ModelWithString, } from '../models'; +import { DefaultsServiceFull } from './DefaultsServiceFull'; + +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 { + return (await DefaultsServiceFull.callWithDefaultParameters( parameterString, + parameterNumber, + parameterBoolean, + parameterEnum, + parameterModel, + + )).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 { + return (await DefaultsServiceFull.callWithDefaultOptionalParameters( parameterString, + parameterNumber, + parameterBoolean, + parameterEnum, + parameterModel, + +)).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 World!', + parameterStringWithEmptyDefault: string = '', + +): Promise { + return (await DefaultsServiceFull.callToTestOrderOfParams( parameterStringWithNoDefault, + parameterOptionalStringWithDefault, + parameterOptionalStringWithEmptyDefault, + parameterOptionalStringWithNoDefault, + parameterStringWithDefault, + parameterStringWithEmptyDefault, + +)).body; +} +}" +`; + +exports[`v3 should generate: ./test/generated/v3/services/DefaultsServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { + ModelWithString, +} from '../models'; import type { ApiResult } from '../core'; import { request as __request, OpenAPI, } from '../core'; -export class DefaultsService { +export class DefaultsServiceFull { /** * @param parameterString This is a simple string with default value @@ -4974,13 +5670,53 @@ exports[`v3 should generate: ./test/generated/v3/services/DuplicateService.ts 1` /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import { DuplicateServiceFull } from './DuplicateServiceFull'; + +export class DuplicateService { + + /** + + * @throws ApiError + */ + public static async duplicateName(): Promise { + return (await DuplicateServiceFull.duplicateName()).body; + } + /** + + * @throws ApiError + */ + public static async duplicateName1(): Promise { + return (await DuplicateServiceFull.duplicateName1()).body; + } + /** + + * @throws ApiError + */ + public static async duplicateName2(): Promise { + return (await DuplicateServiceFull.duplicateName2()).body; + } + /** + + * @throws ApiError + */ + public static async duplicateName3(): Promise { + return (await DuplicateServiceFull.duplicateName3()).body; + } +}" +`; + +exports[`v3 should generate: ./test/generated/v3/services/DuplicateServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ import type { ApiResult } from '../core'; import { request as __request, OpenAPI, } from '../core'; -export class DuplicateService { +export class DuplicateServiceFull { /** @@ -5034,11 +5770,7 @@ exports[`v3 should generate: ./test/generated/v3/services/HeaderService.ts 1`] = /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ApiResult } from '../core'; -import { - request as __request, - OpenAPI, -} from '../core'; +import { HeaderServiceFull } from './HeaderServiceFull'; export class HeaderService { @@ -5047,15 +5779,39 @@ export class HeaderService { * @returns string Successful response * @throws ApiError */ - public static async callWithResultFromHeader(): Promise> { - return __request({ - method: 'POST', - path: \`/api/v\${OpenAPI.version}/header\`, - responseHeader: 'operation-location', - errors: { - 400: \`400 server error\`, - 500: \`500 server error\`, - }, + public static async callWithResultFromHeader(): Promise { + return (await HeaderServiceFull.callWithResultFromHeader()).body; + } +}" +`; + +exports[`v3 should generate: ./test/generated/v3/services/HeaderServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ApiResult } from '../core'; +import { + request as __request, + OpenAPI, +} from '../core'; + +export class HeaderServiceFull { + + /** + + * @returns string Successful response + * @throws ApiError + */ + public static async callWithResultFromHeader(): Promise> { + return __request({ + method: 'POST', + path: \`/api/v\${OpenAPI.version}/header\`, + responseHeader: 'operation-location', + errors: { + 400: \`400 server error\`, + 500: \`500 server error\`, + }, }); } @@ -5067,13 +5823,39 @@ exports[`v3 should generate: ./test/generated/v3/services/MultipartService.ts 1` /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import { MultipartServiceFull } from './MultipartServiceFull'; + +export class MultipartService { + + /** + + * @returns any OK + * @throws ApiError + */ + public static async multipartResponse(): Promise<{ + file?: string, + metadata?: { + foo?: string, + bar?: string, + }, + }> { + return (await MultipartServiceFull.multipartResponse()).body; + } +}" +`; + +exports[`v3 should generate: ./test/generated/v3/services/MultipartServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ import type { ApiResult } from '../core'; import { request as __request, OpenAPI, } from '../core'; -export class MultipartService { +export class MultipartServiceFull { /** @@ -5101,13 +5883,33 @@ exports[`v3 should generate: ./test/generated/v3/services/NoContentService.ts 1` /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import { NoContentServiceFull } from './NoContentServiceFull'; + +export class NoContentService { + + /** + + * @returns void + * @throws ApiError + */ + public static async callWithNoContentResponse(): Promise { + return (await NoContentServiceFull.callWithNoContentResponse()).body; + } +}" +`; + +exports[`v3 should generate: ./test/generated/v3/services/NoContentServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ import type { ApiResult } from '../core'; import { request as __request, OpenAPI, } from '../core'; -export class NoContentService { +export class NoContentServiceFull { /** @@ -5132,13 +5934,125 @@ exports[`v3 should generate: ./test/generated/v3/services/ParametersService.ts 1 import type { ModelWithString, } from '../models'; +import { ParametersServiceFull } from './ParametersServiceFull'; + +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 { + return (await ParametersServiceFull.callWithParameters( parameterHeader, + parameterQuery, + parameterForm, + parameterCookie, + parameterPath, + requestBody, + + )).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 + * @param _default This is the parameter with a reserved keyword + + * @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, + _default?: string, + +): Promise { + return (await ParametersServiceFull.callWithWeirdParameterNames( parameterHeader, + parameterQuery, + parameterForm, + parameterCookie, + requestBody, + parameterPath1, + parameterPath2, + parameterPath3, + _default, + +)).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 { + return (await ParametersServiceFull.getCallWithOptionalParam( requestBody, + parameter, + +)).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 { + return (await ParametersServiceFull.postCallWithOptionalParam( parameter, + requestBody, + +)).body; +} +}" +`; + +exports[`v3 should generate: ./test/generated/v3/services/ParametersServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { + ModelWithString, +} from '../models'; import type { ApiResult } from '../core'; import { request as __request, OpenAPI, } from '../core'; -export class ParametersService { +export class ParametersServiceFull { /** * @param parameterHeader This is the parameter that goes into the header @@ -5280,13 +6194,41 @@ exports[`v3 should generate: ./test/generated/v3/services/RequestBodyService.ts import type { ModelWithString, } from '../models'; +import { RequestBodyServiceFull } from './RequestBodyServiceFull'; + +export class RequestBodyService { + + /** + * @param requestBody A reusable request body + + * @throws ApiError + */ + public static async postRequestBodyService( + requestBody?: ModelWithString, + + ): Promise { + return (await RequestBodyServiceFull.postRequestBodyService( requestBody, + + )).body; +} +}" +`; + +exports[`v3 should generate: ./test/generated/v3/services/RequestBodyServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { + ModelWithString, +} from '../models'; import type { ApiResult } from '../core'; import { request as __request, OpenAPI, } from '../core'; -export class RequestBodyService { +export class RequestBodyServiceFull { /** * @param requestBody A reusable request body @@ -5318,13 +6260,61 @@ import type { ModelThatExtendsExtends, ModelWithString, } from '../models'; +import { ResponseServiceFull } from './ResponseServiceFull'; + +export class ResponseService { + + /** + + * @returns ModelWithString + * @throws ApiError + */ + public static async callWithResponse(): Promise { + return (await ResponseServiceFull.callWithResponse()).body; + } + /** + + * @returns ModelWithString Message for default response + * @throws ApiError + */ + public static async callWithDuplicateResponses(): Promise { + return (await ResponseServiceFull.callWithDuplicateResponses()).body; + } + /** + + * @returns any Message for 200 response + * @returns ModelWithString Message for default response + * @returns ModelThatExtends Message for 201 response + * @returns ModelThatExtendsExtends Message for 202 response + * @throws ApiError + */ + public static async callWithResponses(): Promise<{ + readonly '@namespace.string'?: string, + readonly '@namespace.integer'?: number, + readonly value?: Array, + } | ModelWithString | ModelThatExtends | ModelThatExtendsExtends> { + return (await ResponseServiceFull.callWithResponses()).body; + } +}" +`; + +exports[`v3 should generate: ./test/generated/v3/services/ResponseServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { + ModelThatExtends, + ModelThatExtendsExtends, + ModelWithString, +} from '../models'; import type { ApiResult } from '../core'; import { request as __request, OpenAPI, } from '../core'; -export class ResponseService { +export class ResponseServiceFull { /** @@ -5387,13 +6377,74 @@ exports[`v3 should generate: ./test/generated/v3/services/SimpleService.ts 1`] = /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import { SimpleServiceFull } from './SimpleServiceFull'; + +export class SimpleService { + + /** + + * @throws ApiError + */ + public static async getCallWithoutParametersAndResponse(): Promise { + return (await SimpleServiceFull.getCallWithoutParametersAndResponse()).body; + } + /** + + * @throws ApiError + */ + public static async putCallWithoutParametersAndResponse(): Promise { + return (await SimpleServiceFull.putCallWithoutParametersAndResponse()).body; + } + /** + + * @throws ApiError + */ + public static async postCallWithoutParametersAndResponse(): Promise { + return (await SimpleServiceFull.postCallWithoutParametersAndResponse()).body; + } + /** + + * @throws ApiError + */ + public static async deleteCallWithoutParametersAndResponse(): Promise { + return (await SimpleServiceFull.deleteCallWithoutParametersAndResponse()).body; + } + /** + + * @throws ApiError + */ + public static async optionsCallWithoutParametersAndResponse(): Promise { + return (await SimpleServiceFull.optionsCallWithoutParametersAndResponse()).body; + } + /** + + * @throws ApiError + */ + public static async headCallWithoutParametersAndResponse(): Promise { + return (await SimpleServiceFull.headCallWithoutParametersAndResponse()).body; + } + /** + + * @throws ApiError + */ + public static async patchCallWithoutParametersAndResponse(): Promise { + return (await SimpleServiceFull.patchCallWithoutParametersAndResponse()).body; + } +}" +`; + +exports[`v3 should generate: ./test/generated/v3/services/SimpleServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ import type { ApiResult } from '../core'; import { request as __request, OpenAPI, } from '../core'; -export class SimpleService { +export class SimpleServiceFull { /** @@ -5480,13 +6531,63 @@ exports[`v3 should generate: ./test/generated/v3/services/TypesService.ts 1`] = /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import { TypesServiceFull } from './TypesServiceFull'; + +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 + + * @returns number Response is a simple number + * @returns string Response is a simple string + * @returns boolean Response is a simple boolean + * @returns 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 { + return (await TypesServiceFull.types( parameterArray, + parameterDictionary, + parameterEnum, + parameterNumber, + parameterString, + parameterBoolean, + parameterObject, + id, + + )).body; +} +}" +`; + +exports[`v3 should generate: ./test/generated/v3/services/TypesServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ import type { ApiResult } from '../core'; import { request as __request, OpenAPI, } from '../core'; -export class TypesService { +export class TypesServiceFull { /** * @param parameterArray This is an array parameter @@ -5538,13 +6639,39 @@ exports[`v3 should generate: ./test/generated/v3/services/UploadService.ts 1`] = /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import { UploadServiceFull } from './UploadServiceFull'; + +export class UploadService { + + /** + * @param file Supply a file reference for upload + + * @returns boolean + * @throws ApiError + */ + public static async uploadFile( + file: Blob, + + ): Promise { + return (await UploadServiceFull.uploadFile( file, + + )).body; +} +}" +`; + +exports[`v3 should generate: ./test/generated/v3/services/UploadServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ import type { ApiResult } from '../core'; import { request as __request, OpenAPI, } from '../core'; -export class UploadService { +export class UploadServiceFull { /** * @param file Supply a file reference for upload @@ -5574,17 +6701,30 @@ exports[`v3 should generate: ./test/generated/v3/services/index.ts 1`] = ` /* tslint:disable */ /* eslint-disable */ export { CollectionFormatService } from './CollectionFormatService'; +export { CollectionFormatServiceFull } from './CollectionFormatServiceFull'; export { ComplexService } from './ComplexService'; +export { ComplexServiceFull } from './ComplexServiceFull'; export { DefaultsService } from './DefaultsService'; +export { DefaultsServiceFull } from './DefaultsServiceFull'; export { DuplicateService } from './DuplicateService'; +export { DuplicateServiceFull } from './DuplicateServiceFull'; export { HeaderService } from './HeaderService'; +export { HeaderServiceFull } from './HeaderServiceFull'; export { MultipartService } from './MultipartService'; +export { MultipartServiceFull } from './MultipartServiceFull'; export { NoContentService } from './NoContentService'; +export { NoContentServiceFull } from './NoContentServiceFull'; export { ParametersService } from './ParametersService'; +export { ParametersServiceFull } from './ParametersServiceFull'; export { RequestBodyService } from './RequestBodyService'; +export { RequestBodyServiceFull } from './RequestBodyServiceFull'; export { ResponseService } from './ResponseService'; +export { ResponseServiceFull } from './ResponseServiceFull'; export { SimpleService } from './SimpleService'; +export { SimpleServiceFull } from './SimpleServiceFull'; export { TypesService } from './TypesService'; +export { TypesServiceFull } from './TypesServiceFull'; export { UploadService } from './UploadService'; +export { UploadServiceFull } from './UploadServiceFull'; " `; diff --git a/test/e2e/v2.babel.spec.js b/test/e2e/v2.babel.spec.js index d81b86acd..f691ab9b5 100644 --- a/test/e2e/v2.babel.spec.js +++ b/test/e2e/v2.babel.spec.js @@ -27,7 +27,7 @@ describe('v2.fetch', () => { OpenAPI.token = window.tokenRequest; return await SimpleService.getCallWithoutParametersAndResponse(); }); - expect(result.body.headers.authorization).toBe('Bearer MY_TOKEN'); + expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); }); it('complexService', async () => { @@ -66,7 +66,7 @@ describe('v2.fetch with client', () => { const client = new AppClient({ token: window.tokenRequest }); return await client.simple.getCallWithoutParametersAndResponse(); }); - expect(result.body.headers.authorization).toBe('Bearer MY_TOKEN'); + expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); }); it('complexService', async () => { @@ -81,6 +81,6 @@ describe('v2.fetch with client', () => { }, }); }); - expect(result.body).toBeDefined(); + expect(result).toBeDefined(); }); }); diff --git a/test/e2e/v2.fetch.spec.js b/test/e2e/v2.fetch.spec.js index f881686cd..12a808ab4 100644 --- a/test/e2e/v2.fetch.spec.js +++ b/test/e2e/v2.fetch.spec.js @@ -27,7 +27,7 @@ describe('v2.fetch', () => { OpenAPI.token = window.tokenRequest; return await SimpleService.getCallWithoutParametersAndResponse(); }); - expect(result.body.headers.authorization).toBe('Bearer MY_TOKEN'); + expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); }); it('complexService', async () => { @@ -41,7 +41,7 @@ describe('v2.fetch', () => { }, }); }); - expect(result.body).toBeDefined(); + expect(result).toBeDefined(); }); }); @@ -66,7 +66,7 @@ describe('v2.fetch with client', () => { const client = new AppClient({ token: window.tokenRequest }); return await client.simple.getCallWithoutParametersAndResponse(); }); - expect(result.body.headers.authorization).toBe('Bearer MY_TOKEN'); + expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); }); it('complexService', async () => { @@ -81,6 +81,6 @@ describe('v2.fetch with client', () => { }, }); }); - expect(result.body).toBeDefined(); + expect(result).toBeDefined(); }); }); diff --git a/test/e2e/v2.node.spec.js b/test/e2e/v2.node.spec.js index d30aba312..10af31bdd 100644 --- a/test/e2e/v2.node.spec.js +++ b/test/e2e/v2.node.spec.js @@ -21,7 +21,7 @@ describe('v2.node', () => { OpenAPI.token = tokenRequest; const result = await SimpleService.getCallWithoutParametersAndResponse(); expect(tokenRequest.mock.calls.length).toBe(1); - expect(result.body.headers.authorization).toBe('Bearer MY_TOKEN'); + expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); }); it('complexService', async () => { @@ -33,7 +33,7 @@ describe('v2.node', () => { }, }, }); - expect(result.body).toBeDefined(); + expect(result).toBeDefined(); }); }); @@ -54,7 +54,7 @@ describe('v2.node with client', () => { const client = new AppClient({ token: tokenRequest }); const result = await client.simple.getCallWithoutParametersAndResponse(); expect(tokenRequest.mock.calls.length).toBe(1); - expect(result.body.headers.authorization).toBe('Bearer MY_TOKEN'); + expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); }); it('complexService', async () => { @@ -67,6 +67,6 @@ describe('v2.node with client', () => { }, }, }); - expect(result.body).toBeDefined(); + expect(result).toBeDefined(); }); }); diff --git a/test/e2e/v2.xhr.spec.js b/test/e2e/v2.xhr.spec.js index a4262a6a9..85cc1fd9e 100644 --- a/test/e2e/v2.xhr.spec.js +++ b/test/e2e/v2.xhr.spec.js @@ -27,7 +27,7 @@ describe('v2.xhr', () => { OpenAPI.token = window.tokenRequest; return await SimpleService.getCallWithoutParametersAndResponse(); }); - expect(result.body.headers.authorization).toBe('Bearer MY_TOKEN'); + expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); }); it('complexService', async () => { @@ -41,7 +41,7 @@ describe('v2.xhr', () => { }, }); }); - expect(result.body).toBeDefined(); + expect(result).toBeDefined(); }); }); @@ -66,7 +66,7 @@ describe('v2.xhr with client', () => { const client = new AppClient({ token: window.tokenRequest }); return await client.simple.getCallWithoutParametersAndResponse(); }); - expect(result.body.headers.authorization).toBe('Bearer MY_TOKEN'); + expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); }); it('complexService', async () => { @@ -81,6 +81,6 @@ describe('v2.xhr with client', () => { }, }); }); - expect(result.body).toBeDefined(); + expect(result).toBeDefined(); }); }); diff --git a/test/e2e/v3.babel.spec.js b/test/e2e/v3.babel.spec.js index d43a08d9e..34a87418a 100644 --- a/test/e2e/v3.babel.spec.js +++ b/test/e2e/v3.babel.spec.js @@ -29,7 +29,7 @@ describe('v3.fetch', () => { OpenAPI.password = undefined; return await SimpleService.getCallWithoutParametersAndResponse(); }); - expect(result.body.headers.authorization).toBe('Bearer MY_TOKEN'); + expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); }); it('uses credentials', async () => { @@ -40,7 +40,7 @@ describe('v3.fetch', () => { OpenAPI.password = 'password'; return await SimpleService.getCallWithoutParametersAndResponse(); }); - expect(result.body.headers.authorization).toBe('Basic dXNlcm5hbWU6cGFzc3dvcmQ='); + expect(result.headers.authorization).toBe('Basic dXNlcm5hbWU6cGFzc3dvcmQ='); }); it('complexService', async () => { @@ -54,7 +54,7 @@ describe('v3.fetch', () => { }, }); }); - expect(result.body).toBeDefined(); + expect(result).toBeDefined(); }); }); @@ -79,7 +79,7 @@ describe('v3.fetch with client', () => { const client = new AppClient({ token: window.tokenRequest, username: undefined, password: undefined }); return await client.simple.getCallWithoutParametersAndResponse(); }); - expect(result.body.headers.authorization).toBe('Bearer MY_TOKEN'); + expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); }); it('uses credentials', async () => { @@ -88,7 +88,7 @@ describe('v3.fetch with client', () => { const client = new AppClient({ token: undefined, username: 'username', password: 'password' }); return await client.simple.getCallWithoutParametersAndResponse(); }); - expect(result.body.headers.authorization).toBe('Basic dXNlcm5hbWU6cGFzc3dvcmQ='); + expect(result.headers.authorization).toBe('Basic dXNlcm5hbWU6cGFzc3dvcmQ='); }); it('complexService', async () => { @@ -103,6 +103,6 @@ describe('v3.fetch with client', () => { }, }); }); - expect(result.body).toBeDefined(); + expect(result).toBeDefined(); }); }); diff --git a/test/e2e/v3.fetch.spec.js b/test/e2e/v3.fetch.spec.js index dd821ceaf..fac183e8b 100644 --- a/test/e2e/v3.fetch.spec.js +++ b/test/e2e/v3.fetch.spec.js @@ -29,7 +29,7 @@ describe('v3.fetch', () => { OpenAPI.password = undefined; return await SimpleService.getCallWithoutParametersAndResponse(); }); - expect(result.body.headers.authorization).toBe('Bearer MY_TOKEN'); + expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); }); it('uses credentials', async () => { @@ -40,7 +40,7 @@ describe('v3.fetch', () => { OpenAPI.password = 'password'; return await SimpleService.getCallWithoutParametersAndResponse(); }); - expect(result.body.headers.authorization).toBe('Basic dXNlcm5hbWU6cGFzc3dvcmQ='); + expect(result.headers.authorization).toBe('Basic dXNlcm5hbWU6cGFzc3dvcmQ='); }); it('complexService', async () => { @@ -54,7 +54,7 @@ describe('v3.fetch', () => { }, }); }); - expect(result.body).toBeDefined(); + expect(result).toBeDefined(); }); }); @@ -79,7 +79,7 @@ describe('v3.fetch with client', () => { const client = new AppClient({ token: window.tokenRequest, username: undefined, password: undefined }); return await client.simple.getCallWithoutParametersAndResponse(); }); - expect(result.body.headers.authorization).toBe('Bearer MY_TOKEN'); + expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); }); it('uses credentials', async () => { @@ -88,7 +88,7 @@ describe('v3.fetch with client', () => { const client = new AppClient({ token: undefined, username: 'username', password: 'password' }); return await client.simple.getCallWithoutParametersAndResponse(); }); - expect(result.body.headers.authorization).toBe('Basic dXNlcm5hbWU6cGFzc3dvcmQ='); + expect(result.headers.authorization).toBe('Basic dXNlcm5hbWU6cGFzc3dvcmQ='); }); it('complexService', async () => { @@ -103,6 +103,6 @@ describe('v3.fetch with client', () => { }, }); }); - expect(result.body).toBeDefined(); + expect(result).toBeDefined(); }); }); diff --git a/test/e2e/v3.node.spec.js b/test/e2e/v3.node.spec.js index 5e338351e..7388cd6a9 100644 --- a/test/e2e/v3.node.spec.js +++ b/test/e2e/v3.node.spec.js @@ -23,7 +23,7 @@ describe('v3.node', () => { OpenAPI.password = undefined; const result = await SimpleService.getCallWithoutParametersAndResponse(); expect(tokenRequest.mock.calls.length).toBe(1); - expect(result.body.headers.authorization).toBe('Bearer MY_TOKEN'); + expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); }); it('uses credentials', async () => { @@ -32,7 +32,7 @@ describe('v3.node', () => { OpenAPI.username = 'username'; OpenAPI.password = 'password'; const result = await SimpleService.getCallWithoutParametersAndResponse(); - expect(result.body.headers.authorization).toBe('Basic dXNlcm5hbWU6cGFzc3dvcmQ='); + expect(result.headers.authorization).toBe('Basic dXNlcm5hbWU6cGFzc3dvcmQ='); }); it('complexService', async () => { @@ -44,7 +44,7 @@ describe('v3.node', () => { }, }, }); - expect(result.body).toBeDefined(); + expect(result).toBeDefined(); }); }); @@ -65,14 +65,14 @@ describe('v3.node with client', () => { const client = new AppClient({ token: tokenRequest, username: undefined, password: undefined }); const result = await client.simple.getCallWithoutParametersAndResponse(); expect(tokenRequest.mock.calls.length).toBe(1); - expect(result.body.headers.authorization).toBe('Bearer MY_TOKEN'); + expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); }); it('uses credentials', async () => { const { AppClient } = require('./generated/v3/node_client/index.js'); const client = new AppClient({ token: undefined, username: 'username', password: 'password' }); const result = await client.simple.getCallWithoutParametersAndResponse(); - expect(result.body.headers.authorization).toBe('Basic dXNlcm5hbWU6cGFzc3dvcmQ='); + expect(result.headers.authorization).toBe('Basic dXNlcm5hbWU6cGFzc3dvcmQ='); }); it('complexService', async () => { @@ -85,6 +85,6 @@ describe('v3.node with client', () => { }, }, }); - expect(result.body).toBeDefined(); + expect(result).toBeDefined(); }); }); diff --git a/test/e2e/v3.xhr.spec.js b/test/e2e/v3.xhr.spec.js index 57c64ae58..f1517e4ea 100644 --- a/test/e2e/v3.xhr.spec.js +++ b/test/e2e/v3.xhr.spec.js @@ -29,7 +29,7 @@ describe('v3.xhr', () => { OpenAPI.password = undefined; return await SimpleService.getCallWithoutParametersAndResponse(); }); - expect(result.body.headers.authorization).toBe('Bearer MY_TOKEN'); + expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); }); it('uses credentials', async () => { @@ -40,7 +40,7 @@ describe('v3.xhr', () => { OpenAPI.password = 'password'; return await SimpleService.getCallWithoutParametersAndResponse(); }); - expect(result.body.headers.authorization).toBe('Basic dXNlcm5hbWU6cGFzc3dvcmQ='); + expect(result.headers.authorization).toBe('Basic dXNlcm5hbWU6cGFzc3dvcmQ='); }); it('complexService', async () => { @@ -79,7 +79,7 @@ describe('v3.xhr with client', () => { const client = new AppClient({ token: window.tokenRequest, username: undefined, password: undefined }); return await client.simple.getCallWithoutParametersAndResponse(); }); - expect(result.body.headers.authorization).toBe('Bearer MY_TOKEN'); + expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); }); it('uses credentials', async () => { @@ -88,7 +88,7 @@ describe('v3.xhr with client', () => { const client = new AppClient({ token: undefined, username: 'username', password: 'password' }); return await client.simple.getCallWithoutParametersAndResponse(); }); - expect(result.body.headers.authorization).toBe('Basic dXNlcm5hbWU6cGFzc3dvcmQ='); + expect(result.headers.authorization).toBe('Basic dXNlcm5hbWU6cGFzc3dvcmQ='); }); it('complexService', async () => { @@ -103,6 +103,6 @@ describe('v3.xhr with client', () => { }, }); }); - expect(result.body).toBeDefined(); + expect(result).toBeDefined(); }); }); From e38afc4a830623b02e3460428b121d7f8903d720 Mon Sep 17 00:00:00 2001 From: lub0v-parsable Date: Thu, 26 Aug 2021 17:08:48 -0700 Subject: [PATCH 09/11] PE-2229 - cleanup --- package.json | 2 +- src/templates/exportAppClient.hbs | 16 +- src/templates/partials/passParameters.hbs | 8 +- src/templates/services/exportService.hbs | 1 + test/__snapshots__/index.client.spec.js.snap | 669 +++++++++---------- test/__snapshots__/index.spec.js.snap | 581 ++++++++-------- 6 files changed, 614 insertions(+), 663 deletions(-) diff --git a/package.json b/package.json index cf4db830d..ee2bba952 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@parsable/openapi-typescript-codegen", - "version": "0.0.2-alpha-5", + "version": "0.0.3", "description": "Library that generates Typescript clients based on the OpenAPI specification.", "author": "Ferdi Koomen", "homepage": "https://github.com/ferdikoomen/openapi-typescript-codegen", diff --git a/src/templates/exportAppClient.hbs b/src/templates/exportAppClient.hbs index 6412a7074..7c09a25ef 100644 --- a/src/templates/exportAppClient.hbs +++ b/src/templates/exportAppClient.hbs @@ -16,15 +16,15 @@ export class {{{clientName}}} { readonly {{{shortName}}}: {{{name}}}; {{/each}} - constructor(ClientConfig: ClientConfig, httpClient: BaseHttpRequest = new {{{httpClientRequest}}}()) { + constructor(clientConfig: ClientConfig, httpClient: BaseHttpRequest = new {{{httpClientRequest}}}()) { const config = { - baseUrl: ClientConfig?.baseUrl ?? '{{{server}}}', - version: ClientConfig?.version ?? '{{{version}}}', - withCredentials: ClientConfig?.withCredentials ?? false, - token: ClientConfig?.token, - username: ClientConfig?.username, - password: ClientConfig?.password, - headers: ClientConfig?.headers, + baseUrl: clientConfig?.baseUrl ?? '{{{server}}}', + version: clientConfig?.version ?? '{{{version}}}', + withCredentials: clientConfig?.withCredentials ?? false, + token: clientConfig?.token, + username: clientConfig?.username, + password: clientConfig?.password, + headers: clientConfig?.headers, } {{#each services}} this.{{{shortName}}} = new {{{name}}}(httpClient, config); diff --git a/src/templates/partials/passParameters.hbs b/src/templates/partials/passParameters.hbs index 6c90d4249..3b67efc59 100644 --- a/src/templates/partials/passParameters.hbs +++ b/src/templates/partials/passParameters.hbs @@ -4,11 +4,7 @@ {{#each parameters}} {{{name}}}, {{/each}} -}{{#if @root.exportClient}}, config{{/if}} -{{~else}} -{{#each parameters}} - {{{name}}}, -{{/each}} -{{#if @root.exportClient}}config{{/if}} +}{{#if @root.exportClient}}, config{{/if}}{{~else}} +{{#each parameters}}{{{name}}}, {{/each}}{{#if @root.exportClient}}config{{/if}} {{/if}} {{else}}{{#if @root.exportClient}}config{{/if}}{{/if}} diff --git a/src/templates/services/exportService.hbs b/src/templates/services/exportService.hbs index cb64e4627..fd272b03b 100644 --- a/src/templates/services/exportService.hbs +++ b/src/templates/services/exportService.hbs @@ -56,5 +56,6 @@ export class {{{name}}} { return (await {{{@root.name}}}Full.{{{name}}}({{>passParameters}})).body; {{/if}} } + {{/each}} } diff --git a/test/__snapshots__/index.client.spec.js.snap b/test/__snapshots__/index.client.spec.js.snap index a1e29d384..4f8aa0390 100644 --- a/test/__snapshots__/index.client.spec.js.snap +++ b/test/__snapshots__/index.client.spec.js.snap @@ -33,15 +33,15 @@ export class TestClient { readonly simple: SimpleService; readonly types: TypesService; - constructor(ClientConfig: ClientConfig, httpClient: BaseHttpRequest = new FetchHttpRequest()) { + constructor(clientConfig: ClientConfig, httpClient: BaseHttpRequest = new FetchHttpRequest()) { const config = { - baseUrl: ClientConfig?.baseUrl ?? 'http://localhost:3000/base', - version: ClientConfig?.version ?? '1.0', - withCredentials: ClientConfig?.withCredentials ?? false, - token: ClientConfig?.token, - username: ClientConfig?.username, - password: ClientConfig?.password, - headers: ClientConfig?.headers, + baseUrl: clientConfig?.baseUrl ?? 'http://localhost:3000/base', + version: clientConfig?.version ?? '1.0', + withCredentials: clientConfig?.withCredentials ?? false, + token: clientConfig?.token, + username: clientConfig?.username, + password: clientConfig?.password, + headers: clientConfig?.headers, } this.collectionformat = new CollectionFormatService(httpClient, config); this.complex = new ComplexService(httpClient, config); @@ -1999,14 +1999,11 @@ export class CollectionFormatService { parameterArrayMulti: Array, config?: ClientConfig ): Promise { - return (await this.full.collectionFormat( parameterArrayCsv, - parameterArraySsv, - parameterArrayTsv, - parameterArrayPipes, - parameterArrayMulti, - config - )).body; -} + return (await this.full.collectionFormat( + parameterArrayCsv, parameterArraySsv, parameterArrayTsv, parameterArrayPipes, parameterArrayMulti, config + )).body; + } + }" `; @@ -2099,11 +2096,11 @@ export class ComplexService { parameterReference: ModelWithString, config?: ClientConfig ): Promise> { - return (await this.full.complexTypes( parameterObject, - parameterReference, - config - )).body; -} + return (await this.full.complexTypes( + parameterObject, parameterReference, config + )).body; + } + }" `; @@ -2202,69 +2199,59 @@ export class DefaultsService { }, config?: ClientConfig ): Promise { - return (await this.full.callWithDefaultParameters( parameterString, - parameterNumber, - parameterBoolean, - parameterEnum, - parameterModel, - config - )).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 - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ -public async callWithDefaultOptionalParameters( - parameterString: string = 'Hello World!', - parameterNumber: number = 123, - parameterBoolean: boolean = true, - parameterEnum: 'Success' | 'Warning' | 'Error' = 'Success', - parameterModel: ModelWithString = { - \\"prop\\": \\"Hello World!\\" - }, - config?: ClientConfig -): Promise { - return (await this.full.callWithDefaultOptionalParameters( parameterString, - parameterNumber, - parameterBoolean, - parameterEnum, - parameterModel, - config -)).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 - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ -public async callToTestOrderOfParams( - parameterStringWithNoDefault: string, - parameterOptionalStringWithDefault: string = 'Hello World!', - parameterOptionalStringWithEmptyDefault: string = '', - parameterOptionalStringWithNoDefault?: string, - parameterStringWithDefault: string = 'Hello World!', - parameterStringWithEmptyDefault: string = '', - config?: ClientConfig -): Promise { - return (await this.full.callToTestOrderOfParams( parameterStringWithNoDefault, - parameterOptionalStringWithDefault, - parameterOptionalStringWithEmptyDefault, - parameterOptionalStringWithNoDefault, - parameterStringWithDefault, - parameterStringWithEmptyDefault, - config -)).body; -} + return (await this.full.callWithDefaultParameters( + parameterString, parameterNumber, parameterBoolean, parameterEnum, parameterModel, config + )).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 + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async callWithDefaultOptionalParameters( + parameterString: string = 'Hello World!', + parameterNumber: number = 123, + parameterBoolean: boolean = true, + parameterEnum: 'Success' | 'Warning' | 'Error' = 'Success', + parameterModel: ModelWithString = { + \\"prop\\": \\"Hello World!\\" + }, + config?: ClientConfig + ): Promise { + return (await this.full.callWithDefaultOptionalParameters( + parameterString, parameterNumber, parameterBoolean, parameterEnum, parameterModel, config + )).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 + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async callToTestOrderOfParams( + parameterStringWithNoDefault: string, + parameterOptionalStringWithDefault: string = 'Hello World!', + parameterOptionalStringWithEmptyDefault: string = '', + parameterOptionalStringWithNoDefault?: string, + parameterStringWithDefault: string = 'Hello World!', + parameterStringWithEmptyDefault: string = '', + config?: ClientConfig + ): Promise { + return (await this.full.callToTestOrderOfParams( + parameterStringWithNoDefault, parameterOptionalStringWithDefault, parameterOptionalStringWithEmptyDefault, parameterOptionalStringWithNoDefault, parameterStringWithDefault, parameterStringWithEmptyDefault, config + )).body; + } + }" `; @@ -2413,6 +2400,7 @@ export class DuplicateService { public async duplicateName(config?: ClientConfig): Promise { return (await this.full.duplicateName(config)).body; } + /** * @param [config] the optional OpenAPI config to use * @throws ApiError @@ -2420,6 +2408,7 @@ export class DuplicateService { public async duplicateName1(config?: ClientConfig): Promise { return (await this.full.duplicateName1(config)).body; } + /** * @param [config] the optional OpenAPI config to use * @throws ApiError @@ -2427,6 +2416,7 @@ export class DuplicateService { public async duplicateName2(config?: ClientConfig): Promise { return (await this.full.duplicateName2(config)).body; } + /** * @param [config] the optional OpenAPI config to use * @throws ApiError @@ -2434,6 +2424,7 @@ export class DuplicateService { public async duplicateName3(config?: ClientConfig): Promise { return (await this.full.duplicateName3(config)).body; } + }" `; @@ -2527,6 +2518,7 @@ export class HeaderService { public async callWithResultFromHeader(config?: ClientConfig): Promise { return (await this.full.callWithResultFromHeader(config)).body; } + }" `; @@ -2593,6 +2585,7 @@ export class NoContentService { public async callWithNoContentResponse(config?: ClientConfig): Promise { return (await this.full.callWithNoContentResponse(config)).body; } + }" `; @@ -2663,48 +2656,39 @@ export class ParametersService { parameterPath: string, config?: ClientConfig ): Promise { - return (await this.full.callWithParameters( parameterHeader, - parameterQuery, - parameterForm, - parameterBody, - parameterPath, - config - )).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 - * @param _default This is the parameter with a reserved keyword - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ -public async callWithWeirdParameterNames( - parameterHeader: string, - parameterQuery: string, - parameterForm: string, - parameterBody: string, - parameterPath1?: string, - parameterPath2?: string, - parameterPath3?: string, - _default?: string, - config?: ClientConfig -): Promise { - return (await this.full.callWithWeirdParameterNames( parameterHeader, - parameterQuery, - parameterForm, - parameterBody, - parameterPath1, - parameterPath2, - parameterPath3, - _default, - config -)).body; -} + return (await this.full.callWithParameters( + parameterHeader, parameterQuery, parameterForm, parameterBody, parameterPath, config + )).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 + * @param _default This is the parameter with a reserved keyword + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async callWithWeirdParameterNames( + parameterHeader: string, + parameterQuery: string, + parameterForm: string, + parameterBody: string, + parameterPath1?: string, + parameterPath2?: string, + parameterPath3?: string, + _default?: string, + config?: ClientConfig + ): Promise { + return (await this.full.callWithWeirdParameterNames( + parameterHeader, parameterQuery, parameterForm, parameterBody, parameterPath1, parameterPath2, parameterPath3, _default, config + )).body; + } + }" `; @@ -2832,6 +2816,7 @@ export class ResponseService { public async callWithResponse(config?: ClientConfig): Promise { return (await this.full.callWithResponse(config)).body; } + /** * @param [config] the optional OpenAPI config to use * @returns ModelWithString Message for default response @@ -2840,6 +2825,7 @@ export class ResponseService { public async callWithDuplicateResponses(config?: ClientConfig): Promise { return (await this.full.callWithDuplicateResponses(config)).body; } + /** * @param [config] the optional OpenAPI config to use * @returns any Message for 200 response @@ -2855,6 +2841,7 @@ export class ResponseService { } | ModelWithString | ModelThatExtends | ModelThatExtendsExtends> { return (await this.full.callWithResponses(config)).body; } + }" `; @@ -2961,6 +2948,7 @@ export class SimpleService { public async getCallWithoutParametersAndResponse(config?: ClientConfig): Promise { return (await this.full.getCallWithoutParametersAndResponse(config)).body; } + /** * @param [config] the optional OpenAPI config to use * @throws ApiError @@ -2968,6 +2956,7 @@ export class SimpleService { public async putCallWithoutParametersAndResponse(config?: ClientConfig): Promise { return (await this.full.putCallWithoutParametersAndResponse(config)).body; } + /** * @param [config] the optional OpenAPI config to use * @throws ApiError @@ -2975,6 +2964,7 @@ export class SimpleService { public async postCallWithoutParametersAndResponse(config?: ClientConfig): Promise { return (await this.full.postCallWithoutParametersAndResponse(config)).body; } + /** * @param [config] the optional OpenAPI config to use * @throws ApiError @@ -2982,6 +2972,7 @@ export class SimpleService { public async deleteCallWithoutParametersAndResponse(config?: ClientConfig): Promise { return (await this.full.deleteCallWithoutParametersAndResponse(config)).body; } + /** * @param [config] the optional OpenAPI config to use * @throws ApiError @@ -2989,6 +2980,7 @@ export class SimpleService { public async optionsCallWithoutParametersAndResponse(config?: ClientConfig): Promise { return (await this.full.optionsCallWithoutParametersAndResponse(config)).body; } + /** * @param [config] the optional OpenAPI config to use * @throws ApiError @@ -2996,6 +2988,7 @@ export class SimpleService { public async headCallWithoutParametersAndResponse(config?: ClientConfig): Promise { return (await this.full.headCallWithoutParametersAndResponse(config)).body; } + /** * @param [config] the optional OpenAPI config to use * @throws ApiError @@ -3003,6 +2996,7 @@ export class SimpleService { public async patchCallWithoutParametersAndResponse(config?: ClientConfig): Promise { return (await this.full.patchCallWithoutParametersAndResponse(config)).body; } + }" `; @@ -3148,17 +3142,11 @@ export class TypesService { id?: number, config?: ClientConfig ): Promise { - return (await this.full.types( parameterArray, - parameterDictionary, - parameterEnum, - parameterNumber, - parameterString, - parameterBoolean, - parameterObject, - id, - config - )).body; -} + return (await this.full.types( + parameterArray, parameterDictionary, parameterEnum, parameterNumber, parameterString, parameterBoolean, parameterObject, id, config + )).body; + } + }" `; @@ -3290,15 +3278,15 @@ export class TestClient { readonly types: TypesService; readonly upload: UploadService; - constructor(ClientConfig: ClientConfig, httpClient: BaseHttpRequest = new FetchHttpRequest()) { + constructor(clientConfig: ClientConfig, httpClient: BaseHttpRequest = new FetchHttpRequest()) { const config = { - baseUrl: ClientConfig?.baseUrl ?? 'http://localhost:3000/base', - version: ClientConfig?.version ?? '1.0', - withCredentials: ClientConfig?.withCredentials ?? false, - token: ClientConfig?.token, - username: ClientConfig?.username, - password: ClientConfig?.password, - headers: ClientConfig?.headers, + baseUrl: clientConfig?.baseUrl ?? 'http://localhost:3000/base', + version: clientConfig?.version ?? '1.0', + withCredentials: clientConfig?.withCredentials ?? false, + token: clientConfig?.token, + username: clientConfig?.username, + password: clientConfig?.password, + headers: clientConfig?.headers, } this.collectionformat = new CollectionFormatService(httpClient, config); this.complex = new ComplexService(httpClient, config); @@ -5534,14 +5522,11 @@ export class CollectionFormatService { parameterArrayMulti: Array | null, config?: ClientConfig ): Promise { - return (await this.full.collectionFormat( parameterArrayCsv, - parameterArraySsv, - parameterArrayTsv, - parameterArrayPipes, - parameterArrayMulti, - config - )).body; -} + return (await this.full.collectionFormat( + parameterArrayCsv, parameterArraySsv, parameterArrayTsv, parameterArrayPipes, parameterArrayMulti, config + )).body; + } + }" `; @@ -5637,40 +5622,40 @@ export class ComplexService { parameterReference: ModelWithString, config?: ClientConfig ): Promise> { - return (await this.full.complexTypes( parameterObject, - parameterReference, - config - )).body; -} -/** - * @param id - * @param requestBody - * @param [config] the optional OpenAPI config to use - * @returns ModelWithString Success - * @throws ApiError - */ -public 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: (ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary), - readonly user?: { - readonly id?: number, - readonly name?: string | null, + return (await this.full.complexTypes( + parameterObject, parameterReference, config + )).body; + } + + /** + * @param id + * @param requestBody + * @param [config] the optional OpenAPI config to use + * @returns ModelWithString Success + * @throws ApiError + */ + public 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: (ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary), + readonly user?: { + readonly id?: number, + readonly name?: string | null, + }, }, - }, - config?: ClientConfig -): Promise { - return (await this.full.complexParams( id, - requestBody, - config -)).body; -} + config?: ClientConfig + ): Promise { + return (await this.full.complexParams( + id, requestBody, config + )).body; + } + }" `; @@ -5804,69 +5789,59 @@ export class DefaultsService { }, config?: ClientConfig ): Promise { - return (await this.full.callWithDefaultParameters( parameterString, - parameterNumber, - parameterBoolean, - parameterEnum, - parameterModel, - config - )).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 - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ -public async callWithDefaultOptionalParameters( - parameterString: string = 'Hello World!', - parameterNumber: number = 123, - parameterBoolean: boolean = true, - parameterEnum: 'Success' | 'Warning' | 'Error' = 'Success', - parameterModel: ModelWithString = { - \\"prop\\": \\"Hello World!\\" - }, - config?: ClientConfig -): Promise { - return (await this.full.callWithDefaultOptionalParameters( parameterString, - parameterNumber, - parameterBoolean, - parameterEnum, - parameterModel, - config -)).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 - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ -public async callToTestOrderOfParams( - parameterStringWithNoDefault: string, - parameterOptionalStringWithDefault: string = 'Hello World!', - parameterOptionalStringWithEmptyDefault: string = '', - parameterOptionalStringWithNoDefault?: string, - parameterStringWithDefault: string = 'Hello World!', - parameterStringWithEmptyDefault: string = '', - config?: ClientConfig -): Promise { - return (await this.full.callToTestOrderOfParams( parameterStringWithNoDefault, - parameterOptionalStringWithDefault, - parameterOptionalStringWithEmptyDefault, - parameterOptionalStringWithNoDefault, - parameterStringWithDefault, - parameterStringWithEmptyDefault, - config -)).body; -} + return (await this.full.callWithDefaultParameters( + parameterString, parameterNumber, parameterBoolean, parameterEnum, parameterModel, config + )).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 + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async callWithDefaultOptionalParameters( + parameterString: string = 'Hello World!', + parameterNumber: number = 123, + parameterBoolean: boolean = true, + parameterEnum: 'Success' | 'Warning' | 'Error' = 'Success', + parameterModel: ModelWithString = { + \\"prop\\": \\"Hello World!\\" + }, + config?: ClientConfig + ): Promise { + return (await this.full.callWithDefaultOptionalParameters( + parameterString, parameterNumber, parameterBoolean, parameterEnum, parameterModel, config + )).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 + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async callToTestOrderOfParams( + parameterStringWithNoDefault: string, + parameterOptionalStringWithDefault: string = 'Hello World!', + parameterOptionalStringWithEmptyDefault: string = '', + parameterOptionalStringWithNoDefault?: string, + parameterStringWithDefault: string = 'Hello World!', + parameterStringWithEmptyDefault: string = '', + config?: ClientConfig + ): Promise { + return (await this.full.callToTestOrderOfParams( + parameterStringWithNoDefault, parameterOptionalStringWithDefault, parameterOptionalStringWithEmptyDefault, parameterOptionalStringWithNoDefault, parameterStringWithDefault, parameterStringWithEmptyDefault, config + )).body; + } + }" `; @@ -6015,6 +5990,7 @@ export class DuplicateService { public async duplicateName(config?: ClientConfig): Promise { return (await this.full.duplicateName(config)).body; } + /** * @param [config] the optional OpenAPI config to use * @throws ApiError @@ -6022,6 +5998,7 @@ export class DuplicateService { public async duplicateName1(config?: ClientConfig): Promise { return (await this.full.duplicateName1(config)).body; } + /** * @param [config] the optional OpenAPI config to use * @throws ApiError @@ -6029,6 +6006,7 @@ export class DuplicateService { public async duplicateName2(config?: ClientConfig): Promise { return (await this.full.duplicateName2(config)).body; } + /** * @param [config] the optional OpenAPI config to use * @throws ApiError @@ -6036,6 +6014,7 @@ export class DuplicateService { public async duplicateName3(config?: ClientConfig): Promise { return (await this.full.duplicateName3(config)).body; } + }" `; @@ -6129,6 +6108,7 @@ export class HeaderService { public async callWithResultFromHeader(config?: ClientConfig): Promise { return (await this.full.callWithResultFromHeader(config)).body; } + }" `; @@ -6201,6 +6181,7 @@ export class MultipartService { }> { return (await this.full.multipartResponse(config)).body; } + }" `; @@ -6268,6 +6249,7 @@ export class NoContentService { public async callWithNoContentResponse(config?: ClientConfig): Promise { return (await this.full.callWithNoContentResponse(config)).body; } + }" `; @@ -6343,84 +6325,73 @@ export class ParametersService { requestBody: ModelWithString | null, config?: ClientConfig ): Promise { - return (await this.full.callWithParameters( parameterHeader, - parameterQuery, - parameterForm, - parameterCookie, - parameterPath, - requestBody, - config - )).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 - * @param _default This is the parameter with a reserved keyword - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ -public async callWithWeirdParameterNames( - parameterHeader: string | null, - parameterQuery: string | null, - parameterForm: string | null, - parameterCookie: string | null, - requestBody: ModelWithString | null, - parameterPath1?: string, - parameterPath2?: string, - parameterPath3?: string, - _default?: string, - config?: ClientConfig -): Promise { - return (await this.full.callWithWeirdParameterNames( parameterHeader, - parameterQuery, - parameterForm, - parameterCookie, - requestBody, - parameterPath1, - parameterPath2, - parameterPath3, - _default, - config -)).body; -} -/** - * @param requestBody This is a required parameter - * @param parameter This is an optional parameter - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ -public async getCallWithOptionalParam( - requestBody: ModelWithString, - parameter?: string, - config?: ClientConfig -): Promise { - return (await this.full.getCallWithOptionalParam( requestBody, - parameter, - config -)).body; -} -/** - * @param parameter This is a required parameter - * @param requestBody This is an optional parameter - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ -public async postCallWithOptionalParam( - parameter: string, - requestBody?: ModelWithString, - config?: ClientConfig -): Promise { - return (await this.full.postCallWithOptionalParam( parameter, - requestBody, - config -)).body; -} + return (await this.full.callWithParameters( + parameterHeader, parameterQuery, parameterForm, parameterCookie, parameterPath, requestBody, config + )).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 + * @param _default This is the parameter with a reserved keyword + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async callWithWeirdParameterNames( + parameterHeader: string | null, + parameterQuery: string | null, + parameterForm: string | null, + parameterCookie: string | null, + requestBody: ModelWithString | null, + parameterPath1?: string, + parameterPath2?: string, + parameterPath3?: string, + _default?: string, + config?: ClientConfig + ): Promise { + return (await this.full.callWithWeirdParameterNames( + parameterHeader, parameterQuery, parameterForm, parameterCookie, requestBody, parameterPath1, parameterPath2, parameterPath3, _default, config + )).body; + } + + /** + * @param requestBody This is a required parameter + * @param parameter This is an optional parameter + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async getCallWithOptionalParam( + requestBody: ModelWithString, + parameter?: string, + config?: ClientConfig + ): Promise { + return (await this.full.getCallWithOptionalParam( + requestBody, parameter, config + )).body; + } + + /** + * @param parameter This is a required parameter + * @param requestBody This is an optional parameter + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async postCallWithOptionalParam( + parameter: string, + requestBody?: ModelWithString, + config?: ClientConfig + ): Promise { + return (await this.full.postCallWithOptionalParam( + parameter, requestBody, config + )).body; + } + }" `; @@ -6606,10 +6577,11 @@ export class RequestBodyService { requestBody?: ModelWithString, config?: ClientConfig ): Promise { - return (await this.full.postRequestBodyService( requestBody, - config - )).body; -} + return (await this.full.postRequestBodyService( + requestBody, config + )).body; + } + }" `; @@ -6684,6 +6656,7 @@ export class ResponseService { public async callWithResponse(config?: ClientConfig): Promise { return (await this.full.callWithResponse(config)).body; } + /** * @param [config] the optional OpenAPI config to use * @returns ModelWithString Message for default response @@ -6692,6 +6665,7 @@ export class ResponseService { public async callWithDuplicateResponses(config?: ClientConfig): Promise { return (await this.full.callWithDuplicateResponses(config)).body; } + /** * @param [config] the optional OpenAPI config to use * @returns any Message for 200 response @@ -6707,6 +6681,7 @@ export class ResponseService { } | ModelWithString | ModelThatExtends | ModelThatExtendsExtends> { return (await this.full.callWithResponses(config)).body; } + }" `; @@ -6813,6 +6788,7 @@ export class SimpleService { public async getCallWithoutParametersAndResponse(config?: ClientConfig): Promise { return (await this.full.getCallWithoutParametersAndResponse(config)).body; } + /** * @param [config] the optional OpenAPI config to use * @throws ApiError @@ -6820,6 +6796,7 @@ export class SimpleService { public async putCallWithoutParametersAndResponse(config?: ClientConfig): Promise { return (await this.full.putCallWithoutParametersAndResponse(config)).body; } + /** * @param [config] the optional OpenAPI config to use * @throws ApiError @@ -6827,6 +6804,7 @@ export class SimpleService { public async postCallWithoutParametersAndResponse(config?: ClientConfig): Promise { return (await this.full.postCallWithoutParametersAndResponse(config)).body; } + /** * @param [config] the optional OpenAPI config to use * @throws ApiError @@ -6834,6 +6812,7 @@ export class SimpleService { public async deleteCallWithoutParametersAndResponse(config?: ClientConfig): Promise { return (await this.full.deleteCallWithoutParametersAndResponse(config)).body; } + /** * @param [config] the optional OpenAPI config to use * @throws ApiError @@ -6841,6 +6820,7 @@ export class SimpleService { public async optionsCallWithoutParametersAndResponse(config?: ClientConfig): Promise { return (await this.full.optionsCallWithoutParametersAndResponse(config)).body; } + /** * @param [config] the optional OpenAPI config to use * @throws ApiError @@ -6848,6 +6828,7 @@ export class SimpleService { public async headCallWithoutParametersAndResponse(config?: ClientConfig): Promise { return (await this.full.headCallWithoutParametersAndResponse(config)).body; } + /** * @param [config] the optional OpenAPI config to use * @throws ApiError @@ -6855,6 +6836,7 @@ export class SimpleService { public async patchCallWithoutParametersAndResponse(config?: ClientConfig): Promise { return (await this.full.patchCallWithoutParametersAndResponse(config)).body; } + }" `; @@ -7000,17 +6982,11 @@ export class TypesService { id?: number, config?: ClientConfig ): Promise { - return (await this.full.types( parameterArray, - parameterDictionary, - parameterEnum, - parameterNumber, - parameterString, - parameterBoolean, - parameterObject, - id, - config - )).body; -} + return (await this.full.types( + parameterArray, parameterDictionary, parameterEnum, parameterNumber, parameterString, parameterBoolean, parameterObject, id, config + )).body; + } + }" `; @@ -7104,10 +7080,11 @@ export class UploadService { file: Blob, config?: ClientConfig ): Promise { - return (await this.full.uploadFile( file, - config - )).body; -} + return (await this.full.uploadFile( + file, config + )).body; + } + }" `; diff --git a/test/__snapshots__/index.spec.js.snap b/test/__snapshots__/index.spec.js.snap index 4e7018161..3618474d0 100644 --- a/test/__snapshots__/index.spec.js.snap +++ b/test/__snapshots__/index.spec.js.snap @@ -1916,14 +1916,11 @@ export class CollectionFormatService { parameterArrayMulti: Array, ): Promise { - return (await CollectionFormatServiceFull.collectionFormat( parameterArrayCsv, - parameterArraySsv, - parameterArrayTsv, - parameterArrayPipes, - parameterArrayMulti, + return (await CollectionFormatServiceFull.collectionFormat( + parameterArrayCsv, parameterArraySsv, parameterArrayTsv, parameterArrayPipes, parameterArrayMulti, + )).body; + } - )).body; -} }" `; @@ -2003,11 +2000,11 @@ export class ComplexService { parameterReference: ModelWithString, ): Promise> { - return (await ComplexServiceFull.complexTypes( parameterObject, - parameterReference, + return (await ComplexServiceFull.complexTypes( + parameterObject, parameterReference, + )).body; + } - )).body; -} }" `; @@ -2093,69 +2090,59 @@ export class DefaultsService { }, ): Promise { - return (await DefaultsServiceFull.callWithDefaultParameters( parameterString, - parameterNumber, - parameterBoolean, - parameterEnum, - parameterModel, + return (await DefaultsServiceFull.callWithDefaultParameters( + parameterString, parameterNumber, parameterBoolean, parameterEnum, parameterModel, + )).body; + } - )).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 + /** + * @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!\\" - }, + * @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 { - return (await DefaultsServiceFull.callWithDefaultOptionalParameters( parameterString, - parameterNumber, - parameterBoolean, - parameterEnum, - parameterModel, + ): Promise { + return (await DefaultsServiceFull.callWithDefaultOptionalParameters( + parameterString, parameterNumber, parameterBoolean, parameterEnum, parameterModel, + )).body; + } -)).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 + /** + * @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 World!', + parameterStringWithEmptyDefault: string = '', + + ): Promise { + return (await DefaultsServiceFull.callToTestOrderOfParams( + parameterStringWithNoDefault, parameterOptionalStringWithDefault, parameterOptionalStringWithEmptyDefault, parameterOptionalStringWithNoDefault, parameterStringWithDefault, parameterStringWithEmptyDefault, + )).body; + } - * @throws ApiError - */ -public static async callToTestOrderOfParams( - parameterStringWithNoDefault: string, - parameterOptionalStringWithDefault: string = 'Hello World!', - parameterOptionalStringWithEmptyDefault: string = '', - parameterOptionalStringWithNoDefault?: string, - parameterStringWithDefault: string = 'Hello World!', - parameterStringWithEmptyDefault: string = '', - -): Promise { - return (await DefaultsServiceFull.callToTestOrderOfParams( parameterStringWithNoDefault, - parameterOptionalStringWithDefault, - parameterOptionalStringWithEmptyDefault, - parameterOptionalStringWithNoDefault, - parameterStringWithDefault, - parameterStringWithEmptyDefault, - -)).body; -} }" `; @@ -2291,6 +2278,7 @@ export class DuplicateService { public static async duplicateName(): Promise { return (await DuplicateServiceFull.duplicateName()).body; } + /** * @throws ApiError @@ -2298,6 +2286,7 @@ export class DuplicateService { public static async duplicateName1(): Promise { return (await DuplicateServiceFull.duplicateName1()).body; } + /** * @throws ApiError @@ -2305,6 +2294,7 @@ export class DuplicateService { public static async duplicateName2(): Promise { return (await DuplicateServiceFull.duplicateName2()).body; } + /** * @throws ApiError @@ -2312,6 +2302,7 @@ export class DuplicateService { public static async duplicateName3(): Promise { return (await DuplicateServiceFull.duplicateName3()).body; } + }" `; @@ -2392,6 +2383,7 @@ export class HeaderService { public static async callWithResultFromHeader(): Promise { return (await HeaderServiceFull.callWithResultFromHeader()).body; } + }" `; @@ -2445,6 +2437,7 @@ export class NoContentService { public static async callWithNoContentResponse(): Promise { return (await NoContentServiceFull.callWithNoContentResponse()).body; } + }" `; @@ -2502,48 +2495,39 @@ export class ParametersService { parameterPath: string, ): Promise { - return (await ParametersServiceFull.callWithParameters( parameterHeader, - parameterQuery, - parameterForm, - parameterBody, - parameterPath, + return (await ParametersServiceFull.callWithParameters( + parameterHeader, parameterQuery, parameterForm, parameterBody, parameterPath, + )).body; + } - )).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 - * @param _default This is the parameter with a reserved keyword + /** + * @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 + * @param _default This is the parameter with a reserved keyword + + * @throws ApiError + */ + public static async callWithWeirdParameterNames( + parameterHeader: string, + parameterQuery: string, + parameterForm: string, + parameterBody: string, + parameterPath1?: string, + parameterPath2?: string, + parameterPath3?: string, + _default?: string, + + ): Promise { + return (await ParametersServiceFull.callWithWeirdParameterNames( + parameterHeader, parameterQuery, parameterForm, parameterBody, parameterPath1, parameterPath2, parameterPath3, _default, + )).body; + } - * @throws ApiError - */ -public static async callWithWeirdParameterNames( - parameterHeader: string, - parameterQuery: string, - parameterForm: string, - parameterBody: string, - parameterPath1?: string, - parameterPath2?: string, - parameterPath3?: string, - _default?: string, - -): Promise { - return (await ParametersServiceFull.callWithWeirdParameterNames( parameterHeader, - parameterQuery, - parameterForm, - parameterBody, - parameterPath1, - parameterPath2, - parameterPath3, - _default, - -)).body; -} }" `; @@ -2658,6 +2642,7 @@ export class ResponseService { public static async callWithResponse(): Promise { return (await ResponseServiceFull.callWithResponse()).body; } + /** * @returns ModelWithString Message for default response @@ -2666,6 +2651,7 @@ export class ResponseService { public static async callWithDuplicateResponses(): Promise { return (await ResponseServiceFull.callWithDuplicateResponses()).body; } + /** * @returns any Message for 200 response @@ -2681,6 +2667,7 @@ export class ResponseService { } | ModelWithString | ModelThatExtends | ModelThatExtendsExtends> { return (await ResponseServiceFull.callWithResponses()).body; } + }" `; @@ -2774,6 +2761,7 @@ export class SimpleService { public static async getCallWithoutParametersAndResponse(): Promise { return (await SimpleServiceFull.getCallWithoutParametersAndResponse()).body; } + /** * @throws ApiError @@ -2781,6 +2769,7 @@ export class SimpleService { public static async putCallWithoutParametersAndResponse(): Promise { return (await SimpleServiceFull.putCallWithoutParametersAndResponse()).body; } + /** * @throws ApiError @@ -2788,6 +2777,7 @@ export class SimpleService { public static async postCallWithoutParametersAndResponse(): Promise { return (await SimpleServiceFull.postCallWithoutParametersAndResponse()).body; } + /** * @throws ApiError @@ -2795,6 +2785,7 @@ export class SimpleService { public static async deleteCallWithoutParametersAndResponse(): Promise { return (await SimpleServiceFull.deleteCallWithoutParametersAndResponse()).body; } + /** * @throws ApiError @@ -2802,6 +2793,7 @@ export class SimpleService { public static async optionsCallWithoutParametersAndResponse(): Promise { return (await SimpleServiceFull.optionsCallWithoutParametersAndResponse()).body; } + /** * @throws ApiError @@ -2809,6 +2801,7 @@ export class SimpleService { public static async headCallWithoutParametersAndResponse(): Promise { return (await SimpleServiceFull.headCallWithoutParametersAndResponse()).body; } + /** * @throws ApiError @@ -2816,6 +2809,7 @@ export class SimpleService { public static async patchCallWithoutParametersAndResponse(): Promise { return (await SimpleServiceFull.patchCallWithoutParametersAndResponse()).body; } + }" `; @@ -2948,17 +2942,11 @@ export class TypesService { id?: number, ): Promise { - return (await TypesServiceFull.types( parameterArray, - parameterDictionary, - parameterEnum, - parameterNumber, - parameterString, - parameterBoolean, - parameterObject, - id, - - )).body; -} + return (await TypesServiceFull.types( + parameterArray, parameterDictionary, parameterEnum, parameterNumber, parameterString, parameterBoolean, parameterObject, id, + )).body; + } + }" `; @@ -5239,14 +5227,11 @@ export class CollectionFormatService { parameterArrayMulti: Array | null, ): Promise { - return (await CollectionFormatServiceFull.collectionFormat( parameterArrayCsv, - parameterArraySsv, - parameterArrayTsv, - parameterArrayPipes, - parameterArrayMulti, + return (await CollectionFormatServiceFull.collectionFormat( + parameterArrayCsv, parameterArraySsv, parameterArrayTsv, parameterArrayPipes, parameterArrayMulti, + )).body; + } - )).body; -} }" `; @@ -5329,40 +5314,40 @@ export class ComplexService { parameterReference: ModelWithString, ): Promise> { - return (await ComplexServiceFull.complexTypes( parameterObject, - parameterReference, + return (await ComplexServiceFull.complexTypes( + parameterObject, parameterReference, + )).body; + } - )).body; -} -/** - * @param id - * @param requestBody + /** + * @param id + * @param requestBody - * @returns 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: (ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary), - readonly user?: { - readonly id?: number, - readonly name?: string | null, + * @returns 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: (ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary), + readonly user?: { + readonly id?: number, + readonly name?: string | null, + }, }, - }, -): Promise { - return (await ComplexServiceFull.complexParams( id, - requestBody, + ): Promise { + return (await ComplexServiceFull.complexParams( + id, requestBody, + )).body; + } -)).body; -} }" `; @@ -5483,69 +5468,59 @@ export class DefaultsService { }, ): Promise { - return (await DefaultsServiceFull.callWithDefaultParameters( parameterString, - parameterNumber, - parameterBoolean, - parameterEnum, - parameterModel, + return (await DefaultsServiceFull.callWithDefaultParameters( + parameterString, parameterNumber, parameterBoolean, parameterEnum, parameterModel, + )).body; + } - )).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 + /** + * @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!\\" - }, + * @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 { - return (await DefaultsServiceFull.callWithDefaultOptionalParameters( parameterString, - parameterNumber, - parameterBoolean, - parameterEnum, - parameterModel, + ): Promise { + return (await DefaultsServiceFull.callWithDefaultOptionalParameters( + parameterString, parameterNumber, parameterBoolean, parameterEnum, parameterModel, + )).body; + } -)).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 + /** + * @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 World!', + parameterStringWithEmptyDefault: string = '', + + ): Promise { + return (await DefaultsServiceFull.callToTestOrderOfParams( + parameterStringWithNoDefault, parameterOptionalStringWithDefault, parameterOptionalStringWithEmptyDefault, parameterOptionalStringWithNoDefault, parameterStringWithDefault, parameterStringWithEmptyDefault, + )).body; + } - * @throws ApiError - */ -public static async callToTestOrderOfParams( - parameterStringWithNoDefault: string, - parameterOptionalStringWithDefault: string = 'Hello World!', - parameterOptionalStringWithEmptyDefault: string = '', - parameterOptionalStringWithNoDefault?: string, - parameterStringWithDefault: string = 'Hello World!', - parameterStringWithEmptyDefault: string = '', - -): Promise { - return (await DefaultsServiceFull.callToTestOrderOfParams( parameterStringWithNoDefault, - parameterOptionalStringWithDefault, - parameterOptionalStringWithEmptyDefault, - parameterOptionalStringWithNoDefault, - parameterStringWithDefault, - parameterStringWithEmptyDefault, - -)).body; -} }" `; @@ -5681,6 +5656,7 @@ export class DuplicateService { public static async duplicateName(): Promise { return (await DuplicateServiceFull.duplicateName()).body; } + /** * @throws ApiError @@ -5688,6 +5664,7 @@ export class DuplicateService { public static async duplicateName1(): Promise { return (await DuplicateServiceFull.duplicateName1()).body; } + /** * @throws ApiError @@ -5695,6 +5672,7 @@ export class DuplicateService { public static async duplicateName2(): Promise { return (await DuplicateServiceFull.duplicateName2()).body; } + /** * @throws ApiError @@ -5702,6 +5680,7 @@ export class DuplicateService { public static async duplicateName3(): Promise { return (await DuplicateServiceFull.duplicateName3()).body; } + }" `; @@ -5782,6 +5761,7 @@ export class HeaderService { public static async callWithResultFromHeader(): Promise { return (await HeaderServiceFull.callWithResultFromHeader()).body; } + }" `; @@ -5841,6 +5821,7 @@ export class MultipartService { }> { return (await MultipartServiceFull.multipartResponse()).body; } + }" `; @@ -5895,6 +5876,7 @@ export class NoContentService { public static async callWithNoContentResponse(): Promise { return (await NoContentServiceFull.callWithNoContentResponse()).body; } + }" `; @@ -5957,84 +5939,73 @@ export class ParametersService { requestBody: ModelWithString | null, ): Promise { - return (await ParametersServiceFull.callWithParameters( parameterHeader, - parameterQuery, - parameterForm, - parameterCookie, - parameterPath, - requestBody, - - )).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 - * @param _default This is the parameter with a reserved keyword + return (await ParametersServiceFull.callWithParameters( + parameterHeader, parameterQuery, parameterForm, parameterCookie, parameterPath, requestBody, + )).body; + } - * @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, - _default?: string, - -): Promise { - return (await ParametersServiceFull.callWithWeirdParameterNames( parameterHeader, - parameterQuery, - parameterForm, - parameterCookie, - requestBody, - parameterPath1, - parameterPath2, - parameterPath3, - _default, - -)).body; -} -/** - * @param requestBody This is a required parameter - * @param parameter This is an optional parameter + /** + * @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 + * @param _default This is the parameter with a reserved keyword - * @throws ApiError - */ -public static async getCallWithOptionalParam( - requestBody: ModelWithString, - parameter?: string, + * @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, + _default?: string, -): Promise { - return (await ParametersServiceFull.getCallWithOptionalParam( requestBody, - parameter, + ): Promise { + return (await ParametersServiceFull.callWithWeirdParameterNames( + parameterHeader, parameterQuery, parameterForm, parameterCookie, requestBody, parameterPath1, parameterPath2, parameterPath3, _default, + )).body; + } -)).body; -} -/** - * @param parameter This is a required parameter - * @param requestBody This is an optional parameter + /** + * @param requestBody This is a required parameter + * @param parameter This is an optional parameter - * @throws ApiError - */ -public static async postCallWithOptionalParam( - parameter: string, - requestBody?: ModelWithString, + * @throws ApiError + */ + public static async getCallWithOptionalParam( + requestBody: ModelWithString, + parameter?: string, -): Promise { - return (await ParametersServiceFull.postCallWithOptionalParam( parameter, - requestBody, + ): Promise { + return (await ParametersServiceFull.getCallWithOptionalParam( + requestBody, parameter, + )).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 { + return (await ParametersServiceFull.postCallWithOptionalParam( + parameter, requestBody, + )).body; + } -)).body; -} }" `; @@ -6207,10 +6178,11 @@ export class RequestBodyService { requestBody?: ModelWithString, ): Promise { - return (await RequestBodyServiceFull.postRequestBodyService( requestBody, + return (await RequestBodyServiceFull.postRequestBodyService( + requestBody, + )).body; + } - )).body; -} }" `; @@ -6272,6 +6244,7 @@ export class ResponseService { public static async callWithResponse(): Promise { return (await ResponseServiceFull.callWithResponse()).body; } + /** * @returns ModelWithString Message for default response @@ -6280,6 +6253,7 @@ export class ResponseService { public static async callWithDuplicateResponses(): Promise { return (await ResponseServiceFull.callWithDuplicateResponses()).body; } + /** * @returns any Message for 200 response @@ -6295,6 +6269,7 @@ export class ResponseService { } | ModelWithString | ModelThatExtends | ModelThatExtendsExtends> { return (await ResponseServiceFull.callWithResponses()).body; } + }" `; @@ -6388,6 +6363,7 @@ export class SimpleService { public static async getCallWithoutParametersAndResponse(): Promise { return (await SimpleServiceFull.getCallWithoutParametersAndResponse()).body; } + /** * @throws ApiError @@ -6395,6 +6371,7 @@ export class SimpleService { public static async putCallWithoutParametersAndResponse(): Promise { return (await SimpleServiceFull.putCallWithoutParametersAndResponse()).body; } + /** * @throws ApiError @@ -6402,6 +6379,7 @@ export class SimpleService { public static async postCallWithoutParametersAndResponse(): Promise { return (await SimpleServiceFull.postCallWithoutParametersAndResponse()).body; } + /** * @throws ApiError @@ -6409,6 +6387,7 @@ export class SimpleService { public static async deleteCallWithoutParametersAndResponse(): Promise { return (await SimpleServiceFull.deleteCallWithoutParametersAndResponse()).body; } + /** * @throws ApiError @@ -6416,6 +6395,7 @@ export class SimpleService { public static async optionsCallWithoutParametersAndResponse(): Promise { return (await SimpleServiceFull.optionsCallWithoutParametersAndResponse()).body; } + /** * @throws ApiError @@ -6423,6 +6403,7 @@ export class SimpleService { public static async headCallWithoutParametersAndResponse(): Promise { return (await SimpleServiceFull.headCallWithoutParametersAndResponse()).body; } + /** * @throws ApiError @@ -6430,6 +6411,7 @@ export class SimpleService { public static async patchCallWithoutParametersAndResponse(): Promise { return (await SimpleServiceFull.patchCallWithoutParametersAndResponse()).body; } + }" `; @@ -6562,17 +6544,11 @@ export class TypesService { id?: number, ): Promise { - return (await TypesServiceFull.types( parameterArray, - parameterDictionary, - parameterEnum, - parameterNumber, - parameterString, - parameterBoolean, - parameterObject, - id, - - )).body; -} + return (await TypesServiceFull.types( + parameterArray, parameterDictionary, parameterEnum, parameterNumber, parameterString, parameterBoolean, parameterObject, id, + )).body; + } + }" `; @@ -6653,10 +6629,11 @@ export class UploadService { file: Blob, ): Promise { - return (await UploadServiceFull.uploadFile( file, + return (await UploadServiceFull.uploadFile( + file, + )).body; + } - )).body; -} }" `; From ad6dac92b395869d1cf091d69ab94b55dd2435bc Mon Sep 17 00:00:00 2001 From: lub0v-parsable Date: Mon, 20 Sep 2021 10:21:46 -0700 Subject: [PATCH 10/11] PE-2380 - properly generate client when no tags used --- package.json | 2 +- src/templates/exportAppClient.hbs | 8 +- src/utils/writeAppClient.ts | 11 +- test/__snapshots__/index.client.spec.js.snap | 11690 ++++++++++------- test/index.client.spec.js | 69 +- test/spec/v2_no_tags.json | 25 + test/spec/v2_tags_combined.json | 29 + test/spec/v3_no_tags.json | 25 + test/spec/v3_tags_combined.json | 31 + 9 files changed, 7093 insertions(+), 4797 deletions(-) create mode 100644 test/spec/v2_no_tags.json create mode 100644 test/spec/v2_tags_combined.json create mode 100644 test/spec/v3_no_tags.json create mode 100644 test/spec/v3_tags_combined.json diff --git a/package.json b/package.json index ee2bba952..2274f9f1b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@parsable/openapi-typescript-codegen", - "version": "0.0.3", + "version": "0.0.4", "description": "Library that generates Typescript clients based on the OpenAPI specification.", "author": "Ferdi Koomen", "homepage": "https://github.com/ferdikoomen/openapi-typescript-codegen", diff --git a/src/templates/exportAppClient.hbs b/src/templates/exportAppClient.hbs index 7c09a25ef..a3b93070f 100644 --- a/src/templates/exportAppClient.hbs +++ b/src/templates/exportAppClient.hbs @@ -10,8 +10,11 @@ import { {{/each}} } from './services'; {{/if}} +{{#if service}} +import { {{{service.name}}} } from './services'; +{{/if}} -export class {{{clientName}}} { +export class {{{clientName}}} {{#if service}}extends {{{service.name}}} {{/if}}{ {{#each services}} readonly {{{shortName}}}: {{{name}}}; {{/each}} @@ -26,6 +29,9 @@ export class {{{clientName}}} { password: clientConfig?.password, headers: clientConfig?.headers, } + {{#if service}} + super(httpClient, config); + {{/if}} {{#each services}} this.{{{shortName}}} = new {{{name}}}(httpClient, config); {{/each}} diff --git a/src/utils/writeAppClient.ts b/src/utils/writeAppClient.ts index fc2a86b6e..bf06b5a03 100644 --- a/src/utils/writeAppClient.ts +++ b/src/utils/writeAppClient.ts @@ -19,10 +19,13 @@ export async function writeAppClient(client: Client, templates: Templates, outpu await writeFile( resolve(outputPath, 'client.ts'), templates.client({ - services: sortServicesByName(client.services).map(s => ({ - name: s.name, - shortName: s.name.replace('Service', '').toLowerCase(), - })), + services: sortServicesByName(client.services) + .filter(s => s.name !== 'Service') + .map(s => ({ + name: s.name, + shortName: s.name.replace('Service', '').toLowerCase(), + })), + service: client.services.find(s => s.name === 'Service'), clientName, httpClientRequest: getHttpRequestName(httpClient), server: client.server, diff --git a/test/__snapshots__/index.client.spec.js.snap b/test/__snapshots__/index.client.spec.js.snap index 4f8aa0390..cfa4b28b8 100644 --- a/test/__snapshots__/index.client.spec.js.snap +++ b/test/__snapshots__/index.client.spec.js.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`v2 should generate with exportClient: ./test/generated/v2_client/client.ts 1`] = ` +exports[`v2 should generate with combined tags: ./test/generated/v2_client_tags_combined/client.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ @@ -9,29 +9,12 @@ import type { BaseHttpRequest } from './core'; import { FetchHttpRequest } from './core'; import type { ClientConfig } from './core'; import { - CollectionFormatService, - ComplexService, - DefaultsService, - DuplicateService, - HeaderService, - NoContentService, - ParametersService, - ResponseService, SimpleService, - TypesService, } from './services'; +import { Service } from './services'; -export class TestClient { - readonly collectionformat: CollectionFormatService; - readonly complex: ComplexService; - readonly defaults: DefaultsService; - readonly duplicate: DuplicateService; - readonly header: HeaderService; - readonly nocontent: NoContentService; - readonly parameters: ParametersService; - readonly response: ResponseService; +export class TestClient extends Service { readonly simple: SimpleService; - readonly types: TypesService; constructor(clientConfig: ClientConfig, httpClient: BaseHttpRequest = new FetchHttpRequest()) { const config = { @@ -43,21 +26,13 @@ export class TestClient { password: clientConfig?.password, headers: clientConfig?.headers, } - this.collectionformat = new CollectionFormatService(httpClient, config); - this.complex = new ComplexService(httpClient, config); - this.defaults = new DefaultsService(httpClient, config); - this.duplicate = new DuplicateService(httpClient, config); - this.header = new HeaderService(httpClient, config); - this.nocontent = new NoContentService(httpClient, config); - this.parameters = new ParametersService(httpClient, config); - this.response = new ResponseService(httpClient, config); + super(httpClient, config); this.simple = new SimpleService(httpClient, config); - this.types = new TypesService(httpClient, config); } }" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/core/ApiError.ts 1`] = ` +exports[`v2 should generate with combined tags: ./test/generated/v2_client_tags_combined/core/ApiError.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ @@ -81,7 +56,7 @@ export class ApiError extends Error { }" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/core/ApiRequestOptions.ts 1`] = ` +exports[`v2 should generate with combined tags: ./test/generated/v2_client_tags_combined/core/ApiRequestOptions.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ @@ -100,7 +75,7 @@ export type ApiRequestOptions = { }" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/core/ApiResult.ts 1`] = ` +exports[`v2 should generate with combined tags: ./test/generated/v2_client_tags_combined/core/ApiResult.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ @@ -114,7 +89,7 @@ export type ApiResult = { }" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/core/BaseHttpRequest.ts 1`] = ` +exports[`v2 should generate with combined tags: ./test/generated/v2_client_tags_combined/core/BaseHttpRequest.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ @@ -132,7 +107,7 @@ export interface BaseHttpRequest { }" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/core/FetchHttpRequest.ts 1`] = ` +exports[`v2 should generate with combined tags: ./test/generated/v2_client_tags_combined/core/FetchHttpRequest.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ @@ -372,7 +347,7 @@ export class FetchHttpRequest implements BaseHttpRequest { " `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/core/OpenAPI.ts 1`] = ` +exports[`v2 should generate with combined tags: ./test/generated/v2_client_tags_combined/core/OpenAPI.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ @@ -394,7 +369,7 @@ export type ClientConfig = { " `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/core/index.ts 1`] = ` +exports[`v2 should generate with combined tags: ./test/generated/v2_client_tags_combined/core/index.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ @@ -408,7 +383,7 @@ export type { ClientConfig } from './OpenAPI'; " `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/index.ts 1`] = ` +exports[`v2 should generate with combined tags: ./test/generated/v2_client_tags_combined/index.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ @@ -422,701 +397,728 @@ export { TestClient } from './client'; " `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ArrayWithArray.ts 1`] = ` +exports[`v2 should generate with combined tags: ./test/generated/v2_client_tags_combined/models/index.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ - -import type { ModelWithString } from './ModelWithString'; - -/** - * This is a simple array containing an array - */ -export type ArrayWithArray = Array>;" +" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ArrayWithBooleans.ts 1`] = ` +exports[`v2 should generate with combined tags: ./test/generated/v2_client_tags_combined/schemas/index.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ - -/** - * This is a simple array with booleans - */ -export type ArrayWithBooleans = Array;" +" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ArrayWithNumbers.ts 1`] = ` +exports[`v2 should generate with combined tags: ./test/generated/v2_client_tags_combined/services/Service.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { BaseHttpRequest, ClientConfig } from '../core'; +import { ServiceFull } from './ServiceFull'; -/** - * This is a simple array with numbers - */ -export type ArrayWithNumbers = Array;" -`; +export class Service { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; + readonly full: ServiceFull; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ArrayWithProperties.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + this.full = new ServiceFull(httpRequest, clientConfig); + } -/** - * This is a simple array with properties - */ -export type ArrayWithProperties = Array<{ - foo?: string, - bar?: string, -}>;" + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async postCallWithoutParametersAndResponse(config?: ClientConfig): Promise { + return (await this.full.postCallWithoutParametersAndResponse(config)).body; + } + +}" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ArrayWithReferences.ts 1`] = ` +exports[`v2 should generate with combined tags: ./test/generated/v2_client_tags_combined/services/ServiceFull.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; -import type { ModelWithString } from './ModelWithString'; +export class ServiceFull { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; -/** - * This is a simple array with references - */ -export type ArrayWithReferences = Array;" -`; + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + } -exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ArrayWithStrings.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async postCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { + return this.httpRequest.request({ + method: 'POST', + path: \`/api/v\${this.clientConfig.version}/simple\`, + }, this.clientConfig, config); + } -/** - * This is a simple array with strings - */ -export type ArrayWithStrings = Array;" +}" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/Date.ts 1`] = ` +exports[`v2 should generate with combined tags: ./test/generated/v2_client_tags_combined/services/SimpleService.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { BaseHttpRequest, ClientConfig } from '../core'; +import { SimpleServiceFull } from './SimpleServiceFull'; -/** - * This is a type-only model that defines Date as a string - */ -export type Date = string;" -`; - -exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/DictionaryWithArray.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ +export class SimpleService { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; + readonly full: SimpleServiceFull; -import type { ModelWithString } from './ModelWithString'; + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + this.full = new SimpleServiceFull(httpRequest, clientConfig); + } -/** - * This is a complex dictionary - */ -export type DictionaryWithArray = Record>;" -`; + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async getCallWithoutParametersAndResponse(config?: ClientConfig): Promise { + return (await this.full.getCallWithoutParametersAndResponse(config)).body; + } -exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/DictionaryWithDictionary.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async putCallWithoutParametersAndResponse(config?: ClientConfig): Promise { + return (await this.full.putCallWithoutParametersAndResponse(config)).body; + } -/** - * This is a string dictionary - */ -export type DictionaryWithDictionary = Record>;" +}" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/DictionaryWithProperties.ts 1`] = ` +exports[`v2 should generate with combined tags: ./test/generated/v2_client_tags_combined/services/SimpleServiceFull.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; -/** - * This is a complex dictionary - */ -export type DictionaryWithProperties = Record;" -`; - -exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/DictionaryWithReference.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ +export class SimpleServiceFull { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; -import type { ModelWithString } from './ModelWithString'; + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + } -/** - * This is a string reference - */ -export type DictionaryWithReference = Record;" -`; + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async getCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { + return this.httpRequest.request({ + method: 'GET', + path: \`/api/v\${this.clientConfig.version}/simple\`, + }, this.clientConfig, config); + } -exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/DictionaryWithString.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async putCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { + return this.httpRequest.request({ + method: 'PUT', + path: \`/api/v\${this.clientConfig.version}/simple\`, + }, this.clientConfig, config); + } -/** - * This is a string dictionary - */ -export type DictionaryWithString = Record;" +}" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/EnumFromDescription.ts 1`] = ` +exports[`v2 should generate with combined tags: ./test/generated/v2_client_tags_combined/services/index.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ - -/** - * Success=1,Warning=2,Error=3 - */ -export enum EnumFromDescription { - SUCCESS = 1, - WARNING = 2, - ERROR = 3, -}" +export { Service } from './Service'; +export { ServiceFull } from './ServiceFull'; +export { SimpleService } from './SimpleService'; +export { SimpleServiceFull } from './SimpleServiceFull'; +" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/EnumWithExtensions.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/client.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { BaseHttpRequest } from './core'; +import { FetchHttpRequest } from './core'; +import type { ClientConfig } from './core'; +import { + CollectionFormatService, + ComplexService, + DefaultsService, + DuplicateService, + HeaderService, + NoContentService, + ParametersService, + ResponseService, + SimpleService, + TypesService, +} from './services'; -/** - * 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 with exportClient: ./test/generated/v2_client/models/EnumWithNumbers.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ +export class TestClient { + readonly collectionformat: CollectionFormatService; + readonly complex: ComplexService; + readonly defaults: DefaultsService; + readonly duplicate: DuplicateService; + readonly header: HeaderService; + readonly nocontent: NoContentService; + readonly parameters: ParametersService; + readonly response: ResponseService; + readonly simple: SimpleService; + readonly types: TypesService; -/** - * This is a simple enum with numbers - */ -export enum EnumWithNumbers { - '_1' = 1, - '_2' = 2, - '_3' = 3, - '_1.1' = 1.1, - '_1.2' = 1.2, - '_1.3' = 1.3, - '_100' = 100, - '_200' = 200, - '_300' = 300, - '_-100' = -100, - '_-200' = -200, - '_-300' = -300, - '_-1.1' = -1.1, - '_-1.2' = -1.2, - '_-1.3' = -1.3, + constructor(clientConfig: ClientConfig, httpClient: BaseHttpRequest = new FetchHttpRequest()) { + const config = { + baseUrl: clientConfig?.baseUrl ?? 'http://localhost:3000/base', + version: clientConfig?.version ?? '1.0', + withCredentials: clientConfig?.withCredentials ?? false, + token: clientConfig?.token, + username: clientConfig?.username, + password: clientConfig?.password, + headers: clientConfig?.headers, + } + this.collectionformat = new CollectionFormatService(httpClient, config); + this.complex = new ComplexService(httpClient, config); + this.defaults = new DefaultsService(httpClient, config); + this.duplicate = new DuplicateService(httpClient, config); + this.header = new HeaderService(httpClient, config); + this.nocontent = new NoContentService(httpClient, config); + this.parameters = new ParametersService(httpClient, config); + this.response = new ResponseService(httpClient, config); + this.simple = new SimpleService(httpClient, config); + this.types = new TypesService(httpClient, config); + } }" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/EnumWithStrings.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/core/ApiError.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { ApiResult } from './ApiResult'; -/** - * This is a simple enum with strings - */ -export enum EnumWithStrings { - SUCCESS = 'Success', - WARNING = 'Warning', - ERROR = 'Error', -}" -`; - -exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelThatExtends.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ +export class ApiError extends Error { + public readonly url: string; + public readonly status: number; + public readonly statusText: string; + public readonly body: any; -import type { ModelWithString } from './ModelWithString'; + constructor(response: ApiResult, message: string) { + super(message); -/** - * This is a model that extends another model - */ -export type ModelThatExtends = (ModelWithString & { - propExtendsA?: string, - propExtendsB?: ModelWithString, -}); -" + this.url = response.url; + this.status = response.status; + this.statusText = response.statusText; + this.body = response.body; + } +}" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelThatExtendsExtends.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/core/ApiRequestOptions.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ - -import type { ModelThatExtends } from './ModelThatExtends'; -import type { ModelWithString } from './ModelWithString'; - -/** - * This is a model that extends another model - */ -export type ModelThatExtendsExtends = (ModelWithString & ModelThatExtends & { - propExtendsC?: string, - propExtendsD?: ModelWithString, -}); -" +export type ApiRequestOptions = { + readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH'; + readonly path: string; + readonly cookies?: Record; + readonly headers?: Record; + readonly query?: Record; + readonly formData?: Record; + readonly body?: any; + readonly mediaType?: string; + readonly responseHeader?: string; + readonly errors?: Record; +}" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithArray.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/core/ApiResult.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ - -import type { ModelWithString } from './ModelWithString'; - -/** - * This is a model with one property containing an array - */ -export type ModelWithArray = { - prop?: Array; - propWithFile?: Array; - propWithNumber?: Array; -} -" +export type ApiResult = { + readonly url: string; + readonly ok: boolean; + readonly status: number; + readonly statusText: string; + readonly body: T; +}" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithBoolean.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/core/BaseHttpRequest.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { ApiRequestOptions } from './ApiRequestOptions'; +import type { ApiResult } from './ApiResult'; +import type { ClientConfig } from './OpenAPI'; -/** - * This is a model with one boolean property - */ -export type ModelWithBoolean = { - /** - * This is a simple boolean property - */ - prop?: boolean; -} -" +export interface BaseHttpRequest { + request( + options: ApiRequestOptions, + config: ClientConfig, + mergeConfig?: ClientConfig + ): Promise>; +}" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithCircularReference.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/core/FetchHttpRequest.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import { ApiError } from './ApiError'; +import type { ApiRequestOptions } from './ApiRequestOptions'; +import type { ApiResult } from './ApiResult'; +import type { ClientConfig } from './OpenAPI'; +import type { BaseHttpRequest } from './BaseHttpRequest'; -/** - * This is a model with one property containing a circular reference - */ -export type ModelWithCircularReference = { - prop?: ModelWithCircularReference; +function isDefined(value: T | null | undefined): value is Exclude { + return value !== undefined && value !== null; } -" -`; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithDictionary.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ +function isString(value: any): value is string { + return typeof value === 'string'; +} -/** - * This is a model with one property containing a dictionary - */ -export type ModelWithDictionary = { - prop?: Record; +export function deepAssign( + target: Record, + source: Record, +): Record { + const keys = Object.keys(source); + for (const k of keys) { + const sourceValue: unknown = source[k]; + const targetValue: unknown = target[k]; + if (Object(sourceValue) === sourceValue && Object(targetValue) === targetValue) { + target[k] = deepAssign( + targetValue as Record, + sourceValue as Record, + ); + } else { + target[k] = source[k]; + } + } + return target; } -" -`; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithDuplicateImports.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ +function isStringWithValue(value: any): value is string { + return isString(value) && value !== ''; +} -import type { ModelWithString } from './ModelWithString'; +function isBlob(value: any): value is Blob { + return value instanceof Blob; +} -/** - * This is a model with duplicated imports - */ -export type ModelWithDuplicateImports = { - propA?: ModelWithString; - propB?: ModelWithString; - propC?: ModelWithString; +function getQueryString(params: Record): string { + const qs: string[] = []; + Object.keys(params).forEach(key => { + const value = params[key]; + if (isDefined(value)) { + 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 with exportClient: ./test/generated/v2_client/models/ModelWithDuplicateProperties.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ +function getUrl(options: ApiRequestOptions, config: ClientConfig): string { + const path = options.path.replace(/[:]/g, '_'); + const url = \`\${config.baseUrl}\${path}\`; -import type { ModelWithString } from './ModelWithString'; + if (options.query) { + return \`\${url}\${getQueryString(options.query)}\`; + } + return url; +} -/** - * This is a model with duplicated properties - */ -export type ModelWithDuplicateProperties = { - prop?: ModelWithString; +function getFormData(params: Record): FormData { + const formData = new FormData(); + Object.keys(params).forEach(key => { + const value = params[key]; + if (isDefined(value)) { + formData.append(key, value); + } + }); + return formData; } -" -`; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithEnum.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ +type Resolver = (options: ApiRequestOptions) => Promise; -/** - * This is a model with one enum - */ -export type ModelWithEnum = { - /** - * This is a simple enum with strings - */ - test?: ModelWithEnum.test; - /** - * These are the HTTP error code enums - */ - statusCode?: ModelWithEnum.statusCode; - /** - * Simple boolean enum - */ - bool?: boolean; +async function resolve(options: ApiRequestOptions, resolver?: T | Resolver): Promise { + if (typeof resolver === 'function') { + return (resolver as Resolver)(options); + } + return resolver; } -export namespace ModelWithEnum { +async function getHeaders(options: ApiRequestOptions, config: ClientConfig): Promise { + const token = await resolve(options, config.token); + const username = await resolve(options, config.username); + const password = await resolve(options, config.password); + const defaultHeaders = await resolve(options, config.headers); - /** - * This is a simple enum with strings - */ - export enum test { - SUCCESS = 'Success', - WARNING = 'Warning', - ERROR = 'Error', + const headers = new Headers({ + Accept: 'application/json', + ...defaultHeaders, + ...options.headers, + }); + + if (isStringWithValue(token)) { + headers.append('Authorization', \`Bearer \${token}\`); } - /** - * 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', + if (isStringWithValue(username) && isStringWithValue(password)) { + const credentials = btoa(\`\${username}:\${password}\`); + headers.append('Authorization', \`Basic \${credentials}\`); + } + + if (options.body) { + if (options.mediaType) { + headers.append('Content-Type', options.mediaType); + } else if (isBlob(options.body)) { + headers.append('Content-Type', options.body.type || 'application/octet-stream'); + } else if (isString(options.body)) { + headers.append('Content-Type', 'text/plain'); + } else { + headers.append('Content-Type', 'application/json'); + } } + return headers; +} +function getRequestBody(options: ApiRequestOptions): BodyInit | undefined { + if (options.formData) { + return getFormData(options.formData); + } + if (options.body) { + if (options.mediaType?.includes('/json')) { + return JSON.stringify(options.body) + } else if (isString(options.body) || isBlob(options.body)) { + return options.body; + } else { + return JSON.stringify(options.body); + } + } + return undefined; +} +async function sendRequest(options: ApiRequestOptions, config: ClientConfig, url: string): Promise { + const request: RequestInit = { + method: options.method, + headers: await getHeaders(options, config), + body: getRequestBody(options), + }; + if (config.withCredentials) { + request.credentials = 'include'; + } + return await fetch(url, request); } -" -`; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithEnumFromDescription.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ +function getResponseHeader(response: Response, responseHeader?: string): string | null { + if (responseHeader) { + const content = response.headers.get(responseHeader); + if (isString(content)) { + return content; + } + } + return null; +} -/** - * This is a model with one enum - */ -export type ModelWithEnumFromDescription = { - /** - * Success=1,Warning=2,Error=3 - */ - test?: ModelWithEnumFromDescription.test; +async function getResponseBody(response: Response): Promise { + try { + const contentType = response.headers.get('Content-Type'); + if (contentType) { + const isJSON = contentType.toLowerCase().startsWith('application/json'); + if (isJSON) { + return await response.json(); + } else { + return await response.text(); + } + } + } catch (error) { + console.error(error); + } + return null; } -export namespace ModelWithEnumFromDescription { +function catchErrors(options: ApiRequestOptions, result: ApiResult): void { + const errors: Record = { + 400: 'Bad Request', + 401: 'Unauthorized', + 403: 'Forbidden', + 404: 'Not Found', + 500: 'Internal Server Error', + 502: 'Bad Gateway', + 503: 'Service Unavailable', + ...options.errors, + } - /** - * Success=1,Warning=2,Error=3 - */ - export enum test { - SUCCESS = 1, - WARNING = 2, - ERROR = 3, + const error = errors[result.status]; + if (error) { + throw new ApiError(result, error); + } + + if (!result.ok) { + throw new ApiError(result, 'Generic Error'); } +} + +export class FetchHttpRequest implements BaseHttpRequest { + /** + * Request using fetch client + * @param options The request options from the the service + * @param config The OpenAPI configuration + * @param [mergeConfig] Additional optional OpenAPI configuration that will be merged with the first one + * @returns ApiResult + * @throws ApiError + */ + async request(options: ApiRequestOptions, config: ClientConfig, mergeConfig?: ClientConfig): Promise { + const conf = mergeConfig ? deepAssign(config, mergeConfig) : config; + const url = getUrl(options, conf); + const response = await sendRequest(options, conf, url); + const responseBody = await getResponseBody(response); + const responseHeader = getResponseHeader(response, options.responseHeader); + const result: ApiResult = { + url, + ok: response.ok, + status: response.status, + statusText: response.statusText, + body: responseHeader || responseBody, + }; + catchErrors(options, result); + return result; + } } " `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithInteger.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/core/OpenAPI.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { ApiRequestOptions } from './ApiRequestOptions'; -/** - * This is a model with one number property - */ -export type ModelWithInteger = { - /** - * This is a simple number property - */ - prop?: number; +type Resolver = (options: ApiRequestOptions) => Promise; +type Headers = Record; + +export type ClientConfig = { + baseUrl?: string; + version?: string; + withCredentials?: boolean; + token?: string | Resolver; + username?: string | Resolver; + password?: string | Resolver; + headers?: Headers | Resolver; } " `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithNestedEnums.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/core/index.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ - -/** - * This is a model with nested enums - */ -export type ModelWithNestedEnums = { - dictionaryWithEnum?: Record; - dictionaryWithEnumFromDescription?: Record; - arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; - arrayWithDescription?: Array<1 | 2 | 3>; -} +export { ApiError } from './ApiError'; +export type { ApiRequestOptions } from './ApiRequestOptions'; +export type { ApiResult } from './ApiResult'; +export type { BaseHttpRequest } from './BaseHttpRequest'; +export { FetchHttpRequest } from './FetchHttpRequest'; +export type { ClientConfig } from './OpenAPI'; " `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithNestedProperties.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/index.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +export * from './core'; +export * from './models'; +export * from './schemas'; +export * from './services'; -/** - * This is a model with one nested property - */ -export type ModelWithNestedProperties = { - readonly first: { - readonly second: { - readonly third: string, - }, - }; -} +export { TestClient } from './client'; " `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithNullableString.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ArrayWithArray.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { ModelWithString } from './ModelWithString'; + /** - * This is a model with one string property + * This is a simple array containing an array */ -export type ModelWithNullableString = { - /** - * This is a simple string property - */ - nullableProp?: string | null; - /** - * This is a simple string property - */ - nullableRequiredProp: string | null; -} -" +export type ArrayWithArray = Array>;" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithOrderedProperties.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ArrayWithBooleans.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ /** - * This is a model with ordered properties + * This is a simple array with booleans */ -export type ModelWithOrderedProperties = { - zebra?: string; - apple?: string; - hawaii?: string; -} -" +export type ArrayWithBooleans = Array;" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithPattern.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ArrayWithNumbers.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ /** - * This is a model that contains a some patterns + * This is a simple array with numbers */ -export type ModelWithPattern = { - key: string; - name: string; - readonly enabled?: boolean; - readonly modified?: string; - id?: string; - text?: string; -} -" +export type ArrayWithNumbers = Array;" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithProperties.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ArrayWithProperties.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ModelWithString } from './ModelWithString'; - /** - * This is a model with one nested property + * This is a simple array with properties */ -export type ModelWithProperties = { - required: string; - readonly requiredAndReadOnly: string; - string?: string; - number?: number; - boolean?: boolean; - reference?: ModelWithString; - 'property with space'?: string; - default?: string; - try?: string; - readonly '@namespace.string'?: string; - readonly '@namespace.integer'?: number; -} -" +export type ArrayWithProperties = Array<{ + foo?: string, + bar?: string, +}>;" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithReference.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ArrayWithReferences.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ModelWithProperties } from './ModelWithProperties'; +import type { ModelWithString } from './ModelWithString'; /** - * This is a model with one property containing a reference + * This is a simple array with references */ -export type ModelWithReference = { - prop?: ModelWithProperties; -} -" +export type ArrayWithReferences = Array;" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithString.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ArrayWithStrings.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ /** - * This is a model with one string property + * This is a simple array with strings */ -export type ModelWithString = { - /** - * This is a simple string property - */ - prop?: string; -} -" +export type ArrayWithStrings = Array;" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/MultilineComment.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/Date.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ /** - * Testing multiline comments. - * This must go to the next line. - * - * This will contain a break. + * This is a type-only model that defines Date as a string */ -export type MultilineComment = number;" +export type Date = string;" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/SimpleBoolean.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/DictionaryWithArray.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { ModelWithString } from './ModelWithString'; + /** - * This is a simple boolean + * This is a complex dictionary */ -export type SimpleBoolean = boolean;" +export type DictionaryWithArray = Record>;" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/SimpleFile.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/DictionaryWithDictionary.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ /** - * This is a simple file + * This is a string dictionary */ -export type SimpleFile = Blob;" +export type DictionaryWithDictionary = Record>;" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/SimpleInteger.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/DictionaryWithProperties.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ /** - * This is a simple number + * This is a complex dictionary */ -export type SimpleInteger = number;" +export type DictionaryWithProperties = Record;" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/SimpleReference.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/DictionaryWithReference.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ @@ -1125,1796 +1127,1594 @@ exports[`v2 should generate with exportClient: ./test/generated/v2_client/models import type { ModelWithString } from './ModelWithString'; /** - * This is a simple reference + * This is a string reference */ -export type SimpleReference = ModelWithString;" +export type DictionaryWithReference = Record;" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/SimpleString.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/DictionaryWithString.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ /** - * This is a simple string + * This is a string dictionary */ -export type SimpleString = string;" +export type DictionaryWithString = Record;" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/SimpleStringWithPattern.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/EnumFromDescription.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ /** - * This is a simple string + * Success=1,Warning=2,Error=3 */ -export type SimpleStringWithPattern = string;" +export enum EnumFromDescription { + SUCCESS = 1, + WARNING = 2, + ERROR = 3, +}" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/index.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/EnumWithExtensions.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export type { ArrayWithArray } from './ArrayWithArray'; -export type { ArrayWithBooleans } from './ArrayWithBooleans'; -export type { ArrayWithNumbers } from './ArrayWithNumbers'; -export type { ArrayWithProperties } from './ArrayWithProperties'; -export type { ArrayWithReferences } from './ArrayWithReferences'; -export type { ArrayWithStrings } from './ArrayWithStrings'; -export type { Date } from './Date'; -export type { DictionaryWithArray } from './DictionaryWithArray'; -export type { DictionaryWithDictionary } from './DictionaryWithDictionary'; -export type { DictionaryWithProperties } from './DictionaryWithProperties'; -export type { DictionaryWithReference } from './DictionaryWithReference'; -export type { DictionaryWithString } from './DictionaryWithString'; -export { EnumFromDescription } from './EnumFromDescription'; -export { EnumWithExtensions } from './EnumWithExtensions'; -export { EnumWithNumbers } from './EnumWithNumbers'; -export { EnumWithStrings } from './EnumWithStrings'; -export type { ModelThatExtends } from './ModelThatExtends'; -export type { ModelThatExtendsExtends } from './ModelThatExtendsExtends'; -export type { ModelWithArray } from './ModelWithArray'; -export type { ModelWithBoolean } from './ModelWithBoolean'; -export type { ModelWithCircularReference } from './ModelWithCircularReference'; -export type { ModelWithDictionary } from './ModelWithDictionary'; -export type { ModelWithDuplicateImports } from './ModelWithDuplicateImports'; -export type { ModelWithDuplicateProperties } from './ModelWithDuplicateProperties'; -export type { ModelWithEnum } from './ModelWithEnum'; -export type { ModelWithEnumFromDescription } from './ModelWithEnumFromDescription'; -export type { ModelWithInteger } from './ModelWithInteger'; -export type { ModelWithNestedEnums } from './ModelWithNestedEnums'; -export type { ModelWithNestedProperties } from './ModelWithNestedProperties'; -export type { ModelWithNullableString } from './ModelWithNullableString'; -export type { ModelWithOrderedProperties } from './ModelWithOrderedProperties'; -export type { ModelWithPattern } from './ModelWithPattern'; -export type { ModelWithProperties } from './ModelWithProperties'; -export type { ModelWithReference } from './ModelWithReference'; -export type { ModelWithString } from './ModelWithString'; -export type { MultilineComment } from './MultilineComment'; -export type { SimpleBoolean } from './SimpleBoolean'; -export type { SimpleFile } from './SimpleFile'; -export type { SimpleInteger } from './SimpleInteger'; -export type { SimpleReference } from './SimpleReference'; -export type { SimpleString } from './SimpleString'; -export type { SimpleStringWithPattern } from './SimpleStringWithPattern'; -" + +/** + * 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 with exportClient: ./test/generated/v2_client/schemas/$ArrayWithArray.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/EnumWithNumbers.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $ArrayWithArray = { - type: 'array', - contains: { - type: 'array', - contains: { - type: 'ModelWithString', - }, - }, -};" -`; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ArrayWithBooleans.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -export const $ArrayWithBooleans = { - type: 'array', - contains: { - type: 'boolean', - }, -};" +/** + * This is a simple enum with numbers + */ +export enum EnumWithNumbers { + '_1' = 1, + '_2' = 2, + '_3' = 3, + '_1.1' = 1.1, + '_1.2' = 1.2, + '_1.3' = 1.3, + '_100' = 100, + '_200' = 200, + '_300' = 300, + '_-100' = -100, + '_-200' = -200, + '_-300' = -300, + '_-1.1' = -1.1, + '_-1.2' = -1.2, + '_-1.3' = -1.3, +}" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ArrayWithNumbers.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/EnumWithStrings.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $ArrayWithNumbers = { - type: 'array', - contains: { - type: 'number', - }, -};" -`; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ArrayWithProperties.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -export const $ArrayWithProperties = { - type: 'array', - contains: { - properties: { - foo: { - type: 'string', - }, - bar: { - type: 'string', - }, - }, - }, -};" +/** + * This is a simple enum with strings + */ +export enum EnumWithStrings { + SUCCESS = 'Success', + WARNING = 'Warning', + ERROR = 'Error', +}" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ArrayWithReferences.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelThatExtends.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $ArrayWithReferences = { - type: 'array', - contains: { - type: 'ModelWithString', - }, -};" -`; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ArrayWithStrings.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -export const $ArrayWithStrings = { - type: 'array', - contains: { - type: 'string', - }, -};" -`; +import type { ModelWithString } from './ModelWithString'; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$Date.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -export const $Date = { - type: 'string', -};" +/** + * This is a model that extends another model + */ +export type ModelThatExtends = (ModelWithString & { + propExtendsA?: string, + propExtendsB?: ModelWithString, +}); +" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$DictionaryWithArray.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelThatExtendsExtends.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $DictionaryWithArray = { - type: 'dictionary', - contains: { - type: 'array', - contains: { - type: 'ModelWithString', - }, - }, -};" + +import type { ModelThatExtends } from './ModelThatExtends'; +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model that extends another model + */ +export type ModelThatExtendsExtends = (ModelWithString & ModelThatExtends & { + propExtendsC?: string, + propExtendsD?: ModelWithString, +}); +" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$DictionaryWithDictionary.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithArray.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $DictionaryWithDictionary = { - type: 'dictionary', - contains: { - type: 'dictionary', - contains: { - type: 'string', - }, - }, -};" + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArray = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +} +" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$DictionaryWithProperties.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithBoolean.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $DictionaryWithProperties = { - type: 'dictionary', - contains: { - properties: { - foo: { - type: 'string', - }, - bar: { - type: 'string', - }, - }, - }, -};" + +/** + * This is a model with one boolean property + */ +export type ModelWithBoolean = { + /** + * This is a simple boolean property + */ + prop?: boolean; +} +" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$DictionaryWithReference.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithCircularReference.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $DictionaryWithReference = { - type: 'dictionary', - contains: { - type: 'ModelWithString', - }, -};" + +/** + * This is a model with one property containing a circular reference + */ +export type ModelWithCircularReference = { + prop?: ModelWithCircularReference; +} +" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$DictionaryWithString.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithDictionary.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $DictionaryWithString = { - type: 'dictionary', - contains: { - type: 'string', - }, -};" + +/** + * This is a model with one property containing a dictionary + */ +export type ModelWithDictionary = { + prop?: Record; +} +" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$EnumFromDescription.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithDuplicateImports.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $EnumFromDescription = { - type: 'Enum', -};" + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model with duplicated imports + */ +export type ModelWithDuplicateImports = { + propA?: ModelWithString; + propB?: ModelWithString; + propC?: ModelWithString; +} +" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$EnumWithExtensions.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithDuplicateProperties.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $EnumWithExtensions = { - type: 'Enum', -};" + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model with duplicated properties + */ +export type ModelWithDuplicateProperties = { + prop?: ModelWithString; +} +" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$EnumWithNumbers.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithEnum.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $EnumWithNumbers = { - type: 'Enum', -};" -`; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$EnumWithStrings.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -export const $EnumWithStrings = { - type: 'Enum', -};" +/** + * This is a model with one enum + */ +export type ModelWithEnum = { + /** + * This is a simple enum with strings + */ + test?: ModelWithEnum.test; + /** + * These are the HTTP error code enums + */ + statusCode?: ModelWithEnum.statusCode; + /** + * Simple boolean enum + */ + bool?: boolean; +} + +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 with exportClient: ./test/generated/v2_client/schemas/$ModelThatExtends.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithEnumFromDescription.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $ModelThatExtends = { - type: 'all-of', - contains: [{ - type: 'ModelWithString', - }, { - properties: { - propExtendsA: { - type: 'string', - }, - propExtendsB: { - type: 'ModelWithString', - }, - }, - }], -};" + +/** + * This is a model with one enum + */ +export type 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 with exportClient: ./test/generated/v2_client/schemas/$ModelThatExtendsExtends.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithInteger.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $ModelThatExtendsExtends = { - type: 'all-of', - contains: [{ - type: 'ModelWithString', - }, { - type: 'ModelThatExtends', - }, { - properties: { - propExtendsC: { - type: 'string', - }, - propExtendsD: { - type: 'ModelWithString', - }, - }, - }], -};" + +/** + * This is a model with one number property + */ +export type ModelWithInteger = { + /** + * This is a simple number property + */ + prop?: number; +} +" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithArray.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithNestedEnums.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $ModelWithArray = { - properties: { - prop: { - type: 'array', - contains: { - type: 'ModelWithString', - }, - }, - propWithFile: { - type: 'array', - contains: { - type: 'File', - }, - }, - propWithNumber: { - type: 'array', - contains: { - type: 'number', - }, - }, - }, -};" + +/** + * This is a model with nested enums + */ +export type ModelWithNestedEnums = { + dictionaryWithEnum?: Record; + dictionaryWithEnumFromDescription?: Record; + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; + arrayWithDescription?: Array<1 | 2 | 3>; +} +" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithBoolean.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithNestedProperties.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $ModelWithBoolean = { - properties: { - prop: { - type: 'boolean', + +/** + * This is a model with one nested property + */ +export type ModelWithNestedProperties = { + readonly first: { + readonly second: { + readonly third: string, }, - }, -};" + }; +} +" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithCircularReference.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithNullableString.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $ModelWithCircularReference = { - properties: { - prop: { - type: 'ModelWithCircularReference', - }, - }, -};" + +/** + * This is a model with one string property + */ +export type ModelWithNullableString = { + /** + * This is a simple string property + */ + nullableProp?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp: string | null; +} +" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithDictionary.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithOrderedProperties.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $ModelWithDictionary = { - properties: { - prop: { - type: 'dictionary', - contains: { - type: 'string', - }, - }, - }, -};" + +/** + * This is a model with ordered properties + */ +export type ModelWithOrderedProperties = { + zebra?: string; + apple?: string; + hawaii?: string; +} +" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithDuplicateImports.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithPattern.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $ModelWithDuplicateImports = { - properties: { - propA: { - type: 'ModelWithString', - }, - propB: { - type: 'ModelWithString', - }, - propC: { - type: 'ModelWithString', - }, - }, -};" + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPattern = { + key: string; + name: string; + readonly enabled?: boolean; + readonly modified?: string; + id?: string; + text?: string; +} +" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithDuplicateProperties.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithProperties.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $ModelWithDuplicateProperties = { - properties: { - prop: { - type: 'ModelWithString', - }, - }, -};" + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model with one nested property + */ +export type ModelWithProperties = { + required: string; + readonly requiredAndReadOnly: string; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + 'property with space'?: string; + default?: string; + try?: string; + readonly '@namespace.string'?: string; + readonly '@namespace.integer'?: number; +} +" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithEnum.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithReference.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $ModelWithEnum = { - properties: { - test: { - type: 'Enum', - }, - statusCode: { - type: 'Enum', - }, - bool: { - type: 'boolean', - }, - }, -};" + +import type { ModelWithProperties } from './ModelWithProperties'; + +/** + * This is a model with one property containing a reference + */ +export type ModelWithReference = { + prop?: ModelWithProperties; +} +" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithEnumFromDescription.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/ModelWithString.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $ModelWithEnumFromDescription = { - properties: { - test: { - type: 'Enum', - }, - }, -};" + +/** + * This is a model with one string property + */ +export type ModelWithString = { + /** + * This is a simple string property + */ + prop?: string; +} +" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithInteger.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/MultilineComment.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $ModelWithInteger = { - properties: { - prop: { - type: 'number', - }, - }, -};" + +/** + * Testing multiline comments. + * This must go to the next line. + * + * This will contain a break. + */ +export type MultilineComment = number;" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithNestedEnums.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/SimpleBoolean.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $ModelWithNestedEnums = { - properties: { - dictionaryWithEnum: { - type: 'dictionary', - contains: { - type: 'Enum', - }, - }, - dictionaryWithEnumFromDescription: { - type: 'dictionary', - contains: { - type: 'Enum', - }, - }, - arrayWithEnum: { - type: 'array', - contains: { - type: 'Enum', - }, - }, - arrayWithDescription: { - type: 'array', - contains: { - type: 'Enum', - }, - }, - }, -};" + +/** + * This is a simple boolean + */ +export type SimpleBoolean = boolean;" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithNestedProperties.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/SimpleFile.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* 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, - }, - }, -};" + +/** + * This is a simple file + */ +export type SimpleFile = Blob;" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithNullableString.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/SimpleInteger.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $ModelWithNullableString = { - properties: { - nullableProp: { - type: 'string', - isNullable: true, - }, - nullableRequiredProp: { - type: 'string', - isRequired: true, - isNullable: true, - }, - }, -};" + +/** + * This is a simple number + */ +export type SimpleInteger = number;" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithOrderedProperties.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/SimpleReference.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $ModelWithOrderedProperties = { - properties: { - zebra: { - type: 'string', - }, - apple: { - type: 'string', - }, - hawaii: { - type: 'string', - }, - }, -};" + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a simple reference + */ +export type SimpleReference = ModelWithString;" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithPattern.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/SimpleString.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* 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', - }, - id: { - type: 'string', - pattern: '^\\\\\\\\d{2}-\\\\\\\\d{3}-\\\\\\\\d{4}$', - }, - text: { - type: 'string', - pattern: '^\\\\\\\\w+$', - }, - }, -};" + +/** + * This is a simple string + */ +export type SimpleString = string;" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithProperties.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/SimpleStringWithPattern.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* 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', - }, - 'property with space': { - type: 'string', - }, - default: { - type: 'string', - }, - try: { - type: 'string', - }, - '@namespace.string': { - type: 'string', - isReadOnly: true, - }, - '@namespace.integer': { - type: 'number', - isReadOnly: true, + +/** + * This is a simple string + */ +export type SimpleStringWithPattern = string;" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/models/index.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type { ArrayWithArray } from './ArrayWithArray'; +export type { ArrayWithBooleans } from './ArrayWithBooleans'; +export type { ArrayWithNumbers } from './ArrayWithNumbers'; +export type { ArrayWithProperties } from './ArrayWithProperties'; +export type { ArrayWithReferences } from './ArrayWithReferences'; +export type { ArrayWithStrings } from './ArrayWithStrings'; +export type { Date } from './Date'; +export type { DictionaryWithArray } from './DictionaryWithArray'; +export type { DictionaryWithDictionary } from './DictionaryWithDictionary'; +export type { DictionaryWithProperties } from './DictionaryWithProperties'; +export type { DictionaryWithReference } from './DictionaryWithReference'; +export type { DictionaryWithString } from './DictionaryWithString'; +export { EnumFromDescription } from './EnumFromDescription'; +export { EnumWithExtensions } from './EnumWithExtensions'; +export { EnumWithNumbers } from './EnumWithNumbers'; +export { EnumWithStrings } from './EnumWithStrings'; +export type { ModelThatExtends } from './ModelThatExtends'; +export type { ModelThatExtendsExtends } from './ModelThatExtendsExtends'; +export type { ModelWithArray } from './ModelWithArray'; +export type { ModelWithBoolean } from './ModelWithBoolean'; +export type { ModelWithCircularReference } from './ModelWithCircularReference'; +export type { ModelWithDictionary } from './ModelWithDictionary'; +export type { ModelWithDuplicateImports } from './ModelWithDuplicateImports'; +export type { ModelWithDuplicateProperties } from './ModelWithDuplicateProperties'; +export type { ModelWithEnum } from './ModelWithEnum'; +export type { ModelWithEnumFromDescription } from './ModelWithEnumFromDescription'; +export type { ModelWithInteger } from './ModelWithInteger'; +export type { ModelWithNestedEnums } from './ModelWithNestedEnums'; +export type { ModelWithNestedProperties } from './ModelWithNestedProperties'; +export type { ModelWithNullableString } from './ModelWithNullableString'; +export type { ModelWithOrderedProperties } from './ModelWithOrderedProperties'; +export type { ModelWithPattern } from './ModelWithPattern'; +export type { ModelWithProperties } from './ModelWithProperties'; +export type { ModelWithReference } from './ModelWithReference'; +export type { ModelWithString } from './ModelWithString'; +export type { MultilineComment } from './MultilineComment'; +export type { SimpleBoolean } from './SimpleBoolean'; +export type { SimpleFile } from './SimpleFile'; +export type { SimpleInteger } from './SimpleInteger'; +export type { SimpleReference } from './SimpleReference'; +export type { SimpleString } from './SimpleString'; +export type { SimpleStringWithPattern } from './SimpleStringWithPattern'; +" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ArrayWithArray.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ArrayWithArray = { + type: 'array', + contains: { + type: 'array', + contains: { + type: 'ModelWithString', }, }, };" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithReference.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ArrayWithBooleans.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $ModelWithReference = { - properties: { - prop: { - type: 'ModelWithProperties', - }, +export const $ArrayWithBooleans = { + type: 'array', + contains: { + type: 'boolean', }, };" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithString.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ArrayWithNumbers.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $ModelWithString = { - properties: { - prop: { - type: 'string', - }, +export const $ArrayWithNumbers = { + type: 'array', + contains: { + type: 'number', }, };" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$MultilineComment.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ArrayWithProperties.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $MultilineComment = { - type: 'number', +export const $ArrayWithProperties = { + type: 'array', + contains: { + properties: { + foo: { + type: 'string', + }, + bar: { + type: 'string', + }, + }, + }, };" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$SimpleBoolean.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ArrayWithReferences.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $SimpleBoolean = { - type: 'boolean', +export const $ArrayWithReferences = { + type: 'array', + contains: { + type: 'ModelWithString', + }, };" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$SimpleFile.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ArrayWithStrings.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $SimpleFile = { - type: 'File', +export const $ArrayWithStrings = { + type: 'array', + contains: { + type: 'string', + }, };" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$SimpleInteger.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$Date.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $SimpleInteger = { - type: 'number', +export const $Date = { + type: 'string', };" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$SimpleReference.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$DictionaryWithArray.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $SimpleReference = { - type: 'ModelWithString', +export const $DictionaryWithArray = { + type: 'dictionary', + contains: { + type: 'array', + contains: { + type: 'ModelWithString', + }, + }, };" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$SimpleString.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$DictionaryWithDictionary.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $SimpleString = { - type: 'string', +export const $DictionaryWithDictionary = { + type: 'dictionary', + contains: { + type: 'dictionary', + contains: { + type: 'string', + }, + }, };" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$SimpleStringWithPattern.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$DictionaryWithProperties.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $SimpleStringWithPattern = { - type: 'string', - maxLength: 64, - pattern: '^[a-zA-Z0-9_]*$', +export const $DictionaryWithProperties = { + type: 'dictionary', + contains: { + properties: { + foo: { + type: 'string', + }, + bar: { + type: 'string', + }, + }, + }, };" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/index.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$DictionaryWithReference.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export { $ArrayWithArray } from './$ArrayWithArray'; -export { $ArrayWithBooleans } from './$ArrayWithBooleans'; -export { $ArrayWithNumbers } from './$ArrayWithNumbers'; -export { $ArrayWithProperties } from './$ArrayWithProperties'; -export { $ArrayWithReferences } from './$ArrayWithReferences'; -export { $ArrayWithStrings } from './$ArrayWithStrings'; -export { $Date } from './$Date'; -export { $DictionaryWithArray } from './$DictionaryWithArray'; -export { $DictionaryWithDictionary } from './$DictionaryWithDictionary'; -export { $DictionaryWithProperties } from './$DictionaryWithProperties'; -export { $DictionaryWithReference } from './$DictionaryWithReference'; -export { $DictionaryWithString } from './$DictionaryWithString'; -export { $EnumFromDescription } from './$EnumFromDescription'; -export { $EnumWithExtensions } from './$EnumWithExtensions'; -export { $EnumWithNumbers } from './$EnumWithNumbers'; -export { $EnumWithStrings } from './$EnumWithStrings'; -export { $ModelThatExtends } from './$ModelThatExtends'; -export { $ModelThatExtendsExtends } from './$ModelThatExtendsExtends'; -export { $ModelWithArray } from './$ModelWithArray'; -export { $ModelWithBoolean } from './$ModelWithBoolean'; -export { $ModelWithCircularReference } from './$ModelWithCircularReference'; -export { $ModelWithDictionary } from './$ModelWithDictionary'; -export { $ModelWithDuplicateImports } from './$ModelWithDuplicateImports'; -export { $ModelWithDuplicateProperties } from './$ModelWithDuplicateProperties'; -export { $ModelWithEnum } from './$ModelWithEnum'; -export { $ModelWithEnumFromDescription } from './$ModelWithEnumFromDescription'; -export { $ModelWithInteger } from './$ModelWithInteger'; -export { $ModelWithNestedEnums } from './$ModelWithNestedEnums'; -export { $ModelWithNestedProperties } from './$ModelWithNestedProperties'; -export { $ModelWithNullableString } from './$ModelWithNullableString'; -export { $ModelWithOrderedProperties } from './$ModelWithOrderedProperties'; -export { $ModelWithPattern } from './$ModelWithPattern'; -export { $ModelWithProperties } from './$ModelWithProperties'; -export { $ModelWithReference } from './$ModelWithReference'; -export { $ModelWithString } from './$ModelWithString'; -export { $MultilineComment } from './$MultilineComment'; -export { $SimpleBoolean } from './$SimpleBoolean'; -export { $SimpleFile } from './$SimpleFile'; -export { $SimpleInteger } from './$SimpleInteger'; -export { $SimpleReference } from './$SimpleReference'; -export { $SimpleString } from './$SimpleString'; -export { $SimpleStringWithPattern } from './$SimpleStringWithPattern'; -" +export const $DictionaryWithReference = { + type: 'dictionary', + contains: { + type: 'ModelWithString', + }, +};" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/CollectionFormatService.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$DictionaryWithString.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { BaseHttpRequest, ClientConfig } from '../core'; -import { CollectionFormatServiceFull } from './CollectionFormatServiceFull'; - -export class CollectionFormatService { - private readonly httpRequest: BaseHttpRequest; - private readonly clientConfig: ClientConfig; - readonly full: CollectionFormatServiceFull; +export const $DictionaryWithString = { + type: 'dictionary', + contains: { + type: 'string', + }, +};" +`; - constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { - this.httpRequest = httpRequest; - this.clientConfig = clientConfig; - this.full = new CollectionFormatServiceFull(httpRequest, clientConfig); - } - - /** - * @param parameterArrayCsv This is an array parameter that is send as csv format (comma-separated values) - * @param parameterArraySsv This is an array parameter that is send as ssv format (space-separated values) - * @param parameterArrayTsv This is an array parameter that is send as tsv format (tab-separated values) - * @param parameterArrayPipes This is an array parameter that is send as pipes format (pipe-separated values) - * @param parameterArrayMulti This is an array parameter that is send as multi format (multiple parameter instances) - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ - public async collectionFormat( - parameterArrayCsv: Array, - parameterArraySsv: Array, - parameterArrayTsv: Array, - parameterArrayPipes: Array, - parameterArrayMulti: Array, - config?: ClientConfig - ): Promise { - return (await this.full.collectionFormat( - parameterArrayCsv, parameterArraySsv, parameterArrayTsv, parameterArrayPipes, parameterArrayMulti, config - )).body; - } - -}" +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$EnumFromDescription.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $EnumFromDescription = { + type: 'Enum', +};" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/CollectionFormatServiceFull.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$EnumWithExtensions.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; +export const $EnumWithExtensions = { + type: 'Enum', +};" +`; -export class CollectionFormatServiceFull { - private readonly httpRequest: BaseHttpRequest; - private readonly clientConfig: ClientConfig; +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$EnumWithNumbers.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $EnumWithNumbers = { + type: 'Enum', +};" +`; - constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { - this.httpRequest = httpRequest; - this.clientConfig = clientConfig; - } +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$EnumWithStrings.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $EnumWithStrings = { + type: 'Enum', +};" +`; - /** - * @param parameterArrayCsv This is an array parameter that is send as csv format (comma-separated values) - * @param parameterArraySsv This is an array parameter that is send as ssv format (space-separated values) - * @param parameterArrayTsv This is an array parameter that is send as tsv format (tab-separated values) - * @param parameterArrayPipes This is an array parameter that is send as pipes format (pipe-separated values) - * @param parameterArrayMulti This is an array parameter that is send as multi format (multiple parameter instances) - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ - public async collectionFormat( - parameterArrayCsv: Array, - parameterArraySsv: Array, - parameterArrayTsv: Array, - parameterArrayPipes: Array, - parameterArrayMulti: Array, - config?: ClientConfig - ): Promise> { - return this.httpRequest.request({ - method: 'GET', - path: \`/api/v\${this.clientConfig.version}/collectionFormat\`, - query: { - 'parameterArrayCSV': parameterArrayCsv, - 'parameterArraySSV': parameterArraySsv, - 'parameterArrayTSV': parameterArrayTsv, - 'parameterArrayPipes': parameterArrayPipes, - 'parameterArrayMulti': parameterArrayMulti, +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelThatExtends.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelThatExtends = { + type: 'all-of', + contains: [{ + type: 'ModelWithString', + }, { + properties: { + propExtendsA: { + type: 'string', }, - }, this.clientConfig, config); - } - -}" + propExtendsB: { + type: 'ModelWithString', + }, + }, + }], +};" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/ComplexService.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelThatExtendsExtends.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { - ModelWithString, -} from '../models'; -import type { BaseHttpRequest, ClientConfig } from '../core'; -import { ComplexServiceFull } from './ComplexServiceFull'; - -export class ComplexService { - private readonly httpRequest: BaseHttpRequest; - private readonly clientConfig: ClientConfig; - readonly full: ComplexServiceFull; - - constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { - this.httpRequest = httpRequest; - this.clientConfig = clientConfig; - this.full = new ComplexServiceFull(httpRequest, clientConfig); - } - - /** - * @param parameterObject Parameter containing object - * @param parameterReference Parameter containing reference - * @param [config] the optional OpenAPI config to use - * @returns ModelWithString Successful response - * @throws ApiError - */ - public async complexTypes( - parameterObject: { - first?: { - second?: { - third?: string, - }, +export const $ModelThatExtendsExtends = { + type: 'all-of', + contains: [{ + type: 'ModelWithString', + }, { + type: 'ModelThatExtends', + }, { + properties: { + propExtendsC: { + type: 'string', + }, + propExtendsD: { + type: 'ModelWithString', }, }, - parameterReference: ModelWithString, - config?: ClientConfig - ): Promise> { - return (await this.full.complexTypes( - parameterObject, parameterReference, config - )).body; - } - -}" + }], +};" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/ComplexServiceFull.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithArray.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { - ModelWithString, -} from '../models'; -import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; - -export class ComplexServiceFull { - private readonly httpRequest: BaseHttpRequest; - private readonly clientConfig: ClientConfig; - - constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { - this.httpRequest = httpRequest; - this.clientConfig = clientConfig; - } - - /** - * @param parameterObject Parameter containing object - * @param parameterReference Parameter containing reference - * @param [config] the optional OpenAPI config to use - * @returns ModelWithString Successful response - * @throws ApiError - */ - public async complexTypes( - parameterObject: { - first?: { - second?: { - third?: string, - }, +export const $ModelWithArray = { + properties: { + prop: { + type: 'array', + contains: { + type: 'ModelWithString', }, }, - parameterReference: ModelWithString, - config?: ClientConfig - ): Promise>> { - return this.httpRequest.request({ - method: 'GET', - path: \`/api/v\${this.clientConfig.version}/complex\`, - query: { - 'parameterObject': parameterObject, - 'parameterReference': parameterReference, + propWithFile: { + type: 'array', + contains: { + type: 'File', }, - errors: { - 400: \`400 server error\`, - 500: \`500 server error\`, + }, + propWithNumber: { + type: 'array', + contains: { + type: 'number', }, - }, this.clientConfig, config); - } - -}" + }, + }, +};" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/DefaultsService.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithBoolean.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { - ModelWithString, -} from '../models'; -import type { BaseHttpRequest, ClientConfig } from '../core'; -import { DefaultsServiceFull } from './DefaultsServiceFull'; - -export class DefaultsService { - private readonly httpRequest: BaseHttpRequest; - private readonly clientConfig: ClientConfig; - readonly full: DefaultsServiceFull; +export const $ModelWithBoolean = { + properties: { + prop: { + type: 'boolean', + }, + }, +};" +`; - constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { - this.httpRequest = httpRequest; - this.clientConfig = clientConfig; - this.full = new DefaultsServiceFull(httpRequest, clientConfig); - } - - /** - * @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 - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ - public async callWithDefaultParameters( - parameterString: string = 'Hello World!', - parameterNumber: number = 123, - parameterBoolean: boolean = true, - parameterEnum: 'Success' | 'Warning' | 'Error' = 'Success', - parameterModel: ModelWithString = { - \\"prop\\": \\"Hello World!\\" +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithCircularReference.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithCircularReference = { + properties: { + prop: { + type: 'ModelWithCircularReference', }, - config?: ClientConfig - ): Promise { - return (await this.full.callWithDefaultParameters( - parameterString, parameterNumber, parameterBoolean, parameterEnum, parameterModel, config - )).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 - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ - public async callWithDefaultOptionalParameters( - parameterString: string = 'Hello World!', - parameterNumber: number = 123, - parameterBoolean: boolean = true, - parameterEnum: 'Success' | 'Warning' | 'Error' = 'Success', - parameterModel: ModelWithString = { - \\"prop\\": \\"Hello World!\\" +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithDictionary.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithDictionary = { + properties: { + prop: { + type: 'dictionary', + contains: { + type: 'string', + }, }, - config?: ClientConfig - ): Promise { - return (await this.full.callWithDefaultOptionalParameters( - parameterString, parameterNumber, parameterBoolean, parameterEnum, parameterModel, config - )).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 - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ - public async callToTestOrderOfParams( - parameterStringWithNoDefault: string, - parameterOptionalStringWithDefault: string = 'Hello World!', - parameterOptionalStringWithEmptyDefault: string = '', - parameterOptionalStringWithNoDefault?: string, - parameterStringWithDefault: string = 'Hello World!', - parameterStringWithEmptyDefault: string = '', - config?: ClientConfig - ): Promise { - return (await this.full.callToTestOrderOfParams( - parameterStringWithNoDefault, parameterOptionalStringWithDefault, parameterOptionalStringWithEmptyDefault, parameterOptionalStringWithNoDefault, parameterStringWithDefault, parameterStringWithEmptyDefault, config - )).body; - } - -}" + }, +};" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/DefaultsServiceFull.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithDuplicateImports.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { - ModelWithString, -} from '../models'; -import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; - -export class DefaultsServiceFull { - private readonly httpRequest: BaseHttpRequest; - private readonly clientConfig: ClientConfig; - - constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { - this.httpRequest = httpRequest; - this.clientConfig = clientConfig; - } - - /** - * @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 - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ - public async callWithDefaultParameters( - parameterString: string = 'Hello World!', - parameterNumber: number = 123, - parameterBoolean: boolean = true, - parameterEnum: 'Success' | 'Warning' | 'Error' = 'Success', - parameterModel: ModelWithString = { - \\"prop\\": \\"Hello World!\\" +export const $ModelWithDuplicateImports = { + properties: { + propA: { + type: 'ModelWithString', }, - config?: ClientConfig - ): Promise> { - return this.httpRequest.request({ - method: 'GET', - path: \`/api/v\${this.clientConfig.version}/defaults\`, - query: { - 'parameterString': parameterString, - 'parameterNumber': parameterNumber, - 'parameterBoolean': parameterBoolean, - 'parameterEnum': parameterEnum, - 'parameterModel': parameterModel, - }, - }, this.clientConfig, config); - } - - /** - * @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 - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ - public async callWithDefaultOptionalParameters( - parameterString: string = 'Hello World!', - parameterNumber: number = 123, - parameterBoolean: boolean = true, - parameterEnum: 'Success' | 'Warning' | 'Error' = 'Success', - parameterModel: ModelWithString = { - \\"prop\\": \\"Hello World!\\" + propB: { + type: 'ModelWithString', }, - config?: ClientConfig - ): Promise> { - return this.httpRequest.request({ - method: 'POST', - path: \`/api/v\${this.clientConfig.version}/defaults\`, - query: { - 'parameterString': parameterString, - 'parameterNumber': parameterNumber, - 'parameterBoolean': parameterBoolean, - 'parameterEnum': parameterEnum, - 'parameterModel': parameterModel, - }, - }, this.clientConfig, config); - } - - /** - * @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 - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ - public async callToTestOrderOfParams( - parameterStringWithNoDefault: string, - parameterOptionalStringWithDefault: string = 'Hello World!', - parameterOptionalStringWithEmptyDefault: string = '', - parameterOptionalStringWithNoDefault?: string, - parameterStringWithDefault: string = 'Hello World!', - parameterStringWithEmptyDefault: string = '', - config?: ClientConfig - ): Promise> { - return this.httpRequest.request({ - method: 'PUT', - path: \`/api/v\${this.clientConfig.version}/defaults\`, - query: { - 'parameterStringWithNoDefault': parameterStringWithNoDefault, - 'parameterOptionalStringWithDefault': parameterOptionalStringWithDefault, - 'parameterOptionalStringWithEmptyDefault': parameterOptionalStringWithEmptyDefault, - 'parameterOptionalStringWithNoDefault': parameterOptionalStringWithNoDefault, - 'parameterStringWithDefault': parameterStringWithDefault, - 'parameterStringWithEmptyDefault': parameterStringWithEmptyDefault, - }, - }, this.clientConfig, config); - } + propC: { + type: 'ModelWithString', + }, + }, +};" +`; -}" +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithDuplicateProperties.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithDuplicateProperties = { + properties: { + prop: { + type: 'ModelWithString', + }, + }, +};" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/DuplicateService.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithEnum.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { BaseHttpRequest, ClientConfig } from '../core'; -import { DuplicateServiceFull } from './DuplicateServiceFull'; +export const $ModelWithEnum = { + properties: { + test: { + type: 'Enum', + }, + statusCode: { + type: 'Enum', + }, + bool: { + type: 'boolean', + }, + }, +};" +`; -export class DuplicateService { - private readonly httpRequest: BaseHttpRequest; - private readonly clientConfig: ClientConfig; - readonly full: DuplicateServiceFull; - - constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { - this.httpRequest = httpRequest; - this.clientConfig = clientConfig; - this.full = new DuplicateServiceFull(httpRequest, clientConfig); - } - - /** - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ - public async duplicateName(config?: ClientConfig): Promise { - return (await this.full.duplicateName(config)).body; - } - - /** - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ - public async duplicateName1(config?: ClientConfig): Promise { - return (await this.full.duplicateName1(config)).body; - } - - /** - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ - public async duplicateName2(config?: ClientConfig): Promise { - return (await this.full.duplicateName2(config)).body; - } - - /** - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ - public async duplicateName3(config?: ClientConfig): Promise { - return (await this.full.duplicateName3(config)).body; - } - -}" -`; - -exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/DuplicateServiceFull.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithEnumFromDescription.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; - -export class DuplicateServiceFull { - private readonly httpRequest: BaseHttpRequest; - private readonly clientConfig: ClientConfig; - - constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { - this.httpRequest = httpRequest; - this.clientConfig = clientConfig; - } - - /** - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ - public async duplicateName(config?: ClientConfig): Promise> { - return this.httpRequest.request({ - method: 'GET', - path: \`/api/v\${this.clientConfig.version}/duplicate\`, - }, this.clientConfig, config); - } - - /** - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ - public async duplicateName1(config?: ClientConfig): Promise> { - return this.httpRequest.request({ - method: 'POST', - path: \`/api/v\${this.clientConfig.version}/duplicate\`, - }, this.clientConfig, config); - } - - /** - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ - public async duplicateName2(config?: ClientConfig): Promise> { - return this.httpRequest.request({ - method: 'PUT', - path: \`/api/v\${this.clientConfig.version}/duplicate\`, - }, this.clientConfig, config); - } - - /** - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ - public async duplicateName3(config?: ClientConfig): Promise> { - return this.httpRequest.request({ - method: 'DELETE', - path: \`/api/v\${this.clientConfig.version}/duplicate\`, - }, this.clientConfig, config); - } - -}" +export const $ModelWithEnumFromDescription = { + properties: { + test: { + type: 'Enum', + }, + }, +};" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/HeaderService.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithInteger.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { BaseHttpRequest, ClientConfig } from '../core'; -import { HeaderServiceFull } from './HeaderServiceFull'; - -export class HeaderService { - private readonly httpRequest: BaseHttpRequest; - private readonly clientConfig: ClientConfig; - readonly full: HeaderServiceFull; - - constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { - this.httpRequest = httpRequest; - this.clientConfig = clientConfig; - this.full = new HeaderServiceFull(httpRequest, clientConfig); - } - - /** - * @param [config] the optional OpenAPI config to use - * @returns string Successful response - * @throws ApiError - */ - public async callWithResultFromHeader(config?: ClientConfig): Promise { - return (await this.full.callWithResultFromHeader(config)).body; - } - -}" +export const $ModelWithInteger = { + properties: { + prop: { + type: 'number', + }, + }, +};" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/HeaderServiceFull.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithNestedEnums.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; - -export class HeaderServiceFull { - private readonly httpRequest: BaseHttpRequest; - private readonly clientConfig: ClientConfig; - - constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { - this.httpRequest = httpRequest; - this.clientConfig = clientConfig; - } - - /** - * @param [config] the optional OpenAPI config to use - * @returns string Successful response - * @throws ApiError - */ - public async callWithResultFromHeader(config?: ClientConfig): Promise> { - return this.httpRequest.request({ - method: 'POST', - path: \`/api/v\${this.clientConfig.version}/header\`, - responseHeader: 'operation-location', - errors: { - 400: \`400 server error\`, - 500: \`500 server error\`, +export const $ModelWithNestedEnums = { + properties: { + dictionaryWithEnum: { + type: 'dictionary', + contains: { + type: 'Enum', }, - }, this.clientConfig, config); - } - -}" + }, + dictionaryWithEnumFromDescription: { + type: 'dictionary', + contains: { + type: 'Enum', + }, + }, + arrayWithEnum: { + type: 'array', + contains: { + type: 'Enum', + }, + }, + arrayWithDescription: { + type: 'array', + contains: { + type: 'Enum', + }, + }, + }, +};" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/NoContentService.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithNestedProperties.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { BaseHttpRequest, ClientConfig } from '../core'; -import { NoContentServiceFull } from './NoContentServiceFull'; - -export class NoContentService { - private readonly httpRequest: BaseHttpRequest; - private readonly clientConfig: ClientConfig; - readonly full: NoContentServiceFull; - - constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { - this.httpRequest = httpRequest; - this.clientConfig = clientConfig; - this.full = new NoContentServiceFull(httpRequest, clientConfig); - } - - /** - * @param [config] the optional OpenAPI config to use - * @returns void - * @throws ApiError - */ - public async callWithNoContentResponse(config?: ClientConfig): Promise { - return (await this.full.callWithNoContentResponse(config)).body; - } - -}" +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 with exportClient: ./test/generated/v2_client/services/NoContentServiceFull.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithNullableString.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; - -export class NoContentServiceFull { - private readonly httpRequest: BaseHttpRequest; - private readonly clientConfig: ClientConfig; - - constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { - this.httpRequest = httpRequest; - this.clientConfig = clientConfig; - } - - /** - * @param [config] the optional OpenAPI config to use - * @returns void - * @throws ApiError - */ - public async callWithNoContentResponse(config?: ClientConfig): Promise> { - return this.httpRequest.request({ - method: 'GET', - path: \`/api/v\${this.clientConfig.version}/no-content\`, - }, this.clientConfig, config); - } +export const $ModelWithNullableString = { + properties: { + nullableProp: { + type: 'string', + isNullable: true, + }, + nullableRequiredProp: { + type: 'string', + isRequired: true, + isNullable: true, + }, + }, +};" +`; -}" +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithOrderedProperties.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithOrderedProperties = { + properties: { + zebra: { + type: 'string', + }, + apple: { + type: 'string', + }, + hawaii: { + type: 'string', + }, + }, +};" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/ParametersService.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithPattern.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { BaseHttpRequest, ClientConfig } from '../core'; -import { ParametersServiceFull } from './ParametersServiceFull'; +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', + }, + id: { + type: 'string', + pattern: '^\\\\\\\\d{2}-\\\\\\\\d{3}-\\\\\\\\d{4}$', + }, + text: { + type: 'string', + pattern: '^\\\\\\\\w+$', + }, + }, +};" +`; -export class ParametersService { - private readonly httpRequest: BaseHttpRequest; - private readonly clientConfig: ClientConfig; - readonly full: ParametersServiceFull; +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithProperties.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* 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', + }, + 'property with space': { + type: 'string', + }, + default: { + type: 'string', + }, + try: { + type: 'string', + }, + '@namespace.string': { + type: 'string', + isReadOnly: true, + }, + '@namespace.integer': { + type: 'number', + isReadOnly: true, + }, + }, +};" +`; - constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { - this.httpRequest = httpRequest; - this.clientConfig = clientConfig; - this.full = new ParametersServiceFull(httpRequest, clientConfig); - } +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithReference.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithReference = { + properties: { + prop: { + type: 'ModelWithProperties', + }, + }, +};" +`; - /** - * @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 - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ - public async callWithParameters( - parameterHeader: string, - parameterQuery: string, - parameterForm: string, - parameterBody: string, - parameterPath: string, - config?: ClientConfig - ): Promise { - return (await this.full.callWithParameters( - parameterHeader, parameterQuery, parameterForm, parameterBody, parameterPath, config - )).body; - } +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$ModelWithString.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithString = { + properties: { + prop: { + type: 'string', + }, + }, +};" +`; - /** - * @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 - * @param _default This is the parameter with a reserved keyword - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ - public async callWithWeirdParameterNames( - parameterHeader: string, - parameterQuery: string, - parameterForm: string, - parameterBody: string, - parameterPath1?: string, - parameterPath2?: string, - parameterPath3?: string, - _default?: string, - config?: ClientConfig - ): Promise { - return (await this.full.callWithWeirdParameterNames( - parameterHeader, parameterQuery, parameterForm, parameterBody, parameterPath1, parameterPath2, parameterPath3, _default, config - )).body; - } +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$MultilineComment.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $MultilineComment = { + type: 'number', +};" +`; -}" +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$SimpleBoolean.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $SimpleBoolean = { + type: 'boolean', +};" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/ParametersServiceFull.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$SimpleFile.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; +export const $SimpleFile = { + type: 'File', +};" +`; -export class ParametersServiceFull { - private readonly httpRequest: BaseHttpRequest; - private readonly clientConfig: ClientConfig; +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$SimpleInteger.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $SimpleInteger = { + type: 'number', +};" +`; - constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { - this.httpRequest = httpRequest; - this.clientConfig = clientConfig; - } +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$SimpleReference.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $SimpleReference = { + type: 'ModelWithString', +};" +`; - /** - * @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 - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ - public async callWithParameters( - parameterHeader: string, - parameterQuery: string, - parameterForm: string, - parameterBody: string, - parameterPath: string, - config?: ClientConfig - ): Promise> { - return this.httpRequest.request({ - method: 'GET', - path: \`/api/v\${this.clientConfig.version}/parameters/\${parameterPath}\`, - headers: { - 'parameterHeader': parameterHeader, - }, - query: { - 'parameterQuery': parameterQuery, - }, - formData: { - 'parameterForm': parameterForm, - }, - body: parameterBody, - }, this.clientConfig, config); - } +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$SimpleString.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $SimpleString = { + type: 'string', +};" +`; - /** - * @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 - * @param _default This is the parameter with a reserved keyword - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ - public async callWithWeirdParameterNames( - parameterHeader: string, - parameterQuery: string, - parameterForm: string, - parameterBody: string, - parameterPath1?: string, - parameterPath2?: string, - parameterPath3?: string, - _default?: string, - config?: ClientConfig - ): Promise> { - return this.httpRequest.request({ - method: 'GET', - path: \`/api/v\${this.clientConfig.version}/parameters/\${parameterPath1}/\${parameterPath2}/\${parameterPath3}\`, - headers: { - 'parameter.header': parameterHeader, - }, - query: { - 'parameter-query': parameterQuery, - 'default': _default, - }, - formData: { - 'parameter_form': parameterForm, - }, - body: parameterBody, - }, this.clientConfig, config); - } +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/$SimpleStringWithPattern.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $SimpleStringWithPattern = { + type: 'string', + maxLength: 64, + pattern: '^[a-zA-Z0-9_]*$', +};" +`; -}" +exports[`v2 should generate with exportClient: ./test/generated/v2_client/schemas/index.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export { $ArrayWithArray } from './$ArrayWithArray'; +export { $ArrayWithBooleans } from './$ArrayWithBooleans'; +export { $ArrayWithNumbers } from './$ArrayWithNumbers'; +export { $ArrayWithProperties } from './$ArrayWithProperties'; +export { $ArrayWithReferences } from './$ArrayWithReferences'; +export { $ArrayWithStrings } from './$ArrayWithStrings'; +export { $Date } from './$Date'; +export { $DictionaryWithArray } from './$DictionaryWithArray'; +export { $DictionaryWithDictionary } from './$DictionaryWithDictionary'; +export { $DictionaryWithProperties } from './$DictionaryWithProperties'; +export { $DictionaryWithReference } from './$DictionaryWithReference'; +export { $DictionaryWithString } from './$DictionaryWithString'; +export { $EnumFromDescription } from './$EnumFromDescription'; +export { $EnumWithExtensions } from './$EnumWithExtensions'; +export { $EnumWithNumbers } from './$EnumWithNumbers'; +export { $EnumWithStrings } from './$EnumWithStrings'; +export { $ModelThatExtends } from './$ModelThatExtends'; +export { $ModelThatExtendsExtends } from './$ModelThatExtendsExtends'; +export { $ModelWithArray } from './$ModelWithArray'; +export { $ModelWithBoolean } from './$ModelWithBoolean'; +export { $ModelWithCircularReference } from './$ModelWithCircularReference'; +export { $ModelWithDictionary } from './$ModelWithDictionary'; +export { $ModelWithDuplicateImports } from './$ModelWithDuplicateImports'; +export { $ModelWithDuplicateProperties } from './$ModelWithDuplicateProperties'; +export { $ModelWithEnum } from './$ModelWithEnum'; +export { $ModelWithEnumFromDescription } from './$ModelWithEnumFromDescription'; +export { $ModelWithInteger } from './$ModelWithInteger'; +export { $ModelWithNestedEnums } from './$ModelWithNestedEnums'; +export { $ModelWithNestedProperties } from './$ModelWithNestedProperties'; +export { $ModelWithNullableString } from './$ModelWithNullableString'; +export { $ModelWithOrderedProperties } from './$ModelWithOrderedProperties'; +export { $ModelWithPattern } from './$ModelWithPattern'; +export { $ModelWithProperties } from './$ModelWithProperties'; +export { $ModelWithReference } from './$ModelWithReference'; +export { $ModelWithString } from './$ModelWithString'; +export { $MultilineComment } from './$MultilineComment'; +export { $SimpleBoolean } from './$SimpleBoolean'; +export { $SimpleFile } from './$SimpleFile'; +export { $SimpleInteger } from './$SimpleInteger'; +export { $SimpleReference } from './$SimpleReference'; +export { $SimpleString } from './$SimpleString'; +export { $SimpleStringWithPattern } from './$SimpleStringWithPattern'; +" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/ResponseService.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/CollectionFormatService.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { - ModelThatExtends, - ModelThatExtendsExtends, - ModelWithString, -} from '../models'; import type { BaseHttpRequest, ClientConfig } from '../core'; -import { ResponseServiceFull } from './ResponseServiceFull'; +import { CollectionFormatServiceFull } from './CollectionFormatServiceFull'; -export class ResponseService { +export class CollectionFormatService { private readonly httpRequest: BaseHttpRequest; private readonly clientConfig: ClientConfig; - readonly full: ResponseServiceFull; + readonly full: CollectionFormatServiceFull; constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { this.httpRequest = httpRequest; this.clientConfig = clientConfig; - this.full = new ResponseServiceFull(httpRequest, clientConfig); + this.full = new CollectionFormatServiceFull(httpRequest, clientConfig); } /** + * @param parameterArrayCsv This is an array parameter that is send as csv format (comma-separated values) + * @param parameterArraySsv This is an array parameter that is send as ssv format (space-separated values) + * @param parameterArrayTsv This is an array parameter that is send as tsv format (tab-separated values) + * @param parameterArrayPipes This is an array parameter that is send as pipes format (pipe-separated values) + * @param parameterArrayMulti This is an array parameter that is send as multi format (multiple parameter instances) * @param [config] the optional OpenAPI config to use - * @returns ModelWithString Message for default response * @throws ApiError */ - public async callWithResponse(config?: ClientConfig): Promise { - return (await this.full.callWithResponse(config)).body; + public async collectionFormat( + parameterArrayCsv: Array, + parameterArraySsv: Array, + parameterArrayTsv: Array, + parameterArrayPipes: Array, + parameterArrayMulti: Array, + config?: ClientConfig + ): Promise { + return (await this.full.collectionFormat( + parameterArrayCsv, parameterArraySsv, parameterArrayTsv, parameterArrayPipes, parameterArrayMulti, config + )).body; } - /** - * @param [config] the optional OpenAPI config to use - * @returns ModelWithString Message for default response - * @throws ApiError - */ - public async callWithDuplicateResponses(config?: ClientConfig): Promise { - return (await this.full.callWithDuplicateResponses(config)).body; +}" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/CollectionFormatServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; + +export class CollectionFormatServiceFull { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; } /** + * @param parameterArrayCsv This is an array parameter that is send as csv format (comma-separated values) + * @param parameterArraySsv This is an array parameter that is send as ssv format (space-separated values) + * @param parameterArrayTsv This is an array parameter that is send as tsv format (tab-separated values) + * @param parameterArrayPipes This is an array parameter that is send as pipes format (pipe-separated values) + * @param parameterArrayMulti This is an array parameter that is send as multi format (multiple parameter instances) * @param [config] the optional OpenAPI config to use - * @returns any Message for 200 response - * @returns ModelWithString Message for default response - * @returns ModelThatExtends Message for 201 response - * @returns ModelThatExtendsExtends Message for 202 response * @throws ApiError */ - public async callWithResponses(config?: ClientConfig): Promise<{ - readonly '@namespace.string'?: string, - readonly '@namespace.integer'?: number, - readonly value?: Array, - } | ModelWithString | ModelThatExtends | ModelThatExtendsExtends> { - return (await this.full.callWithResponses(config)).body; + public async collectionFormat( + parameterArrayCsv: Array, + parameterArraySsv: Array, + parameterArrayTsv: Array, + parameterArrayPipes: Array, + parameterArrayMulti: Array, + config?: ClientConfig + ): Promise> { + return this.httpRequest.request({ + method: 'GET', + path: \`/api/v\${this.clientConfig.version}/collectionFormat\`, + query: { + 'parameterArrayCSV': parameterArrayCsv, + 'parameterArraySSV': parameterArraySsv, + 'parameterArrayTSV': parameterArrayTsv, + 'parameterArrayPipes': parameterArrayPipes, + 'parameterArrayMulti': parameterArrayMulti, + }, + }, this.clientConfig, config); } }" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/ResponseServiceFull.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/ComplexService.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ import type { - ModelThatExtends, - ModelThatExtendsExtends, ModelWithString, } from '../models'; -import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; +import type { BaseHttpRequest, ClientConfig } from '../core'; +import { ComplexServiceFull } from './ComplexServiceFull'; -export class ResponseServiceFull { +export class ComplexService { private readonly httpRequest: BaseHttpRequest; private readonly clientConfig: ClientConfig; + readonly full: ComplexServiceFull; constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { this.httpRequest = httpRequest; this.clientConfig = clientConfig; + this.full = new ComplexServiceFull(httpRequest, clientConfig); } /** + * @param parameterObject Parameter containing object + * @param parameterReference Parameter containing reference * @param [config] the optional OpenAPI config to use - * @returns ModelWithString Message for default response + * @returns ModelWithString Successful response * @throws ApiError */ - public async callWithResponse(config?: ClientConfig): Promise> { - return this.httpRequest.request({ - method: 'GET', - path: \`/api/v\${this.clientConfig.version}/response\`, - }, this.clientConfig, config); + public async complexTypes( + parameterObject: { + first?: { + second?: { + third?: string, + }, + }, + }, + parameterReference: ModelWithString, + config?: ClientConfig + ): Promise> { + return (await this.full.complexTypes( + parameterObject, parameterReference, config + )).body; } - /** - * @param [config] the optional OpenAPI config to use - * @returns ModelWithString Message for default response - * @throws ApiError - */ - public async callWithDuplicateResponses(config?: ClientConfig): Promise> { - return this.httpRequest.request({ - method: 'POST', - path: \`/api/v\${this.clientConfig.version}/response\`, - errors: { - 500: \`Message for 500 error\`, - 501: \`Message for 501 error\`, - 502: \`Message for 502 error\`, - }, - }, this.clientConfig, config); +}" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/ComplexServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { + ModelWithString, +} from '../models'; +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; + +export class ComplexServiceFull { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; } /** + * @param parameterObject Parameter containing object + * @param parameterReference Parameter containing reference * @param [config] the optional OpenAPI config to use - * @returns any Message for 200 response - * @returns ModelWithString Message for default response - * @returns ModelThatExtends Message for 201 response - * @returns ModelThatExtendsExtends Message for 202 response + * @returns ModelWithString Successful response * @throws ApiError */ - public async callWithResponses(config?: ClientConfig): Promise, - } | ModelWithString | ModelThatExtends | ModelThatExtendsExtends>> { + public async complexTypes( + parameterObject: { + first?: { + second?: { + third?: string, + }, + }, + }, + parameterReference: ModelWithString, + config?: ClientConfig + ): Promise>> { return this.httpRequest.request({ - method: 'PUT', - path: \`/api/v\${this.clientConfig.version}/response\`, + method: 'GET', + path: \`/api/v\${this.clientConfig.version}/complex\`, + query: { + 'parameterObject': parameterObject, + 'parameterReference': parameterReference, + }, errors: { - 500: \`Message for 500 error\`, - 501: \`Message for 501 error\`, - 502: \`Message for 502 error\`, + 400: \`400 server error\`, + 500: \`500 server error\`, }, }, this.clientConfig, config); } @@ -2922,92 +2722,114 @@ export class ResponseServiceFull { }" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/SimpleService.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/DefaultsService.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { + ModelWithString, +} from '../models'; import type { BaseHttpRequest, ClientConfig } from '../core'; -import { SimpleServiceFull } from './SimpleServiceFull'; +import { DefaultsServiceFull } from './DefaultsServiceFull'; -export class SimpleService { +export class DefaultsService { private readonly httpRequest: BaseHttpRequest; private readonly clientConfig: ClientConfig; - readonly full: SimpleServiceFull; + readonly full: DefaultsServiceFull; constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { this.httpRequest = httpRequest; this.clientConfig = clientConfig; - this.full = new SimpleServiceFull(httpRequest, clientConfig); - } - - /** - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ - public async getCallWithoutParametersAndResponse(config?: ClientConfig): Promise { - return (await this.full.getCallWithoutParametersAndResponse(config)).body; - } - - /** - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ - public async putCallWithoutParametersAndResponse(config?: ClientConfig): Promise { - return (await this.full.putCallWithoutParametersAndResponse(config)).body; - } - - /** - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ - public async postCallWithoutParametersAndResponse(config?: ClientConfig): Promise { - return (await this.full.postCallWithoutParametersAndResponse(config)).body; - } - - /** - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ - public async deleteCallWithoutParametersAndResponse(config?: ClientConfig): Promise { - return (await this.full.deleteCallWithoutParametersAndResponse(config)).body; + this.full = new DefaultsServiceFull(httpRequest, clientConfig); } /** + * @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 * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async optionsCallWithoutParametersAndResponse(config?: ClientConfig): Promise { - return (await this.full.optionsCallWithoutParametersAndResponse(config)).body; + public async callWithDefaultParameters( + parameterString: string = 'Hello World!', + parameterNumber: number = 123, + parameterBoolean: boolean = true, + parameterEnum: 'Success' | 'Warning' | 'Error' = 'Success', + parameterModel: ModelWithString = { + \\"prop\\": \\"Hello World!\\" + }, + config?: ClientConfig + ): Promise { + return (await this.full.callWithDefaultParameters( + parameterString, parameterNumber, parameterBoolean, parameterEnum, parameterModel, config + )).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 * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async headCallWithoutParametersAndResponse(config?: ClientConfig): Promise { - return (await this.full.headCallWithoutParametersAndResponse(config)).body; + public async callWithDefaultOptionalParameters( + parameterString: string = 'Hello World!', + parameterNumber: number = 123, + parameterBoolean: boolean = true, + parameterEnum: 'Success' | 'Warning' | 'Error' = 'Success', + parameterModel: ModelWithString = { + \\"prop\\": \\"Hello World!\\" + }, + config?: ClientConfig + ): Promise { + return (await this.full.callWithDefaultOptionalParameters( + parameterString, parameterNumber, parameterBoolean, parameterEnum, parameterModel, config + )).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 * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async patchCallWithoutParametersAndResponse(config?: ClientConfig): Promise { - return (await this.full.patchCallWithoutParametersAndResponse(config)).body; + public async callToTestOrderOfParams( + parameterStringWithNoDefault: string, + parameterOptionalStringWithDefault: string = 'Hello World!', + parameterOptionalStringWithEmptyDefault: string = '', + parameterOptionalStringWithNoDefault?: string, + parameterStringWithDefault: string = 'Hello World!', + parameterStringWithEmptyDefault: string = '', + config?: ClientConfig + ): Promise { + return (await this.full.callToTestOrderOfParams( + parameterStringWithNoDefault, parameterOptionalStringWithDefault, parameterOptionalStringWithEmptyDefault, parameterOptionalStringWithNoDefault, parameterStringWithDefault, parameterStringWithEmptyDefault, config + )).body; } }" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/SimpleServiceFull.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/DefaultsServiceFull.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { + ModelWithString, +} from '../models'; import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; -export class SimpleServiceFull { +export class DefaultsServiceFull { private readonly httpRequest: BaseHttpRequest; private readonly clientConfig: ClientConfig; @@ -3017,46 +2839,183 @@ export class SimpleServiceFull { } /** + * @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 * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async getCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { + public async callWithDefaultParameters( + parameterString: string = 'Hello World!', + parameterNumber: number = 123, + parameterBoolean: boolean = true, + parameterEnum: 'Success' | 'Warning' | 'Error' = 'Success', + parameterModel: ModelWithString = { + \\"prop\\": \\"Hello World!\\" + }, + config?: ClientConfig + ): Promise> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.clientConfig.version}/simple\`, + path: \`/api/v\${this.clientConfig.version}/defaults\`, + query: { + 'parameterString': parameterString, + 'parameterNumber': parameterNumber, + 'parameterBoolean': parameterBoolean, + 'parameterEnum': parameterEnum, + 'parameterModel': parameterModel, + }, }, this.clientConfig, config); } /** + * @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 * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async putCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { + public async callWithDefaultOptionalParameters( + parameterString: string = 'Hello World!', + parameterNumber: number = 123, + parameterBoolean: boolean = true, + parameterEnum: 'Success' | 'Warning' | 'Error' = 'Success', + parameterModel: ModelWithString = { + \\"prop\\": \\"Hello World!\\" + }, + config?: ClientConfig + ): Promise> { return this.httpRequest.request({ - method: 'PUT', - path: \`/api/v\${this.clientConfig.version}/simple\`, + method: 'POST', + path: \`/api/v\${this.clientConfig.version}/defaults\`, + query: { + 'parameterString': parameterString, + 'parameterNumber': parameterNumber, + 'parameterBoolean': parameterBoolean, + 'parameterEnum': parameterEnum, + 'parameterModel': parameterModel, + }, }, this.clientConfig, config); } /** - * @param [config] the optional OpenAPI config to use - * @throws ApiError + * @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 + * @param [config] the optional OpenAPI config to use + * @throws ApiError */ - public async postCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { + public async callToTestOrderOfParams( + parameterStringWithNoDefault: string, + parameterOptionalStringWithDefault: string = 'Hello World!', + parameterOptionalStringWithEmptyDefault: string = '', + parameterOptionalStringWithNoDefault?: string, + parameterStringWithDefault: string = 'Hello World!', + parameterStringWithEmptyDefault: string = '', + config?: ClientConfig + ): Promise> { return this.httpRequest.request({ - method: 'POST', - path: \`/api/v\${this.clientConfig.version}/simple\`, + method: 'PUT', + path: \`/api/v\${this.clientConfig.version}/defaults\`, + query: { + 'parameterStringWithNoDefault': parameterStringWithNoDefault, + 'parameterOptionalStringWithDefault': parameterOptionalStringWithDefault, + 'parameterOptionalStringWithEmptyDefault': parameterOptionalStringWithEmptyDefault, + 'parameterOptionalStringWithNoDefault': parameterOptionalStringWithNoDefault, + 'parameterStringWithDefault': parameterStringWithDefault, + 'parameterStringWithEmptyDefault': parameterStringWithEmptyDefault, + }, }, this.clientConfig, config); } +}" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/DuplicateService.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { BaseHttpRequest, ClientConfig } from '../core'; +import { DuplicateServiceFull } from './DuplicateServiceFull'; + +export class DuplicateService { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; + readonly full: DuplicateServiceFull; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + this.full = new DuplicateServiceFull(httpRequest, clientConfig); + } + /** * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async deleteCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { + public async duplicateName(config?: ClientConfig): Promise { + return (await this.full.duplicateName(config)).body; + } + + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async duplicateName1(config?: ClientConfig): Promise { + return (await this.full.duplicateName1(config)).body; + } + + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async duplicateName2(config?: ClientConfig): Promise { + return (await this.full.duplicateName2(config)).body; + } + + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async duplicateName3(config?: ClientConfig): Promise { + return (await this.full.duplicateName3(config)).body; + } + +}" +`; + +exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/DuplicateServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; + +export class DuplicateServiceFull { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + } + + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async duplicateName(config?: ClientConfig): Promise> { return this.httpRequest.request({ - method: 'DELETE', - path: \`/api/v\${this.clientConfig.version}/simple\`, + method: 'GET', + path: \`/api/v\${this.clientConfig.version}/duplicate\`, }, this.clientConfig, config); } @@ -3064,10 +3023,10 @@ export class SimpleServiceFull { * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async optionsCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { + public async duplicateName1(config?: ClientConfig): Promise> { return this.httpRequest.request({ - method: 'OPTIONS', - path: \`/api/v\${this.clientConfig.version}/simple\`, + method: 'POST', + path: \`/api/v\${this.clientConfig.version}/duplicate\`, }, this.clientConfig, config); } @@ -3075,10 +3034,10 @@ export class SimpleServiceFull { * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async headCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { + public async duplicateName2(config?: ClientConfig): Promise> { return this.httpRequest.request({ - method: 'HEAD', - path: \`/api/v\${this.clientConfig.version}/simple\`, + method: 'PUT', + path: \`/api/v\${this.clientConfig.version}/duplicate\`, }, this.clientConfig, config); } @@ -3086,78 +3045,55 @@ export class SimpleServiceFull { * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async patchCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { + public async duplicateName3(config?: ClientConfig): Promise> { return this.httpRequest.request({ - method: 'PATCH', - path: \`/api/v\${this.clientConfig.version}/simple\`, + method: 'DELETE', + path: \`/api/v\${this.clientConfig.version}/duplicate\`, }, this.clientConfig, config); } }" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/TypesService.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/HeaderService.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ import type { BaseHttpRequest, ClientConfig } from '../core'; -import { TypesServiceFull } from './TypesServiceFull'; +import { HeaderServiceFull } from './HeaderServiceFull'; -export class TypesService { +export class HeaderService { private readonly httpRequest: BaseHttpRequest; private readonly clientConfig: ClientConfig; - readonly full: TypesServiceFull; + readonly full: HeaderServiceFull; constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { this.httpRequest = httpRequest; this.clientConfig = clientConfig; - this.full = new TypesServiceFull(httpRequest, clientConfig); + this.full = new HeaderServiceFull(httpRequest, clientConfig); } /** - * @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 * @param [config] the optional OpenAPI config to use - * @returns number Response is a simple number - * @returns string Response is a simple string - * @returns boolean Response is a simple boolean - * @returns any Response is a simple object + * @returns string Successful response * @throws ApiError */ - public async types( - parameterArray: Array, - parameterDictionary: Record, - parameterEnum: 'Success' | 'Warning' | 'Error', - parameterNumber: number = 123, - parameterString: string = 'default', - parameterBoolean: boolean = true, - parameterObject: any = null, - id?: number, - config?: ClientConfig - ): Promise { - return (await this.full.types( - parameterArray, parameterDictionary, parameterEnum, parameterNumber, parameterString, parameterBoolean, parameterObject, id, config - )).body; + public async callWithResultFromHeader(config?: ClientConfig): Promise { + return (await this.full.callWithResultFromHeader(config)).body; } }" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/TypesServiceFull.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/HeaderServiceFull.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; -export class TypesServiceFull { +export class HeaderServiceFull { private readonly httpRequest: BaseHttpRequest; private readonly clientConfig: ClientConfig; @@ -3167,43 +3103,18 @@ export class TypesServiceFull { } /** - * @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 * @param [config] the optional OpenAPI config to use - * @returns number Response is a simple number - * @returns string Response is a simple string - * @returns boolean Response is a simple boolean - * @returns any Response is a simple object + * @returns string Successful response * @throws ApiError */ - public async types( - parameterArray: Array, - parameterDictionary: Record, - parameterEnum: 'Success' | 'Warning' | 'Error', - parameterNumber: number = 123, - parameterString: string = 'default', - parameterBoolean: boolean = true, - parameterObject: any = null, - id?: number, - config?: ClientConfig - ): Promise> { + public async callWithResultFromHeader(config?: ClientConfig): Promise> { return this.httpRequest.request({ - method: 'GET', - path: \`/api/v\${this.clientConfig.version}/types\`, - query: { - 'parameterArray': parameterArray, - 'parameterDictionary': parameterDictionary, - 'parameterEnum': parameterEnum, - 'parameterNumber': parameterNumber, - 'parameterString': parameterString, - 'parameterBoolean': parameterBoolean, - 'parameterObject': parameterObject, + method: 'POST', + path: \`/api/v\${this.clientConfig.version}/header\`, + responseHeader: 'operation-location', + errors: { + 400: \`400 server error\`, + 500: \`500 server error\`, }, }, this.clientConfig, config); } @@ -3211,2080 +3122,3813 @@ export class TypesServiceFull { }" `; -exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/index.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/NoContentService.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export { CollectionFormatService } from './CollectionFormatService'; -export { CollectionFormatServiceFull } from './CollectionFormatServiceFull'; -export { ComplexService } from './ComplexService'; -export { ComplexServiceFull } from './ComplexServiceFull'; -export { DefaultsService } from './DefaultsService'; -export { DefaultsServiceFull } from './DefaultsServiceFull'; -export { DuplicateService } from './DuplicateService'; -export { DuplicateServiceFull } from './DuplicateServiceFull'; -export { HeaderService } from './HeaderService'; -export { HeaderServiceFull } from './HeaderServiceFull'; -export { NoContentService } from './NoContentService'; -export { NoContentServiceFull } from './NoContentServiceFull'; -export { ParametersService } from './ParametersService'; -export { ParametersServiceFull } from './ParametersServiceFull'; -export { ResponseService } from './ResponseService'; -export { ResponseServiceFull } from './ResponseServiceFull'; -export { SimpleService } from './SimpleService'; -export { SimpleServiceFull } from './SimpleServiceFull'; -export { TypesService } from './TypesService'; -export { TypesServiceFull } from './TypesServiceFull'; -" -`; +import type { BaseHttpRequest, ClientConfig } from '../core'; +import { NoContentServiceFull } from './NoContentServiceFull'; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/client.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -import type { BaseHttpRequest } from './core'; -import { FetchHttpRequest } from './core'; -import type { ClientConfig } from './core'; -import { - CollectionFormatService, - ComplexService, - DefaultsService, - DuplicateService, - HeaderService, - MultipartService, - NoContentService, - ParametersService, - RequestBodyService, - ResponseService, - SimpleService, - TypesService, - UploadService, -} from './services'; +export class NoContentService { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; + readonly full: NoContentServiceFull; -export class TestClient { - readonly collectionformat: CollectionFormatService; - readonly complex: ComplexService; - readonly defaults: DefaultsService; - readonly duplicate: DuplicateService; - readonly header: HeaderService; - readonly multipart: MultipartService; - readonly nocontent: NoContentService; - readonly parameters: ParametersService; - readonly requestbody: RequestBodyService; - readonly response: ResponseService; - readonly simple: SimpleService; - readonly types: TypesService; - readonly upload: UploadService; + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + this.full = new NoContentServiceFull(httpRequest, clientConfig); + } - constructor(clientConfig: ClientConfig, httpClient: BaseHttpRequest = new FetchHttpRequest()) { - const config = { - baseUrl: clientConfig?.baseUrl ?? 'http://localhost:3000/base', - version: clientConfig?.version ?? '1.0', - withCredentials: clientConfig?.withCredentials ?? false, - token: clientConfig?.token, - username: clientConfig?.username, - password: clientConfig?.password, - headers: clientConfig?.headers, - } - this.collectionformat = new CollectionFormatService(httpClient, config); - this.complex = new ComplexService(httpClient, config); - this.defaults = new DefaultsService(httpClient, config); - this.duplicate = new DuplicateService(httpClient, config); - this.header = new HeaderService(httpClient, config); - this.multipart = new MultipartService(httpClient, config); - this.nocontent = new NoContentService(httpClient, config); - this.parameters = new ParametersService(httpClient, config); - this.requestbody = new RequestBodyService(httpClient, config); - this.response = new ResponseService(httpClient, config); - this.simple = new SimpleService(httpClient, config); - this.types = new TypesService(httpClient, config); - this.upload = new UploadService(httpClient, config); + /** + * @param [config] the optional OpenAPI config to use + * @returns void + * @throws ApiError + */ + public async callWithNoContentResponse(config?: ClientConfig): Promise { + return (await this.full.callWithNoContentResponse(config)).body; } + }" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/core/ApiError.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/NoContentServiceFull.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ApiResult } from './ApiResult'; +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; -export class ApiError extends Error { - public readonly url: string; - public readonly status: number; - public readonly statusText: string; - public readonly body: any; +export class NoContentServiceFull { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; - constructor(response: ApiResult, message: string) { - super(message); + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + } - this.url = response.url; - this.status = response.status; - this.statusText = response.statusText; - this.body = response.body; + /** + * @param [config] the optional OpenAPI config to use + * @returns void + * @throws ApiError + */ + public async callWithNoContentResponse(config?: ClientConfig): Promise> { + return this.httpRequest.request({ + method: 'GET', + path: \`/api/v\${this.clientConfig.version}/no-content\`, + }, this.clientConfig, config); } -}" -`; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/core/ApiRequestOptions.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -export type ApiRequestOptions = { - readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH'; - readonly path: string; - readonly cookies?: Record; - readonly headers?: Record; - readonly query?: Record; - readonly formData?: Record; - readonly body?: any; - readonly mediaType?: string; - readonly responseHeader?: string; - readonly errors?: Record; }" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/core/ApiResult.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/ParametersService.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export type ApiResult = { - readonly url: string; - readonly ok: boolean; - readonly status: number; - readonly statusText: string; - readonly body: T; -}" -`; +import type { BaseHttpRequest, ClientConfig } from '../core'; +import { ParametersServiceFull } from './ParametersServiceFull'; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/core/BaseHttpRequest.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -import type { ApiRequestOptions } from './ApiRequestOptions'; -import type { ApiResult } from './ApiResult'; -import type { ClientConfig } from './OpenAPI'; +export class ParametersService { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; + readonly full: ParametersServiceFull; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + this.full = new ParametersServiceFull(httpRequest, clientConfig); + } + + /** + * @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 + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async callWithParameters( + parameterHeader: string, + parameterQuery: string, + parameterForm: string, + parameterBody: string, + parameterPath: string, + config?: ClientConfig + ): Promise { + return (await this.full.callWithParameters( + parameterHeader, parameterQuery, parameterForm, parameterBody, parameterPath, config + )).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 + * @param _default This is the parameter with a reserved keyword + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async callWithWeirdParameterNames( + parameterHeader: string, + parameterQuery: string, + parameterForm: string, + parameterBody: string, + parameterPath1?: string, + parameterPath2?: string, + parameterPath3?: string, + _default?: string, + config?: ClientConfig + ): Promise { + return (await this.full.callWithWeirdParameterNames( + parameterHeader, parameterQuery, parameterForm, parameterBody, parameterPath1, parameterPath2, parameterPath3, _default, config + )).body; + } -export interface BaseHttpRequest { - request( - options: ApiRequestOptions, - config: ClientConfig, - mergeConfig?: ClientConfig - ): Promise>; }" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/core/FetchHttpRequest.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/ParametersServiceFull.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import { ApiError } from './ApiError'; -import type { ApiRequestOptions } from './ApiRequestOptions'; -import type { ApiResult } from './ApiResult'; -import type { ClientConfig } from './OpenAPI'; -import type { BaseHttpRequest } from './BaseHttpRequest'; - -function isDefined(value: T | null | undefined): value is Exclude { - return value !== undefined && value !== null; -} +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; -function isString(value: any): value is string { - return typeof value === 'string'; -} +export class ParametersServiceFull { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; -export function deepAssign( - target: Record, - source: Record, -): Record { - const keys = Object.keys(source); - for (const k of keys) { - const sourceValue: unknown = source[k]; - const targetValue: unknown = target[k]; - if (Object(sourceValue) === sourceValue && Object(targetValue) === targetValue) { - target[k] = deepAssign( - targetValue as Record, - sourceValue as Record, - ); - } else { - target[k] = source[k]; - } + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; } - return target; -} - -function isStringWithValue(value: any): value is string { - return isString(value) && value !== ''; -} - -function isBlob(value: any): value is Blob { - return value instanceof Blob; -} -function getQueryString(params: Record): string { - const qs: string[] = []; - Object.keys(params).forEach(key => { - const value = params[key]; - if (isDefined(value)) { - 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('&')}\`; + /** + * @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 + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async callWithParameters( + parameterHeader: string, + parameterQuery: string, + parameterForm: string, + parameterBody: string, + parameterPath: string, + config?: ClientConfig + ): Promise> { + return this.httpRequest.request({ + method: 'GET', + path: \`/api/v\${this.clientConfig.version}/parameters/\${parameterPath}\`, + headers: { + 'parameterHeader': parameterHeader, + }, + query: { + 'parameterQuery': parameterQuery, + }, + formData: { + 'parameterForm': parameterForm, + }, + body: parameterBody, + }, this.clientConfig, config); } - return ''; -} - -function getUrl(options: ApiRequestOptions, config: ClientConfig): string { - const path = options.path.replace(/[:]/g, '_'); - const url = \`\${config.baseUrl}\${path}\`; - if (options.query) { - return \`\${url}\${getQueryString(options.query)}\`; + /** + * @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 + * @param _default This is the parameter with a reserved keyword + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async callWithWeirdParameterNames( + parameterHeader: string, + parameterQuery: string, + parameterForm: string, + parameterBody: string, + parameterPath1?: string, + parameterPath2?: string, + parameterPath3?: string, + _default?: string, + config?: ClientConfig + ): Promise> { + return this.httpRequest.request({ + method: 'GET', + path: \`/api/v\${this.clientConfig.version}/parameters/\${parameterPath1}/\${parameterPath2}/\${parameterPath3}\`, + headers: { + 'parameter.header': parameterHeader, + }, + query: { + 'parameter-query': parameterQuery, + 'default': _default, + }, + formData: { + 'parameter_form': parameterForm, + }, + body: parameterBody, + }, this.clientConfig, config); } - return url; -} -function getFormData(params: Record): FormData { - const formData = new FormData(); - Object.keys(params).forEach(key => { - const value = params[key]; - if (isDefined(value)) { - formData.append(key, value); - } - }); - return formData; -} - -type Resolver = (options: ApiRequestOptions) => Promise; - -async function resolve(options: ApiRequestOptions, resolver?: T | Resolver): Promise { - if (typeof resolver === 'function') { - return (resolver as Resolver)(options); - } - return resolver; -} +}" +`; -async function getHeaders(options: ApiRequestOptions, config: ClientConfig): Promise { - const token = await resolve(options, config.token); - const username = await resolve(options, config.username); - const password = await resolve(options, config.password); - const defaultHeaders = await resolve(options, config.headers); +exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/ResponseService.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { + ModelThatExtends, + ModelThatExtendsExtends, + ModelWithString, +} from '../models'; +import type { BaseHttpRequest, ClientConfig } from '../core'; +import { ResponseServiceFull } from './ResponseServiceFull'; - const headers = new Headers({ - Accept: 'application/json', - ...defaultHeaders, - ...options.headers, - }); +export class ResponseService { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; + readonly full: ResponseServiceFull; - if (isStringWithValue(token)) { - headers.append('Authorization', \`Bearer \${token}\`); + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + this.full = new ResponseServiceFull(httpRequest, clientConfig); } - if (isStringWithValue(username) && isStringWithValue(password)) { - const credentials = btoa(\`\${username}:\${password}\`); - headers.append('Authorization', \`Basic \${credentials}\`); + /** + * @param [config] the optional OpenAPI config to use + * @returns ModelWithString Message for default response + * @throws ApiError + */ + public async callWithResponse(config?: ClientConfig): Promise { + return (await this.full.callWithResponse(config)).body; } - if (options.body) { - if (options.mediaType) { - headers.append('Content-Type', options.mediaType); - } else if (isBlob(options.body)) { - headers.append('Content-Type', options.body.type || 'application/octet-stream'); - } else if (isString(options.body)) { - headers.append('Content-Type', 'text/plain'); - } else { - headers.append('Content-Type', 'application/json'); - } + /** + * @param [config] the optional OpenAPI config to use + * @returns ModelWithString Message for default response + * @throws ApiError + */ + public async callWithDuplicateResponses(config?: ClientConfig): Promise { + return (await this.full.callWithDuplicateResponses(config)).body; } - return headers; -} -function getRequestBody(options: ApiRequestOptions): BodyInit | undefined { - if (options.formData) { - return getFormData(options.formData); - } - if (options.body) { - if (options.mediaType?.includes('/json')) { - return JSON.stringify(options.body) - } else if (isString(options.body) || isBlob(options.body)) { - return options.body; - } else { - return JSON.stringify(options.body); - } + /** + * @param [config] the optional OpenAPI config to use + * @returns any Message for 200 response + * @returns ModelWithString Message for default response + * @returns ModelThatExtends Message for 201 response + * @returns ModelThatExtendsExtends Message for 202 response + * @throws ApiError + */ + public async callWithResponses(config?: ClientConfig): Promise<{ + readonly '@namespace.string'?: string, + readonly '@namespace.integer'?: number, + readonly value?: Array, + } | ModelWithString | ModelThatExtends | ModelThatExtendsExtends> { + return (await this.full.callWithResponses(config)).body; } - return undefined; -} -async function sendRequest(options: ApiRequestOptions, config: ClientConfig, url: string): Promise { - const request: RequestInit = { - method: options.method, - headers: await getHeaders(options, config), - body: getRequestBody(options), - }; - if (config.withCredentials) { - request.credentials = 'include'; - } - return await fetch(url, request); -} +}" +`; -function getResponseHeader(response: Response, responseHeader?: string): string | null { - if (responseHeader) { - const content = response.headers.get(responseHeader); - if (isString(content)) { - return content; - } - } - return null; -} +exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/ResponseServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { + ModelThatExtends, + ModelThatExtendsExtends, + ModelWithString, +} from '../models'; +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; -async function getResponseBody(response: Response): Promise { - try { - const contentType = response.headers.get('Content-Type'); - if (contentType) { - const isJSON = contentType.toLowerCase().startsWith('application/json'); - if (isJSON) { - return await response.json(); - } else { - return await response.text(); - } - } - } catch (error) { - console.error(error); - } - return null; -} +export class ResponseServiceFull { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; -function catchErrors(options: ApiRequestOptions, result: ApiResult): void { - const errors: Record = { - 400: 'Bad Request', - 401: 'Unauthorized', - 403: 'Forbidden', - 404: 'Not Found', - 500: 'Internal Server Error', - 502: 'Bad Gateway', - 503: 'Service Unavailable', - ...options.errors, + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; } - const error = errors[result.status]; - if (error) { - throw new ApiError(result, error); + /** + * @param [config] the optional OpenAPI config to use + * @returns ModelWithString Message for default response + * @throws ApiError + */ + public async callWithResponse(config?: ClientConfig): Promise> { + return this.httpRequest.request({ + method: 'GET', + path: \`/api/v\${this.clientConfig.version}/response\`, + }, this.clientConfig, config); } - if (!result.ok) { - throw new ApiError(result, 'Generic Error'); + /** + * @param [config] the optional OpenAPI config to use + * @returns ModelWithString Message for default response + * @throws ApiError + */ + public async callWithDuplicateResponses(config?: ClientConfig): Promise> { + return this.httpRequest.request({ + method: 'POST', + path: \`/api/v\${this.clientConfig.version}/response\`, + errors: { + 500: \`Message for 500 error\`, + 501: \`Message for 501 error\`, + 502: \`Message for 502 error\`, + }, + }, this.clientConfig, config); } -} -export class FetchHttpRequest implements BaseHttpRequest { /** - * Request using fetch client - * @param options The request options from the the service - * @param config The OpenAPI configuration - * @param [mergeConfig] Additional optional OpenAPI configuration that will be merged with the first one - * @returns ApiResult - * @throws ApiError - */ - async request(options: ApiRequestOptions, config: ClientConfig, mergeConfig?: ClientConfig): Promise { - const conf = mergeConfig ? deepAssign(config, mergeConfig) : config; - const url = getUrl(options, conf); - const response = await sendRequest(options, conf, url); - const responseBody = await getResponseBody(response); - const responseHeader = getResponseHeader(response, options.responseHeader); - - const result: ApiResult = { - url, - ok: response.ok, - status: response.status, - statusText: response.statusText, - body: responseHeader || responseBody, - }; - - catchErrors(options, result); - return result; + * @param [config] the optional OpenAPI config to use + * @returns any Message for 200 response + * @returns ModelWithString Message for default response + * @returns ModelThatExtends Message for 201 response + * @returns ModelThatExtendsExtends Message for 202 response + * @throws ApiError + */ + public async callWithResponses(config?: ClientConfig): Promise, + } | ModelWithString | ModelThatExtends | ModelThatExtendsExtends>> { + return this.httpRequest.request({ + method: 'PUT', + path: \`/api/v\${this.clientConfig.version}/response\`, + errors: { + 500: \`Message for 500 error\`, + 501: \`Message for 501 error\`, + 502: \`Message for 502 error\`, + }, + }, this.clientConfig, config); } -} -" + +}" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/core/OpenAPI.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/SimpleService.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ApiRequestOptions } from './ApiRequestOptions'; +import type { BaseHttpRequest, ClientConfig } from '../core'; +import { SimpleServiceFull } from './SimpleServiceFull'; -type Resolver = (options: ApiRequestOptions) => Promise; -type Headers = Record; +export class SimpleService { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; + readonly full: SimpleServiceFull; -export type ClientConfig = { - baseUrl?: string; - version?: string; - withCredentials?: boolean; - token?: string | Resolver; - username?: string | Resolver; - password?: string | Resolver; - headers?: Headers | Resolver; -} -" -`; + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + this.full = new SimpleServiceFull(httpRequest, clientConfig); + } -exports[`v3 should generate with exportClient: ./test/generated/v3_client/core/index.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -export { ApiError } from './ApiError'; -export type { ApiRequestOptions } from './ApiRequestOptions'; -export type { ApiResult } from './ApiResult'; -export type { BaseHttpRequest } from './BaseHttpRequest'; -export { FetchHttpRequest } from './FetchHttpRequest'; -export type { ClientConfig } from './OpenAPI'; -" -`; + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async getCallWithoutParametersAndResponse(config?: ClientConfig): Promise { + return (await this.full.getCallWithoutParametersAndResponse(config)).body; + } -exports[`v3 should generate with exportClient: ./test/generated/v3_client/index.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -export * from './core'; -export * from './models'; -export * from './schemas'; -export * from './services'; + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async putCallWithoutParametersAndResponse(config?: ClientConfig): Promise { + return (await this.full.putCallWithoutParametersAndResponse(config)).body; + } -export { TestClient } from './client'; -" -`; + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async postCallWithoutParametersAndResponse(config?: ClientConfig): Promise { + return (await this.full.postCallWithoutParametersAndResponse(config)).body; + } -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ArrayWithArray.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async deleteCallWithoutParametersAndResponse(config?: ClientConfig): Promise { + return (await this.full.deleteCallWithoutParametersAndResponse(config)).body; + } -import type { ModelWithString } from './ModelWithString'; + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async optionsCallWithoutParametersAndResponse(config?: ClientConfig): Promise { + return (await this.full.optionsCallWithoutParametersAndResponse(config)).body; + } -/** - * This is a simple array containing an array - */ -export type ArrayWithArray = Array>;" -`; + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async headCallWithoutParametersAndResponse(config?: ClientConfig): Promise { + return (await this.full.headCallWithoutParametersAndResponse(config)).body; + } -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ArrayWithBooleans.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async patchCallWithoutParametersAndResponse(config?: ClientConfig): Promise { + return (await this.full.patchCallWithoutParametersAndResponse(config)).body; + } -/** - * This is a simple array with booleans - */ -export type ArrayWithBooleans = Array;" +}" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ArrayWithNumbers.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/SimpleServiceFull.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; -/** - * This is a simple array with numbers - */ -export type ArrayWithNumbers = Array;" -`; +export class SimpleServiceFull { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ArrayWithProperties.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + } -/** - * This is a simple array with properties - */ -export type ArrayWithProperties = Array<{ - foo?: string, - bar?: string, -}>;" -`; + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async getCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { + return this.httpRequest.request({ + method: 'GET', + path: \`/api/v\${this.clientConfig.version}/simple\`, + }, this.clientConfig, config); + } -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ArrayWithReferences.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async putCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { + return this.httpRequest.request({ + method: 'PUT', + path: \`/api/v\${this.clientConfig.version}/simple\`, + }, this.clientConfig, config); + } -import type { ModelWithString } from './ModelWithString'; + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async postCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { + return this.httpRequest.request({ + method: 'POST', + path: \`/api/v\${this.clientConfig.version}/simple\`, + }, this.clientConfig, config); + } -/** - * This is a simple array with references - */ -export type ArrayWithReferences = Array;" -`; + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async deleteCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { + return this.httpRequest.request({ + method: 'DELETE', + path: \`/api/v\${this.clientConfig.version}/simple\`, + }, this.clientConfig, config); + } -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ArrayWithStrings.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async optionsCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { + return this.httpRequest.request({ + method: 'OPTIONS', + path: \`/api/v\${this.clientConfig.version}/simple\`, + }, this.clientConfig, config); + } -/** - * This is a simple array with strings - */ -export type ArrayWithStrings = Array;" + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async headCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { + return this.httpRequest.request({ + method: 'HEAD', + path: \`/api/v\${this.clientConfig.version}/simple\`, + }, this.clientConfig, config); + } + + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async patchCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { + return this.httpRequest.request({ + method: 'PATCH', + path: \`/api/v\${this.clientConfig.version}/simple\`, + }, this.clientConfig, config); + } + +}" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/CompositionWithAllOfAndNullable.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/TypesService.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { BaseHttpRequest, ClientConfig } from '../core'; +import { TypesServiceFull } from './TypesServiceFull'; -import type { ModelWithArray } from './ModelWithArray'; -import type { ModelWithDictionary } from './ModelWithDictionary'; -import type { ModelWithEnum } from './ModelWithEnum'; +export class TypesService { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; + readonly full: TypesServiceFull; -/** - * This is a model with one property with a 'all of' relationship - */ -export type CompositionWithAllOfAndNullable = { - propA?: ({ - boolean?: boolean, - } & ModelWithEnum & ModelWithArray & ModelWithDictionary) | null; -} -" + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + this.full = new TypesServiceFull(httpRequest, clientConfig); + } + + /** + * @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 + * @param [config] the optional OpenAPI config to use + * @returns number Response is a simple number + * @returns string Response is a simple string + * @returns boolean Response is a simple boolean + * @returns any Response is a simple object + * @throws ApiError + */ + public async types( + parameterArray: Array, + parameterDictionary: Record, + parameterEnum: 'Success' | 'Warning' | 'Error', + parameterNumber: number = 123, + parameterString: string = 'default', + parameterBoolean: boolean = true, + parameterObject: any = null, + id?: number, + config?: ClientConfig + ): Promise { + return (await this.full.types( + parameterArray, parameterDictionary, parameterEnum, parameterNumber, parameterString, parameterBoolean, parameterObject, id, config + )).body; + } + +}" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/CompositionWithAnyOf.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/TypesServiceFull.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; -import type { ModelWithArray } from './ModelWithArray'; -import type { ModelWithDictionary } from './ModelWithDictionary'; -import type { ModelWithEnum } from './ModelWithEnum'; -import type { ModelWithString } from './ModelWithString'; +export class TypesServiceFull { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; -/** - * This is a model with one property with a 'any of' relationship - */ -export type CompositionWithAnyOf = { - propA?: (ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary); -} -" + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + } + + /** + * @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 + * @param [config] the optional OpenAPI config to use + * @returns number Response is a simple number + * @returns string Response is a simple string + * @returns boolean Response is a simple boolean + * @returns any Response is a simple object + * @throws ApiError + */ + public async types( + parameterArray: Array, + parameterDictionary: Record, + parameterEnum: 'Success' | 'Warning' | 'Error', + parameterNumber: number = 123, + parameterString: string = 'default', + parameterBoolean: boolean = true, + parameterObject: any = null, + id?: number, + config?: ClientConfig + ): Promise> { + return this.httpRequest.request({ + method: 'GET', + path: \`/api/v\${this.clientConfig.version}/types\`, + query: { + 'parameterArray': parameterArray, + 'parameterDictionary': parameterDictionary, + 'parameterEnum': parameterEnum, + 'parameterNumber': parameterNumber, + 'parameterString': parameterString, + 'parameterBoolean': parameterBoolean, + 'parameterObject': parameterObject, + }, + }, this.clientConfig, config); + } + +}" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/CompositionWithAnyOfAndNullable.ts 1`] = ` +exports[`v2 should generate with exportClient: ./test/generated/v2_client/services/index.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ - -import type { ModelWithArray } from './ModelWithArray'; -import type { ModelWithDictionary } from './ModelWithDictionary'; -import type { ModelWithEnum } from './ModelWithEnum'; - -/** - * This is a model with one property with a 'any of' relationship - */ -export type CompositionWithAnyOfAndNullable = { - propA?: ({ - boolean?: boolean, - } | ModelWithEnum | ModelWithArray | ModelWithDictionary) | null; -} +export { CollectionFormatService } from './CollectionFormatService'; +export { CollectionFormatServiceFull } from './CollectionFormatServiceFull'; +export { ComplexService } from './ComplexService'; +export { ComplexServiceFull } from './ComplexServiceFull'; +export { DefaultsService } from './DefaultsService'; +export { DefaultsServiceFull } from './DefaultsServiceFull'; +export { DuplicateService } from './DuplicateService'; +export { DuplicateServiceFull } from './DuplicateServiceFull'; +export { HeaderService } from './HeaderService'; +export { HeaderServiceFull } from './HeaderServiceFull'; +export { NoContentService } from './NoContentService'; +export { NoContentServiceFull } from './NoContentServiceFull'; +export { ParametersService } from './ParametersService'; +export { ParametersServiceFull } from './ParametersServiceFull'; +export { ResponseService } from './ResponseService'; +export { ResponseServiceFull } from './ResponseServiceFull'; +export { SimpleService } from './SimpleService'; +export { SimpleServiceFull } from './SimpleServiceFull'; +export { TypesService } from './TypesService'; +export { TypesServiceFull } from './TypesServiceFull'; " `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/CompositionWithAnyOfAnonymous.ts 1`] = ` +exports[`v2 should generate with no tags: ./test/generated/v2_client_no_tags/client.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { BaseHttpRequest } from './core'; +import { FetchHttpRequest } from './core'; +import type { ClientConfig } from './core'; +import { Service } from './services'; -/** - * This is a model with one property with a 'any of' relationship where the options are not $ref - */ -export type CompositionWithAnyOfAnonymous = { - propA?: ({ - propA?: any, - } | string | number); -} -" +export class TestClient extends Service { + + constructor(clientConfig: ClientConfig, httpClient: BaseHttpRequest = new FetchHttpRequest()) { + const config = { + baseUrl: clientConfig?.baseUrl ?? 'http://localhost:3000/base', + version: clientConfig?.version ?? '1.0', + withCredentials: clientConfig?.withCredentials ?? false, + token: clientConfig?.token, + username: clientConfig?.username, + password: clientConfig?.password, + headers: clientConfig?.headers, + } + super(httpClient, config); + } +}" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/CompositionWithOneOf.ts 1`] = ` +exports[`v2 should generate with no tags: ./test/generated/v2_client_no_tags/core/ApiError.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { ApiResult } from './ApiResult'; -import type { ModelWithArray } from './ModelWithArray'; -import type { ModelWithDictionary } from './ModelWithDictionary'; -import type { ModelWithEnum } from './ModelWithEnum'; -import type { ModelWithString } from './ModelWithString'; - -/** - * This is a model with one property with a 'one of' relationship - */ -export type CompositionWithOneOf = { - propA?: (ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary); -} -" -`; - -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/CompositionWithOneOfAndNullable.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ +export class ApiError extends Error { + public readonly url: string; + public readonly status: number; + public readonly statusText: string; + public readonly body: any; -import type { ModelWithArray } from './ModelWithArray'; -import type { ModelWithDictionary } from './ModelWithDictionary'; -import type { ModelWithEnum } from './ModelWithEnum'; + constructor(response: ApiResult, message: string) { + super(message); -/** - * This is a model with one property with a 'one of' relationship - */ -export type CompositionWithOneOfAndNullable = { - propA?: ({ - boolean?: boolean, - } | ModelWithEnum | ModelWithArray | ModelWithDictionary) | null; -} -" + this.url = response.url; + this.status = response.status; + this.statusText = response.statusText; + this.body = response.body; + } +}" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/CompositionWithOneOfAnonymous.ts 1`] = ` +exports[`v2 should generate with no tags: ./test/generated/v2_client_no_tags/core/ApiRequestOptions.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ - -/** - * This is a model with one property with a 'one of' relationship where the options are not $ref - */ -export type CompositionWithOneOfAnonymous = { - propA?: ({ - propA?: any, - } | string | number); -} -" +export type ApiRequestOptions = { + readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH'; + readonly path: string; + readonly cookies?: Record; + readonly headers?: Record; + readonly query?: Record; + readonly formData?: Record; + readonly body?: any; + readonly mediaType?: string; + readonly responseHeader?: string; + readonly errors?: Record; +}" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/DictionaryWithArray.ts 1`] = ` +exports[`v2 should generate with no tags: ./test/generated/v2_client_no_tags/core/ApiResult.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ - -import type { ModelWithString } from './ModelWithString'; - -/** - * This is a complex dictionary - */ -export type DictionaryWithArray = Record>;" +export type ApiResult = { + readonly url: string; + readonly ok: boolean; + readonly status: number; + readonly statusText: string; + readonly body: T; +}" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/DictionaryWithDictionary.ts 1`] = ` +exports[`v2 should generate with no tags: ./test/generated/v2_client_no_tags/core/BaseHttpRequest.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { ApiRequestOptions } from './ApiRequestOptions'; +import type { ApiResult } from './ApiResult'; +import type { ClientConfig } from './OpenAPI'; -/** - * This is a string dictionary - */ -export type DictionaryWithDictionary = Record>;" +export interface BaseHttpRequest { + request( + options: ApiRequestOptions, + config: ClientConfig, + mergeConfig?: ClientConfig + ): Promise>; +}" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/DictionaryWithProperties.ts 1`] = ` +exports[`v2 should generate with no tags: ./test/generated/v2_client_no_tags/core/FetchHttpRequest.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import { ApiError } from './ApiError'; +import type { ApiRequestOptions } from './ApiRequestOptions'; +import type { ApiResult } from './ApiResult'; +import type { ClientConfig } from './OpenAPI'; +import type { BaseHttpRequest } from './BaseHttpRequest'; -/** - * This is a complex dictionary - */ -export type DictionaryWithProperties = Record;" -`; +function isDefined(value: T | null | undefined): value is Exclude { + return value !== undefined && value !== null; +} -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/DictionaryWithReference.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ +function isString(value: any): value is string { + return typeof value === 'string'; +} -import type { ModelWithString } from './ModelWithString'; +export function deepAssign( + target: Record, + source: Record, +): Record { + const keys = Object.keys(source); + for (const k of keys) { + const sourceValue: unknown = source[k]; + const targetValue: unknown = target[k]; + if (Object(sourceValue) === sourceValue && Object(targetValue) === targetValue) { + target[k] = deepAssign( + targetValue as Record, + sourceValue as Record, + ); + } else { + target[k] = source[k]; + } + } + return target; +} -/** - * This is a string reference - */ -export type DictionaryWithReference = Record;" -`; +function isStringWithValue(value: any): value is string { + return isString(value) && value !== ''; +} -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/DictionaryWithString.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ +function isBlob(value: any): value is Blob { + return value instanceof Blob; +} -/** - * This is a string dictionary - */ -export type DictionaryWithString = Record;" -`; +function getQueryString(params: Record): string { + const qs: string[] = []; + Object.keys(params).forEach(key => { + const value = params[key]; + if (isDefined(value)) { + 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 with exportClient: ./test/generated/v3_client/models/EnumFromDescription.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ +function getUrl(options: ApiRequestOptions, config: ClientConfig): string { + const path = options.path.replace(/[:]/g, '_'); + const url = \`\${config.baseUrl}\${path}\`; -/** - * Success=1,Warning=2,Error=3 - */ -export enum EnumFromDescription { - SUCCESS = 1, - WARNING = 2, - ERROR = 3, -}" -`; + if (options.query) { + return \`\${url}\${getQueryString(options.query)}\`; + } + return url; +} -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/EnumWithExtensions.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ +function getFormData(params: Record): FormData { + const formData = new FormData(); + Object.keys(params).forEach(key => { + const value = params[key]; + if (isDefined(value)) { + formData.append(key, value); + } + }); + return formData; +} -/** - * 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, -}" -`; +type Resolver = (options: ApiRequestOptions) => Promise; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/EnumWithNumbers.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ +async function resolve(options: ApiRequestOptions, resolver?: T | Resolver): Promise { + if (typeof resolver === 'function') { + return (resolver as Resolver)(options); + } + return resolver; +} -/** - * This is a simple enum with numbers - */ -export enum EnumWithNumbers { - '_1' = 1, - '_2' = 2, - '_3' = 3, - '_1.1' = 1.1, - '_1.2' = 1.2, - '_1.3' = 1.3, - '_100' = 100, - '_200' = 200, - '_300' = 300, - '_-100' = -100, - '_-200' = -200, - '_-300' = -300, - '_-1.1' = -1.1, - '_-1.2' = -1.2, - '_-1.3' = -1.3, -}" -`; +async function getHeaders(options: ApiRequestOptions, config: ClientConfig): Promise { + const token = await resolve(options, config.token); + const username = await resolve(options, config.username); + const password = await resolve(options, config.password); + const defaultHeaders = await resolve(options, config.headers); -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/EnumWithStrings.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ + const headers = new Headers({ + Accept: 'application/json', + ...defaultHeaders, + ...options.headers, + }); -/** - * This is a simple enum with strings - */ -export enum EnumWithStrings { - SUCCESS = 'Success', - WARNING = 'Warning', - ERROR = 'Error', -}" -`; + if (isStringWithValue(token)) { + headers.append('Authorization', \`Bearer \${token}\`); + } -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelThatExtends.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ + if (isStringWithValue(username) && isStringWithValue(password)) { + const credentials = btoa(\`\${username}:\${password}\`); + headers.append('Authorization', \`Basic \${credentials}\`); + } -import type { ModelWithString } from './ModelWithString'; + if (options.body) { + if (options.mediaType) { + headers.append('Content-Type', options.mediaType); + } else if (isBlob(options.body)) { + headers.append('Content-Type', options.body.type || 'application/octet-stream'); + } else if (isString(options.body)) { + headers.append('Content-Type', 'text/plain'); + } else { + headers.append('Content-Type', 'application/json'); + } + } + return headers; +} -/** - * This is a model that extends another model - */ -export type ModelThatExtends = (ModelWithString & { - propExtendsA?: string, - propExtendsB?: ModelWithString, -}); +function getRequestBody(options: ApiRequestOptions): BodyInit | undefined { + if (options.formData) { + return getFormData(options.formData); + } + if (options.body) { + if (options.mediaType?.includes('/json')) { + return JSON.stringify(options.body) + } else if (isString(options.body) || isBlob(options.body)) { + return options.body; + } else { + return JSON.stringify(options.body); + } + } + return undefined; +} + +async function sendRequest(options: ApiRequestOptions, config: ClientConfig, url: string): Promise { + const request: RequestInit = { + method: options.method, + headers: await getHeaders(options, config), + body: getRequestBody(options), + }; + if (config.withCredentials) { + request.credentials = 'include'; + } + return await fetch(url, request); +} + +function getResponseHeader(response: Response, responseHeader?: string): string | null { + if (responseHeader) { + const content = response.headers.get(responseHeader); + if (isString(content)) { + return content; + } + } + return null; +} + +async function getResponseBody(response: Response): Promise { + try { + const contentType = response.headers.get('Content-Type'); + if (contentType) { + const isJSON = contentType.toLowerCase().startsWith('application/json'); + if (isJSON) { + return await response.json(); + } else { + return await response.text(); + } + } + } catch (error) { + console.error(error); + } + return null; +} + +function catchErrors(options: ApiRequestOptions, result: ApiResult): void { + const errors: Record = { + 400: 'Bad Request', + 401: 'Unauthorized', + 403: 'Forbidden', + 404: 'Not Found', + 500: 'Internal Server Error', + 502: 'Bad Gateway', + 503: 'Service Unavailable', + ...options.errors, + } + + const error = errors[result.status]; + if (error) { + throw new ApiError(result, error); + } + + if (!result.ok) { + throw new ApiError(result, 'Generic Error'); + } +} + +export class FetchHttpRequest implements BaseHttpRequest { + /** + * Request using fetch client + * @param options The request options from the the service + * @param config The OpenAPI configuration + * @param [mergeConfig] Additional optional OpenAPI configuration that will be merged with the first one + * @returns ApiResult + * @throws ApiError + */ + async request(options: ApiRequestOptions, config: ClientConfig, mergeConfig?: ClientConfig): Promise { + const conf = mergeConfig ? deepAssign(config, mergeConfig) : config; + const url = getUrl(options, conf); + const response = await sendRequest(options, conf, url); + const responseBody = await getResponseBody(response); + const responseHeader = getResponseHeader(response, options.responseHeader); + + const result: ApiResult = { + url, + ok: response.ok, + status: response.status, + statusText: response.statusText, + body: responseHeader || responseBody, + }; + + catchErrors(options, result); + return result; + } +} " `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelThatExtendsExtends.ts 1`] = ` +exports[`v2 should generate with no tags: ./test/generated/v2_client_no_tags/core/OpenAPI.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { ApiRequestOptions } from './ApiRequestOptions'; -import type { ModelThatExtends } from './ModelThatExtends'; -import type { ModelWithString } from './ModelWithString'; +type Resolver = (options: ApiRequestOptions) => Promise; +type Headers = Record; -/** - * This is a model that extends another model - */ -export type ModelThatExtendsExtends = (ModelWithString & ModelThatExtends & { - propExtendsC?: string, - propExtendsD?: ModelWithString, -}); +export type ClientConfig = { + baseUrl?: string; + version?: string; + withCredentials?: boolean; + token?: string | Resolver; + username?: string | Resolver; + password?: string | Resolver; + headers?: Headers | Resolver; +} " `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithArray.ts 1`] = ` +exports[`v2 should generate with no tags: ./test/generated/v2_client_no_tags/core/index.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ - -import type { ModelWithString } from './ModelWithString'; - -/** - * This is a model with one property containing an array - */ -export type ModelWithArray = { - prop?: Array; - propWithFile?: Array; - propWithNumber?: Array; -} +export { ApiError } from './ApiError'; +export type { ApiRequestOptions } from './ApiRequestOptions'; +export type { ApiResult } from './ApiResult'; +export type { BaseHttpRequest } from './BaseHttpRequest'; +export { FetchHttpRequest } from './FetchHttpRequest'; +export type { ClientConfig } from './OpenAPI'; " `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithBoolean.ts 1`] = ` +exports[`v2 should generate with no tags: ./test/generated/v2_client_no_tags/index.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +export * from './core'; +export * from './models'; +export * from './schemas'; +export * from './services'; -/** - * This is a model with one boolean property - */ -export type ModelWithBoolean = { - /** - * This is a simple boolean property - */ - prop?: boolean; -} +export { TestClient } from './client'; " `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithCircularReference.ts 1`] = ` +exports[`v2 should generate with no tags: ./test/generated/v2_client_no_tags/models/index.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ - -/** - * This is a model with one property containing a circular reference - */ -export type ModelWithCircularReference = { - prop?: ModelWithCircularReference; -} " `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithDictionary.ts 1`] = ` +exports[`v2 should generate with no tags: ./test/generated/v2_client_no_tags/schemas/index.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ - -/** - * This is a model with one property containing a dictionary - */ -export type ModelWithDictionary = { - prop?: Record; -} " `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithDuplicateImports.ts 1`] = ` +exports[`v2 should generate with no tags: ./test/generated/v2_client_no_tags/services/Service.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { BaseHttpRequest, ClientConfig } from '../core'; +import { ServiceFull } from './ServiceFull'; -import type { ModelWithString } from './ModelWithString'; +export class Service { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; + readonly full: ServiceFull; -/** - * This is a model with duplicated imports - */ -export type ModelWithDuplicateImports = { - propA?: ModelWithString; - propB?: ModelWithString; - propC?: ModelWithString; -} -" -`; - -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithDuplicateProperties.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import type { ModelWithString } from './ModelWithString'; - -/** - * This is a model with duplicated properties - */ -export type ModelWithDuplicateProperties = { - prop?: ModelWithString; -} -" -`; - -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithEnum.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + this.full = new ServiceFull(httpRequest, clientConfig); + } -/** - * This is a model with one enum - */ -export type ModelWithEnum = { - /** - * This is a simple enum with strings - */ - test?: ModelWithEnum.test; - /** - * These are the HTTP error code enums - */ - statusCode?: ModelWithEnum.statusCode; /** - * Simple boolean enum + * @param [config] the optional OpenAPI config to use + * @throws ApiError */ - bool?: boolean; -} - -export namespace ModelWithEnum { + public async getCallWithoutParametersAndResponse(config?: ClientConfig): Promise { + return (await this.full.getCallWithoutParametersAndResponse(config)).body; + } /** - * This is a simple enum with strings + * @param [config] the optional OpenAPI config to use + * @throws ApiError */ - export enum test { - SUCCESS = 'Success', - WARNING = 'Warning', - ERROR = 'Error', + public async putCallWithoutParametersAndResponse(config?: ClientConfig): Promise { + return (await this.full.putCallWithoutParametersAndResponse(config)).body; } /** - * These are the HTTP error code enums + * @param [config] the optional OpenAPI config to use + * @throws ApiError */ - 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', + public async postCallWithoutParametersAndResponse(config?: ClientConfig): Promise { + return (await this.full.postCallWithoutParametersAndResponse(config)).body; } - -} -" +}" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithEnumFromDescription.ts 1`] = ` +exports[`v2 should generate with no tags: ./test/generated/v2_client_no_tags/services/ServiceFull.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; + +export class ServiceFull { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + } -/** - * This is a model with one enum - */ -export type ModelWithEnumFromDescription = { /** - * Success=1,Warning=2,Error=3 + * @param [config] the optional OpenAPI config to use + * @throws ApiError */ - test?: ModelWithEnumFromDescription.test; -} - -export namespace ModelWithEnumFromDescription { + public async getCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { + return this.httpRequest.request({ + method: 'GET', + path: \`/api/v\${this.clientConfig.version}/simple\`, + }, this.clientConfig, config); + } /** - * Success=1,Warning=2,Error=3 + * @param [config] the optional OpenAPI config to use + * @throws ApiError */ - export enum test { - SUCCESS = 1, - WARNING = 2, - ERROR = 3, + public async putCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { + return this.httpRequest.request({ + method: 'PUT', + path: \`/api/v\${this.clientConfig.version}/simple\`, + }, this.clientConfig, config); } + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async postCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { + return this.httpRequest.request({ + method: 'POST', + path: \`/api/v\${this.clientConfig.version}/simple\`, + }, this.clientConfig, config); + } -} -" +}" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithInteger.ts 1`] = ` +exports[`v2 should generate with no tags: ./test/generated/v2_client_no_tags/services/index.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ - -/** - * This is a model with one number property - */ -export type ModelWithInteger = { - /** - * This is a simple number property - */ - prop?: number; -} +export { Service } from './Service'; +export { ServiceFull } from './ServiceFull'; " `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithNestedEnums.ts 1`] = ` +exports[`v3 should generate with combined tags: ./test/generated/v3_client_tags_combined/client.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { BaseHttpRequest } from './core'; +import { FetchHttpRequest } from './core'; +import type { ClientConfig } from './core'; +import { + SimpleService, +} from './services'; +import { Service } from './services'; -/** - * This is a model with nested enums - */ -export type ModelWithNestedEnums = { - dictionaryWithEnum?: Record; - dictionaryWithEnumFromDescription?: Record; - arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; - arrayWithDescription?: Array<1 | 2 | 3>; -} -" +export class TestClient extends Service { + readonly simple: SimpleService; + + constructor(clientConfig: ClientConfig, httpClient: BaseHttpRequest = new FetchHttpRequest()) { + const config = { + baseUrl: clientConfig?.baseUrl ?? 'http://localhost:3000/base', + version: clientConfig?.version ?? '1.0', + withCredentials: clientConfig?.withCredentials ?? false, + token: clientConfig?.token, + username: clientConfig?.username, + password: clientConfig?.password, + headers: clientConfig?.headers, + } + super(httpClient, config); + this.simple = new SimpleService(httpClient, config); + } +}" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithNestedProperties.ts 1`] = ` +exports[`v3 should generate with combined tags: ./test/generated/v3_client_tags_combined/core/ApiError.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { ApiResult } from './ApiResult'; -/** - * This is a model with one nested property - */ -export type ModelWithNestedProperties = { - readonly first: { - readonly second: { - readonly third: string | null, - } | null, - } | null; -} -" +export class ApiError extends Error { + public readonly url: string; + public readonly status: number; + public readonly statusText: string; + public readonly body: any; + + constructor(response: ApiResult, message: string) { + super(message); + + this.url = response.url; + this.status = response.status; + this.statusText = response.statusText; + this.body = response.body; + } +}" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithOrderedProperties.ts 1`] = ` +exports[`v3 should generate with combined tags: ./test/generated/v3_client_tags_combined/core/ApiRequestOptions.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ - -/** - * This is a model with ordered properties - */ -export type ModelWithOrderedProperties = { - zebra?: string; - apple?: string; - hawaii?: string; -} -" +export type ApiRequestOptions = { + readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH'; + readonly path: string; + readonly cookies?: Record; + readonly headers?: Record; + readonly query?: Record; + readonly formData?: Record; + readonly body?: any; + readonly mediaType?: string; + readonly responseHeader?: string; + readonly errors?: Record; +}" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithPattern.ts 1`] = ` +exports[`v3 should generate with combined tags: ./test/generated/v3_client_tags_combined/core/ApiResult.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ - -/** - * This is a model that contains a some patterns - */ -export type ModelWithPattern = { - key: string; - name: string; - readonly enabled?: boolean; - readonly modified?: string; - id?: string; - text?: string; -} -" +export type ApiResult = { + readonly url: string; + readonly ok: boolean; + readonly status: number; + readonly statusText: string; + readonly body: T; +}" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithProperties.ts 1`] = ` +exports[`v3 should generate with combined tags: ./test/generated/v3_client_tags_combined/core/BaseHttpRequest.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { ApiRequestOptions } from './ApiRequestOptions'; +import type { ApiResult } from './ApiResult'; +import type { ClientConfig } from './OpenAPI'; -import type { ModelWithString } from './ModelWithString'; - -/** - * This is a model with one nested property - */ -export type ModelWithProperties = { - required: string; - readonly requiredAndReadOnly: string; - requiredAndNullable: string | null; - string?: string; - number?: number; - boolean?: boolean; - reference?: ModelWithString; - 'property with space'?: string; - default?: string; - try?: string; - readonly '@namespace.string'?: string; - readonly '@namespace.integer'?: number; -} -" +export interface BaseHttpRequest { + request( + options: ApiRequestOptions, + config: ClientConfig, + mergeConfig?: ClientConfig + ): Promise>; +}" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithReference.ts 1`] = ` +exports[`v3 should generate with combined tags: ./test/generated/v3_client_tags_combined/core/FetchHttpRequest.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import { ApiError } from './ApiError'; +import type { ApiRequestOptions } from './ApiRequestOptions'; +import type { ApiResult } from './ApiResult'; +import type { ClientConfig } from './OpenAPI'; +import type { BaseHttpRequest } from './BaseHttpRequest'; -import type { ModelWithProperties } from './ModelWithProperties'; - -/** - * This is a model with one property containing a reference - */ -export type ModelWithReference = { - prop?: ModelWithProperties; +function isDefined(value: T | null | undefined): value is Exclude { + return value !== undefined && value !== null; } -" -`; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithString.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ +function isString(value: any): value is string { + return typeof value === 'string'; +} -/** - * This is a model with one string property - */ -export type ModelWithString = { - /** - * This is a simple string property - */ - prop?: string; +export function deepAssign( + target: Record, + source: Record, +): Record { + const keys = Object.keys(source); + for (const k of keys) { + const sourceValue: unknown = source[k]; + const targetValue: unknown = target[k]; + if (Object(sourceValue) === sourceValue && Object(targetValue) === targetValue) { + target[k] = deepAssign( + targetValue as Record, + sourceValue as Record, + ); + } else { + target[k] = source[k]; + } + } + return target; } -" -`; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/MultilineComment.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ +function isStringWithValue(value: any): value is string { + return isString(value) && value !== ''; +} -/** - * Testing multiline comments. - * This must go to the next line. - * - * This will contain a break. - */ -export type MultilineComment = number;" -`; +function isBlob(value: any): value is Blob { + return value instanceof Blob; +} -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/SimpleBoolean.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ +function getQueryString(params: Record): string { + const qs: string[] = []; + Object.keys(params).forEach(key => { + const value = params[key]; + if (isDefined(value)) { + 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 ''; +} -/** - * This is a simple boolean - */ -export type SimpleBoolean = boolean;" -`; +function getUrl(options: ApiRequestOptions, config: ClientConfig): string { + const path = options.path.replace(/[:]/g, '_'); + const url = \`\${config.baseUrl}\${path}\`; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/SimpleFile.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ + if (options.query) { + return \`\${url}\${getQueryString(options.query)}\`; + } + return url; +} -/** - * This is a simple file - */ -export type SimpleFile = Blob;" -`; +function getFormData(params: Record): FormData { + const formData = new FormData(); + Object.keys(params).forEach(key => { + const value = params[key]; + if (isDefined(value)) { + formData.append(key, value); + } + }); + return formData; +} -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/SimpleInteger.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ +type Resolver = (options: ApiRequestOptions) => Promise; -/** - * This is a simple number - */ -export type SimpleInteger = number;" -`; +async function resolve(options: ApiRequestOptions, resolver?: T | Resolver): Promise { + if (typeof resolver === 'function') { + return (resolver as Resolver)(options); + } + return resolver; +} -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/SimpleReference.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ +async function getHeaders(options: ApiRequestOptions, config: ClientConfig): Promise { + const token = await resolve(options, config.token); + const username = await resolve(options, config.username); + const password = await resolve(options, config.password); + const defaultHeaders = await resolve(options, config.headers); -import type { ModelWithString } from './ModelWithString'; + const headers = new Headers({ + Accept: 'application/json', + ...defaultHeaders, + ...options.headers, + }); -/** - * This is a simple reference - */ -export type SimpleReference = ModelWithString;" -`; + if (isStringWithValue(token)) { + headers.append('Authorization', \`Bearer \${token}\`); + } -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/SimpleString.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ + if (isStringWithValue(username) && isStringWithValue(password)) { + const credentials = btoa(\`\${username}:\${password}\`); + headers.append('Authorization', \`Basic \${credentials}\`); + } -/** - * This is a simple string - */ -export type SimpleString = string;" -`; + if (options.body) { + if (options.mediaType) { + headers.append('Content-Type', options.mediaType); + } else if (isBlob(options.body)) { + headers.append('Content-Type', options.body.type || 'application/octet-stream'); + } else if (isString(options.body)) { + headers.append('Content-Type', 'text/plain'); + } else { + headers.append('Content-Type', 'application/json'); + } + } + return headers; +} -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/SimpleStringWithPattern.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ +function getRequestBody(options: ApiRequestOptions): BodyInit | undefined { + if (options.formData) { + return getFormData(options.formData); + } + if (options.body) { + if (options.mediaType?.includes('/json')) { + return JSON.stringify(options.body) + } else if (isString(options.body) || isBlob(options.body)) { + return options.body; + } else { + return JSON.stringify(options.body); + } + } + return undefined; +} -/** - * This is a simple string - */ -export type SimpleStringWithPattern = string | null;" -`; +async function sendRequest(options: ApiRequestOptions, config: ClientConfig, url: string): Promise { + const request: RequestInit = { + method: options.method, + headers: await getHeaders(options, config), + body: getRequestBody(options), + }; + if (config.withCredentials) { + request.credentials = 'include'; + } + return await fetch(url, request); +} -exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/index.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ +function getResponseHeader(response: Response, responseHeader?: string): string | null { + if (responseHeader) { + const content = response.headers.get(responseHeader); + if (isString(content)) { + return content; + } + } + return null; +} + +async function getResponseBody(response: Response): Promise { + try { + const contentType = response.headers.get('Content-Type'); + if (contentType) { + const isJSON = contentType.toLowerCase().startsWith('application/json'); + if (isJSON) { + return await response.json(); + } else { + return await response.text(); + } + } + } catch (error) { + console.error(error); + } + return null; +} + +function catchErrors(options: ApiRequestOptions, result: ApiResult): void { + const errors: Record = { + 400: 'Bad Request', + 401: 'Unauthorized', + 403: 'Forbidden', + 404: 'Not Found', + 500: 'Internal Server Error', + 502: 'Bad Gateway', + 503: 'Service Unavailable', + ...options.errors, + } + + const error = errors[result.status]; + if (error) { + throw new ApiError(result, error); + } + + if (!result.ok) { + throw new ApiError(result, 'Generic Error'); + } +} + +export class FetchHttpRequest implements BaseHttpRequest { + /** + * Request using fetch client + * @param options The request options from the the service + * @param config The OpenAPI configuration + * @param [mergeConfig] Additional optional OpenAPI configuration that will be merged with the first one + * @returns ApiResult + * @throws ApiError + */ + async request(options: ApiRequestOptions, config: ClientConfig, mergeConfig?: ClientConfig): Promise { + const conf = mergeConfig ? deepAssign(config, mergeConfig) : config; + const url = getUrl(options, conf); + const response = await sendRequest(options, conf, url); + const responseBody = await getResponseBody(response); + const responseHeader = getResponseHeader(response, options.responseHeader); + + const result: ApiResult = { + url, + ok: response.ok, + status: response.status, + statusText: response.statusText, + body: responseHeader || responseBody, + }; + + catchErrors(options, result); + return result; + } +} +" +`; + +exports[`v3 should generate with combined tags: ./test/generated/v3_client_tags_combined/core/OpenAPI.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export type { ArrayWithArray } from './ArrayWithArray'; -export type { ArrayWithBooleans } from './ArrayWithBooleans'; -export type { ArrayWithNumbers } from './ArrayWithNumbers'; -export type { ArrayWithProperties } from './ArrayWithProperties'; -export type { ArrayWithReferences } from './ArrayWithReferences'; -export type { ArrayWithStrings } from './ArrayWithStrings'; -export type { CompositionWithAllOfAndNullable } from './CompositionWithAllOfAndNullable'; -export type { CompositionWithAnyOf } from './CompositionWithAnyOf'; -export type { CompositionWithAnyOfAndNullable } from './CompositionWithAnyOfAndNullable'; -export type { CompositionWithAnyOfAnonymous } from './CompositionWithAnyOfAnonymous'; -export type { CompositionWithOneOf } from './CompositionWithOneOf'; -export type { CompositionWithOneOfAndNullable } from './CompositionWithOneOfAndNullable'; -export type { CompositionWithOneOfAnonymous } from './CompositionWithOneOfAnonymous'; -export type { DictionaryWithArray } from './DictionaryWithArray'; -export type { DictionaryWithDictionary } from './DictionaryWithDictionary'; -export type { DictionaryWithProperties } from './DictionaryWithProperties'; -export type { DictionaryWithReference } from './DictionaryWithReference'; -export type { DictionaryWithString } from './DictionaryWithString'; -export { EnumFromDescription } from './EnumFromDescription'; -export { EnumWithExtensions } from './EnumWithExtensions'; -export { EnumWithNumbers } from './EnumWithNumbers'; -export { EnumWithStrings } from './EnumWithStrings'; -export type { ModelThatExtends } from './ModelThatExtends'; -export type { ModelThatExtendsExtends } from './ModelThatExtendsExtends'; -export type { ModelWithArray } from './ModelWithArray'; -export type { ModelWithBoolean } from './ModelWithBoolean'; -export type { ModelWithCircularReference } from './ModelWithCircularReference'; -export type { ModelWithDictionary } from './ModelWithDictionary'; -export type { ModelWithDuplicateImports } from './ModelWithDuplicateImports'; -export type { ModelWithDuplicateProperties } from './ModelWithDuplicateProperties'; -export type { ModelWithEnum } from './ModelWithEnum'; -export type { ModelWithEnumFromDescription } from './ModelWithEnumFromDescription'; -export type { ModelWithInteger } from './ModelWithInteger'; -export type { ModelWithNestedEnums } from './ModelWithNestedEnums'; -export type { ModelWithNestedProperties } from './ModelWithNestedProperties'; -export type { ModelWithOrderedProperties } from './ModelWithOrderedProperties'; -export type { ModelWithPattern } from './ModelWithPattern'; -export type { ModelWithProperties } from './ModelWithProperties'; -export type { ModelWithReference } from './ModelWithReference'; -export type { ModelWithString } from './ModelWithString'; -export type { MultilineComment } from './MultilineComment'; -export type { SimpleBoolean } from './SimpleBoolean'; -export type { SimpleFile } from './SimpleFile'; -export type { SimpleInteger } from './SimpleInteger'; -export type { SimpleReference } from './SimpleReference'; -export type { SimpleString } from './SimpleString'; -export type { SimpleStringWithPattern } from './SimpleStringWithPattern'; +import type { ApiRequestOptions } from './ApiRequestOptions'; + +type Resolver = (options: ApiRequestOptions) => Promise; +type Headers = Record; + +export type ClientConfig = { + baseUrl?: string; + version?: string; + withCredentials?: boolean; + token?: string | Resolver; + username?: string | Resolver; + password?: string | Resolver; + headers?: Headers | Resolver; +} " `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ArrayWithArray.ts 1`] = ` +exports[`v3 should generate with combined tags: ./test/generated/v3_client_tags_combined/core/index.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $ArrayWithArray = { - type: 'array', - contains: { - type: 'array', - contains: { - type: 'ModelWithString', - }, - }, -};" +export { ApiError } from './ApiError'; +export type { ApiRequestOptions } from './ApiRequestOptions'; +export type { ApiResult } from './ApiResult'; +export type { BaseHttpRequest } from './BaseHttpRequest'; +export { FetchHttpRequest } from './FetchHttpRequest'; +export type { ClientConfig } from './OpenAPI'; +" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ArrayWithBooleans.ts 1`] = ` +exports[`v3 should generate with combined tags: ./test/generated/v3_client_tags_combined/index.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $ArrayWithBooleans = { - type: 'array', - contains: { - type: 'boolean', - }, -};" +export * from './core'; +export * from './models'; +export * from './schemas'; +export * from './services'; + +export { TestClient } from './client'; +" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ArrayWithNumbers.ts 1`] = ` +exports[`v3 should generate with combined tags: ./test/generated/v3_client_tags_combined/models/index.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $ArrayWithNumbers = { - type: 'array', - contains: { - type: 'number', - }, -};" +" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ArrayWithProperties.ts 1`] = ` +exports[`v3 should generate with combined tags: ./test/generated/v3_client_tags_combined/schemas/index.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $ArrayWithProperties = { - type: 'array', - contains: { - properties: { - foo: { - type: 'string', - }, - bar: { - type: 'string', - }, - }, - }, -};" +" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ArrayWithReferences.ts 1`] = ` +exports[`v3 should generate with combined tags: ./test/generated/v3_client_tags_combined/services/Service.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $ArrayWithReferences = { - type: 'array', - contains: { - type: 'ModelWithString', - }, -};" +import type { BaseHttpRequest, ClientConfig } from '../core'; +import { ServiceFull } from './ServiceFull'; + +export class Service { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; + readonly full: ServiceFull; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + this.full = new ServiceFull(httpRequest, clientConfig); + } + + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async postCallWithoutParametersAndResponse(config?: ClientConfig): Promise { + return (await this.full.postCallWithoutParametersAndResponse(config)).body; + } + +}" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ArrayWithStrings.ts 1`] = ` +exports[`v3 should generate with combined tags: ./test/generated/v3_client_tags_combined/services/ServiceFull.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $ArrayWithStrings = { - type: 'array', - contains: { - type: 'string', - }, -};" +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; + +export class ServiceFull { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + } + + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async postCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { + return this.httpRequest.request({ + method: 'POST', + path: \`/api/v\${this.clientConfig.version}/simple\`, + }, this.clientConfig, config); + } + +}" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$CompositionWithAllOfAndNullable.ts 1`] = ` +exports[`v3 should generate with combined tags: ./test/generated/v3_client_tags_combined/services/SimpleService.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $CompositionWithAllOfAndNullable = { - properties: { - propA: { - type: 'all-of', - contains: [{ - properties: { - boolean: { - type: 'boolean', - }, - }, - }, { - type: 'ModelWithEnum', - }, { - type: 'ModelWithArray', - }, { - type: 'ModelWithDictionary', - }], - isNullable: true, - }, - }, -};" +import type { BaseHttpRequest, ClientConfig } from '../core'; +import { SimpleServiceFull } from './SimpleServiceFull'; + +export class SimpleService { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; + readonly full: SimpleServiceFull; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + this.full = new SimpleServiceFull(httpRequest, clientConfig); + } + + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async getCallWithoutParametersAndResponse(config?: ClientConfig): Promise { + return (await this.full.getCallWithoutParametersAndResponse(config)).body; + } + + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async putCallWithoutParametersAndResponse(config?: ClientConfig): Promise { + return (await this.full.putCallWithoutParametersAndResponse(config)).body; + } + +}" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$CompositionWithAnyOf.ts 1`] = ` +exports[`v3 should generate with combined tags: ./test/generated/v3_client_tags_combined/services/SimpleServiceFull.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $CompositionWithAnyOf = { - properties: { - propA: { - type: 'any-of', - contains: [{ - type: 'ModelWithString', - }, { - type: 'ModelWithEnum', - }, { - type: 'ModelWithArray', - }, { - type: 'ModelWithDictionary', - }], - }, - }, -};" +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; + +export class SimpleServiceFull { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + } + + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async getCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { + return this.httpRequest.request({ + method: 'GET', + path: \`/api/v\${this.clientConfig.version}/simple\`, + }, this.clientConfig, config); + } + + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async putCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { + return this.httpRequest.request({ + method: 'PUT', + path: \`/api/v\${this.clientConfig.version}/simple\`, + }, this.clientConfig, config); + } + +}" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$CompositionWithAnyOfAndNullable.ts 1`] = ` +exports[`v3 should generate with combined tags: ./test/generated/v3_client_tags_combined/services/index.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $CompositionWithAnyOfAndNullable = { - properties: { - propA: { - type: 'any-of', - contains: [{ - properties: { - boolean: { - type: 'boolean', - }, - }, - }, { - type: 'ModelWithEnum', - }, { - type: 'ModelWithArray', - }, { - type: 'ModelWithDictionary', - }], - isNullable: true, - }, - }, -};" +export { Service } from './Service'; +export { ServiceFull } from './ServiceFull'; +export { SimpleService } from './SimpleService'; +export { SimpleServiceFull } from './SimpleServiceFull'; +" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$CompositionWithAnyOfAnonymous.ts 1`] = ` +exports[`v3 should generate with exportClient: ./test/generated/v3_client/client.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $CompositionWithAnyOfAnonymous = { - properties: { - propA: { - type: 'any-of', - contains: [{ - properties: { - propA: { - properties: { - }, - }, - }, - }, { - type: 'string', - }, { - type: 'number', - }], - }, - }, -};" +import type { BaseHttpRequest } from './core'; +import { FetchHttpRequest } from './core'; +import type { ClientConfig } from './core'; +import { + CollectionFormatService, + ComplexService, + DefaultsService, + DuplicateService, + HeaderService, + MultipartService, + NoContentService, + ParametersService, + RequestBodyService, + ResponseService, + SimpleService, + TypesService, + UploadService, +} from './services'; + +export class TestClient { + readonly collectionformat: CollectionFormatService; + readonly complex: ComplexService; + readonly defaults: DefaultsService; + readonly duplicate: DuplicateService; + readonly header: HeaderService; + readonly multipart: MultipartService; + readonly nocontent: NoContentService; + readonly parameters: ParametersService; + readonly requestbody: RequestBodyService; + readonly response: ResponseService; + readonly simple: SimpleService; + readonly types: TypesService; + readonly upload: UploadService; + + constructor(clientConfig: ClientConfig, httpClient: BaseHttpRequest = new FetchHttpRequest()) { + const config = { + baseUrl: clientConfig?.baseUrl ?? 'http://localhost:3000/base', + version: clientConfig?.version ?? '1.0', + withCredentials: clientConfig?.withCredentials ?? false, + token: clientConfig?.token, + username: clientConfig?.username, + password: clientConfig?.password, + headers: clientConfig?.headers, + } + this.collectionformat = new CollectionFormatService(httpClient, config); + this.complex = new ComplexService(httpClient, config); + this.defaults = new DefaultsService(httpClient, config); + this.duplicate = new DuplicateService(httpClient, config); + this.header = new HeaderService(httpClient, config); + this.multipart = new MultipartService(httpClient, config); + this.nocontent = new NoContentService(httpClient, config); + this.parameters = new ParametersService(httpClient, config); + this.requestbody = new RequestBodyService(httpClient, config); + this.response = new ResponseService(httpClient, config); + this.simple = new SimpleService(httpClient, config); + this.types = new TypesService(httpClient, config); + this.upload = new UploadService(httpClient, config); + } +}" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$CompositionWithOneOf.ts 1`] = ` +exports[`v3 should generate with exportClient: ./test/generated/v3_client/core/ApiError.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $CompositionWithOneOf = { - properties: { - propA: { - type: 'one-of', - contains: [{ - type: 'ModelWithString', - }, { - type: 'ModelWithEnum', - }, { - type: 'ModelWithArray', - }, { - type: 'ModelWithDictionary', - }], - }, - }, -};" +import type { ApiResult } from './ApiResult'; + +export class ApiError extends Error { + public readonly url: string; + public readonly status: number; + public readonly statusText: string; + public readonly body: any; + + constructor(response: ApiResult, message: string) { + super(message); + + this.url = response.url; + this.status = response.status; + this.statusText = response.statusText; + this.body = response.body; + } +}" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$CompositionWithOneOfAndNullable.ts 1`] = ` +exports[`v3 should generate with exportClient: ./test/generated/v3_client/core/ApiRequestOptions.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $CompositionWithOneOfAndNullable = { - properties: { - propA: { - type: 'one-of', - contains: [{ - properties: { - boolean: { - type: 'boolean', - }, - }, - }, { - type: 'ModelWithEnum', - }, { - type: 'ModelWithArray', - }, { - type: 'ModelWithDictionary', - }], - isNullable: true, - }, - }, -};" +export type ApiRequestOptions = { + readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH'; + readonly path: string; + readonly cookies?: Record; + readonly headers?: Record; + readonly query?: Record; + readonly formData?: Record; + readonly body?: any; + readonly mediaType?: string; + readonly responseHeader?: string; + readonly errors?: Record; +}" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$CompositionWithOneOfAnonymous.ts 1`] = ` +exports[`v3 should generate with exportClient: ./test/generated/v3_client/core/ApiResult.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $CompositionWithOneOfAnonymous = { - properties: { - propA: { - type: 'one-of', - contains: [{ - properties: { - propA: { - properties: { - }, - }, - }, - }, { - type: 'string', - }, { - type: 'number', - }], - }, - }, -};" +export type ApiResult = { + readonly url: string; + readonly ok: boolean; + readonly status: number; + readonly statusText: string; + readonly body: T; +}" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$DictionaryWithArray.ts 1`] = ` +exports[`v3 should generate with exportClient: ./test/generated/v3_client/core/BaseHttpRequest.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $DictionaryWithArray = { - type: 'dictionary', - contains: { - type: 'array', - contains: { - type: 'ModelWithString', - }, - }, -};" -`; +import type { ApiRequestOptions } from './ApiRequestOptions'; +import type { ApiResult } from './ApiResult'; +import type { ClientConfig } from './OpenAPI'; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$DictionaryWithDictionary.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -export const $DictionaryWithDictionary = { - type: 'dictionary', - contains: { - type: 'dictionary', - contains: { - type: 'string', - }, - }, -};" +export interface BaseHttpRequest { + request( + options: ApiRequestOptions, + config: ClientConfig, + mergeConfig?: ClientConfig + ): Promise>; +}" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$DictionaryWithProperties.ts 1`] = ` +exports[`v3 should generate with exportClient: ./test/generated/v3_client/core/FetchHttpRequest.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $DictionaryWithProperties = { - type: 'dictionary', - contains: { - properties: { - foo: { - type: 'string', - }, - bar: { - type: 'string', - }, - }, - }, -};" -`; +import { ApiError } from './ApiError'; +import type { ApiRequestOptions } from './ApiRequestOptions'; +import type { ApiResult } from './ApiResult'; +import type { ClientConfig } from './OpenAPI'; +import type { BaseHttpRequest } from './BaseHttpRequest'; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$DictionaryWithReference.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -export const $DictionaryWithReference = { - type: 'dictionary', - contains: { - type: 'ModelWithString', - }, -};" -`; +function isDefined(value: T | null | undefined): value is Exclude { + return value !== undefined && value !== null; +} -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$DictionaryWithString.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -export const $DictionaryWithString = { - type: 'dictionary', - contains: { - type: 'string', - }, -};" -`; +function isString(value: any): value is string { + return typeof value === 'string'; +} -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$EnumFromDescription.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -export const $EnumFromDescription = { - type: 'Enum', -};" -`; +export function deepAssign( + target: Record, + source: Record, +): Record { + const keys = Object.keys(source); + for (const k of keys) { + const sourceValue: unknown = source[k]; + const targetValue: unknown = target[k]; + if (Object(sourceValue) === sourceValue && Object(targetValue) === targetValue) { + target[k] = deepAssign( + targetValue as Record, + sourceValue as Record, + ); + } else { + target[k] = source[k]; + } + } + return target; +} -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$EnumWithExtensions.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -export const $EnumWithExtensions = { - type: 'Enum', -};" -`; +function isStringWithValue(value: any): value is string { + return isString(value) && value !== ''; +} -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$EnumWithNumbers.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -export const $EnumWithNumbers = { - type: 'Enum', -};" -`; +function isBlob(value: any): value is Blob { + return value instanceof Blob; +} -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$EnumWithStrings.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -export const $EnumWithStrings = { - type: 'Enum', -};" -`; +function getQueryString(params: Record): string { + const qs: string[] = []; + Object.keys(params).forEach(key => { + const value = params[key]; + if (isDefined(value)) { + 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 with exportClient: ./test/generated/v3_client/schemas/$ModelThatExtends.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -export const $ModelThatExtends = { - type: 'all-of', - contains: [{ - type: 'ModelWithString', - }, { - properties: { - propExtendsA: { - type: 'string', - }, - propExtendsB: { - type: 'ModelWithString', - }, - }, - }], -};" -`; +function getUrl(options: ApiRequestOptions, config: ClientConfig): string { + const path = options.path.replace(/[:]/g, '_'); + const url = \`\${config.baseUrl}\${path}\`; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelThatExtendsExtends.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -export const $ModelThatExtendsExtends = { - type: 'all-of', - contains: [{ - type: 'ModelWithString', - }, { - type: 'ModelThatExtends', - }, { - properties: { - propExtendsC: { - type: 'string', - }, - propExtendsD: { - type: 'ModelWithString', - }, - }, - }], -};" + if (options.query) { + return \`\${url}\${getQueryString(options.query)}\`; + } + return url; +} + +function getFormData(params: Record): FormData { + const formData = new FormData(); + Object.keys(params).forEach(key => { + const value = params[key]; + if (isDefined(value)) { + formData.append(key, value); + } + }); + return formData; +} + +type Resolver = (options: ApiRequestOptions) => Promise; + +async function resolve(options: ApiRequestOptions, resolver?: T | Resolver): Promise { + if (typeof resolver === 'function') { + return (resolver as Resolver)(options); + } + return resolver; +} + +async function getHeaders(options: ApiRequestOptions, config: ClientConfig): Promise { + const token = await resolve(options, config.token); + const username = await resolve(options, config.username); + const password = await resolve(options, config.password); + const defaultHeaders = await resolve(options, config.headers); + + const headers = new Headers({ + Accept: 'application/json', + ...defaultHeaders, + ...options.headers, + }); + + if (isStringWithValue(token)) { + headers.append('Authorization', \`Bearer \${token}\`); + } + + if (isStringWithValue(username) && isStringWithValue(password)) { + const credentials = btoa(\`\${username}:\${password}\`); + headers.append('Authorization', \`Basic \${credentials}\`); + } + + if (options.body) { + if (options.mediaType) { + headers.append('Content-Type', options.mediaType); + } else if (isBlob(options.body)) { + headers.append('Content-Type', options.body.type || 'application/octet-stream'); + } else if (isString(options.body)) { + headers.append('Content-Type', 'text/plain'); + } else { + headers.append('Content-Type', 'application/json'); + } + } + return headers; +} + +function getRequestBody(options: ApiRequestOptions): BodyInit | undefined { + if (options.formData) { + return getFormData(options.formData); + } + if (options.body) { + if (options.mediaType?.includes('/json')) { + return JSON.stringify(options.body) + } else if (isString(options.body) || isBlob(options.body)) { + return options.body; + } else { + return JSON.stringify(options.body); + } + } + return undefined; +} + +async function sendRequest(options: ApiRequestOptions, config: ClientConfig, url: string): Promise { + const request: RequestInit = { + method: options.method, + headers: await getHeaders(options, config), + body: getRequestBody(options), + }; + if (config.withCredentials) { + request.credentials = 'include'; + } + return await fetch(url, request); +} + +function getResponseHeader(response: Response, responseHeader?: string): string | null { + if (responseHeader) { + const content = response.headers.get(responseHeader); + if (isString(content)) { + return content; + } + } + return null; +} + +async function getResponseBody(response: Response): Promise { + try { + const contentType = response.headers.get('Content-Type'); + if (contentType) { + const isJSON = contentType.toLowerCase().startsWith('application/json'); + if (isJSON) { + return await response.json(); + } else { + return await response.text(); + } + } + } catch (error) { + console.error(error); + } + return null; +} + +function catchErrors(options: ApiRequestOptions, result: ApiResult): void { + const errors: Record = { + 400: 'Bad Request', + 401: 'Unauthorized', + 403: 'Forbidden', + 404: 'Not Found', + 500: 'Internal Server Error', + 502: 'Bad Gateway', + 503: 'Service Unavailable', + ...options.errors, + } + + const error = errors[result.status]; + if (error) { + throw new ApiError(result, error); + } + + if (!result.ok) { + throw new ApiError(result, 'Generic Error'); + } +} + +export class FetchHttpRequest implements BaseHttpRequest { + /** + * Request using fetch client + * @param options The request options from the the service + * @param config The OpenAPI configuration + * @param [mergeConfig] Additional optional OpenAPI configuration that will be merged with the first one + * @returns ApiResult + * @throws ApiError + */ + async request(options: ApiRequestOptions, config: ClientConfig, mergeConfig?: ClientConfig): Promise { + const conf = mergeConfig ? deepAssign(config, mergeConfig) : config; + const url = getUrl(options, conf); + const response = await sendRequest(options, conf, url); + const responseBody = await getResponseBody(response); + const responseHeader = getResponseHeader(response, options.responseHeader); + + const result: ApiResult = { + url, + ok: response.ok, + status: response.status, + statusText: response.statusText, + body: responseHeader || responseBody, + }; + + catchErrors(options, result); + return result; + } +} +" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithArray.ts 1`] = ` +exports[`v3 should generate with exportClient: ./test/generated/v3_client/core/OpenAPI.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $ModelWithArray = { - properties: { - prop: { - type: 'array', - contains: { - type: 'ModelWithString', - }, - }, - propWithFile: { - type: 'array', - contains: { - type: 'File', - }, - }, - propWithNumber: { - type: 'array', - contains: { - type: 'number', - }, - }, - }, -};" +import type { ApiRequestOptions } from './ApiRequestOptions'; + +type Resolver = (options: ApiRequestOptions) => Promise; +type Headers = Record; + +export type ClientConfig = { + baseUrl?: string; + version?: string; + withCredentials?: boolean; + token?: string | Resolver; + username?: string | Resolver; + password?: string | Resolver; + headers?: Headers | Resolver; +} +" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithBoolean.ts 1`] = ` +exports[`v3 should generate with exportClient: ./test/generated/v3_client/core/index.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $ModelWithBoolean = { - properties: { - prop: { - type: 'boolean', - }, - }, -};" +export { ApiError } from './ApiError'; +export type { ApiRequestOptions } from './ApiRequestOptions'; +export type { ApiResult } from './ApiResult'; +export type { BaseHttpRequest } from './BaseHttpRequest'; +export { FetchHttpRequest } from './FetchHttpRequest'; +export type { ClientConfig } from './OpenAPI'; +" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithCircularReference.ts 1`] = ` +exports[`v3 should generate with exportClient: ./test/generated/v3_client/index.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $ModelWithCircularReference = { - properties: { - prop: { - type: 'ModelWithCircularReference', - }, - }, -};" +export * from './core'; +export * from './models'; +export * from './schemas'; +export * from './services'; + +export { TestClient } from './client'; +" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithDictionary.ts 1`] = ` +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ArrayWithArray.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $ModelWithDictionary = { - properties: { - prop: { - type: 'dictionary', - contains: { - type: 'string', - }, - }, - }, -};" -`; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithDuplicateImports.ts 1`] = ` +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a simple array containing an array + */ +export type ArrayWithArray = Array>;" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ArrayWithBooleans.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $ModelWithDuplicateImports = { - properties: { - propA: { - type: 'ModelWithString', - }, - propB: { - type: 'ModelWithString', - }, - propC: { - type: 'ModelWithString', - }, - }, -};" + +/** + * This is a simple array with booleans + */ +export type ArrayWithBooleans = Array;" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithDuplicateProperties.ts 1`] = ` +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ArrayWithNumbers.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $ModelWithDuplicateProperties = { - properties: { - prop: { - type: 'ModelWithString', - }, - }, -};" + +/** + * This is a simple array with numbers + */ +export type ArrayWithNumbers = Array;" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithEnum.ts 1`] = ` +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ArrayWithProperties.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $ModelWithEnum = { - properties: { - test: { - type: 'Enum', - }, - statusCode: { - type: 'Enum', - }, - bool: { - type: 'boolean', - }, - }, -};" + +/** + * This is a simple array with properties + */ +export type ArrayWithProperties = Array<{ + foo?: string, + bar?: string, +}>;" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithEnumFromDescription.ts 1`] = ` +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ArrayWithReferences.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $ModelWithEnumFromDescription = { - properties: { - test: { - type: 'Enum', - }, - }, -};" + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a simple array with references + */ +export type ArrayWithReferences = Array;" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithInteger.ts 1`] = ` +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ArrayWithStrings.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $ModelWithInteger = { - properties: { - prop: { - type: 'number', - }, - }, -};" + +/** + * This is a simple array with strings + */ +export type ArrayWithStrings = Array;" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithNestedEnums.ts 1`] = ` +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/CompositionWithAllOfAndNullable.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $ModelWithNestedEnums = { - properties: { - dictionaryWithEnum: { - type: 'dictionary', - contains: { - type: 'Enum', - }, - }, - dictionaryWithEnumFromDescription: { - type: 'dictionary', - contains: { - type: 'Enum', - }, - }, - arrayWithEnum: { - type: 'array', - contains: { - type: 'Enum', - }, - }, - arrayWithDescription: { - type: 'array', - contains: { - type: 'Enum', - }, - }, - }, -};" + +import type { ModelWithArray } from './ModelWithArray'; +import type { ModelWithDictionary } from './ModelWithDictionary'; +import type { ModelWithEnum } from './ModelWithEnum'; + +/** + * This is a model with one property with a 'all of' relationship + */ +export type CompositionWithAllOfAndNullable = { + propA?: ({ + boolean?: boolean, + } & ModelWithEnum & ModelWithArray & ModelWithDictionary) | null; +} +" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithNestedProperties.ts 1`] = ` +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/CompositionWithAnyOf.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* 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, - }, - }, -};" + +import type { ModelWithArray } from './ModelWithArray'; +import type { ModelWithDictionary } from './ModelWithDictionary'; +import type { ModelWithEnum } from './ModelWithEnum'; +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOf = { + propA?: (ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary); +} +" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithOrderedProperties.ts 1`] = ` +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/CompositionWithAnyOfAndNullable.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $ModelWithOrderedProperties = { - properties: { - zebra: { - type: 'string', - }, - apple: { - type: 'string', - }, - hawaii: { - type: 'string', - }, - }, -};" + +import type { ModelWithArray } from './ModelWithArray'; +import type { ModelWithDictionary } from './ModelWithDictionary'; +import type { ModelWithEnum } from './ModelWithEnum'; + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOfAndNullable = { + propA?: ({ + boolean?: boolean, + } | ModelWithEnum | ModelWithArray | ModelWithDictionary) | null; +} +" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithPattern.ts 1`] = ` +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/CompositionWithAnyOfAnonymous.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* 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', - }, - id: { - type: 'string', - pattern: '^\\\\\\\\d{2}-\\\\\\\\d{3}-\\\\\\\\d{4}$', - }, - text: { - type: 'string', - pattern: '^\\\\\\\\w+$', - }, - }, -};" + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithAnyOfAnonymous = { + propA?: ({ + propA?: any, + } | string | number); +} +" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithProperties.ts 1`] = ` +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/CompositionWithOneOf.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $ModelWithProperties = { - properties: { - required: { - type: 'string', + +import type { ModelWithArray } from './ModelWithArray'; +import type { ModelWithDictionary } from './ModelWithDictionary'; +import type { ModelWithEnum } from './ModelWithEnum'; +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOf = { + propA?: (ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary); +} +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/CompositionWithOneOfAndNullable.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithArray } from './ModelWithArray'; +import type { ModelWithDictionary } from './ModelWithDictionary'; +import type { ModelWithEnum } from './ModelWithEnum'; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOfAndNullable = { + propA?: ({ + boolean?: boolean, + } | ModelWithEnum | ModelWithArray | ModelWithDictionary) | null; +} +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/CompositionWithOneOfAnonymous.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfAnonymous = { + propA?: ({ + propA?: any, + } | string | number); +} +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/DictionaryWithArray.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a complex dictionary + */ +export type DictionaryWithArray = Record>;" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/DictionaryWithDictionary.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a string dictionary + */ +export type DictionaryWithDictionary = Record>;" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/DictionaryWithProperties.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a complex dictionary + */ +export type DictionaryWithProperties = Record;" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/DictionaryWithReference.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a string reference + */ +export type DictionaryWithReference = Record;" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/DictionaryWithString.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a string dictionary + */ +export type DictionaryWithString = Record;" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/EnumFromDescription.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* 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 with exportClient: ./test/generated/v3_client/models/EnumWithExtensions.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* 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 with exportClient: ./test/generated/v3_client/models/EnumWithNumbers.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a simple enum with numbers + */ +export enum EnumWithNumbers { + '_1' = 1, + '_2' = 2, + '_3' = 3, + '_1.1' = 1.1, + '_1.2' = 1.2, + '_1.3' = 1.3, + '_100' = 100, + '_200' = 200, + '_300' = 300, + '_-100' = -100, + '_-200' = -200, + '_-300' = -300, + '_-1.1' = -1.1, + '_-1.2' = -1.2, + '_-1.3' = -1.3, +}" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/EnumWithStrings.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* 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 with exportClient: ./test/generated/v3_client/models/ModelThatExtends.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model that extends another model + */ +export type ModelThatExtends = (ModelWithString & { + propExtendsA?: string, + propExtendsB?: ModelWithString, +}); +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelThatExtendsExtends.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelThatExtends } from './ModelThatExtends'; +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model that extends another model + */ +export type ModelThatExtendsExtends = (ModelWithString & ModelThatExtends & { + propExtendsC?: string, + propExtendsD?: ModelWithString, +}); +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithArray.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArray = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +} +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithBoolean.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one boolean property + */ +export type ModelWithBoolean = { + /** + * This is a simple boolean property + */ + prop?: boolean; +} +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithCircularReference.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one property containing a circular reference + */ +export type ModelWithCircularReference = { + prop?: ModelWithCircularReference; +} +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithDictionary.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one property containing a dictionary + */ +export type ModelWithDictionary = { + prop?: Record; +} +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithDuplicateImports.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model with duplicated imports + */ +export type ModelWithDuplicateImports = { + propA?: ModelWithString; + propB?: ModelWithString; + propC?: ModelWithString; +} +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithDuplicateProperties.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model with duplicated properties + */ +export type ModelWithDuplicateProperties = { + prop?: ModelWithString; +} +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithEnum.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one enum + */ +export type ModelWithEnum = { + /** + * This is a simple enum with strings + */ + test?: ModelWithEnum.test; + /** + * These are the HTTP error code enums + */ + statusCode?: ModelWithEnum.statusCode; + /** + * Simple boolean enum + */ + bool?: boolean; +} + +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 with exportClient: ./test/generated/v3_client/models/ModelWithEnumFromDescription.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one enum + */ +export type 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 with exportClient: ./test/generated/v3_client/models/ModelWithInteger.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one number property + */ +export type ModelWithInteger = { + /** + * This is a simple number property + */ + prop?: number; +} +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithNestedEnums.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with nested enums + */ +export type ModelWithNestedEnums = { + dictionaryWithEnum?: Record; + dictionaryWithEnumFromDescription?: Record; + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; + arrayWithDescription?: Array<1 | 2 | 3>; +} +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithNestedProperties.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one nested property + */ +export type ModelWithNestedProperties = { + readonly first: { + readonly second: { + readonly third: string | null, + } | null, + } | null; +} +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithOrderedProperties.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with ordered properties + */ +export type ModelWithOrderedProperties = { + zebra?: string; + apple?: string; + hawaii?: string; +} +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithPattern.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPattern = { + key: string; + name: string; + readonly enabled?: boolean; + readonly modified?: string; + id?: string; + text?: string; +} +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithProperties.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model with one nested property + */ +export type ModelWithProperties = { + required: string; + readonly requiredAndReadOnly: string; + requiredAndNullable: string | null; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + 'property with space'?: string; + default?: string; + try?: string; + readonly '@namespace.string'?: string; + readonly '@namespace.integer'?: number; +} +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithReference.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithProperties } from './ModelWithProperties'; + +/** + * This is a model with one property containing a reference + */ +export type ModelWithReference = { + prop?: ModelWithProperties; +} +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/ModelWithString.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one string property + */ +export type ModelWithString = { + /** + * This is a simple string property + */ + prop?: string; +} +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/MultilineComment.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* 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 with exportClient: ./test/generated/v3_client/models/SimpleBoolean.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a simple boolean + */ +export type SimpleBoolean = boolean;" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/SimpleFile.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a simple file + */ +export type SimpleFile = Blob;" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/SimpleInteger.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a simple number + */ +export type SimpleInteger = number;" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/SimpleReference.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a simple reference + */ +export type SimpleReference = ModelWithString;" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/SimpleString.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a simple string + */ +export type SimpleString = string;" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/SimpleStringWithPattern.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a simple string + */ +export type SimpleStringWithPattern = string | null;" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/models/index.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type { ArrayWithArray } from './ArrayWithArray'; +export type { ArrayWithBooleans } from './ArrayWithBooleans'; +export type { ArrayWithNumbers } from './ArrayWithNumbers'; +export type { ArrayWithProperties } from './ArrayWithProperties'; +export type { ArrayWithReferences } from './ArrayWithReferences'; +export type { ArrayWithStrings } from './ArrayWithStrings'; +export type { CompositionWithAllOfAndNullable } from './CompositionWithAllOfAndNullable'; +export type { CompositionWithAnyOf } from './CompositionWithAnyOf'; +export type { CompositionWithAnyOfAndNullable } from './CompositionWithAnyOfAndNullable'; +export type { CompositionWithAnyOfAnonymous } from './CompositionWithAnyOfAnonymous'; +export type { CompositionWithOneOf } from './CompositionWithOneOf'; +export type { CompositionWithOneOfAndNullable } from './CompositionWithOneOfAndNullable'; +export type { CompositionWithOneOfAnonymous } from './CompositionWithOneOfAnonymous'; +export type { DictionaryWithArray } from './DictionaryWithArray'; +export type { DictionaryWithDictionary } from './DictionaryWithDictionary'; +export type { DictionaryWithProperties } from './DictionaryWithProperties'; +export type { DictionaryWithReference } from './DictionaryWithReference'; +export type { DictionaryWithString } from './DictionaryWithString'; +export { EnumFromDescription } from './EnumFromDescription'; +export { EnumWithExtensions } from './EnumWithExtensions'; +export { EnumWithNumbers } from './EnumWithNumbers'; +export { EnumWithStrings } from './EnumWithStrings'; +export type { ModelThatExtends } from './ModelThatExtends'; +export type { ModelThatExtendsExtends } from './ModelThatExtendsExtends'; +export type { ModelWithArray } from './ModelWithArray'; +export type { ModelWithBoolean } from './ModelWithBoolean'; +export type { ModelWithCircularReference } from './ModelWithCircularReference'; +export type { ModelWithDictionary } from './ModelWithDictionary'; +export type { ModelWithDuplicateImports } from './ModelWithDuplicateImports'; +export type { ModelWithDuplicateProperties } from './ModelWithDuplicateProperties'; +export type { ModelWithEnum } from './ModelWithEnum'; +export type { ModelWithEnumFromDescription } from './ModelWithEnumFromDescription'; +export type { ModelWithInteger } from './ModelWithInteger'; +export type { ModelWithNestedEnums } from './ModelWithNestedEnums'; +export type { ModelWithNestedProperties } from './ModelWithNestedProperties'; +export type { ModelWithOrderedProperties } from './ModelWithOrderedProperties'; +export type { ModelWithPattern } from './ModelWithPattern'; +export type { ModelWithProperties } from './ModelWithProperties'; +export type { ModelWithReference } from './ModelWithReference'; +export type { ModelWithString } from './ModelWithString'; +export type { MultilineComment } from './MultilineComment'; +export type { SimpleBoolean } from './SimpleBoolean'; +export type { SimpleFile } from './SimpleFile'; +export type { SimpleInteger } from './SimpleInteger'; +export type { SimpleReference } from './SimpleReference'; +export type { SimpleString } from './SimpleString'; +export type { SimpleStringWithPattern } from './SimpleStringWithPattern'; +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ArrayWithArray.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ArrayWithArray = { + type: 'array', + contains: { + type: 'array', + contains: { + type: 'ModelWithString', + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ArrayWithBooleans.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ArrayWithBooleans = { + type: 'array', + contains: { + type: 'boolean', + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ArrayWithNumbers.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ArrayWithNumbers = { + type: 'array', + contains: { + type: 'number', + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ArrayWithProperties.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ArrayWithProperties = { + type: 'array', + contains: { + properties: { + foo: { + type: 'string', + }, + bar: { + type: 'string', + }, + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ArrayWithReferences.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ArrayWithReferences = { + type: 'array', + contains: { + type: 'ModelWithString', + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ArrayWithStrings.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ArrayWithStrings = { + type: 'array', + contains: { + type: 'string', + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$CompositionWithAllOfAndNullable.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $CompositionWithAllOfAndNullable = { + properties: { + propA: { + type: 'all-of', + contains: [{ + properties: { + boolean: { + type: 'boolean', + }, + }, + }, { + type: 'ModelWithEnum', + }, { + type: 'ModelWithArray', + }, { + type: 'ModelWithDictionary', + }], + isNullable: true, + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$CompositionWithAnyOf.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $CompositionWithAnyOf = { + properties: { + propA: { + type: 'any-of', + contains: [{ + type: 'ModelWithString', + }, { + type: 'ModelWithEnum', + }, { + type: 'ModelWithArray', + }, { + type: 'ModelWithDictionary', + }], + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$CompositionWithAnyOfAndNullable.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $CompositionWithAnyOfAndNullable = { + properties: { + propA: { + type: 'any-of', + contains: [{ + properties: { + boolean: { + type: 'boolean', + }, + }, + }, { + type: 'ModelWithEnum', + }, { + type: 'ModelWithArray', + }, { + type: 'ModelWithDictionary', + }], + isNullable: true, + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$CompositionWithAnyOfAnonymous.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $CompositionWithAnyOfAnonymous = { + properties: { + propA: { + type: 'any-of', + contains: [{ + properties: { + propA: { + properties: { + }, + }, + }, + }, { + type: 'string', + }, { + type: 'number', + }], + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$CompositionWithOneOf.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $CompositionWithOneOf = { + properties: { + propA: { + type: 'one-of', + contains: [{ + type: 'ModelWithString', + }, { + type: 'ModelWithEnum', + }, { + type: 'ModelWithArray', + }, { + type: 'ModelWithDictionary', + }], + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$CompositionWithOneOfAndNullable.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $CompositionWithOneOfAndNullable = { + properties: { + propA: { + type: 'one-of', + contains: [{ + properties: { + boolean: { + type: 'boolean', + }, + }, + }, { + type: 'ModelWithEnum', + }, { + type: 'ModelWithArray', + }, { + type: 'ModelWithDictionary', + }], + isNullable: true, + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$CompositionWithOneOfAnonymous.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $CompositionWithOneOfAnonymous = { + properties: { + propA: { + type: 'one-of', + contains: [{ + properties: { + propA: { + properties: { + }, + }, + }, + }, { + type: 'string', + }, { + type: 'number', + }], + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$DictionaryWithArray.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $DictionaryWithArray = { + type: 'dictionary', + contains: { + type: 'array', + contains: { + type: 'ModelWithString', + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$DictionaryWithDictionary.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $DictionaryWithDictionary = { + type: 'dictionary', + contains: { + type: 'dictionary', + contains: { + type: 'string', + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$DictionaryWithProperties.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $DictionaryWithProperties = { + type: 'dictionary', + contains: { + properties: { + foo: { + type: 'string', + }, + bar: { + type: 'string', + }, + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$DictionaryWithReference.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $DictionaryWithReference = { + type: 'dictionary', + contains: { + type: 'ModelWithString', + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$DictionaryWithString.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $DictionaryWithString = { + type: 'dictionary', + contains: { + type: 'string', + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$EnumFromDescription.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $EnumFromDescription = { + type: 'Enum', +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$EnumWithExtensions.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $EnumWithExtensions = { + type: 'Enum', +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$EnumWithNumbers.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $EnumWithNumbers = { + type: 'Enum', +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$EnumWithStrings.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $EnumWithStrings = { + type: 'Enum', +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelThatExtends.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelThatExtends = { + type: 'all-of', + contains: [{ + type: 'ModelWithString', + }, { + properties: { + propExtendsA: { + type: 'string', + }, + propExtendsB: { + type: 'ModelWithString', + }, + }, + }], +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelThatExtendsExtends.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelThatExtendsExtends = { + type: 'all-of', + contains: [{ + type: 'ModelWithString', + }, { + type: 'ModelThatExtends', + }, { + properties: { + propExtendsC: { + type: 'string', + }, + propExtendsD: { + type: 'ModelWithString', + }, + }, + }], +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithArray.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithArray = { + properties: { + prop: { + type: 'array', + contains: { + type: 'ModelWithString', + }, + }, + propWithFile: { + type: 'array', + contains: { + type: 'File', + }, + }, + propWithNumber: { + type: 'array', + contains: { + type: 'number', + }, + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithBoolean.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithBoolean = { + properties: { + prop: { + type: 'boolean', + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithCircularReference.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithCircularReference = { + properties: { + prop: { + type: 'ModelWithCircularReference', + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithDictionary.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithDictionary = { + properties: { + prop: { + type: 'dictionary', + contains: { + type: 'string', + }, + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithDuplicateImports.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithDuplicateImports = { + properties: { + propA: { + type: 'ModelWithString', + }, + propB: { + type: 'ModelWithString', + }, + propC: { + type: 'ModelWithString', + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithDuplicateProperties.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithDuplicateProperties = { + properties: { + prop: { + type: 'ModelWithString', + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithEnum.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithEnum = { + properties: { + test: { + type: 'Enum', + }, + statusCode: { + type: 'Enum', + }, + bool: { + type: 'boolean', + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithEnumFromDescription.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithEnumFromDescription = { + properties: { + test: { + type: 'Enum', + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithInteger.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithInteger = { + properties: { + prop: { + type: 'number', + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithNestedEnums.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithNestedEnums = { + properties: { + dictionaryWithEnum: { + type: 'dictionary', + contains: { + type: 'Enum', + }, + }, + dictionaryWithEnumFromDescription: { + type: 'dictionary', + contains: { + type: 'Enum', + }, + }, + arrayWithEnum: { + type: 'array', + contains: { + type: 'Enum', + }, + }, + arrayWithDescription: { + type: 'array', + contains: { + type: 'Enum', + }, + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithNestedProperties.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* 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 with exportClient: ./test/generated/v3_client/schemas/$ModelWithOrderedProperties.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithOrderedProperties = { + properties: { + zebra: { + type: 'string', + }, + apple: { + type: 'string', + }, + hawaii: { + type: 'string', + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithPattern.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* 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', + }, + id: { + type: 'string', + pattern: '^\\\\\\\\d{2}-\\\\\\\\d{3}-\\\\\\\\d{4}$', + }, + text: { + type: 'string', + pattern: '^\\\\\\\\w+$', + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithProperties.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithProperties = { + properties: { + required: { + type: 'string', isRequired: true, }, requiredAndReadOnly: { @@ -5303,241 +6947,896 @@ export const $ModelWithProperties = { number: { type: 'number', }, - boolean: { - type: 'boolean', + boolean: { + type: 'boolean', + }, + reference: { + type: 'ModelWithString', + }, + 'property with space': { + type: 'string', + }, + default: { + type: 'string', + }, + try: { + type: 'string', + }, + '@namespace.string': { + type: 'string', + isReadOnly: true, + }, + '@namespace.integer': { + type: 'number', + isReadOnly: true, + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithReference.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithReference = { + properties: { + prop: { + type: 'ModelWithProperties', + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithString.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithString = { + properties: { + prop: { + type: 'string', + }, + }, +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$MultilineComment.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $MultilineComment = { + type: 'number', +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$SimpleBoolean.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $SimpleBoolean = { + type: 'boolean', +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$SimpleFile.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $SimpleFile = { + type: 'File', +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$SimpleInteger.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $SimpleInteger = { + type: 'number', +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$SimpleReference.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $SimpleReference = { + type: 'ModelWithString', +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$SimpleString.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $SimpleString = { + type: 'string', +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$SimpleStringWithPattern.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $SimpleStringWithPattern = { + type: 'string', + isNullable: true, + maxLength: 64, + pattern: '^[a-zA-Z0-9_]*$', +};" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/index.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export { $ArrayWithArray } from './$ArrayWithArray'; +export { $ArrayWithBooleans } from './$ArrayWithBooleans'; +export { $ArrayWithNumbers } from './$ArrayWithNumbers'; +export { $ArrayWithProperties } from './$ArrayWithProperties'; +export { $ArrayWithReferences } from './$ArrayWithReferences'; +export { $ArrayWithStrings } from './$ArrayWithStrings'; +export { $CompositionWithAllOfAndNullable } from './$CompositionWithAllOfAndNullable'; +export { $CompositionWithAnyOf } from './$CompositionWithAnyOf'; +export { $CompositionWithAnyOfAndNullable } from './$CompositionWithAnyOfAndNullable'; +export { $CompositionWithAnyOfAnonymous } from './$CompositionWithAnyOfAnonymous'; +export { $CompositionWithOneOf } from './$CompositionWithOneOf'; +export { $CompositionWithOneOfAndNullable } from './$CompositionWithOneOfAndNullable'; +export { $CompositionWithOneOfAnonymous } from './$CompositionWithOneOfAnonymous'; +export { $DictionaryWithArray } from './$DictionaryWithArray'; +export { $DictionaryWithDictionary } from './$DictionaryWithDictionary'; +export { $DictionaryWithProperties } from './$DictionaryWithProperties'; +export { $DictionaryWithReference } from './$DictionaryWithReference'; +export { $DictionaryWithString } from './$DictionaryWithString'; +export { $EnumFromDescription } from './$EnumFromDescription'; +export { $EnumWithExtensions } from './$EnumWithExtensions'; +export { $EnumWithNumbers } from './$EnumWithNumbers'; +export { $EnumWithStrings } from './$EnumWithStrings'; +export { $ModelThatExtends } from './$ModelThatExtends'; +export { $ModelThatExtendsExtends } from './$ModelThatExtendsExtends'; +export { $ModelWithArray } from './$ModelWithArray'; +export { $ModelWithBoolean } from './$ModelWithBoolean'; +export { $ModelWithCircularReference } from './$ModelWithCircularReference'; +export { $ModelWithDictionary } from './$ModelWithDictionary'; +export { $ModelWithDuplicateImports } from './$ModelWithDuplicateImports'; +export { $ModelWithDuplicateProperties } from './$ModelWithDuplicateProperties'; +export { $ModelWithEnum } from './$ModelWithEnum'; +export { $ModelWithEnumFromDescription } from './$ModelWithEnumFromDescription'; +export { $ModelWithInteger } from './$ModelWithInteger'; +export { $ModelWithNestedEnums } from './$ModelWithNestedEnums'; +export { $ModelWithNestedProperties } from './$ModelWithNestedProperties'; +export { $ModelWithOrderedProperties } from './$ModelWithOrderedProperties'; +export { $ModelWithPattern } from './$ModelWithPattern'; +export { $ModelWithProperties } from './$ModelWithProperties'; +export { $ModelWithReference } from './$ModelWithReference'; +export { $ModelWithString } from './$ModelWithString'; +export { $MultilineComment } from './$MultilineComment'; +export { $SimpleBoolean } from './$SimpleBoolean'; +export { $SimpleFile } from './$SimpleFile'; +export { $SimpleInteger } from './$SimpleInteger'; +export { $SimpleReference } from './$SimpleReference'; +export { $SimpleString } from './$SimpleString'; +export { $SimpleStringWithPattern } from './$SimpleStringWithPattern'; +" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/CollectionFormatService.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { BaseHttpRequest, ClientConfig } from '../core'; +import { CollectionFormatServiceFull } from './CollectionFormatServiceFull'; + +export class CollectionFormatService { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; + readonly full: CollectionFormatServiceFull; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + this.full = new CollectionFormatServiceFull(httpRequest, clientConfig); + } + + /** + * @param parameterArrayCsv This is an array parameter that is send as csv format (comma-separated values) + * @param parameterArraySsv This is an array parameter that is send as ssv format (space-separated values) + * @param parameterArrayTsv This is an array parameter that is send as tsv format (tab-separated values) + * @param parameterArrayPipes This is an array parameter that is send as pipes format (pipe-separated values) + * @param parameterArrayMulti This is an array parameter that is send as multi format (multiple parameter instances) + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async collectionFormat( + parameterArrayCsv: Array | null, + parameterArraySsv: Array | null, + parameterArrayTsv: Array | null, + parameterArrayPipes: Array | null, + parameterArrayMulti: Array | null, + config?: ClientConfig + ): Promise { + return (await this.full.collectionFormat( + parameterArrayCsv, parameterArraySsv, parameterArrayTsv, parameterArrayPipes, parameterArrayMulti, config + )).body; + } + +}" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/CollectionFormatServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; + +export class CollectionFormatServiceFull { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + } + + /** + * @param parameterArrayCsv This is an array parameter that is send as csv format (comma-separated values) + * @param parameterArraySsv This is an array parameter that is send as ssv format (space-separated values) + * @param parameterArrayTsv This is an array parameter that is send as tsv format (tab-separated values) + * @param parameterArrayPipes This is an array parameter that is send as pipes format (pipe-separated values) + * @param parameterArrayMulti This is an array parameter that is send as multi format (multiple parameter instances) + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async collectionFormat( + parameterArrayCsv: Array | null, + parameterArraySsv: Array | null, + parameterArrayTsv: Array | null, + parameterArrayPipes: Array | null, + parameterArrayMulti: Array | null, + config?: ClientConfig + ): Promise> { + return this.httpRequest.request({ + method: 'GET', + path: \`/api/v\${this.clientConfig.version}/collectionFormat\`, + query: { + 'parameterArrayCSV': parameterArrayCsv, + 'parameterArraySSV': parameterArraySsv, + 'parameterArrayTSV': parameterArrayTsv, + 'parameterArrayPipes': parameterArrayPipes, + 'parameterArrayMulti': parameterArrayMulti, + }, + }, this.clientConfig, config); + } + +}" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/ComplexService.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { + ModelWithArray, + ModelWithDictionary, + ModelWithEnum, + ModelWithString, +} from '../models'; +import type { BaseHttpRequest, ClientConfig } from '../core'; +import { ComplexServiceFull } from './ComplexServiceFull'; + +export class ComplexService { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; + readonly full: ComplexServiceFull; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + this.full = new ComplexServiceFull(httpRequest, clientConfig); + } + + /** + * @param parameterObject Parameter containing object + * @param parameterReference Parameter containing reference + * @param [config] the optional OpenAPI config to use + * @returns ModelWithString Successful response + * @throws ApiError + */ + public async complexTypes( + parameterObject: { + first?: { + second?: { + third?: string, + }, + }, + }, + parameterReference: ModelWithString, + config?: ClientConfig + ): Promise> { + return (await this.full.complexTypes( + parameterObject, parameterReference, config + )).body; + } + + /** + * @param id + * @param requestBody + * @param [config] the optional OpenAPI config to use + * @returns ModelWithString Success + * @throws ApiError + */ + public 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: (ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary), + readonly user?: { + readonly id?: number, + readonly name?: string | null, + }, }, - reference: { - type: 'ModelWithString', + config?: ClientConfig + ): Promise { + return (await this.full.complexParams( + id, requestBody, config + )).body; + } + +}" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/ComplexServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { + ModelWithArray, + ModelWithDictionary, + ModelWithEnum, + ModelWithString, +} from '../models'; +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; + +export class ComplexServiceFull { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + } + + /** + * @param parameterObject Parameter containing object + * @param parameterReference Parameter containing reference + * @param [config] the optional OpenAPI config to use + * @returns ModelWithString Successful response + * @throws ApiError + */ + public async complexTypes( + parameterObject: { + first?: { + second?: { + third?: string, + }, + }, }, - 'property with space': { - type: 'string', + parameterReference: ModelWithString, + config?: ClientConfig + ): Promise>> { + return this.httpRequest.request({ + method: 'GET', + path: \`/api/v\${this.clientConfig.version}/complex\`, + query: { + 'parameterObject': parameterObject, + 'parameterReference': parameterReference, + }, + errors: { + 400: \`400 server error\`, + 500: \`500 server error\`, + }, + }, this.clientConfig, config); + } + + /** + * @param id + * @param requestBody + * @param [config] the optional OpenAPI config to use + * @returns ModelWithString Success + * @throws ApiError + */ + public 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: (ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary), + readonly user?: { + readonly id?: number, + readonly name?: string | null, + }, }, - default: { - type: 'string', + config?: ClientConfig + ): Promise> { + return this.httpRequest.request({ + method: 'PUT', + path: \`/api/v\${this.clientConfig.version}/complex/\${id}\`, + body: requestBody, + mediaType: 'application/json-patch+json', + }, this.clientConfig, config); + } + +}" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/DefaultsService.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { + ModelWithString, +} from '../models'; +import type { BaseHttpRequest, ClientConfig } from '../core'; +import { DefaultsServiceFull } from './DefaultsServiceFull'; + +export class DefaultsService { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; + readonly full: DefaultsServiceFull; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + this.full = new DefaultsServiceFull(httpRequest, clientConfig); + } + + /** + * @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 + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public 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!\\" }, - try: { - type: 'string', + config?: ClientConfig + ): Promise { + return (await this.full.callWithDefaultParameters( + parameterString, parameterNumber, parameterBoolean, parameterEnum, parameterModel, config + )).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 + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async callWithDefaultOptionalParameters( + parameterString: string = 'Hello World!', + parameterNumber: number = 123, + parameterBoolean: boolean = true, + parameterEnum: 'Success' | 'Warning' | 'Error' = 'Success', + parameterModel: ModelWithString = { + \\"prop\\": \\"Hello World!\\" }, - '@namespace.string': { - type: 'string', - isReadOnly: true, + config?: ClientConfig + ): Promise { + return (await this.full.callWithDefaultOptionalParameters( + parameterString, parameterNumber, parameterBoolean, parameterEnum, parameterModel, config + )).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 + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async callToTestOrderOfParams( + parameterStringWithNoDefault: string, + parameterOptionalStringWithDefault: string = 'Hello World!', + parameterOptionalStringWithEmptyDefault: string = '', + parameterOptionalStringWithNoDefault?: string, + parameterStringWithDefault: string = 'Hello World!', + parameterStringWithEmptyDefault: string = '', + config?: ClientConfig + ): Promise { + return (await this.full.callToTestOrderOfParams( + parameterStringWithNoDefault, parameterOptionalStringWithDefault, parameterOptionalStringWithEmptyDefault, parameterOptionalStringWithNoDefault, parameterStringWithDefault, parameterStringWithEmptyDefault, config + )).body; + } + +}" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/DefaultsServiceFull.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { + ModelWithString, +} from '../models'; +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; + +export class DefaultsServiceFull { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + } + + /** + * @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 + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public 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!\\" }, - '@namespace.integer': { - type: 'number', - isReadOnly: true, + config?: ClientConfig + ): Promise> { + return this.httpRequest.request({ + method: 'GET', + path: \`/api/v\${this.clientConfig.version}/defaults\`, + query: { + 'parameterString': parameterString, + 'parameterNumber': parameterNumber, + 'parameterBoolean': parameterBoolean, + 'parameterEnum': parameterEnum, + 'parameterModel': parameterModel, + }, + }, this.clientConfig, config); + } + + /** + * @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 + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async callWithDefaultOptionalParameters( + parameterString: string = 'Hello World!', + parameterNumber: number = 123, + parameterBoolean: boolean = true, + parameterEnum: 'Success' | 'Warning' | 'Error' = 'Success', + parameterModel: ModelWithString = { + \\"prop\\": \\"Hello World!\\" }, - }, -};" -`; + config?: ClientConfig + ): Promise> { + return this.httpRequest.request({ + method: 'POST', + path: \`/api/v\${this.clientConfig.version}/defaults\`, + query: { + 'parameterString': parameterString, + 'parameterNumber': parameterNumber, + 'parameterBoolean': parameterBoolean, + 'parameterEnum': parameterEnum, + 'parameterModel': parameterModel, + }, + }, this.clientConfig, config); + } + + /** + * @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 + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async callToTestOrderOfParams( + parameterStringWithNoDefault: string, + parameterOptionalStringWithDefault: string = 'Hello World!', + parameterOptionalStringWithEmptyDefault: string = '', + parameterOptionalStringWithNoDefault?: string, + parameterStringWithDefault: string = 'Hello World!', + parameterStringWithEmptyDefault: string = '', + config?: ClientConfig + ): Promise> { + return this.httpRequest.request({ + method: 'PUT', + path: \`/api/v\${this.clientConfig.version}/defaults\`, + query: { + 'parameterStringWithNoDefault': parameterStringWithNoDefault, + 'parameterOptionalStringWithDefault': parameterOptionalStringWithDefault, + 'parameterOptionalStringWithEmptyDefault': parameterOptionalStringWithEmptyDefault, + 'parameterOptionalStringWithNoDefault': parameterOptionalStringWithNoDefault, + 'parameterStringWithDefault': parameterStringWithDefault, + 'parameterStringWithEmptyDefault': parameterStringWithEmptyDefault, + }, + }, this.clientConfig, config); + } -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithReference.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -export const $ModelWithReference = { - properties: { - prop: { - type: 'ModelWithProperties', - }, - }, -};" +}" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$ModelWithString.ts 1`] = ` +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/DuplicateService.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $ModelWithString = { - properties: { - prop: { - type: 'string', - }, - }, -};" -`; +import type { BaseHttpRequest, ClientConfig } from '../core'; +import { DuplicateServiceFull } from './DuplicateServiceFull'; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$MultilineComment.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -export const $MultilineComment = { - type: 'number', -};" -`; +export class DuplicateService { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; + readonly full: DuplicateServiceFull; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$SimpleBoolean.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -export const $SimpleBoolean = { - type: 'boolean', -};" -`; + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + this.full = new DuplicateServiceFull(httpRequest, clientConfig); + } -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$SimpleFile.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -export const $SimpleFile = { - type: 'File', -};" -`; + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async duplicateName(config?: ClientConfig): Promise { + return (await this.full.duplicateName(config)).body; + } -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$SimpleInteger.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -export const $SimpleInteger = { - type: 'number', -};" -`; + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async duplicateName1(config?: ClientConfig): Promise { + return (await this.full.duplicateName1(config)).body; + } -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$SimpleReference.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -export const $SimpleReference = { - type: 'ModelWithString', -};" + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async duplicateName2(config?: ClientConfig): Promise { + return (await this.full.duplicateName2(config)).body; + } + + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async duplicateName3(config?: ClientConfig): Promise { + return (await this.full.duplicateName3(config)).body; + } + +}" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$SimpleString.ts 1`] = ` +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/DuplicateServiceFull.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $SimpleString = { - type: 'string', -};" +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; + +export class DuplicateServiceFull { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + } + + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async duplicateName(config?: ClientConfig): Promise> { + return this.httpRequest.request({ + method: 'GET', + path: \`/api/v\${this.clientConfig.version}/duplicate\`, + }, this.clientConfig, config); + } + + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async duplicateName1(config?: ClientConfig): Promise> { + return this.httpRequest.request({ + method: 'POST', + path: \`/api/v\${this.clientConfig.version}/duplicate\`, + }, this.clientConfig, config); + } + + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async duplicateName2(config?: ClientConfig): Promise> { + return this.httpRequest.request({ + method: 'PUT', + path: \`/api/v\${this.clientConfig.version}/duplicate\`, + }, this.clientConfig, config); + } + + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async duplicateName3(config?: ClientConfig): Promise> { + return this.httpRequest.request({ + method: 'DELETE', + path: \`/api/v\${this.clientConfig.version}/duplicate\`, + }, this.clientConfig, config); + } + +}" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/$SimpleStringWithPattern.ts 1`] = ` +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/HeaderService.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export const $SimpleStringWithPattern = { - type: 'string', - isNullable: true, - maxLength: 64, - pattern: '^[a-zA-Z0-9_]*$', -};" +import type { BaseHttpRequest, ClientConfig } from '../core'; +import { HeaderServiceFull } from './HeaderServiceFull'; + +export class HeaderService { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; + readonly full: HeaderServiceFull; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + this.full = new HeaderServiceFull(httpRequest, clientConfig); + } + + /** + * @param [config] the optional OpenAPI config to use + * @returns string Successful response + * @throws ApiError + */ + public async callWithResultFromHeader(config?: ClientConfig): Promise { + return (await this.full.callWithResultFromHeader(config)).body; + } + +}" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/schemas/index.ts 1`] = ` +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/HeaderServiceFull.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ -/* eslint-disable */ -export { $ArrayWithArray } from './$ArrayWithArray'; -export { $ArrayWithBooleans } from './$ArrayWithBooleans'; -export { $ArrayWithNumbers } from './$ArrayWithNumbers'; -export { $ArrayWithProperties } from './$ArrayWithProperties'; -export { $ArrayWithReferences } from './$ArrayWithReferences'; -export { $ArrayWithStrings } from './$ArrayWithStrings'; -export { $CompositionWithAllOfAndNullable } from './$CompositionWithAllOfAndNullable'; -export { $CompositionWithAnyOf } from './$CompositionWithAnyOf'; -export { $CompositionWithAnyOfAndNullable } from './$CompositionWithAnyOfAndNullable'; -export { $CompositionWithAnyOfAnonymous } from './$CompositionWithAnyOfAnonymous'; -export { $CompositionWithOneOf } from './$CompositionWithOneOf'; -export { $CompositionWithOneOfAndNullable } from './$CompositionWithOneOfAndNullable'; -export { $CompositionWithOneOfAnonymous } from './$CompositionWithOneOfAnonymous'; -export { $DictionaryWithArray } from './$DictionaryWithArray'; -export { $DictionaryWithDictionary } from './$DictionaryWithDictionary'; -export { $DictionaryWithProperties } from './$DictionaryWithProperties'; -export { $DictionaryWithReference } from './$DictionaryWithReference'; -export { $DictionaryWithString } from './$DictionaryWithString'; -export { $EnumFromDescription } from './$EnumFromDescription'; -export { $EnumWithExtensions } from './$EnumWithExtensions'; -export { $EnumWithNumbers } from './$EnumWithNumbers'; -export { $EnumWithStrings } from './$EnumWithStrings'; -export { $ModelThatExtends } from './$ModelThatExtends'; -export { $ModelThatExtendsExtends } from './$ModelThatExtendsExtends'; -export { $ModelWithArray } from './$ModelWithArray'; -export { $ModelWithBoolean } from './$ModelWithBoolean'; -export { $ModelWithCircularReference } from './$ModelWithCircularReference'; -export { $ModelWithDictionary } from './$ModelWithDictionary'; -export { $ModelWithDuplicateImports } from './$ModelWithDuplicateImports'; -export { $ModelWithDuplicateProperties } from './$ModelWithDuplicateProperties'; -export { $ModelWithEnum } from './$ModelWithEnum'; -export { $ModelWithEnumFromDescription } from './$ModelWithEnumFromDescription'; -export { $ModelWithInteger } from './$ModelWithInteger'; -export { $ModelWithNestedEnums } from './$ModelWithNestedEnums'; -export { $ModelWithNestedProperties } from './$ModelWithNestedProperties'; -export { $ModelWithOrderedProperties } from './$ModelWithOrderedProperties'; -export { $ModelWithPattern } from './$ModelWithPattern'; -export { $ModelWithProperties } from './$ModelWithProperties'; -export { $ModelWithReference } from './$ModelWithReference'; -export { $ModelWithString } from './$ModelWithString'; -export { $MultilineComment } from './$MultilineComment'; -export { $SimpleBoolean } from './$SimpleBoolean'; -export { $SimpleFile } from './$SimpleFile'; -export { $SimpleInteger } from './$SimpleInteger'; -export { $SimpleReference } from './$SimpleReference'; -export { $SimpleString } from './$SimpleString'; -export { $SimpleStringWithPattern } from './$SimpleStringWithPattern'; -" +/* eslint-disable */ +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; + +export class HeaderServiceFull { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + } + + /** + * @param [config] the optional OpenAPI config to use + * @returns string Successful response + * @throws ApiError + */ + public async callWithResultFromHeader(config?: ClientConfig): Promise> { + return this.httpRequest.request({ + method: 'POST', + path: \`/api/v\${this.clientConfig.version}/header\`, + responseHeader: 'operation-location', + errors: { + 400: \`400 server error\`, + 500: \`500 server error\`, + }, + }, this.clientConfig, config); + } + +}" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/CollectionFormatService.ts 1`] = ` +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/MultipartService.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ import type { BaseHttpRequest, ClientConfig } from '../core'; -import { CollectionFormatServiceFull } from './CollectionFormatServiceFull'; +import { MultipartServiceFull } from './MultipartServiceFull'; -export class CollectionFormatService { +export class MultipartService { private readonly httpRequest: BaseHttpRequest; private readonly clientConfig: ClientConfig; - readonly full: CollectionFormatServiceFull; + readonly full: MultipartServiceFull; constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { this.httpRequest = httpRequest; this.clientConfig = clientConfig; - this.full = new CollectionFormatServiceFull(httpRequest, clientConfig); + this.full = new MultipartServiceFull(httpRequest, clientConfig); } /** - * @param parameterArrayCsv This is an array parameter that is send as csv format (comma-separated values) - * @param parameterArraySsv This is an array parameter that is send as ssv format (space-separated values) - * @param parameterArrayTsv This is an array parameter that is send as tsv format (tab-separated values) - * @param parameterArrayPipes This is an array parameter that is send as pipes format (pipe-separated values) - * @param parameterArrayMulti This is an array parameter that is send as multi format (multiple parameter instances) * @param [config] the optional OpenAPI config to use + * @returns any OK * @throws ApiError */ - public async collectionFormat( - parameterArrayCsv: Array | null, - parameterArraySsv: Array | null, - parameterArrayTsv: Array | null, - parameterArrayPipes: Array | null, - parameterArrayMulti: Array | null, - config?: ClientConfig - ): Promise { - return (await this.full.collectionFormat( - parameterArrayCsv, parameterArraySsv, parameterArrayTsv, parameterArrayPipes, parameterArrayMulti, config - )).body; + public async multipartResponse(config?: ClientConfig): Promise<{ + file?: string, + metadata?: { + foo?: string, + bar?: string, + }, + }> { + return (await this.full.multipartResponse(config)).body; } }" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/CollectionFormatServiceFull.ts 1`] = ` +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/MultipartServiceFull.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; -export class CollectionFormatServiceFull { +export class MultipartServiceFull { private readonly httpRequest: BaseHttpRequest; private readonly clientConfig: ClientConfig; @@ -5547,132 +7846,65 @@ export class CollectionFormatServiceFull { } /** - * @param parameterArrayCsv This is an array parameter that is send as csv format (comma-separated values) - * @param parameterArraySsv This is an array parameter that is send as ssv format (space-separated values) - * @param parameterArrayTsv This is an array parameter that is send as tsv format (tab-separated values) - * @param parameterArrayPipes This is an array parameter that is send as pipes format (pipe-separated values) - * @param parameterArrayMulti This is an array parameter that is send as multi format (multiple parameter instances) * @param [config] the optional OpenAPI config to use + * @returns any OK * @throws ApiError */ - public async collectionFormat( - parameterArrayCsv: Array | null, - parameterArraySsv: Array | null, - parameterArrayTsv: Array | null, - parameterArrayPipes: Array | null, - parameterArrayMulti: Array | null, - config?: ClientConfig - ): Promise> { + public async multipartResponse(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.clientConfig.version}/collectionFormat\`, - query: { - 'parameterArrayCSV': parameterArrayCsv, - 'parameterArraySSV': parameterArraySsv, - 'parameterArrayTSV': parameterArrayTsv, - 'parameterArrayPipes': parameterArrayPipes, - 'parameterArrayMulti': parameterArrayMulti, - }, + path: \`/api/v\${this.clientConfig.version}/multipart\`, }, this.clientConfig, config); } }" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/ComplexService.ts 1`] = ` +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/NoContentService.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { - ModelWithArray, - ModelWithDictionary, - ModelWithEnum, - ModelWithString, -} from '../models'; import type { BaseHttpRequest, ClientConfig } from '../core'; -import { ComplexServiceFull } from './ComplexServiceFull'; +import { NoContentServiceFull } from './NoContentServiceFull'; -export class ComplexService { +export class NoContentService { private readonly httpRequest: BaseHttpRequest; private readonly clientConfig: ClientConfig; - readonly full: ComplexServiceFull; + readonly full: NoContentServiceFull; constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { this.httpRequest = httpRequest; this.clientConfig = clientConfig; - this.full = new ComplexServiceFull(httpRequest, clientConfig); - } - - /** - * @param parameterObject Parameter containing object - * @param parameterReference Parameter containing reference - * @param [config] the optional OpenAPI config to use - * @returns ModelWithString Successful response - * @throws ApiError - */ - public async complexTypes( - parameterObject: { - first?: { - second?: { - third?: string, - }, - }, - }, - parameterReference: ModelWithString, - config?: ClientConfig - ): Promise> { - return (await this.full.complexTypes( - parameterObject, parameterReference, config - )).body; + this.full = new NoContentServiceFull(httpRequest, clientConfig); } /** - * @param id - * @param requestBody * @param [config] the optional OpenAPI config to use - * @returns ModelWithString Success + * @returns void * @throws ApiError */ - public 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: (ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary), - readonly user?: { - readonly id?: number, - readonly name?: string | null, - }, - }, - config?: ClientConfig - ): Promise { - return (await this.full.complexParams( - id, requestBody, config - )).body; + public async callWithNoContentResponse(config?: ClientConfig): Promise { + return (await this.full.callWithNoContentResponse(config)).body; } }" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/ComplexServiceFull.ts 1`] = ` +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/NoContentServiceFull.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { - ModelWithArray, - ModelWithDictionary, - ModelWithEnum, - ModelWithString, -} from '../models'; import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; -export class ComplexServiceFull { +export class NoContentServiceFull { private readonly httpRequest: BaseHttpRequest; private readonly clientConfig: ClientConfig; @@ -5682,73 +7914,21 @@ export class ComplexServiceFull { } /** - * @param parameterObject Parameter containing object - * @param parameterReference Parameter containing reference * @param [config] the optional OpenAPI config to use - * @returns ModelWithString Successful response + * @returns void * @throws ApiError */ - public async complexTypes( - parameterObject: { - first?: { - second?: { - third?: string, - }, - }, - }, - parameterReference: ModelWithString, - config?: ClientConfig - ): Promise>> { + public async callWithNoContentResponse(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.clientConfig.version}/complex\`, - query: { - 'parameterObject': parameterObject, - 'parameterReference': parameterReference, - }, - errors: { - 400: \`400 server error\`, - 500: \`500 server error\`, - }, - }, this.clientConfig, config); - } - - /** - * @param id - * @param requestBody - * @param [config] the optional OpenAPI config to use - * @returns ModelWithString Success - * @throws ApiError - */ - public 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: (ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary), - readonly user?: { - readonly id?: number, - readonly name?: string | null, - }, - }, - config?: ClientConfig - ): Promise> { - return this.httpRequest.request({ - method: 'PUT', - path: \`/api/v\${this.clientConfig.version}/complex/\${id}\`, - body: requestBody, - mediaType: 'application/json-patch+json', + path: \`/api/v\${this.clientConfig.version}/no-content\`, }, this.clientConfig, config); } }" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/DefaultsService.ts 1`] = ` +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/ParametersService.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ @@ -5757,95 +7937,109 @@ import type { ModelWithString, } from '../models'; import type { BaseHttpRequest, ClientConfig } from '../core'; -import { DefaultsServiceFull } from './DefaultsServiceFull'; +import { ParametersServiceFull } from './ParametersServiceFull'; -export class DefaultsService { +export class ParametersService { private readonly httpRequest: BaseHttpRequest; private readonly clientConfig: ClientConfig; - readonly full: DefaultsServiceFull; + readonly full: ParametersServiceFull; constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { this.httpRequest = httpRequest; this.clientConfig = clientConfig; - this.full = new DefaultsServiceFull(httpRequest, clientConfig); + this.full = new ParametersServiceFull(httpRequest, clientConfig); + } + + /** + * @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 + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async callWithParameters( + parameterHeader: string | null, + parameterQuery: string | null, + parameterForm: string | null, + parameterCookie: string | null, + parameterPath: string | null, + requestBody: ModelWithString | null, + config?: ClientConfig + ): Promise { + return (await this.full.callWithParameters( + parameterHeader, parameterQuery, parameterForm, parameterCookie, parameterPath, requestBody, config + )).body; } /** - * @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 + * @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 + * @param _default This is the parameter with a reserved keyword * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public 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!\\" - }, + public async callWithWeirdParameterNames( + parameterHeader: string | null, + parameterQuery: string | null, + parameterForm: string | null, + parameterCookie: string | null, + requestBody: ModelWithString | null, + parameterPath1?: string, + parameterPath2?: string, + parameterPath3?: string, + _default?: string, config?: ClientConfig ): Promise { - return (await this.full.callWithDefaultParameters( - parameterString, parameterNumber, parameterBoolean, parameterEnum, parameterModel, config + return (await this.full.callWithWeirdParameterNames( + parameterHeader, parameterQuery, parameterForm, parameterCookie, requestBody, parameterPath1, parameterPath2, parameterPath3, _default, config )).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 + * @param requestBody This is a required parameter + * @param parameter This is an optional parameter * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async callWithDefaultOptionalParameters( - parameterString: string = 'Hello World!', - parameterNumber: number = 123, - parameterBoolean: boolean = true, - parameterEnum: 'Success' | 'Warning' | 'Error' = 'Success', - parameterModel: ModelWithString = { - \\"prop\\": \\"Hello World!\\" - }, + public async getCallWithOptionalParam( + requestBody: ModelWithString, + parameter?: string, config?: ClientConfig ): Promise { - return (await this.full.callWithDefaultOptionalParameters( - parameterString, parameterNumber, parameterBoolean, parameterEnum, parameterModel, config + return (await this.full.getCallWithOptionalParam( + requestBody, parameter, config )).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 + * @param parameter This is a required parameter + * @param requestBody This is an optional parameter * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async callToTestOrderOfParams( - parameterStringWithNoDefault: string, - parameterOptionalStringWithDefault: string = 'Hello World!', - parameterOptionalStringWithEmptyDefault: string = '', - parameterOptionalStringWithNoDefault?: string, - parameterStringWithDefault: string = 'Hello World!', - parameterStringWithEmptyDefault: string = '', + public async postCallWithOptionalParam( + parameter: string, + requestBody?: ModelWithString, config?: ClientConfig ): Promise { - return (await this.full.callToTestOrderOfParams( - parameterStringWithNoDefault, parameterOptionalStringWithDefault, parameterOptionalStringWithEmptyDefault, parameterOptionalStringWithNoDefault, parameterStringWithDefault, parameterStringWithEmptyDefault, config + return (await this.full.postCallWithOptionalParam( + parameter, requestBody, config )).body; } }" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/DefaultsServiceFull.ts 1`] = ` +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/ParametersServiceFull.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ @@ -5855,7 +8049,7 @@ import type { } from '../models'; import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; -export class DefaultsServiceFull { +export class ParametersServiceFull { private readonly httpRequest: BaseHttpRequest; private readonly clientConfig: ClientConfig; @@ -5865,167 +8059,289 @@ export class DefaultsServiceFull { } /** - * @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 + * @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 * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public 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!\\" - }, + public async callWithParameters( + parameterHeader: string | null, + parameterQuery: string | null, + parameterForm: string | null, + parameterCookie: string | null, + parameterPath: string | null, + requestBody: ModelWithString | null, config?: ClientConfig ): Promise> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.clientConfig.version}/defaults\`, + path: \`/api/v\${this.clientConfig.version}/parameters/\${parameterPath}\`, + cookies: { + 'parameterCookie': parameterCookie, + }, + headers: { + 'parameterHeader': parameterHeader, + }, query: { - 'parameterString': parameterString, - 'parameterNumber': parameterNumber, - 'parameterBoolean': parameterBoolean, - 'parameterEnum': parameterEnum, - 'parameterModel': parameterModel, + 'parameterQuery': parameterQuery, + }, + formData: { + 'parameterForm': parameterForm, }, + body: requestBody, + mediaType: 'application/json', }, this.clientConfig, config); } /** - * @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 + * @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 + * @param _default This is the parameter with a reserved keyword * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async callWithDefaultOptionalParameters( - parameterString: string = 'Hello World!', - parameterNumber: number = 123, - parameterBoolean: boolean = true, - parameterEnum: 'Success' | 'Warning' | 'Error' = 'Success', - parameterModel: ModelWithString = { - \\"prop\\": \\"Hello World!\\" - }, + public async callWithWeirdParameterNames( + parameterHeader: string | null, + parameterQuery: string | null, + parameterForm: string | null, + parameterCookie: string | null, + requestBody: ModelWithString | null, + parameterPath1?: string, + parameterPath2?: string, + parameterPath3?: string, + _default?: string, + config?: ClientConfig + ): Promise> { + return this.httpRequest.request({ + method: 'GET', + path: \`/api/v\${this.clientConfig.version}/parameters/\${parameterPath1}/\${parameterPath2}/\${parameterPath3}\`, + cookies: { + 'PARAMETER-COOKIE': parameterCookie, + }, + headers: { + 'parameter.header': parameterHeader, + }, + query: { + 'parameter-query': parameterQuery, + 'default': _default, + }, + formData: { + 'parameter_form': parameterForm, + }, + body: requestBody, + mediaType: 'application/json', + }, this.clientConfig, config); + } + + /** + * @param requestBody This is a required parameter + * @param parameter This is an optional parameter + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async getCallWithOptionalParam( + requestBody: ModelWithString, + parameter?: string, + config?: ClientConfig + ): Promise> { + return this.httpRequest.request({ + method: 'GET', + path: \`/api/v\${this.clientConfig.version}/parameters/\`, + query: { + 'parameter': parameter, + }, + body: requestBody, + mediaType: 'application/json', + }, this.clientConfig, config); + } + + /** + * @param parameter This is a required parameter + * @param requestBody This is an optional parameter + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async postCallWithOptionalParam( + parameter: string, + requestBody?: ModelWithString, config?: ClientConfig ): Promise> { return this.httpRequest.request({ method: 'POST', - path: \`/api/v\${this.clientConfig.version}/defaults\`, + path: \`/api/v\${this.clientConfig.version}/parameters/\`, query: { - 'parameterString': parameterString, - 'parameterNumber': parameterNumber, - 'parameterBoolean': parameterBoolean, - 'parameterEnum': parameterEnum, - 'parameterModel': parameterModel, + 'parameter': parameter, }, + body: requestBody, + mediaType: 'application/json', }, this.clientConfig, config); } +}" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/RequestBodyService.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { + ModelWithString, +} from '../models'; +import type { BaseHttpRequest, ClientConfig } from '../core'; +import { RequestBodyServiceFull } from './RequestBodyServiceFull'; + +export class RequestBodyService { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; + readonly full: RequestBodyServiceFull; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + this.full = new RequestBodyServiceFull(httpRequest, clientConfig); + } + /** - * @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 + * @param requestBody A reusable request body * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async callToTestOrderOfParams( - parameterStringWithNoDefault: string, - parameterOptionalStringWithDefault: string = 'Hello World!', - parameterOptionalStringWithEmptyDefault: string = '', - parameterOptionalStringWithNoDefault?: string, - parameterStringWithDefault: string = 'Hello World!', - parameterStringWithEmptyDefault: string = '', + public async postRequestBodyService( + requestBody?: ModelWithString, config?: ClientConfig - ): Promise> { - return this.httpRequest.request({ - method: 'PUT', - path: \`/api/v\${this.clientConfig.version}/defaults\`, - query: { - 'parameterStringWithNoDefault': parameterStringWithNoDefault, - 'parameterOptionalStringWithDefault': parameterOptionalStringWithDefault, - 'parameterOptionalStringWithEmptyDefault': parameterOptionalStringWithEmptyDefault, - 'parameterOptionalStringWithNoDefault': parameterOptionalStringWithNoDefault, - 'parameterStringWithDefault': parameterStringWithDefault, - 'parameterStringWithEmptyDefault': parameterStringWithEmptyDefault, - }, - }, this.clientConfig, config); + ): Promise { + return (await this.full.postRequestBodyService( + requestBody, config + )).body; } }" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/DuplicateService.ts 1`] = ` +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/RequestBodyServiceFull.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { BaseHttpRequest, ClientConfig } from '../core'; -import { DuplicateServiceFull } from './DuplicateServiceFull'; +import type { + ModelWithString, +} from '../models'; +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; -export class DuplicateService { +export class RequestBodyServiceFull { private readonly httpRequest: BaseHttpRequest; private readonly clientConfig: ClientConfig; - readonly full: DuplicateServiceFull; constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { this.httpRequest = httpRequest; this.clientConfig = clientConfig; - this.full = new DuplicateServiceFull(httpRequest, clientConfig); } /** + * @param requestBody A reusable request body * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async duplicateName(config?: ClientConfig): Promise { - return (await this.full.duplicateName(config)).body; + public async postRequestBodyService( + requestBody?: ModelWithString, + config?: ClientConfig + ): Promise> { + return this.httpRequest.request({ + method: 'POST', + path: \`/api/v\${this.clientConfig.version}/requestBody/\`, + body: requestBody, + mediaType: 'application/json', + }, this.clientConfig, config); + } + +}" +`; + +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/ResponseService.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { + ModelThatExtends, + ModelThatExtendsExtends, + ModelWithString, +} from '../models'; +import type { BaseHttpRequest, ClientConfig } from '../core'; +import { ResponseServiceFull } from './ResponseServiceFull'; + +export class ResponseService { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; + readonly full: ResponseServiceFull; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + this.full = new ResponseServiceFull(httpRequest, clientConfig); } /** * @param [config] the optional OpenAPI config to use + * @returns ModelWithString * @throws ApiError */ - public async duplicateName1(config?: ClientConfig): Promise { - return (await this.full.duplicateName1(config)).body; + public async callWithResponse(config?: ClientConfig): Promise { + return (await this.full.callWithResponse(config)).body; } /** * @param [config] the optional OpenAPI config to use + * @returns ModelWithString Message for default response * @throws ApiError */ - public async duplicateName2(config?: ClientConfig): Promise { - return (await this.full.duplicateName2(config)).body; + public async callWithDuplicateResponses(config?: ClientConfig): Promise { + return (await this.full.callWithDuplicateResponses(config)).body; } /** * @param [config] the optional OpenAPI config to use + * @returns any Message for 200 response + * @returns ModelWithString Message for default response + * @returns ModelThatExtends Message for 201 response + * @returns ModelThatExtendsExtends Message for 202 response * @throws ApiError */ - public async duplicateName3(config?: ClientConfig): Promise { - return (await this.full.duplicateName3(config)).body; + public async callWithResponses(config?: ClientConfig): Promise<{ + readonly '@namespace.string'?: string, + readonly '@namespace.integer'?: number, + readonly value?: Array, + } | ModelWithString | ModelThatExtends | ModelThatExtendsExtends> { + return (await this.full.callWithResponses(config)).body; } }" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/DuplicateServiceFull.ts 1`] = ` +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/ResponseServiceFull.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { + ModelThatExtends, + ModelThatExtendsExtends, + ModelWithString, +} from '../models'; import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; -export class DuplicateServiceFull { +export class ResponseServiceFull { private readonly httpRequest: BaseHttpRequest; private readonly clientConfig: ClientConfig; @@ -6036,163 +8352,146 @@ export class DuplicateServiceFull { /** * @param [config] the optional OpenAPI config to use + * @returns ModelWithString * @throws ApiError */ - public async duplicateName(config?: ClientConfig): Promise> { + public async callWithResponse(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.clientConfig.version}/duplicate\`, + path: \`/api/v\${this.clientConfig.version}/response\`, }, this.clientConfig, config); } /** * @param [config] the optional OpenAPI config to use + * @returns ModelWithString Message for default response * @throws ApiError */ - public async duplicateName1(config?: ClientConfig): Promise> { + public async callWithDuplicateResponses(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'POST', - path: \`/api/v\${this.clientConfig.version}/duplicate\`, + path: \`/api/v\${this.clientConfig.version}/response\`, + errors: { + 500: \`Message for 500 error\`, + 501: \`Message for 501 error\`, + 502: \`Message for 502 error\`, + }, }, this.clientConfig, config); } /** * @param [config] the optional OpenAPI config to use + * @returns any Message for 200 response + * @returns ModelWithString Message for default response + * @returns ModelThatExtends Message for 201 response + * @returns ModelThatExtendsExtends Message for 202 response * @throws ApiError */ - public async duplicateName2(config?: ClientConfig): Promise> { + public async callWithResponses(config?: ClientConfig): Promise, + } | ModelWithString | ModelThatExtends | ModelThatExtendsExtends>> { return this.httpRequest.request({ method: 'PUT', - path: \`/api/v\${this.clientConfig.version}/duplicate\`, - }, this.clientConfig, config); - } - - /** - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ - public async duplicateName3(config?: ClientConfig): Promise> { - return this.httpRequest.request({ - method: 'DELETE', - path: \`/api/v\${this.clientConfig.version}/duplicate\`, + path: \`/api/v\${this.clientConfig.version}/response\`, + errors: { + 500: \`Message for 500 error\`, + 501: \`Message for 501 error\`, + 502: \`Message for 502 error\`, + }, }, this.clientConfig, config); } }" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/HeaderService.ts 1`] = ` +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/SimpleService.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ import type { BaseHttpRequest, ClientConfig } from '../core'; -import { HeaderServiceFull } from './HeaderServiceFull'; +import { SimpleServiceFull } from './SimpleServiceFull'; -export class HeaderService { +export class SimpleService { private readonly httpRequest: BaseHttpRequest; private readonly clientConfig: ClientConfig; - readonly full: HeaderServiceFull; + readonly full: SimpleServiceFull; constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { this.httpRequest = httpRequest; this.clientConfig = clientConfig; - this.full = new HeaderServiceFull(httpRequest, clientConfig); + this.full = new SimpleServiceFull(httpRequest, clientConfig); } /** * @param [config] the optional OpenAPI config to use - * @returns string Successful response * @throws ApiError */ - public async callWithResultFromHeader(config?: ClientConfig): Promise { - return (await this.full.callWithResultFromHeader(config)).body; + public async getCallWithoutParametersAndResponse(config?: ClientConfig): Promise { + return (await this.full.getCallWithoutParametersAndResponse(config)).body; } -}" -`; - -exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/HeaderServiceFull.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; - -export class HeaderServiceFull { - private readonly httpRequest: BaseHttpRequest; - private readonly clientConfig: ClientConfig; - - constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { - this.httpRequest = httpRequest; - this.clientConfig = clientConfig; + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async putCallWithoutParametersAndResponse(config?: ClientConfig): Promise { + return (await this.full.putCallWithoutParametersAndResponse(config)).body; } /** * @param [config] the optional OpenAPI config to use - * @returns string Successful response * @throws ApiError */ - public async callWithResultFromHeader(config?: ClientConfig): Promise> { - return this.httpRequest.request({ - method: 'POST', - path: \`/api/v\${this.clientConfig.version}/header\`, - responseHeader: 'operation-location', - errors: { - 400: \`400 server error\`, - 500: \`500 server error\`, - }, - }, this.clientConfig, config); + public async postCallWithoutParametersAndResponse(config?: ClientConfig): Promise { + return (await this.full.postCallWithoutParametersAndResponse(config)).body; } -}" -`; - -exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/MultipartService.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -import type { BaseHttpRequest, ClientConfig } from '../core'; -import { MultipartServiceFull } from './MultipartServiceFull'; - -export class MultipartService { - private readonly httpRequest: BaseHttpRequest; - private readonly clientConfig: ClientConfig; - readonly full: MultipartServiceFull; + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async deleteCallWithoutParametersAndResponse(config?: ClientConfig): Promise { + return (await this.full.deleteCallWithoutParametersAndResponse(config)).body; + } - constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { - this.httpRequest = httpRequest; - this.clientConfig = clientConfig; - this.full = new MultipartServiceFull(httpRequest, clientConfig); + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async optionsCallWithoutParametersAndResponse(config?: ClientConfig): Promise { + return (await this.full.optionsCallWithoutParametersAndResponse(config)).body; } /** * @param [config] the optional OpenAPI config to use - * @returns any OK * @throws ApiError */ - public async multipartResponse(config?: ClientConfig): Promise<{ - file?: string, - metadata?: { - foo?: string, - bar?: string, - }, - }> { - return (await this.full.multipartResponse(config)).body; + public async headCallWithoutParametersAndResponse(config?: ClientConfig): Promise { + return (await this.full.headCallWithoutParametersAndResponse(config)).body; + } + + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async patchCallWithoutParametersAndResponse(config?: ClientConfig): Promise { + return (await this.full.patchCallWithoutParametersAndResponse(config)).body; } }" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/MultipartServiceFull.ts 1`] = ` +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/SimpleServiceFull.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; -export class MultipartServiceFull { +export class SimpleServiceFull { private readonly httpRequest: BaseHttpRequest; private readonly clientConfig: ClientConfig; @@ -6203,64 +8502,146 @@ export class MultipartServiceFull { /** * @param [config] the optional OpenAPI config to use - * @returns any OK * @throws ApiError */ - public async multipartResponse(config?: ClientConfig): Promise> { + public async getCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.clientConfig.version}/multipart\`, + path: \`/api/v\${this.clientConfig.version}/simple\`, + }, this.clientConfig, config); + } + + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async putCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { + return this.httpRequest.request({ + method: 'PUT', + path: \`/api/v\${this.clientConfig.version}/simple\`, + }, this.clientConfig, config); + } + + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async postCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { + return this.httpRequest.request({ + method: 'POST', + path: \`/api/v\${this.clientConfig.version}/simple\`, + }, this.clientConfig, config); + } + + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async deleteCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { + return this.httpRequest.request({ + method: 'DELETE', + path: \`/api/v\${this.clientConfig.version}/simple\`, + }, this.clientConfig, config); + } + + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async optionsCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { + return this.httpRequest.request({ + method: 'OPTIONS', + path: \`/api/v\${this.clientConfig.version}/simple\`, + }, this.clientConfig, config); + } + + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async headCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { + return this.httpRequest.request({ + method: 'HEAD', + path: \`/api/v\${this.clientConfig.version}/simple\`, + }, this.clientConfig, config); + } + + /** + * @param [config] the optional OpenAPI config to use + * @throws ApiError + */ + public async patchCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { + return this.httpRequest.request({ + method: 'PATCH', + path: \`/api/v\${this.clientConfig.version}/simple\`, }, this.clientConfig, config); } }" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/NoContentService.ts 1`] = ` +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/TypesService.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ import type { BaseHttpRequest, ClientConfig } from '../core'; -import { NoContentServiceFull } from './NoContentServiceFull'; +import { TypesServiceFull } from './TypesServiceFull'; -export class NoContentService { +export class TypesService { private readonly httpRequest: BaseHttpRequest; private readonly clientConfig: ClientConfig; - readonly full: NoContentServiceFull; + readonly full: TypesServiceFull; constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { this.httpRequest = httpRequest; this.clientConfig = clientConfig; - this.full = new NoContentServiceFull(httpRequest, clientConfig); + this.full = new TypesServiceFull(httpRequest, clientConfig); } /** + * @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 * @param [config] the optional OpenAPI config to use - * @returns void + * @returns number Response is a simple number + * @returns string Response is a simple string + * @returns boolean Response is a simple boolean + * @returns any Response is a simple object * @throws ApiError */ - public async callWithNoContentResponse(config?: ClientConfig): Promise { - return (await this.full.callWithNoContentResponse(config)).body; + public 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, + config?: ClientConfig + ): Promise { + return (await this.full.types( + parameterArray, parameterDictionary, parameterEnum, parameterNumber, parameterString, parameterBoolean, parameterObject, id, config + )).body; } }" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/NoContentServiceFull.ts 1`] = ` +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/TypesServiceFull.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; -export class NoContentServiceFull { +export class TypesServiceFull { private readonly httpRequest: BaseHttpRequest; private readonly clientConfig: ClientConfig; @@ -6270,142 +8651,95 @@ export class NoContentServiceFull { } /** + * @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 * @param [config] the optional OpenAPI config to use - * @returns void + * @returns number Response is a simple number + * @returns string Response is a simple string + * @returns boolean Response is a simple boolean + * @returns any Response is a simple object * @throws ApiError */ - public async callWithNoContentResponse(config?: ClientConfig): Promise> { + public 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, + config?: ClientConfig + ): Promise> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.clientConfig.version}/no-content\`, + path: \`/api/v\${this.clientConfig.version}/types\`, + query: { + 'parameterArray': parameterArray, + 'parameterDictionary': parameterDictionary, + 'parameterEnum': parameterEnum, + 'parameterNumber': parameterNumber, + 'parameterString': parameterString, + 'parameterBoolean': parameterBoolean, + 'parameterObject': parameterObject, + }, }, this.clientConfig, config); } }" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/ParametersService.ts 1`] = ` +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/UploadService.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { - ModelWithString, -} from '../models'; import type { BaseHttpRequest, ClientConfig } from '../core'; -import { ParametersServiceFull } from './ParametersServiceFull'; - -export class ParametersService { - private readonly httpRequest: BaseHttpRequest; - private readonly clientConfig: ClientConfig; - readonly full: ParametersServiceFull; - - constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { - this.httpRequest = httpRequest; - this.clientConfig = clientConfig; - this.full = new ParametersServiceFull(httpRequest, clientConfig); - } - - /** - * @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 - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ - public async callWithParameters( - parameterHeader: string | null, - parameterQuery: string | null, - parameterForm: string | null, - parameterCookie: string | null, - parameterPath: string | null, - requestBody: ModelWithString | null, - config?: ClientConfig - ): Promise { - return (await this.full.callWithParameters( - parameterHeader, parameterQuery, parameterForm, parameterCookie, parameterPath, requestBody, config - )).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 - * @param _default This is the parameter with a reserved keyword - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ - public async callWithWeirdParameterNames( - parameterHeader: string | null, - parameterQuery: string | null, - parameterForm: string | null, - parameterCookie: string | null, - requestBody: ModelWithString | null, - parameterPath1?: string, - parameterPath2?: string, - parameterPath3?: string, - _default?: string, - config?: ClientConfig - ): Promise { - return (await this.full.callWithWeirdParameterNames( - parameterHeader, parameterQuery, parameterForm, parameterCookie, requestBody, parameterPath1, parameterPath2, parameterPath3, _default, config - )).body; - } +import { UploadServiceFull } from './UploadServiceFull'; - /** - * @param requestBody This is a required parameter - * @param parameter This is an optional parameter - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ - public async getCallWithOptionalParam( - requestBody: ModelWithString, - parameter?: string, - config?: ClientConfig - ): Promise { - return (await this.full.getCallWithOptionalParam( - requestBody, parameter, config - )).body; +export class UploadService { + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; + readonly full: UploadServiceFull; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + this.full = new UploadServiceFull(httpRequest, clientConfig); } /** - * @param parameter This is a required parameter - * @param requestBody This is an optional parameter + * @param file Supply a file reference for upload * @param [config] the optional OpenAPI config to use + * @returns boolean * @throws ApiError */ - public async postCallWithOptionalParam( - parameter: string, - requestBody?: ModelWithString, + public async uploadFile( + file: Blob, config?: ClientConfig - ): Promise { - return (await this.full.postCallWithOptionalParam( - parameter, requestBody, config + ): Promise { + return (await this.full.uploadFile( + file, config )).body; } }" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/ParametersServiceFull.ts 1`] = ` +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/UploadServiceFull.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { - ModelWithString, -} from '../models'; import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; -export class ParametersServiceFull { +export class UploadServiceFull { private readonly httpRequest: BaseHttpRequest; private readonly clientConfig: ClientConfig; @@ -6415,589 +8749,523 @@ export class ParametersServiceFull { } /** - * @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 + * @param file Supply a file reference for upload * @param [config] the optional OpenAPI config to use + * @returns boolean * @throws ApiError */ - public async callWithParameters( - parameterHeader: string | null, - parameterQuery: string | null, - parameterForm: string | null, - parameterCookie: string | null, - parameterPath: string | null, - requestBody: ModelWithString | null, + public async uploadFile( + file: Blob, config?: ClientConfig - ): Promise> { + ): Promise> { return this.httpRequest.request({ - method: 'GET', - path: \`/api/v\${this.clientConfig.version}/parameters/\${parameterPath}\`, - cookies: { - 'parameterCookie': parameterCookie, - }, - headers: { - 'parameterHeader': parameterHeader, - }, - query: { - 'parameterQuery': parameterQuery, - }, + method: 'POST', + path: \`/api/v\${this.clientConfig.version}/upload\`, formData: { - 'parameterForm': parameterForm, + 'file': file, }, - body: requestBody, - mediaType: 'application/json', }, this.clientConfig, config); } - /** - * @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 - * @param _default This is the parameter with a reserved keyword - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ - public async callWithWeirdParameterNames( - parameterHeader: string | null, - parameterQuery: string | null, - parameterForm: string | null, - parameterCookie: string | null, - requestBody: ModelWithString | null, - parameterPath1?: string, - parameterPath2?: string, - parameterPath3?: string, - _default?: string, - config?: ClientConfig - ): Promise> { - return this.httpRequest.request({ - method: 'GET', - path: \`/api/v\${this.clientConfig.version}/parameters/\${parameterPath1}/\${parameterPath2}/\${parameterPath3}\`, - cookies: { - 'PARAMETER-COOKIE': parameterCookie, - }, - headers: { - 'parameter.header': parameterHeader, - }, - query: { - 'parameter-query': parameterQuery, - 'default': _default, - }, - formData: { - 'parameter_form': parameterForm, - }, - body: requestBody, - mediaType: 'application/json', - }, this.clientConfig, config); - } +}" +`; - /** - * @param requestBody This is a required parameter - * @param parameter This is an optional parameter - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ - public async getCallWithOptionalParam( - requestBody: ModelWithString, - parameter?: string, - config?: ClientConfig - ): Promise> { - return this.httpRequest.request({ - method: 'GET', - path: \`/api/v\${this.clientConfig.version}/parameters/\`, - query: { - 'parameter': parameter, - }, - body: requestBody, - mediaType: 'application/json', - }, this.clientConfig, config); +exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/index.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export { CollectionFormatService } from './CollectionFormatService'; +export { CollectionFormatServiceFull } from './CollectionFormatServiceFull'; +export { ComplexService } from './ComplexService'; +export { ComplexServiceFull } from './ComplexServiceFull'; +export { DefaultsService } from './DefaultsService'; +export { DefaultsServiceFull } from './DefaultsServiceFull'; +export { DuplicateService } from './DuplicateService'; +export { DuplicateServiceFull } from './DuplicateServiceFull'; +export { HeaderService } from './HeaderService'; +export { HeaderServiceFull } from './HeaderServiceFull'; +export { MultipartService } from './MultipartService'; +export { MultipartServiceFull } from './MultipartServiceFull'; +export { NoContentService } from './NoContentService'; +export { NoContentServiceFull } from './NoContentServiceFull'; +export { ParametersService } from './ParametersService'; +export { ParametersServiceFull } from './ParametersServiceFull'; +export { RequestBodyService } from './RequestBodyService'; +export { RequestBodyServiceFull } from './RequestBodyServiceFull'; +export { ResponseService } from './ResponseService'; +export { ResponseServiceFull } from './ResponseServiceFull'; +export { SimpleService } from './SimpleService'; +export { SimpleServiceFull } from './SimpleServiceFull'; +export { TypesService } from './TypesService'; +export { TypesServiceFull } from './TypesServiceFull'; +export { UploadService } from './UploadService'; +export { UploadServiceFull } from './UploadServiceFull'; +" +`; + +exports[`v3 should generate with no tags: ./test/generated/v3_client_no_tags/client.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { BaseHttpRequest } from './core'; +import { FetchHttpRequest } from './core'; +import type { ClientConfig } from './core'; +import { Service } from './services'; + +export class TestClient extends Service { + + constructor(clientConfig: ClientConfig, httpClient: BaseHttpRequest = new FetchHttpRequest()) { + const config = { + baseUrl: clientConfig?.baseUrl ?? 'http://localhost:3000/base', + version: clientConfig?.version ?? '1.0', + withCredentials: clientConfig?.withCredentials ?? false, + token: clientConfig?.token, + username: clientConfig?.username, + password: clientConfig?.password, + headers: clientConfig?.headers, + } + super(httpClient, config); } +}" +`; - /** - * @param parameter This is a required parameter - * @param requestBody This is an optional parameter - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ - public async postCallWithOptionalParam( - parameter: string, - requestBody?: ModelWithString, - config?: ClientConfig - ): Promise> { - return this.httpRequest.request({ - method: 'POST', - path: \`/api/v\${this.clientConfig.version}/parameters/\`, - query: { - 'parameter': parameter, - }, - body: requestBody, - mediaType: 'application/json', - }, this.clientConfig, config); +exports[`v3 should generate with no tags: ./test/generated/v3_client_no_tags/core/ApiError.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ApiResult } from './ApiResult'; + +export class ApiError extends Error { + public readonly url: string; + public readonly status: number; + public readonly statusText: string; + public readonly body: any; + + constructor(response: ApiResult, message: string) { + super(message); + + this.url = response.url; + this.status = response.status; + this.statusText = response.statusText; + this.body = response.body; } +}" +`; + +exports[`v3 should generate with no tags: ./test/generated/v3_client_no_tags/core/ApiRequestOptions.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type ApiRequestOptions = { + readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH'; + readonly path: string; + readonly cookies?: Record; + readonly headers?: Record; + readonly query?: Record; + readonly formData?: Record; + readonly body?: any; + readonly mediaType?: string; + readonly responseHeader?: string; + readonly errors?: Record; +}" +`; +exports[`v3 should generate with no tags: ./test/generated/v3_client_no_tags/core/ApiResult.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type ApiResult = { + readonly url: string; + readonly ok: boolean; + readonly status: number; + readonly statusText: string; + readonly body: T; }" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/RequestBodyService.ts 1`] = ` +exports[`v3 should generate with no tags: ./test/generated/v3_client_no_tags/core/BaseHttpRequest.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { - ModelWithString, -} from '../models'; -import type { BaseHttpRequest, ClientConfig } from '../core'; -import { RequestBodyServiceFull } from './RequestBodyServiceFull'; - -export class RequestBodyService { - private readonly httpRequest: BaseHttpRequest; - private readonly clientConfig: ClientConfig; - readonly full: RequestBodyServiceFull; - - constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { - this.httpRequest = httpRequest; - this.clientConfig = clientConfig; - this.full = new RequestBodyServiceFull(httpRequest, clientConfig); - } - - /** - * @param requestBody A reusable request body - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ - public async postRequestBodyService( - requestBody?: ModelWithString, - config?: ClientConfig - ): Promise { - return (await this.full.postRequestBodyService( - requestBody, config - )).body; - } +import type { ApiRequestOptions } from './ApiRequestOptions'; +import type { ApiResult } from './ApiResult'; +import type { ClientConfig } from './OpenAPI'; +export interface BaseHttpRequest { + request( + options: ApiRequestOptions, + config: ClientConfig, + mergeConfig?: ClientConfig + ): Promise>; }" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/RequestBodyServiceFull.ts 1`] = ` +exports[`v3 should generate with no tags: ./test/generated/v3_client_no_tags/core/FetchHttpRequest.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { - ModelWithString, -} from '../models'; -import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; +import { ApiError } from './ApiError'; +import type { ApiRequestOptions } from './ApiRequestOptions'; +import type { ApiResult } from './ApiResult'; +import type { ClientConfig } from './OpenAPI'; +import type { BaseHttpRequest } from './BaseHttpRequest'; -export class RequestBodyServiceFull { - private readonly httpRequest: BaseHttpRequest; - private readonly clientConfig: ClientConfig; +function isDefined(value: T | null | undefined): value is Exclude { + return value !== undefined && value !== null; +} - constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { - this.httpRequest = httpRequest; - this.clientConfig = clientConfig; +function isString(value: any): value is string { + return typeof value === 'string'; +} + +export function deepAssign( + target: Record, + source: Record, +): Record { + const keys = Object.keys(source); + for (const k of keys) { + const sourceValue: unknown = source[k]; + const targetValue: unknown = target[k]; + if (Object(sourceValue) === sourceValue && Object(targetValue) === targetValue) { + target[k] = deepAssign( + targetValue as Record, + sourceValue as Record, + ); + } else { + target[k] = source[k]; + } } + return target; +} - /** - * @param requestBody A reusable request body - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ - public async postRequestBodyService( - requestBody?: ModelWithString, - config?: ClientConfig - ): Promise> { - return this.httpRequest.request({ - method: 'POST', - path: \`/api/v\${this.clientConfig.version}/requestBody/\`, - body: requestBody, - mediaType: 'application/json', - }, this.clientConfig, config); +function isStringWithValue(value: any): value is string { + return isString(value) && value !== ''; +} + +function isBlob(value: any): value is Blob { + return value instanceof Blob; +} + +function getQueryString(params: Record): string { + const qs: string[] = []; + Object.keys(params).forEach(key => { + const value = params[key]; + if (isDefined(value)) { + 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 ''; +} -}" -`; +function getUrl(options: ApiRequestOptions, config: ClientConfig): string { + const path = options.path.replace(/[:]/g, '_'); + const url = \`\${config.baseUrl}\${path}\`; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/ResponseService.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -import type { - ModelThatExtends, - ModelThatExtendsExtends, - ModelWithString, -} from '../models'; -import type { BaseHttpRequest, ClientConfig } from '../core'; -import { ResponseServiceFull } from './ResponseServiceFull'; + if (options.query) { + return \`\${url}\${getQueryString(options.query)}\`; + } + return url; +} -export class ResponseService { - private readonly httpRequest: BaseHttpRequest; - private readonly clientConfig: ClientConfig; - readonly full: ResponseServiceFull; +function getFormData(params: Record): FormData { + const formData = new FormData(); + Object.keys(params).forEach(key => { + const value = params[key]; + if (isDefined(value)) { + formData.append(key, value); + } + }); + return formData; +} + +type Resolver = (options: ApiRequestOptions) => Promise; + +async function resolve(options: ApiRequestOptions, resolver?: T | Resolver): Promise { + if (typeof resolver === 'function') { + return (resolver as Resolver)(options); + } + return resolver; +} + +async function getHeaders(options: ApiRequestOptions, config: ClientConfig): Promise { + const token = await resolve(options, config.token); + const username = await resolve(options, config.username); + const password = await resolve(options, config.password); + const defaultHeaders = await resolve(options, config.headers); + + const headers = new Headers({ + Accept: 'application/json', + ...defaultHeaders, + ...options.headers, + }); + + if (isStringWithValue(token)) { + headers.append('Authorization', \`Bearer \${token}\`); + } + + if (isStringWithValue(username) && isStringWithValue(password)) { + const credentials = btoa(\`\${username}:\${password}\`); + headers.append('Authorization', \`Basic \${credentials}\`); + } + + if (options.body) { + if (options.mediaType) { + headers.append('Content-Type', options.mediaType); + } else if (isBlob(options.body)) { + headers.append('Content-Type', options.body.type || 'application/octet-stream'); + } else if (isString(options.body)) { + headers.append('Content-Type', 'text/plain'); + } else { + headers.append('Content-Type', 'application/json'); + } + } + return headers; +} + +function getRequestBody(options: ApiRequestOptions): BodyInit | undefined { + if (options.formData) { + return getFormData(options.formData); + } + if (options.body) { + if (options.mediaType?.includes('/json')) { + return JSON.stringify(options.body) + } else if (isString(options.body) || isBlob(options.body)) { + return options.body; + } else { + return JSON.stringify(options.body); + } + } + return undefined; +} + +async function sendRequest(options: ApiRequestOptions, config: ClientConfig, url: string): Promise { + const request: RequestInit = { + method: options.method, + headers: await getHeaders(options, config), + body: getRequestBody(options), + }; + if (config.withCredentials) { + request.credentials = 'include'; + } + return await fetch(url, request); +} + +function getResponseHeader(response: Response, responseHeader?: string): string | null { + if (responseHeader) { + const content = response.headers.get(responseHeader); + if (isString(content)) { + return content; + } + } + return null; +} + +async function getResponseBody(response: Response): Promise { + try { + const contentType = response.headers.get('Content-Type'); + if (contentType) { + const isJSON = contentType.toLowerCase().startsWith('application/json'); + if (isJSON) { + return await response.json(); + } else { + return await response.text(); + } + } + } catch (error) { + console.error(error); + } + return null; +} - constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { - this.httpRequest = httpRequest; - this.clientConfig = clientConfig; - this.full = new ResponseServiceFull(httpRequest, clientConfig); +function catchErrors(options: ApiRequestOptions, result: ApiResult): void { + const errors: Record = { + 400: 'Bad Request', + 401: 'Unauthorized', + 403: 'Forbidden', + 404: 'Not Found', + 500: 'Internal Server Error', + 502: 'Bad Gateway', + 503: 'Service Unavailable', + ...options.errors, } - /** - * @param [config] the optional OpenAPI config to use - * @returns ModelWithString - * @throws ApiError - */ - public async callWithResponse(config?: ClientConfig): Promise { - return (await this.full.callWithResponse(config)).body; + const error = errors[result.status]; + if (error) { + throw new ApiError(result, error); } - /** - * @param [config] the optional OpenAPI config to use - * @returns ModelWithString Message for default response - * @throws ApiError - */ - public async callWithDuplicateResponses(config?: ClientConfig): Promise { - return (await this.full.callWithDuplicateResponses(config)).body; + if (!result.ok) { + throw new ApiError(result, 'Generic Error'); } +} +export class FetchHttpRequest implements BaseHttpRequest { /** - * @param [config] the optional OpenAPI config to use - * @returns any Message for 200 response - * @returns ModelWithString Message for default response - * @returns ModelThatExtends Message for 201 response - * @returns ModelThatExtendsExtends Message for 202 response - * @throws ApiError - */ - public async callWithResponses(config?: ClientConfig): Promise<{ - readonly '@namespace.string'?: string, - readonly '@namespace.integer'?: number, - readonly value?: Array, - } | ModelWithString | ModelThatExtends | ModelThatExtendsExtends> { - return (await this.full.callWithResponses(config)).body; - } + * Request using fetch client + * @param options The request options from the the service + * @param config The OpenAPI configuration + * @param [mergeConfig] Additional optional OpenAPI configuration that will be merged with the first one + * @returns ApiResult + * @throws ApiError + */ + async request(options: ApiRequestOptions, config: ClientConfig, mergeConfig?: ClientConfig): Promise { + const conf = mergeConfig ? deepAssign(config, mergeConfig) : config; + const url = getUrl(options, conf); + const response = await sendRequest(options, conf, url); + const responseBody = await getResponseBody(response); + const responseHeader = getResponseHeader(response, options.responseHeader); -}" + const result: ApiResult = { + url, + ok: response.ok, + status: response.status, + statusText: response.statusText, + body: responseHeader || responseBody, + }; + + catchErrors(options, result); + return result; + } +} +" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/ResponseServiceFull.ts 1`] = ` +exports[`v3 should generate with no tags: ./test/generated/v3_client_no_tags/core/OpenAPI.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { - ModelThatExtends, - ModelThatExtendsExtends, - ModelWithString, -} from '../models'; -import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; - -export class ResponseServiceFull { - private readonly httpRequest: BaseHttpRequest; - private readonly clientConfig: ClientConfig; - - constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { - this.httpRequest = httpRequest; - this.clientConfig = clientConfig; - } - - /** - * @param [config] the optional OpenAPI config to use - * @returns ModelWithString - * @throws ApiError - */ - public async callWithResponse(config?: ClientConfig): Promise> { - return this.httpRequest.request({ - method: 'GET', - path: \`/api/v\${this.clientConfig.version}/response\`, - }, this.clientConfig, config); - } - - /** - * @param [config] the optional OpenAPI config to use - * @returns ModelWithString Message for default response - * @throws ApiError - */ - public async callWithDuplicateResponses(config?: ClientConfig): Promise> { - return this.httpRequest.request({ - method: 'POST', - path: \`/api/v\${this.clientConfig.version}/response\`, - errors: { - 500: \`Message for 500 error\`, - 501: \`Message for 501 error\`, - 502: \`Message for 502 error\`, - }, - }, this.clientConfig, config); - } +import type { ApiRequestOptions } from './ApiRequestOptions'; - /** - * @param [config] the optional OpenAPI config to use - * @returns any Message for 200 response - * @returns ModelWithString Message for default response - * @returns ModelThatExtends Message for 201 response - * @returns ModelThatExtendsExtends Message for 202 response - * @throws ApiError - */ - public async callWithResponses(config?: ClientConfig): Promise, - } | ModelWithString | ModelThatExtends | ModelThatExtendsExtends>> { - return this.httpRequest.request({ - method: 'PUT', - path: \`/api/v\${this.clientConfig.version}/response\`, - errors: { - 500: \`Message for 500 error\`, - 501: \`Message for 501 error\`, - 502: \`Message for 502 error\`, - }, - }, this.clientConfig, config); - } +type Resolver = (options: ApiRequestOptions) => Promise; +type Headers = Record; -}" +export type ClientConfig = { + baseUrl?: string; + version?: string; + withCredentials?: boolean; + token?: string | Resolver; + username?: string | Resolver; + password?: string | Resolver; + headers?: Headers | Resolver; +} +" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/SimpleService.ts 1`] = ` +exports[`v3 should generate with no tags: ./test/generated/v3_client_no_tags/core/index.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { BaseHttpRequest, ClientConfig } from '../core'; -import { SimpleServiceFull } from './SimpleServiceFull'; - -export class SimpleService { - private readonly httpRequest: BaseHttpRequest; - private readonly clientConfig: ClientConfig; - readonly full: SimpleServiceFull; - - constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { - this.httpRequest = httpRequest; - this.clientConfig = clientConfig; - this.full = new SimpleServiceFull(httpRequest, clientConfig); - } - - /** - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ - public async getCallWithoutParametersAndResponse(config?: ClientConfig): Promise { - return (await this.full.getCallWithoutParametersAndResponse(config)).body; - } - - /** - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ - public async putCallWithoutParametersAndResponse(config?: ClientConfig): Promise { - return (await this.full.putCallWithoutParametersAndResponse(config)).body; - } - - /** - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ - public async postCallWithoutParametersAndResponse(config?: ClientConfig): Promise { - return (await this.full.postCallWithoutParametersAndResponse(config)).body; - } - - /** - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ - public async deleteCallWithoutParametersAndResponse(config?: ClientConfig): Promise { - return (await this.full.deleteCallWithoutParametersAndResponse(config)).body; - } +export { ApiError } from './ApiError'; +export type { ApiRequestOptions } from './ApiRequestOptions'; +export type { ApiResult } from './ApiResult'; +export type { BaseHttpRequest } from './BaseHttpRequest'; +export { FetchHttpRequest } from './FetchHttpRequest'; +export type { ClientConfig } from './OpenAPI'; +" +`; - /** - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ - public async optionsCallWithoutParametersAndResponse(config?: ClientConfig): Promise { - return (await this.full.optionsCallWithoutParametersAndResponse(config)).body; - } +exports[`v3 should generate with no tags: ./test/generated/v3_client_no_tags/index.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export * from './core'; +export * from './models'; +export * from './schemas'; +export * from './services'; - /** - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ - public async headCallWithoutParametersAndResponse(config?: ClientConfig): Promise { - return (await this.full.headCallWithoutParametersAndResponse(config)).body; - } +export { TestClient } from './client'; +" +`; - /** - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ - public async patchCallWithoutParametersAndResponse(config?: ClientConfig): Promise { - return (await this.full.patchCallWithoutParametersAndResponse(config)).body; - } +exports[`v3 should generate with no tags: ./test/generated/v3_client_no_tags/models/index.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +" +`; -}" +exports[`v3 should generate with no tags: ./test/generated/v3_client_no_tags/schemas/index.ts 1`] = ` +"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/SimpleServiceFull.ts 1`] = ` +exports[`v3 should generate with no tags: ./test/generated/v3_client_no_tags/services/Service.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; +import type { BaseHttpRequest, ClientConfig } from '../core'; +import { ServiceFull } from './ServiceFull'; -export class SimpleServiceFull { +export class Service { private readonly httpRequest: BaseHttpRequest; private readonly clientConfig: ClientConfig; + readonly full: ServiceFull; constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { this.httpRequest = httpRequest; this.clientConfig = clientConfig; + this.full = new ServiceFull(httpRequest, clientConfig); } /** * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async getCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { - return this.httpRequest.request({ - method: 'GET', - path: \`/api/v\${this.clientConfig.version}/simple\`, - }, this.clientConfig, config); - } - - /** - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ - public async putCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { - return this.httpRequest.request({ - method: 'PUT', - path: \`/api/v\${this.clientConfig.version}/simple\`, - }, this.clientConfig, config); - } - - /** - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ - public async postCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { - return this.httpRequest.request({ - method: 'POST', - path: \`/api/v\${this.clientConfig.version}/simple\`, - }, this.clientConfig, config); - } - - /** - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ - public async deleteCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { - return this.httpRequest.request({ - method: 'DELETE', - path: \`/api/v\${this.clientConfig.version}/simple\`, - }, this.clientConfig, config); - } - - /** - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ - public async optionsCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { - return this.httpRequest.request({ - method: 'OPTIONS', - path: \`/api/v\${this.clientConfig.version}/simple\`, - }, this.clientConfig, config); - } - - /** - * @param [config] the optional OpenAPI config to use - * @throws ApiError - */ - public async headCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { - return this.httpRequest.request({ - method: 'HEAD', - path: \`/api/v\${this.clientConfig.version}/simple\`, - }, this.clientConfig, config); + public async getCallWithoutParametersAndResponse(config?: ClientConfig): Promise { + return (await this.full.getCallWithoutParametersAndResponse(config)).body; } /** * @param [config] the optional OpenAPI config to use * @throws ApiError */ - public async patchCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { - return this.httpRequest.request({ - method: 'PATCH', - path: \`/api/v\${this.clientConfig.version}/simple\`, - }, this.clientConfig, config); - } - -}" -`; - -exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/TypesService.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -import type { BaseHttpRequest, ClientConfig } from '../core'; -import { TypesServiceFull } from './TypesServiceFull'; - -export class TypesService { - private readonly httpRequest: BaseHttpRequest; - private readonly clientConfig: ClientConfig; - readonly full: TypesServiceFull; - - constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { - this.httpRequest = httpRequest; - this.clientConfig = clientConfig; - this.full = new TypesServiceFull(httpRequest, clientConfig); + public async putCallWithoutParametersAndResponse(config?: ClientConfig): Promise { + return (await this.full.putCallWithoutParametersAndResponse(config)).body; } /** - * @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 * @param [config] the optional OpenAPI config to use - * @returns number Response is a simple number - * @returns string Response is a simple string - * @returns boolean Response is a simple boolean - * @returns any Response is a simple object * @throws ApiError */ - public 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, - config?: ClientConfig - ): Promise { - return (await this.full.types( - parameterArray, parameterDictionary, parameterEnum, parameterNumber, parameterString, parameterBoolean, parameterObject, id, config - )).body; + public async postCallWithoutParametersAndResponse(config?: ClientConfig): Promise { + return (await this.full.postCallWithoutParametersAndResponse(config)).body; } }" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/TypesServiceFull.ts 1`] = ` +exports[`v3 should generate with no tags: ./test/generated/v3_client_no_tags/services/ServiceFull.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; -export class TypesServiceFull { +export class ServiceFull { private readonly httpRequest: BaseHttpRequest; private readonly clientConfig: ClientConfig; @@ -7007,155 +9275,47 @@ export class TypesServiceFull { } /** - * @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 * @param [config] the optional OpenAPI config to use - * @returns number Response is a simple number - * @returns string Response is a simple string - * @returns boolean Response is a simple boolean - * @returns any Response is a simple object * @throws ApiError */ - public 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, - config?: ClientConfig - ): Promise> { + public async getCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'GET', - path: \`/api/v\${this.clientConfig.version}/types\`, - query: { - 'parameterArray': parameterArray, - 'parameterDictionary': parameterDictionary, - 'parameterEnum': parameterEnum, - 'parameterNumber': parameterNumber, - 'parameterString': parameterString, - 'parameterBoolean': parameterBoolean, - 'parameterObject': parameterObject, - }, + path: \`/api/v\${this.clientConfig.version}/simple\`, }, this.clientConfig, config); } -}" -`; - -exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/UploadService.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -import type { BaseHttpRequest, ClientConfig } from '../core'; -import { UploadServiceFull } from './UploadServiceFull'; - -export class UploadService { - private readonly httpRequest: BaseHttpRequest; - private readonly clientConfig: ClientConfig; - readonly full: UploadServiceFull; - - constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { - this.httpRequest = httpRequest; - this.clientConfig = clientConfig; - this.full = new UploadServiceFull(httpRequest, clientConfig); - } - /** - * @param file Supply a file reference for upload * @param [config] the optional OpenAPI config to use - * @returns boolean * @throws ApiError */ - public async uploadFile( - file: Blob, - config?: ClientConfig - ): Promise { - return (await this.full.uploadFile( - file, config - )).body; - } - -}" -`; - -exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/UploadServiceFull.ts 1`] = ` -"/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; - -export class UploadServiceFull { - private readonly httpRequest: BaseHttpRequest; - private readonly clientConfig: ClientConfig; - - constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { - this.httpRequest = httpRequest; - this.clientConfig = clientConfig; + public async putCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { + return this.httpRequest.request({ + method: 'PUT', + path: \`/api/v\${this.clientConfig.version}/simple\`, + }, this.clientConfig, config); } /** - * @param file Supply a file reference for upload * @param [config] the optional OpenAPI config to use - * @returns boolean * @throws ApiError */ - public async uploadFile( - file: Blob, - config?: ClientConfig - ): Promise> { + public async postCallWithoutParametersAndResponse(config?: ClientConfig): Promise> { return this.httpRequest.request({ method: 'POST', - path: \`/api/v\${this.clientConfig.version}/upload\`, - formData: { - 'file': file, - }, + path: \`/api/v\${this.clientConfig.version}/simple\`, }, this.clientConfig, config); } }" `; -exports[`v3 should generate with exportClient: ./test/generated/v3_client/services/index.ts 1`] = ` +exports[`v3 should generate with no tags: ./test/generated/v3_client_no_tags/services/index.ts 1`] = ` "/* DO NOT EDIT THIS FILE, IT IS GENERATED FROM THE OPEN API SPECIFICATION */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export { CollectionFormatService } from './CollectionFormatService'; -export { CollectionFormatServiceFull } from './CollectionFormatServiceFull'; -export { ComplexService } from './ComplexService'; -export { ComplexServiceFull } from './ComplexServiceFull'; -export { DefaultsService } from './DefaultsService'; -export { DefaultsServiceFull } from './DefaultsServiceFull'; -export { DuplicateService } from './DuplicateService'; -export { DuplicateServiceFull } from './DuplicateServiceFull'; -export { HeaderService } from './HeaderService'; -export { HeaderServiceFull } from './HeaderServiceFull'; -export { MultipartService } from './MultipartService'; -export { MultipartServiceFull } from './MultipartServiceFull'; -export { NoContentService } from './NoContentService'; -export { NoContentServiceFull } from './NoContentServiceFull'; -export { ParametersService } from './ParametersService'; -export { ParametersServiceFull } from './ParametersServiceFull'; -export { RequestBodyService } from './RequestBodyService'; -export { RequestBodyServiceFull } from './RequestBodyServiceFull'; -export { ResponseService } from './ResponseService'; -export { ResponseServiceFull } from './ResponseServiceFull'; -export { SimpleService } from './SimpleService'; -export { SimpleServiceFull } from './SimpleServiceFull'; -export { TypesService } from './TypesService'; -export { TypesServiceFull } from './TypesServiceFull'; -export { UploadService } from './UploadService'; -export { UploadServiceFull } from './UploadServiceFull'; +export { Service } from './Service'; +export { ServiceFull } from './ServiceFull'; " `; diff --git a/test/index.client.spec.js b/test/index.client.spec.js index fdce7fff1..4edda3ebb 100644 --- a/test/index.client.spec.js +++ b/test/index.client.spec.js @@ -4,23 +4,40 @@ const OpenAPI = require('../dist'); const glob = require('glob'); const fs = require('fs'); +async function gen(version, postfix) { + await OpenAPI.generate({ + input: `./test/spec/v${version}${postfix}.json`, + output: `./test/generated/v${version}_client${postfix}`, + httpClient: OpenAPI.HttpClient.FETCH, + useOptions: false, + useUnionTypes: false, + exportCore: true, + exportSchemas: true, + exportModels: true, + exportServices: true, + exportClient: true, + clientName: 'TestClient', + }); + return glob.sync(`./test/generated/v${version}_client${postfix}/**/*.ts`); +} + describe('v2', () => { it('should generate with exportClient', async () => { - await OpenAPI.generate({ - input: './test/spec/v2.json', - output: './test/generated/v2_client', - httpClient: OpenAPI.HttpClient.FETCH, - useOptions: false, - useUnionTypes: false, - exportCore: true, - exportSchemas: true, - exportModels: true, - exportServices: true, - exportClient: true, - clientName: 'TestClient', + (await gen(2, '')).forEach(file => { + const content = fs.readFileSync(file, 'utf8').toString(); + expect(content).toMatchSnapshot(file); + }); + }); + + it('should generate with no tags', async () => { + (await gen(2, '_no_tags')).forEach(file => { + const content = fs.readFileSync(file, 'utf8').toString(); + expect(content).toMatchSnapshot(file); }); + }); - glob.sync('./test/generated/v2_client/**/*.ts').forEach(file => { + it('should generate with combined tags', async () => { + (await gen(2, '_tags_combined')).forEach(file => { const content = fs.readFileSync(file, 'utf8').toString(); expect(content).toMatchSnapshot(file); }); @@ -29,21 +46,21 @@ describe('v2', () => { describe('v3', () => { it('should generate with exportClient', async () => { - await OpenAPI.generate({ - input: './test/spec/v3.json', - output: './test/generated/v3_client', - httpClient: OpenAPI.HttpClient.FETCH, - useOptions: false, - useUnionTypes: false, - exportCore: true, - exportSchemas: true, - exportModels: true, - exportServices: true, - exportClient: true, - clientName: 'TestClient', + (await gen(3, '')).forEach(file => { + const content = fs.readFileSync(file, 'utf8').toString(); + expect(content).toMatchSnapshot(file); }); + }); + + it('should generate with no tags', async () => { + (await gen(3, '_no_tags')).forEach(file => { + const content = fs.readFileSync(file, 'utf8').toString(); + expect(content).toMatchSnapshot(file); + }); + }); - glob.sync('./test/generated/v3_client/**/*.ts').forEach(file => { + it('should generate with combined tags', async () => { + (await gen(3, '_tags_combined')).forEach(file => { const content = fs.readFileSync(file, 'utf8').toString(); expect(content).toMatchSnapshot(file); }); diff --git a/test/spec/v2_no_tags.json b/test/spec/v2_no_tags.json new file mode 100644 index 000000000..f4db4ce10 --- /dev/null +++ b/test/spec/v2_no_tags.json @@ -0,0 +1,25 @@ +{ + "swagger": "2.0", + "info": { + "title": "swagger", + "version": "v1.0" + }, + "host": "localhost:3000", + "basePath": "/base", + "schemes": [ + "http" + ], + "paths": { + "/api/v{api-version}/simple": { + "get": { + "operationId": "GetCallWithoutParametersAndResponse" + }, + "put": { + "operationId": "PutCallWithoutParametersAndResponse" + }, + "post": { + "operationId": "PostCallWithoutParametersAndResponse" + } + } + } +} diff --git a/test/spec/v2_tags_combined.json b/test/spec/v2_tags_combined.json new file mode 100644 index 000000000..c5e80d533 --- /dev/null +++ b/test/spec/v2_tags_combined.json @@ -0,0 +1,29 @@ +{ + "swagger": "2.0", + "info": { + "title": "swagger", + "version": "v1.0" + }, + "host": "localhost:3000", + "basePath": "/base", + "schemes": ["http"], + "paths": { + "/api/v{api-version}/simple": { + "get": { + "tags": [ + "Simple" + ], + "operationId": "GetCallWithoutParametersAndResponse" + }, + "put": { + "tags": [ + "Simple" + ], + "operationId": "PutCallWithoutParametersAndResponse" + }, + "post": { + "operationId": "PostCallWithoutParametersAndResponse" + } + } + } +} diff --git a/test/spec/v3_no_tags.json b/test/spec/v3_no_tags.json new file mode 100644 index 000000000..dc9b92853 --- /dev/null +++ b/test/spec/v3_no_tags.json @@ -0,0 +1,25 @@ +{ + "openapi": "3.0.0", + "info": { + "title": "swagger", + "version": "v1.0" + }, + "servers": [ + { + "url": "http://localhost:3000/base" + } + ], + "paths": { + "/api/v{api-version}/simple": { + "get": { + "operationId": "GetCallWithoutParametersAndResponse" + }, + "put": { + "operationId": "PutCallWithoutParametersAndResponse" + }, + "post": { + "operationId": "PostCallWithoutParametersAndResponse" + } + } + } +} diff --git a/test/spec/v3_tags_combined.json b/test/spec/v3_tags_combined.json new file mode 100644 index 000000000..37b42b0f8 --- /dev/null +++ b/test/spec/v3_tags_combined.json @@ -0,0 +1,31 @@ +{ + "openapi": "3.0.0", + "info": { + "title": "swagger", + "version": "v1.0" + }, + "servers": [ + { + "url": "http://localhost:3000/base" + } + ], + "paths": { + "/api/v{api-version}/simple": { + "get": { + "tags": [ + "Simple" + ], + "operationId": "GetCallWithoutParametersAndResponse" + }, + "put": { + "tags": [ + "Simple" + ], + "operationId": "PutCallWithoutParametersAndResponse" + }, + "post": { + "operationId": "PostCallWithoutParametersAndResponse" + } + } + } +} From 81922a7536c64c7131435d2e4386f61c2ef9920b Mon Sep 17 00:00:00 2001 From: pbrobles Date: Fri, 13 Sep 2024 09:32:57 -0500 Subject: [PATCH 11/11] INFRA-3185: publishing current version. --- .github/dependabot.yml | 27 ++++++++++++++ .github/workflows/build-publish.yml | 57 +++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/build-publish.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000..a1ee06c77 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,27 @@ +version: 2 +updates: + - package-ecosystem: npm + directory: "/" + schedule: + interval: "weekly" + day: "sunday" + time: "09:00" + timezone: "America/Los_Angeles" + ignore: + - dependency-name: "*" + update-types: [version-update:semver-major] + open-pull-requests-limit: 5 + commit-message: + prefix: "bot: update npm dependencies: " + + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + day: "sunday" + time: "09:00" + timezone: "America/Los_Angeles" + open-pull-requests-limit: 10 + commit-message: + prefix: "[no-jira] bot: update github-actions image to " + diff --git a/.github/workflows/build-publish.yml b/.github/workflows/build-publish.yml new file mode 100644 index 000000000..36e1d9227 --- /dev/null +++ b/.github/workflows/build-publish.yml @@ -0,0 +1,57 @@ +name: build-publish +permissions: + contents: write + id-token: write + packages: write + +on: + pull_request_target: + types: + - closed + branches: + - master + +jobs: + build-publish: + name: build publish artifact + runs-on: ubuntu-latest + if: github.event.pull_request.merged == true + timeout-minutes: 20 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: master + fetch-depth: 0 + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 16.x + registry-url: https://npm.pkg.github.com/ + scope: '@parsable' + cache: yarn + env: + NODE_AUTH_TOKEN: ${{secrets.GH_PAT_CLASSIC_MACHINE_PARSABLE}} + - name: Install Dependencies + run: yarn install + env: + NODE_AUTH_TOKEN: ${{secrets.GH_PAT_CLASSIC_MACHINE_PARSABLE}} + - name: Tag + id: tag + run: | + truncated_version=1.0.4 + git config --global user.email "ops+machine-parsable@parsable.com" + git config --global user.name "machine-parsable" + npm version -m "Updating package.json for version ${truncated_version}" ${truncated_version} + git pull --ff-only + git push origin $(git branch --show-current) --tags + git status + echo "new_tag=${truncated_version}" >> $GITHUB_OUTPUT + - name: Release + env: + GITHUB_TOKEN: ${{ secrets.GH_PARSABLE_BOT_BYPASS }} + run: gh release create "${{steps.version.outputs.version}}" + - name: publishing artifact + run: npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}