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}} 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/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/package.json b/package.json index 9b56ef5e4..2274f9f1b 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.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/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/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 new file mode 100644 index 000000000..a20419eca --- /dev/null +++ b/src/templates/core/BaseHttpRequest.hbs @@ -0,0 +1,13 @@ +{{>header}} + +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>; +} diff --git a/src/templates/core/OpenAPI.hbs b/src/templates/core/OpenAPI.hbs index 2b59a9708..9c2678508 100644 --- a/src/templates/core/OpenAPI.hbs +++ b/src/templates/core/OpenAPI.hbs @@ -5,22 +5,23 @@ import type { ApiRequestOptions } from './ApiRequestOptions'; type Resolver = (options: ApiRequestOptions) => Promise; type Headers = Record; -type Config = { - BASE: string; - VERSION: string; - WITH_CREDENTIALS: boolean; - TOKEN?: string | Resolver; - USERNAME?: string | Resolver; - PASSWORD?: string | Resolver; - HEADERS?: Headers | Resolver; +export type ClientConfig = { + baseUrl?: string; + version?: string; + withCredentials?: boolean; + token?: string | Resolver; + username?: string | Resolver; + password?: string | Resolver; + headers?: Headers | Resolver; } - -export const OpenAPI: Config = { - BASE: '{{{server}}}', - VERSION: '{{{version}}}', - WITH_CREDENTIALS: false, - TOKEN: undefined, - USERNAME: undefined, - PASSWORD: undefined, - HEADERS: undefined, +{{#unless @root.exportClient}} +export const OpenAPI: ClientConfig = { + 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 3d1a62c7e..82676f4c9 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: 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', diff --git a/src/templates/core/fetch/request.hbs b/src/templates/core/fetch/request.hbs index c22330e51..980f4d3a3 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 { ClientConfig } from './OpenAPI'; +{{#if @root.exportClient}} +import type { BaseHttpRequest } from './BaseHttpRequest'; +{{else}} import { OpenAPI } from './OpenAPI'; +{{/if}} {{>functions/isDefined}} @@ -11,6 +16,9 @@ import { OpenAPI } from './OpenAPI'; {{>functions/isString}} +{{>functions/deepAssign}} + + {{>functions/isStringWithValue}} @@ -47,6 +55,36 @@ import { OpenAPI } from './OpenAPI'; {{>functions/catchErrors}} +{{#if @root.exportClient}} +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; + } +} +{{else}} /** * Request using fetch client * @param options The request options from the the service @@ -54,8 +92,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 +108,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..5bb9ae4f4 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: ClientConfig, 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.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 be040bbb6..848e3fc8b 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: ClientConfig): string { const path = options.path.replace(/[:]/g, '_'); - const url = `${OpenAPI.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 new file mode 100644 index 000000000..ff17398b6 --- /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 type { BaseHttpRequest } from './BaseHttpRequest'; +export { {{{httpRequestName}}} } from './{{{httpRequestName}}}'; +export type { ClientConfig } from './OpenAPI'; +{{else}} +export { OpenAPI } from './OpenAPI'; +export { request } from './request'; +{{/if}} diff --git a/src/templates/core/node/getHeaders.hbs b/src/templates/core/node/getHeaders.hbs index fc6d55164..8711afe80 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: 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', diff --git a/src/templates/core/node/request.hbs b/src/templates/core/node/request.hbs index 1bf15050b..b17cfb324 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 { ClientConfig } from './OpenAPI'; +{{#if @root.exportClient}} +import type { BaseHttpRequest } from './BaseHttpRequest'; +{{else}} import { OpenAPI } from './OpenAPI'; +{{/if}} {{>functions/isDefined}} @@ -15,6 +20,9 @@ import { OpenAPI } from './OpenAPI'; {{>functions/isString}} +{{>functions/deepAssign}} + + {{>functions/isStringWithValue}} @@ -51,6 +59,36 @@ import { OpenAPI } from './OpenAPI'; {{>functions/catchErrors}} +{{#if @root.exportClient}} +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, 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; + } +} +{{else}} /** * Request using node-fetch client * @param options The request options from the the service @@ -58,8 +96,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 +112,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..0eba4e8dc 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: ClientConfig, 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..82676f4c9 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: 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', diff --git a/src/templates/core/xhr/request.hbs b/src/templates/core/xhr/request.hbs index 9faf192f2..832b964dd 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 { ClientConfig } from './OpenAPI'; +{{#if @root.exportClient}} +import type { BaseHttpRequest } from './BaseHttpRequest'; +{{else}} import { OpenAPI } from './OpenAPI'; +{{/if}} + {{>functions/isDefined}} @@ -11,6 +17,9 @@ import { OpenAPI } from './OpenAPI'; {{>functions/isString}} +{{>functions/deepAssign}} + + {{>functions/isStringWithValue}} @@ -50,6 +59,36 @@ import { OpenAPI } from './OpenAPI'; {{>functions/catchErrors}} +{{#if @root.exportClient}} +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, 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 = 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 +96,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 +112,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..687c9fff6 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: ClientConfig, url: string): Promise { const xhr = new XMLHttpRequest(); xhr.open(options.method, url, true); - xhr.withCredentials = OpenAPI.WITH_CREDENTIALS; + xhr.withCredentials = config.withCredentials ?? 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..a3b93070f --- /dev/null +++ b/src/templates/exportAppClient.hbs @@ -0,0 +1,39 @@ +{{>header}} + +import type { BaseHttpRequest } from './core'; +import { {{{httpClientRequest}}} } from './core'; +import type { ClientConfig } from './core'; +{{#if services}} +import { +{{#each services}} + {{{name}}}, +{{/each}} +} from './services'; +{{/if}} +{{#if service}} +import { {{{service.name}}} } from './services'; +{{/if}} + +export class {{{clientName}}} {{#if service}}extends {{{service.name}}} {{/if}}{ +{{#each services}} + readonly {{{shortName}}}: {{{name}}}; +{{/each}} + + 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, + } + {{#if service}} + super(httpClient, config); + {{/if}} + {{#each services}} + this.{{{shortName}}} = new {{{name}}}(httpClient, config); + {{/each}} + } +} diff --git a/src/templates/index.hbs b/src/templates/index.hbs index e10436ba6..3b8deb6f9 100644 --- a/src/templates/index.hbs +++ b/src/templates/index.hbs @@ -1,38 +1,18 @@ {{>header}} -{{#if @root.exportCore}} -export { ApiError } from './core/ApiError'; -export { OpenAPI } from './core/OpenAPI'; +{{#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}} +export * from './services'; {{/if}} + +{{#if @root.exportClient}} +export { {{{clientName}}} } from './client'; {{/if}} 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/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 */ diff --git a/src/templates/partials/parameters.hbs b/src/templates/partials/parameters.hbs index a911f3a42..24f3c81db 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?: ClientConfig{{/if}} {{~else}} {{#each parameters}} {{{name}}}{{>isRequired}}: {{>type}}{{#if default}} = {{{default}}}{{/if}}, {{/each}} +{{#if @root.exportClient}}config?: ClientConfig{{/if}} {{/if}} -{{/if}} +{{else}}{{#if @root.exportClient}}config?: ClientConfig{{/if}}{{/if}} diff --git a/src/templates/partials/passParameters.hbs b/src/templates/partials/passParameters.hbs new file mode 100644 index 000000000..3b67efc59 --- /dev/null +++ b/src/templates/partials/passParameters.hbs @@ -0,0 +1,10 @@ +{{#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/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/services/exportService.hbs b/src/templates/services/exportService.hbs new file mode 100644 index 000000000..fd272b03b --- /dev/null +++ b/src/templates/services/exportService.hbs @@ -0,0 +1,61 @@ +{{>header}} + +{{#if imports}} +import type { +{{#each imports}} +{{{this}}}, +{{/each}} +} from '../models'; +{{/if}} +{{#if @root.exportClient}} +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; + readonly full: {{{name}}}Full; + + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + this.full = new {{{name}}}Full(httpRequest, 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}}): 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/exportService.hbs b/src/templates/services/exportServiceFull.hbs similarity index 65% rename from src/templates/exportService.hbs rename to src/templates/services/exportServiceFull.hbs index c45ed830d..df742f3f5 100644 --- a/src/templates/exportService.hbs +++ b/src/templates/services/exportServiceFull.hbs @@ -1,16 +1,34 @@ {{>header}} {{#if imports}} +import type { {{#each imports}} -import type { {{{this}}} } from '../models/{{{this}}}'; + {{{this}}}, {{/each}} +} from '../models'; {{/if}} -import { request as __request } from '../core/request'; +{{#if @root.exportClient}} +import type { ApiResult, BaseHttpRequest, ClientConfig } from '../core'; +{{else}} +import type { ApiResult } from '../core'; +import { + request as __request, {{#if @root.useVersion}} -import { OpenAPI } from '../core/OpenAPI'; + OpenAPI, {{/if}} +} from '../core'; +{{/if}} + +export class {{{name}}}Full { + {{#if @root.exportClient}} + private readonly httpRequest: BaseHttpRequest; + private readonly clientConfig: ClientConfig; -export class {{{name}}} { + constructor(httpRequest: BaseHttpRequest, clientConfig: ClientConfig) { + this.httpRequest = httpRequest; + this.clientConfig = clientConfig; + } + {{/if}} {{#each operations}} /** @@ -30,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 static async {{{name}}}({{>parameters}}): Promise<{{>result}}> { - const result = await __request({ + * @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}} @@ -83,8 +102,7 @@ export class {{{name}}} { {{/each}} }, {{/if}} - }); - return result.body; + }{{#if @root.exportClient}}, this.clientConfig, config{{/if}}); } {{/each}} diff --git a/src/templates/services/index.hbs b/src/templates/services/index.hbs new file mode 100644 index 000000000..4b5c22683 --- /dev/null +++ b/src/templates/services/index.hbs @@ -0,0 +1,6 @@ +{{>header}} + +{{#each services}} +export { {{{name}}} } from './{{{name}}}'; +export { {{{name}}}Full } from './{{{name}}}Full'; +{{/each}} 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..88c0e235b 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.clientConfig.version}' : '${OpenAPI.version}'); + return clone; }); } diff --git a/src/utils/registerHandlebarTemplates.spec.ts b/src/utils/registerHandlebarTemplates.spec.ts index 5e1302384..1aea8fc12 100644 --- a/src/utils/registerHandlebarTemplates.spec.ts +++ b/src/utils/registerHandlebarTemplates.spec.ts @@ -9,13 +9,18 @@ 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(); expect(templates.core.apiResult).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 347b2b98b..7de4c2daa 100644 --- a/src/utils/registerHandlebarTemplates.ts +++ b/src/utils/registerHandlebarTemplates.ts @@ -4,6 +4,7 @@ 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 fetchGetHeaders from '../templates/core/fetch/getHeaders.hbs'; import fetchGetRequestBody from '../templates/core/fetch/getRequestBody.hbs'; import fetchGetResponseBody from '../templates/core/fetch/getResponseBody.hbs'; @@ -11,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'; @@ -21,6 +23,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'; @@ -35,10 +38,10 @@ 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 templateExportModel from '../templates/exportModel.hbs'; -import templateExportSchema from '../templates/exportSchema.hbs'; -import templateExportService from '../templates/exportService.hbs'; +import templateAppClient from '../templates/exportAppClient.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'; @@ -49,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'; @@ -66,21 +70,42 @@ 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 templateExportServiceFull from '../templates/services/exportServiceFull.hbs'; +import templateExportServiceIndex from '../templates/services/index.hbs'; import { registerHandlebarHelpers } from './registerHandlebarHelpers'; export interface Templates { index: Handlebars.TemplateDelegate; - exports: { + client: Handlebars.TemplateDelegate; + models: { model: Handlebars.TemplateDelegate; - schema: Handlebars.TemplateDelegate; + index: Handlebars.TemplateDelegate; + }; + services: { service: Handlebars.TemplateDelegate; + serviceFull: 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; apiResult: Handlebars.TemplateDelegate; + baseHttpRequest: Handlebars.TemplateDelegate; request: Handlebars.TemplateDelegate; + httpRequest: { + fetch: Handlebars.TemplateDelegate; + node: Handlebars.TemplateDelegate; + xhr: Handlebars.TemplateDelegate; + }; }; } @@ -94,17 +119,33 @@ 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), - exports: { + client: Handlebars.template(templateAppClient), + models: { model: Handlebars.template(templateExportModel), - schema: Handlebars.template(templateExportSchema), + index: Handlebars.template(templateExportModelIndex), + }, + services: { service: Handlebars.template(templateExportService), + serviceFull: Handlebars.template(templateExportServiceFull), + 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), apiResult: Handlebars.template(templateCoreApiResult), + baseHttpRequest: Handlebars.template(templateCoreBaseHttpClient), request: Handlebars.template(templateCoreRequest), + httpRequest: { + fetch: Handlebars.template(fetchRequest), + node: Handlebars.template(nodeRequest), + xhr: Handlebars.template(xhrRequest), + }, }, }; @@ -118,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)); @@ -148,6 +190,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/writeAppClient.spec.ts b/src/utils/writeAppClient.spec.ts new file mode 100644 index 000000000..abafed8cf --- /dev/null +++ b/src/utils/writeAppClient.spec.ts @@ -0,0 +1,44 @@ +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', + request: () => 'concreteHttpRequest', + httpRequest: { + fetch: () => 'fetchRequest', + node: () => 'nodeRequest', + xhr: () => 'xhrRequest', + }, + }, + }; + + 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..bf06b5a03 --- /dev/null +++ b/src/utils/writeAppClient.ts @@ -0,0 +1,35 @@ +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) + .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, + version: client.version, + }) + ); +} diff --git a/src/utils/writeClient.spec.ts b/src/utils/writeClient.spec.ts index 75fdf1771..a91b53419 100644 --- a/src/utils/writeClient.spec.ts +++ b/src/utils/writeClient.spec.ts @@ -17,21 +17,36 @@ describe('writeClient', () => { const templates: Templates = { index: () => 'index', - exports: { + client: () => 'client', + 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: () => 'request', + httpRequest: { + fetch: () => 'fetchRequest', + node: () => 'nodeRequest', + xhr: () => 'xhrRequest', + }, }, }; - 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..e2c86e22c 100644 --- a/src/utils/writeClientCore.spec.ts +++ b/src/utils/writeClientCore.spec.ts @@ -7,36 +7,64 @@ 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', + const templates: Templates = { + index: () => 'index', + client: () => 'client', + models: { + model: () => 'model', + 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: () => 'request', + httpRequest: { + fetch: () => 'fetchRequest', + node: () => 'nodeRequest', + xhr: () => 'xhrRequest', }, - core: { - settings: () => 'settings', - apiError: () => 'apiError', - apiRequestOptions: () => 'apiRequestOptions', - apiResult: () => 'apiResult', - request: () => 'request', - }, - }; + }, + }; - 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('/index.ts', 'coreIndex'); + }); + + 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', 'fetchRequest'); + expect(writeFile).toBeCalledWith('/index.ts', 'coreIndex'); }); }); diff --git a/src/utils/writeClientCore.ts b/src/utils/writeClientCore.ts index c7cac72f8..f76c62ae7 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,28 @@ 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, + httpRequestName: getHttpRequestName(httpClient), }; 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.httpRequest[httpClient](context)); + } else { + await writeFile(resolve(outputPath, `request.ts`), templates.core.request(context)); + } if (request) { const requestFile = resolve(process.cwd(), request); @@ -34,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 ded3932fb..583bf070e 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,21 +17,36 @@ describe('writeClientIndex', () => { const templates: Templates = { index: () => 'index', - exports: { + client: () => 'client', + 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: () => 'request', + httpRequest: { + fetch: () => 'fetchRequest', + node: () => 'nodeRequest', + xhr: () => 'xhrRequest', + }, }, }; - 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..207a371c3 100644 --- a/src/utils/writeClientModels.spec.ts +++ b/src/utils/writeClientModels.spec.ts @@ -30,22 +30,38 @@ describe('writeClientModels', () => { const templates: Templates = { index: () => 'index', - exports: { + client: () => 'client', + 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: () => 'request', + httpRequest: { + fetch: () => 'fetchRequest', + node: () => 'nodeRequest', + xhr: () => 'xhrRequest', + }, }, }; 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 fd69fc1b4..8bc152056 100644 --- a/src/utils/writeClientSchemas.spec.ts +++ b/src/utils/writeClientSchemas.spec.ts @@ -30,22 +30,38 @@ describe('writeClientSchemas', () => { const templates: Templates = { index: () => 'index', - exports: { + client: () => 'client', + 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: () => 'request', + httpRequest: { + fetch: () => 'fetchRequest', + node: () => 'nodeRequest', + xhr: () => 'xhrRequest', + }, }, }; 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 a1be88096..d5eda3a31 100644 --- a/src/utils/writeClientServices.spec.ts +++ b/src/utils/writeClientServices.spec.ts @@ -18,22 +18,40 @@ describe('writeClientServices', () => { const templates: Templates = { index: () => 'index', - exports: { + client: () => 'client', + models: { model: () => 'model', - schema: () => 'schema', + index: () => 'modelIndex', + }, + services: { service: () => 'service', + serviceFull: () => 'serviceFull', + index: () => 'serviceIndex', + }, + schemas: { + schema: () => 'schema', + index: () => 'schemaIndex', }, core: { + index: () => 'coreIndex', settings: () => 'settings', apiError: () => 'apiError', apiRequestOptions: () => 'apiRequestOptions', apiResult: () => 'apiResult', + baseHttpRequest: () => 'baseHttpRequest', request: () => 'request', + httpRequest: { + fetch: () => 'fetchRequest', + node: () => 'nodeRequest', + xhr: () => 'xhrRequest', + }, }, }; - await writeClientServices(services, templates, '/', HttpClient.FETCH, false, false); + 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 8f82e0ce4..79f2450de 100644 --- a/src/utils/writeClientServices.ts +++ b/src/utils/writeClientServices.ts @@ -4,9 +4,11 @@ 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'; +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. @@ -16,18 +18,43 @@ 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)); - const templateResult = templates.exports.service({ + const templateResult = templates.services.service({ ...service, httpClient, useUnionTypes, useVersion, useOptions, + exportClient, + 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 new file mode 100644 index 000000000..cfa4b28b8 --- /dev/null +++ b/test/__snapshots__/index.client.spec.js.snap @@ -0,0 +1,9321 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +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 */ +/* eslint-disable */ +import type { BaseHttpRequest } from './core'; +import { FetchHttpRequest } from './core'; +import type { ClientConfig } from './core'; +import { + SimpleService, +} from './services'; +import { Service } from './services'; + +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[`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 */ +/* 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 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 */ +/* 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 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 */ +/* eslint-disable */ +export type ApiResult = { + readonly url: string; + readonly ok: boolean; + readonly status: number; + readonly statusText: string; + readonly body: T; +}" +`; + +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 */ +/* eslint-disable */ +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[`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 */ +/* 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; +} + +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 !== ''; +} + +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}\`; + + 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[`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 */ +/* eslint-disable */ +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[`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 */ +/* 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'; +" +`; + +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 */ +/* eslint-disable */ +export * from './core'; +export * from './models'; +export * from './schemas'; +export * from './services'; + +export { TestClient } from './client'; +" +`; + +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 */ +" +`; + +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 */ +" +`; + +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'; + +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[`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'; + +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[`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'; + +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[`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'; + +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[`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 */ +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/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'; + +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; + + 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/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[`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 */ +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`] = ` +"/* 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[`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'; + +export interface BaseHttpRequest { + request( + options: ApiRequestOptions, + config: ClientConfig, + mergeConfig?: ClientConfig + ): Promise>; +}" +`; + +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'; + +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'; +} + +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 !== ''; +} + +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}\`; + + 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[`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'; + +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/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'; +" +`; + +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'; + +export { TestClient } from './client'; +" +`; + +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 simple array containing an array + */ +export type ArrayWithArray = Array>;" +`; + +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 simple array with booleans + */ +export type ArrayWithBooleans = Array;" +`; + +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 simple array with numbers + */ +export type ArrayWithNumbers = Array;" +`; + +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 */ + +/** + * 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`] = ` +"/* 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 with references + */ +export type ArrayWithReferences = Array;" +`; + +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 simple array with strings + */ +export type ArrayWithStrings = Array;" +`; + +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 */ + +/** + * 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 */ + +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`] = ` +"/* 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[`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 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 */ + +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`] = ` +"/* 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[`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 */ + +/** + * 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`] = ` +"/* 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[`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 */ + +/** + * 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`] = ` +"/* 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[`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 */ + +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`] = ` +"/* 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[`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 */ + +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`] = ` +"/* 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[`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 */ + +/** + * 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`] = ` +"/* 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[`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 */ + +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`] = ` +"/* 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[`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 */ + +/** + * 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`] = ` +"/* 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[`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 */ + +/** + * 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`] = ` +"/* 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[`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 */ + +/** + * 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`] = ` +"/* 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 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`] = ` +"/* 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[`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 */ + +/** + * 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`] = ` +"/* 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; + 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`] = ` +"/* 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[`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 */ + +/** + * 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`] = ` +"/* 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[`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 */ + +/** + * This is a simple boolean + */ +export type SimpleBoolean = boolean;" +`; + +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 */ + +/** + * This is a simple file + */ +export type SimpleFile = Blob;" +`; + +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 */ + +/** + * This is a simple number + */ +export type SimpleInteger = number;" +`; + +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 */ + +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`] = ` +"/* 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[`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 */ + +/** + * 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/$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[`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 $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', + }, + }, + }, +};" +`; + +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 $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', + }, +};" +`; + +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', +};" +`; + +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 $DictionaryWithArray = { + type: 'dictionary', + contains: { + type: 'array', + contains: { + type: 'ModelWithString', + }, + }, +};" +`; + +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 $DictionaryWithDictionary = { + type: 'dictionary', + contains: { + type: 'dictionary', + contains: { + type: 'string', + }, + }, +};" +`; + +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 $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`] = ` +"/* 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[`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 */ +export const $DictionaryWithString = { + type: 'dictionary', + contains: { + type: 'string', + }, +};" +`; + +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/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[`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', +};" +`; + +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', +};" +`; + +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', + }, + propExtendsB: { + type: 'ModelWithString', + }, + }, + }], +};" +`; + +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 */ +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`] = ` +"/* 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[`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 */ +export const $ModelWithBoolean = { + properties: { + prop: { + type: 'boolean', + }, + }, +};" +`; + +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', + }, + }, +};" +`; + +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', + }, + }, + }, +};" +`; + +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 */ +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`] = ` +"/* 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/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[`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 */ +export const $ModelWithEnumFromDescription = { + properties: { + test: { + type: 'Enum', + }, + }, +};" +`; + +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 */ +export const $ModelWithInteger = { + properties: { + prop: { + type: 'number', + }, + }, +};" +`; + +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 */ +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`] = ` +"/* 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, + }, + }, +};" +`; + +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 */ +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/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[`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, + }, + }, +};" +`; + +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', + }, + }, +};" +`; + +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', + }, + }, +};" +`; + +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/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[`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', +};" +`; + +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', +};" +`; + +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', +};" +`; + +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/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, + 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) { + 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, + 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/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 { + 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; + } + +}" +`; + +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 ModelWithString Successful response + * @throws ApiError + */ + public async complexTypes( + parameterObject: { + first?: { + second?: { + third?: 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); + } + +}" +`; + +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 { 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 = '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) { + 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!\\" + }, + 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[`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 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: '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[`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 { 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[`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) { + 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[`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 */ +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; + } + +}" +`; + +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) { + 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); + } + +}" +`; + +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 */ +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 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) { + this.httpRequest = httpRequest; + this.clientConfig = 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 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); + } + + /** + * @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/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 Message for default response + * @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[`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 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 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; + } + + /** + * @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); + } + + /** + * @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[`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'; + +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); + } + + /** + * @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) { + 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[`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 { 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[`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'; + +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[`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'; + +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 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 */ +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 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 */ +export type ApiResult = { + readonly url: string; + readonly ok: boolean; + readonly status: number; + readonly statusText: string; + readonly body: T; +}" +`; + +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'; + +export interface BaseHttpRequest { + request( + options: ApiRequestOptions, + config: ClientConfig, + mergeConfig?: ClientConfig + ): Promise>; +}" +`; + +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'; + +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'; +} + +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 !== ''; +} + +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}\`; + + 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[`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'; + +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 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 */ +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 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'; + +export { TestClient } from './client'; +" +`; + +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 */ +" +`; + +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 */ +" +`; + +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'; + +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 (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; + } + +}" +`; + +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; + } + + /** + * @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); + } + +}" +`; + +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 */ +export { Service } from './Service'; +export { ServiceFull } from './ServiceFull'; +" +`; + +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'; + +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 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'; + +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 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 */ +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 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 */ +export type ApiResult = { + readonly url: string; + readonly ok: boolean; + readonly status: number; + readonly statusText: string; + readonly body: T; +}" +`; + +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'; + +export interface BaseHttpRequest { + request( + options: ApiRequestOptions, + config: ClientConfig, + mergeConfig?: ClientConfig + ): Promise>; +}" +`; + +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'; + +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'; +} + +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 !== ''; +} + +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}\`; + + 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 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 */ +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 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 { 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 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 * from './core'; +export * from './models'; +export * from './schemas'; +export * from './services'; + +export { TestClient } from './client'; +" +`; + +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 */ +" +`; + +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 */ +" +`; + +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 */ +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 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 */ +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 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 */ +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 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 */ +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 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 { 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/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 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/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 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`] = ` +"/* 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/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 interface BaseHttpRequest { + request( + options: ApiRequestOptions, + config: ClientConfig, + mergeConfig?: ClientConfig + ): Promise>; +}" +`; + +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 { 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; +} + +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 !== ''; +} + +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}\`; + + 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/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'; + +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/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'; +" +`; + +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'; + +export { TestClient } from './client'; +" +`; + +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 */ + +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 */ + +/** + * 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`] = ` +"/* 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 numbers + */ +export type ArrayWithNumbers = Array;" +`; + +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 */ + +/** + * 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`] = ` +"/* 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 with references + */ +export type ArrayWithReferences = Array;" +`; + +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 */ + +/** + * 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`] = ` +"/* 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 '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`] = ` +"/* 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'; +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`] = ` +"/* 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; +} +" +`; + +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 */ + +/** + * 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`] = ` +"/* 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'; +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: { + 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`] = ` +"/* 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, + }, + }, + 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, + }, + }, + }, + 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, + }, + }, + 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!\\" + }, + 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[`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 + */ + 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/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 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) { + 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/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 { 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/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 + * @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/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; + + 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 + * @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; + } + + /** + * @param [config] the optional OpenAPI config to use + * @returns any OK + * @throws ApiError + */ + public async multipartResponse(config?: ClientConfig): Promise> { + return this.httpRequest.request({ + method: 'GET', + path: \`/api/v\${this.clientConfig.version}/multipart\`, + }, this.clientConfig, config); + } + +}" +`; + +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 { 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; + } + +}" +`; + +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; + } + + /** + * @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/services/ParametersService.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; + } + + /** + * @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; + } + + /** + * @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 this.httpRequest.request({ + method: 'GET', + path: \`/api/v\${this.clientConfig.version}/parameters/\${parameterPath}\`, + cookies: { + 'parameterCookie': parameterCookie, + }, + headers: { + 'parameterHeader': parameterHeader, + }, + query: { + 'parameterQuery': parameterQuery, + }, + formData: { + 'parameterForm': parameterForm, + }, + 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); + } + + /** + * @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 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 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; + } + + /** + * @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); + } + +}" +`; + +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 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; + } + + /** + * @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); + } + + /** + * @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/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[`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; + } + + /** + * @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); + } + + /** + * @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); + } + + /** + * @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) { + 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 | 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}/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/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; + } + + /** + * @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 this.httpRequest.request({ + method: 'POST', + path: \`/api/v\${this.clientConfig.version}/upload\`, + formData: { + 'file': file, + }, + }, 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); + } +}" +`; + +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 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 { 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 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 { 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; +} + +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 !== ''; +} + +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}\`; + + 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 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 { 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 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 */ +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 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'; + +export { TestClient } from './client'; +" +`; + +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 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 { 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 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; + } + +}" +`; + +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 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 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); + } + +}" +`; + +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 { Service } from './Service'; +export { ServiceFull } from './ServiceFull'; +" +`; diff --git a/test/__snapshots__/index.spec.js.snap b/test/__snapshots__/index.spec.js.snap index 0047c137c..3618474d0 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,20 +44,22 @@ 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 = { +export type ApiResult = { readonly url: string; readonly ok: boolean; readonly status: number; readonly statusText: string; - readonly body: any; + readonly body: T; }" `; 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'; @@ -63,34 +67,49 @@ import type { ApiRequestOptions } from './ApiRequestOptions'; type Resolver = (options: ApiRequestOptions) => Promise; type Headers = Record; -type Config = { - BASE: string; - VERSION: string; - WITH_CREDENTIALS: boolean; - TOKEN?: string | Resolver; - USERNAME?: string | Resolver; - PASSWORD?: string | Resolver; - HEADERS?: Headers | Resolver; +export type ClientConfig = { + baseUrl?: string; + version?: string; + withCredentials?: boolean; + token?: string | Resolver; + username?: string | Resolver; + password?: string | Resolver; + headers?: Headers | Resolver; } +export const OpenAPI: ClientConfig = { + baseUrl: 'http://localhost:3000/base', + version: '1.0', + withCredentials: false, + token: undefined, + username: undefined, + password: undefined, + headers: undefined, +}; +" +`; -export const OpenAPI: Config = { - BASE: 'http://localhost:3000/base', - VERSION: '1.0', - WITH_CREDENTIALS: false, - TOKEN: undefined, - USERNAME: undefined, - PASSWORD: undefined, - HEADERS: undefined, -};" +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'; import type { ApiRequestOptions } from './ApiRequestOptions'; import type { ApiResult } from './ApiResult'; +import type { ClientConfig } from './OpenAPI'; import { OpenAPI } from './OpenAPI'; function isDefined(value: T | null | undefined): value is Exclude { @@ -101,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 !== ''; } @@ -129,9 +168,9 @@ function getQueryString(params: Record): string { return ''; } -function getUrl(options: ApiRequestOptions): string { +function getUrl(options: ApiRequestOptions, config: ClientConfig): string { const path = options.path.replace(/[:]/g, '_'); - const url = \`\${OpenAPI.BASE}\${path}\`; + const url = \`\${config.baseUrl}\${path}\`; if (options.query) { return \`\${url}\${getQueryString(options.query)}\`; @@ -159,11 +198,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: 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', @@ -210,13 +249,13 @@ function getRequestBody(options: ApiRequestOptions): BodyInit | undefined { return undefined; } -async function sendRequest(options: ApiRequestOptions, url: string): Promise { +async function sendRequest(options: ApiRequestOptions, config: ClientConfig, 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.withCredentials) { request.credentials = 'include'; } return await fetch(url, request); @@ -278,8 +317,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,117 +332,26 @@ export async function request(options: ApiRequestOptions): Promise { catchErrors(options, result); return result; -}" +} +" `; 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 */ @@ -416,7 +364,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 */ @@ -427,7 +376,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 */ @@ -438,7 +388,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 */ @@ -452,7 +403,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 */ @@ -465,7 +417,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 */ @@ -476,7 +429,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 */ @@ -487,7 +441,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 */ @@ -500,7 +455,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 */ @@ -511,7 +467,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 */ @@ -525,7 +482,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 */ @@ -549,7 +508,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 */ @@ -564,7 +524,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 */ @@ -588,7 +549,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 */ @@ -615,7 +577,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 */ @@ -630,7 +593,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 */ @@ -647,7 +611,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 */ @@ -665,7 +630,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 */ @@ -683,7 +649,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 */ @@ -700,7 +667,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 */ @@ -714,7 +682,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 */ @@ -728,7 +697,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 */ @@ -746,7 +716,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 */ @@ -762,7 +733,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 */ @@ -813,7 +785,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 */ @@ -844,7 +817,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 */ @@ -861,7 +835,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 */ @@ -878,7 +853,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 */ @@ -896,7 +872,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 */ @@ -917,7 +894,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 */ @@ -933,7 +911,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 */ @@ -952,7 +931,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 */ @@ -978,7 +958,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 */ @@ -994,7 +975,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 */ @@ -1011,7 +993,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 */ @@ -1025,7 +1008,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 */ @@ -1036,7 +1020,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 */ @@ -1047,7 +1032,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 */ @@ -1058,7 +1044,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 */ @@ -1071,7 +1058,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 */ @@ -1082,7 +1070,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 */ @@ -1092,8 +1081,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 = { @@ -1108,7 +1148,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 = { @@ -1120,7 +1161,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 = { @@ -1132,7 +1174,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 = { @@ -1151,7 +1194,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 = { @@ -1163,7 +1207,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 = { @@ -1175,7 +1220,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 = { @@ -1184,7 +1230,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 = { @@ -1199,7 +1246,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 = { @@ -1214,7 +1262,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 = { @@ -1233,7 +1282,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 = { @@ -1245,7 +1295,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 = { @@ -1257,7 +1308,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 = { @@ -1266,7 +1318,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 = { @@ -1275,7 +1328,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 = { @@ -1284,7 +1338,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 = { @@ -1293,7 +1348,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 = { @@ -1314,7 +1370,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 = { @@ -1337,7 +1394,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 = { @@ -1365,7 +1423,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 = { @@ -1378,7 +1437,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 = { @@ -1391,7 +1451,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 = { @@ -1407,7 +1468,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 = { @@ -1426,7 +1488,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 = { @@ -1439,7 +1502,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 = { @@ -1458,7 +1522,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 = { @@ -1471,7 +1536,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 = { @@ -1484,7 +1550,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 = { @@ -1518,7 +1585,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 = { @@ -1545,7 +1613,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 = { @@ -1564,7 +1633,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 = { @@ -1583,7 +1653,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 = { @@ -1621,7 +1692,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 = { @@ -1669,7 +1741,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 = { @@ -1682,7 +1755,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 = { @@ -1695,7 +1769,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 = { @@ -1704,7 +1779,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 = { @@ -1713,7 +1789,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 = { @@ -1722,7 +1799,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 = { @@ -1731,7 +1809,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 = { @@ -1740,7 +1819,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 = { @@ -1749,7 +1829,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 = { @@ -1759,12 +1840,62 @@ 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 { CollectionFormatServiceFull } from './CollectionFormatServiceFull'; export class CollectionFormatService { @@ -1774,6 +1905,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( @@ -1782,10 +1914,49 @@ export class CollectionFormatService { parameterArrayTsv: Array, parameterArrayPipes: Array, parameterArrayMulti: Array, + ): Promise { - const result = await __request({ + 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 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) + + * @throws ApiError + */ + public static async collectionFormat( + parameterArrayCsv: Array, + parameterArraySsv: Array, + parameterArrayTsv: Array, + parameterArrayPipes: Array, + parameterArrayMulti: Array, + + ): Promise> { + return __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/collectionFormat\`, + path: \`/api/v\${OpenAPI.version}/collectionFormat\`, query: { 'parameterArrayCSV': parameterArrayCsv, 'parameterArraySSV': parameterArraySsv, @@ -1794,25 +1965,27 @@ export class CollectionFormatService { 'parameterArrayMulti': parameterArrayMulti, }, }); - return result.body; } }" `; 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 { ComplexServiceFull } from './ComplexServiceFull'; export class ComplexService { /** * @param parameterObject Parameter containing object * @param parameterReference Parameter containing reference + * @returns ModelWithString Successful response * @throws ApiError */ @@ -1825,10 +1998,53 @@ export class ComplexService { }, }, parameterReference: ModelWithString, + ): Promise> { - const result = await __request({ + 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 ComplexServiceFull { + + /** + * @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 __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/complex\`, + path: \`/api/v\${OpenAPI.version}/complex\`, query: { 'parameterObject': parameterObject, 'parameterReference': parameterReference, @@ -1838,19 +2054,20 @@ export class ComplexService { 500: \`500 server error\`, }, }); - return result.body; } }" `; 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 { DefaultsServiceFull } from './DefaultsServiceFull'; export class DefaultsService { @@ -1860,6 +2077,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( @@ -1870,10 +2088,102 @@ export class DefaultsService { 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 { - const result = await __request({ + 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 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 + + * @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 __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/defaults\`, + path: \`/api/v\${OpenAPI.version}/defaults\`, query: { 'parameterString': parameterString, 'parameterNumber': parameterNumber, @@ -1882,7 +2192,6 @@ export class DefaultsService { 'parameterModel': parameterModel, }, }); - return result.body; } /** @@ -1891,6 +2200,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( @@ -1901,10 +2211,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, @@ -1913,7 +2224,6 @@ export class DefaultsService { 'parameterModel': parameterModel, }, }); - return result.body; } /** @@ -1923,6 +2233,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( @@ -1932,10 +2243,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, @@ -1945,127 +2257,224 @@ export class DefaultsService { 'parameterStringWithEmptyDefault': parameterStringWithEmptyDefault, }, }); - return result.body; } }" `; 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 { DuplicateServiceFull } from './DuplicateServiceFull'; export class DuplicateService { /** + * @throws ApiError */ public static async duplicateName(): Promise { - const result = await __request({ + 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 DuplicateServiceFull { + + /** + + * @throws ApiError + */ + 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; } }" `; 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 { HeaderServiceFull } from './HeaderServiceFull'; export class HeaderService { /** + * @returns string Successful response * @throws ApiError */ public static async callWithResultFromHeader(): Promise { - const result = await __request({ + 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 HeaderServiceFull { + + /** + + * @returns string Successful response + * @throws ApiError + */ + 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; } }" `; 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 { NoContentServiceFull } from './NoContentServiceFull'; export class NoContentService { /** + * @returns void * @throws ApiError */ public static async callWithNoContentResponse(): Promise { - const result = await __request({ + 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 NoContentServiceFull { + + /** + + * @returns void + * @throws ApiError + */ + 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; } }" `; 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 { ParametersServiceFull } from './ParametersServiceFull'; export class ParametersService { @@ -2075,6 +2484,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( @@ -2083,22 +2493,11 @@ export class ParametersService { parameterForm: string, parameterBody: string, parameterPath: string, + ): Promise { - const result = await __request({ - method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/parameters/\${parameterPath}\`, - headers: { - 'parameterHeader': parameterHeader, - }, - query: { - 'parameterQuery': parameterQuery, - }, - formData: { - 'parameterForm': parameterForm, - }, - body: parameterBody, - }); - return result.body; + return (await ParametersServiceFull.callWithParameters( + parameterHeader, parameterQuery, parameterForm, parameterBody, parameterPath, + )).body; } /** @@ -2110,6 +2509,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( @@ -2121,191 +2521,397 @@ export class ParametersService { parameterPath2?: string, parameterPath3?: string, _default?: string, + ): Promise { - const result = await __request({ - method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/parameters/\${parameterPath1}/\${parameterPath2}/\${parameterPath3}\`, - headers: { - 'parameter.header': parameterHeader, - }, - query: { - 'parameter-query': parameterQuery, - 'default': _default, - }, - formData: { - 'parameter_form': parameterForm, - }, - body: parameterBody, - }); - return result.body; + return (await ParametersServiceFull.callWithWeirdParameterNames( + parameterHeader, parameterQuery, parameterForm, parameterBody, parameterPath1, parameterPath2, parameterPath3, _default, + )).body; } }" `; -exports[`v2 should generate: ./test/generated/v2/services/ResponseService.ts 1`] = ` -"/* istanbul ignore file */ +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 { 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 { ApiResult } from '../core'; +import { + request as __request, + OpenAPI, +} from '../core'; + +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 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 __request({ + method: 'GET', + path: \`/api/v\${OpenAPI.version}/parameters/\${parameterPath}\`, + headers: { + 'parameterHeader': parameterHeader, + }, + query: { + 'parameterQuery': parameterQuery, + }, + formData: { + 'parameterForm': parameterForm, + }, + body: parameterBody, + }); + } + + /** + * @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 __request({ + method: 'GET', + path: \`/api/v\${OpenAPI.version}/parameters/\${parameterPath1}/\${parameterPath2}/\${parameterPath3}\`, + headers: { + 'parameter.header': parameterHeader, + }, + query: { + 'parameter-query': parameterQuery, + 'default': _default, + }, + formData: { + 'parameter_form': parameterForm, + }, + body: parameterBody, + }); + } + +}" +`; + +exports[`v2 should generate: ./test/generated/v2/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 { ResponseServiceFull } from './ResponseServiceFull'; export class ResponseService { /** + * @returns ModelWithString Message for default response * @throws ApiError */ public static async callWithResponse(): Promise { - const result = await __request({ + 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 ResponseServiceFull { + + /** + + * @returns ModelWithString Message for default response + * @throws ApiError + */ + 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; } }" `; 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 { SimpleServiceFull } from './SimpleServiceFull'; export class SimpleService { /** + * @throws ApiError */ public static async getCallWithoutParametersAndResponse(): Promise { - const result = await __request({ + 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\`, + 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; } }" `; 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 { TypesServiceFull } from './TypesServiceFull'; export class TypesService { @@ -2318,6 +2924,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 @@ -2333,10 +2940,59 @@ export class TypesService { parameterBoolean: boolean = true, parameterObject: any = null, id?: number, + ): Promise { - const result = await __request({ + 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 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 + + * @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 __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/types\`, + path: \`/api/v\${OpenAPI.version}/types\`, query: { 'parameterArray': parameterArray, 'parameterDictionary': parameterDictionary, @@ -2347,14 +3003,42 @@ export class TypesService { 'parameterObject': parameterObject, }, }); - return result.body; } }" `; +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 { 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: ./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'; @@ -2377,7 +3061,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 = { @@ -2395,20 +3080,22 @@ 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 = { +export type ApiResult = { readonly url: string; readonly ok: boolean; readonly status: number; readonly statusText: string; - readonly body: any; + readonly body: T; }" `; 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'; @@ -2416,34 +3103,49 @@ import type { ApiRequestOptions } from './ApiRequestOptions'; type Resolver = (options: ApiRequestOptions) => Promise; type Headers = Record; -type Config = { - BASE: string; - VERSION: string; - WITH_CREDENTIALS: boolean; - TOKEN?: string | Resolver; - USERNAME?: string | Resolver; - PASSWORD?: string | Resolver; - HEADERS?: Headers | Resolver; +export type ClientConfig = { + baseUrl?: string; + version?: string; + withCredentials?: boolean; + token?: string | Resolver; + username?: string | Resolver; + password?: string | Resolver; + headers?: Headers | Resolver; } +export const OpenAPI: ClientConfig = { + baseUrl: 'http://localhost:3000/base', + version: '1.0', + withCredentials: false, + token: undefined, + username: undefined, + password: undefined, + headers: undefined, +}; +" +`; -export const OpenAPI: Config = { - BASE: 'http://localhost:3000/base', - VERSION: '1.0', - WITH_CREDENTIALS: false, - TOKEN: undefined, - USERNAME: undefined, - PASSWORD: undefined, - HEADERS: undefined, -};" +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'; import type { ApiRequestOptions } from './ApiRequestOptions'; import type { ApiResult } from './ApiResult'; +import type { ClientConfig } from './OpenAPI'; import { OpenAPI } from './OpenAPI'; function isDefined(value: T | null | undefined): value is Exclude { @@ -2454,6 +3156,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 !== ''; } @@ -2482,9 +3204,9 @@ function getQueryString(params: Record): string { return ''; } -function getUrl(options: ApiRequestOptions): string { +function getUrl(options: ApiRequestOptions, config: ClientConfig): string { const path = options.path.replace(/[:]/g, '_'); - const url = \`\${OpenAPI.BASE}\${path}\`; + const url = \`\${config.baseUrl}\${path}\`; if (options.query) { return \`\${url}\${getQueryString(options.query)}\`; @@ -2512,11 +3234,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: 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', @@ -2563,13 +3285,13 @@ function getRequestBody(options: ApiRequestOptions): BodyInit | undefined { return undefined; } -async function sendRequest(options: ApiRequestOptions, url: string): Promise { +async function sendRequest(options: ApiRequestOptions, config: ClientConfig, 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.withCredentials) { request.credentials = 'include'; } return await fetch(url, request); @@ -2631,8 +3353,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,130 +3368,26 @@ export async function request(options: ApiRequestOptions): Promise { catchErrors(options, result); return result; -}" +} +" `; 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 */ @@ -2782,7 +3400,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 */ @@ -2793,7 +3412,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 */ @@ -2804,7 +3424,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 */ @@ -2818,7 +3439,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 */ @@ -2831,7 +3453,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 */ @@ -2842,7 +3465,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 */ @@ -2862,7 +3486,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 */ @@ -2881,7 +3506,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 */ @@ -2901,7 +3527,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 */ @@ -2917,7 +3544,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 */ @@ -2936,7 +3564,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 */ @@ -2956,7 +3585,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 */ @@ -2972,7 +3602,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 */ @@ -2985,7 +3616,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 */ @@ -2996,7 +3628,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 */ @@ -3010,7 +3643,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 */ @@ -3034,7 +3669,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 */ @@ -3049,7 +3685,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 */ @@ -3073,7 +3710,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 */ @@ -3100,7 +3738,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 */ @@ -3115,7 +3754,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 */ @@ -3132,7 +3772,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 */ @@ -3150,7 +3791,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 */ @@ -3168,7 +3810,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 */ @@ -3185,7 +3828,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 */ @@ -3199,7 +3843,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 */ @@ -3213,7 +3858,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 */ @@ -3231,7 +3877,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 */ @@ -3247,7 +3894,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 */ @@ -3298,7 +3946,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 */ @@ -3329,7 +3978,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 */ @@ -3346,7 +3996,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 */ @@ -3363,7 +4014,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 */ @@ -3381,7 +4033,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 */ @@ -3397,7 +4050,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 */ @@ -3416,7 +4070,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 */ @@ -3443,7 +4098,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 */ @@ -3459,7 +4115,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 */ @@ -3476,7 +4133,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 */ @@ -3490,7 +4148,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 */ @@ -3501,7 +4160,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 */ @@ -3512,7 +4172,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 */ @@ -3523,7 +4184,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 */ @@ -3536,7 +4198,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 */ @@ -3547,7 +4210,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 */ @@ -3557,8 +4221,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 = { @@ -3573,7 +4293,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 = { @@ -3585,7 +4306,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 = { @@ -3597,7 +4319,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 = { @@ -3616,7 +4339,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 = { @@ -3628,7 +4352,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 = { @@ -3640,7 +4365,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 = { @@ -3667,7 +4393,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 = { @@ -3689,7 +4416,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 = { @@ -3716,7 +4444,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 = { @@ -3741,7 +4470,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 = { @@ -3763,7 +4493,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 = { @@ -3790,7 +4521,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 = { @@ -3815,7 +4547,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 = { @@ -3830,7 +4563,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 = { @@ -3845,7 +4579,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 = { @@ -3864,7 +4599,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 = { @@ -3876,7 +4612,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 = { @@ -3888,7 +4625,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 = { @@ -3897,7 +4635,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 = { @@ -3906,7 +4645,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 = { @@ -3915,7 +4655,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 = { @@ -3924,7 +4665,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 = { @@ -3945,7 +4687,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 = { @@ -3968,7 +4711,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 = { @@ -3996,7 +4740,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 = { @@ -4009,7 +4754,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 = { @@ -4022,7 +4768,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 = { @@ -4038,7 +4785,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 = { @@ -4057,7 +4805,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 = { @@ -4070,7 +4819,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 = { @@ -4089,7 +4839,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 = { @@ -4102,7 +4853,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 = { @@ -4115,7 +4867,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 = { @@ -4149,7 +4902,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 = { @@ -4179,7 +4933,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 = { @@ -4198,7 +4953,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 = { @@ -4236,7 +4992,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 = { @@ -4289,7 +5046,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 = { @@ -4302,7 +5060,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 = { @@ -4315,7 +5074,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 = { @@ -4324,7 +5084,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 = { @@ -4333,7 +5094,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 = { @@ -4342,7 +5104,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 = { @@ -4351,7 +5114,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 = { @@ -4360,7 +5124,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 = { @@ -4369,7 +5134,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 = { @@ -4380,12 +5146,67 @@ 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 { CollectionFormatServiceFull } from './CollectionFormatServiceFull'; export class CollectionFormatService { @@ -4395,6 +5216,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( @@ -4403,40 +5225,81 @@ export class CollectionFormatService { parameterArrayTsv: Array | null, parameterArrayPipes: Array | null, parameterArrayMulti: Array | null, + ): Promise { - const result = await __request({ - method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/collectionFormat\`, - query: { - 'parameterArrayCSV': parameterArrayCsv, - 'parameterArraySSV': parameterArraySsv, - 'parameterArrayTSV': parameterArrayTsv, + 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 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) + + * @throws ApiError + */ + public static async collectionFormat( + parameterArrayCsv: Array | null, + parameterArraySsv: Array | null, + parameterArrayTsv: Array | null, + parameterArrayPipes: Array | null, + parameterArrayMulti: Array | null, + + ): Promise> { + return __request({ + method: 'GET', + path: \`/api/v\${OpenAPI.version}/collectionFormat\`, + query: { + 'parameterArrayCSV': parameterArrayCsv, + 'parameterArraySSV': parameterArraySsv, + 'parameterArrayTSV': parameterArrayTsv, 'parameterArrayPipes': parameterArrayPipes, 'parameterArrayMulti': parameterArrayMulti, }, }); - return result.body; } }" `; 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 { ComplexServiceFull } from './ComplexServiceFull'; export class ComplexService { /** * @param parameterObject Parameter containing object * @param parameterReference Parameter containing reference + * @returns ModelWithString Successful response * @throws ApiError */ @@ -4449,10 +5312,85 @@ export class ComplexService { }, }, parameterReference: ModelWithString, + ): Promise> { - const result = await __request({ + 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 ComplexServiceFull { + + /** + * @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 __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/complex\`, + path: \`/api/v\${OpenAPI.version}/complex\`, query: { 'parameterObject': parameterObject, 'parameterReference': parameterReference, @@ -4462,12 +5400,12 @@ export class ComplexService { 500: \`500 server error\`, }, }); - return result.body; } /** * @param id * @param requestBody + * @returns ModelWithString Success * @throws ApiError */ @@ -4486,26 +5424,28 @@ 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; } }" `; 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 { DefaultsServiceFull } from './DefaultsServiceFull'; export class DefaultsService { @@ -4515,6 +5455,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( @@ -4525,10 +5466,102 @@ export class DefaultsService { 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 { - const result = await __request({ + 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 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 + + * @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 __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/defaults\`, + path: \`/api/v\${OpenAPI.version}/defaults\`, query: { 'parameterString': parameterString, 'parameterNumber': parameterNumber, @@ -4537,7 +5570,6 @@ export class DefaultsService { 'parameterModel': parameterModel, }, }); - return result.body; } /** @@ -4546,6 +5578,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( @@ -4556,10 +5589,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, @@ -4568,7 +5602,6 @@ export class DefaultsService { 'parameterModel': parameterModel, }, }); - return result.body; } /** @@ -4578,6 +5611,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( @@ -4587,10 +5621,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, @@ -4600,160 +5635,395 @@ export class DefaultsService { 'parameterStringWithEmptyDefault': parameterStringWithEmptyDefault, }, }); - return result.body; } }" `; 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 { DuplicateServiceFull } from './DuplicateServiceFull'; export class DuplicateService { /** + * @throws ApiError */ public static async duplicateName(): Promise { - const result = await __request({ + 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 DuplicateServiceFull { + + /** + + * @throws ApiError + */ + 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; } }" `; 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 { HeaderServiceFull } from './HeaderServiceFull'; export class HeaderService { /** + * @returns string Successful response * @throws ApiError */ public static async callWithResultFromHeader(): Promise { - const result = await __request({ + 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\`, + path: \`/api/v\${OpenAPI.version}/header\`, responseHeader: 'operation-location', errors: { 400: \`400 server error\`, 500: \`500 server error\`, }, }); - return result.body; } }" `; 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 { MultipartServiceFull } from './MultipartServiceFull'; export class MultipartService { - /** - * @returns any OK + /** + + * @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 MultipartServiceFull { + + /** + + * @returns any OK + * @throws ApiError + */ + public static async multipartResponse(): Promise> { + return __request({ + method: 'GET', + path: \`/api/v\${OpenAPI.version}/multipart\`, + }); + } + +}" +`; + +exports[`v3 should generate: ./test/generated/v3/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 { 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 NoContentServiceFull { + + /** + + * @returns void + * @throws ApiError + */ + public static async callWithNoContentResponse(): Promise> { + return __request({ + method: 'GET', + path: \`/api/v\${OpenAPI.version}/no-content\`, + }); + } + +}" +`; + +exports[`v3 should generate: ./test/generated/v3/services/ParametersService.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 { 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 multipartResponse(): Promise<{ - file?: string, - metadata?: { - foo?: string, - bar?: string, - }, - }> { - const result = await __request({ - method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/multipart\`, - }); - return result.body; + 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 -exports[`v3 should generate: ./test/generated/v3/services/NoContentService.ts 1`] = ` -"/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; + * @throws ApiError + */ + public static async getCallWithOptionalParam( + requestBody: ModelWithString, + parameter?: string, -export class NoContentService { + ): Promise { + return (await ParametersServiceFull.getCallWithOptionalParam( + requestBody, parameter, + )).body; + } /** - * @returns void + * @param parameter This is a required parameter + * @param requestBody This is an optional parameter + * @throws ApiError */ - public static async callWithNoContentResponse(): Promise { - const result = await __request({ - method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/no-content\`, - }); - return result.body; + public static async postCallWithOptionalParam( + parameter: string, + requestBody?: ModelWithString, + + ): Promise { + return (await ParametersServiceFull.postCallWithOptionalParam( + parameter, requestBody, + )).body; } }" `; -exports[`v3 should generate: ./test/generated/v3/services/ParametersService.ts 1`] = ` -"/* istanbul ignore file */ +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/ModelWithString'; -import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; +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 @@ -4762,6 +6032,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( @@ -4771,10 +6042,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, }, @@ -4790,7 +6062,6 @@ export class ParametersService { body: requestBody, mediaType: 'application/json', }); - return result.body; } /** @@ -4803,6 +6074,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( @@ -4815,10 +6087,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, }, @@ -4835,246 +6108,412 @@ 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; } }" `; 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 { RequestBodyServiceFull } from './RequestBodyServiceFull'; export class RequestBodyService { /** * @param requestBody A reusable request body + * @throws ApiError */ public static async postRequestBodyService( requestBody?: ModelWithString, + ): Promise { - const result = await __request({ + 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 RequestBodyServiceFull { + + /** + * @param requestBody A reusable request body + + * @throws ApiError + */ + public static async postRequestBodyService( + requestBody?: ModelWithString, + + ): 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; } }" `; 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 { ResponseServiceFull } from './ResponseServiceFull'; export class ResponseService { /** + * @returns ModelWithString * @throws ApiError */ public static async callWithResponse(): Promise { - const result = await __request({ + 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 ResponseServiceFull { + + /** + + * @returns ModelWithString + * @throws ApiError + */ + 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; } }" `; 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 { SimpleServiceFull } from './SimpleServiceFull'; export class SimpleService { /** + * @throws ApiError */ public static async getCallWithoutParametersAndResponse(): Promise { - const result = await __request({ + 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 SimpleServiceFull { + + /** + + * @throws ApiError + */ + 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; } }" `; 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 { TypesServiceFull } from './TypesServiceFull'; export class TypesService { @@ -5087,6 +6526,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 @@ -5102,10 +6542,59 @@ export class TypesService { parameterBoolean: boolean | null = true, parameterObject: any = null, id?: number, + ): Promise { - const result = await __request({ + 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 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 + + * @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 __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/types\`, + path: \`/api/v\${OpenAPI.version}/types\`, query: { 'parameterArray': parameterArray, 'parameterDictionary': parameterDictionary, @@ -5116,38 +6605,103 @@ export class TypesService { 'parameterObject': parameterObject, }, }); - return result.body; } }" `; 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 { 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 { - const result = await __request({ + 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 UploadServiceFull { + + /** + * @param file Supply a file reference for upload + + * @returns boolean + * @throws ApiError + */ + public static async uploadFile( + file: Blob, + + ): Promise> { + return __request({ method: 'POST', - path: \`/api/v\${OpenAPI.VERSION}/upload\`, + path: \`/api/v\${OpenAPI.version}/upload\`, formData: { 'file': file, }, }); - return result.body; } }" `; + +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 { 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/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..f691ab9b5 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'); @@ -25,7 +24,7 @@ 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'); @@ -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..12a808ab4 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'); @@ -25,7 +24,7 @@ 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'); @@ -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..10af31bdd 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,8 +17,8 @@ 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; + const tokenRequest = jest.fn().mockResolvedValue('MY_TOKEN'); + OpenAPI.token = tokenRequest; const result = await SimpleService.getCallWithoutParametersAndResponse(); expect(tokenRequest.mock.calls.length).toBe(1); expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); @@ -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..85cc1fd9e 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'); @@ -25,7 +24,7 @@ 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'); @@ -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..34a87418a 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'); @@ -25,9 +24,9 @@ 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'); @@ -36,9 +35,9 @@ describe('v3.fetch', () => { 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='); @@ -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..fac183e8b 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'); @@ -25,9 +24,9 @@ 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'); @@ -36,9 +35,9 @@ describe('v3.fetch', () => { 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='); @@ -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..7388cd6a9 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,10 +17,10 @@ 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; + const tokenRequest = jest.fn().mockResolvedValue('MY_TOKEN'); + 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'); @@ -29,9 +28,9 @@ describe('v3.node', () => { 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='); }); @@ -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..f1517e4ea 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'); @@ -25,9 +24,9 @@ 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'); @@ -36,9 +35,9 @@ describe('v3.xhr', () => { 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='); @@ -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..4edda3ebb --- /dev/null +++ b/test/index.client.spec.js @@ -0,0 +1,68 @@ +'use strict'; + +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 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); + }); + }); + + 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); + }); + }); +}); + +describe('v3', () => { + it('should generate with exportClient', async () => { + (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); + }); + }); + + 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/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 => { 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" + } + } + } +}