diff --git a/docs/authorization.md b/docs/authorization.md index 3682aff30..5247a48a0 100644 --- a/docs/authorization.md +++ b/docs/authorization.md @@ -22,3 +22,22 @@ const getToken = async () => { OpenAPI.TOKEN = getToken; ``` + +Also, you can pass `TOKEN` or any OpenAPI configuration params to method call. +```typescript +const organizations = new OrganizationsService(); +OpenAPI.BASE = 'https://example.com/api'; + +express.use(async (req, res) => { + const response = await organizations.createOrganization( + { + name: 'OrgName', + description: 'OrgDescription', + }, + { + TOKEN: getToken(req) + } + ); + res.send(response); +}) +``` diff --git a/src/templates/core/BaseHttpRequest.hbs b/src/templates/core/BaseHttpRequest.hbs index 43ff79cbb..bc7de33e5 100644 --- a/src/templates/core/BaseHttpRequest.hbs +++ b/src/templates/core/BaseHttpRequest.hbs @@ -23,9 +23,12 @@ export abstract class BaseHttpRequest { constructor(public readonly config: OpenAPIConfig) {} {{/equals}} + public abstract request( + options: ApiRequestOptions, + configOverrides?: OpenAPIConfig {{#equals @root.httpClient 'angular'}} - public abstract request(options: ApiRequestOptions): Observable; + ): Observable; {{else}} - public abstract request(options: ApiRequestOptions): CancelablePromise; + ): CancelablePromise; {{/equals}} } diff --git a/src/templates/core/HttpRequest.hbs b/src/templates/core/HttpRequest.hbs index e1620a3c0..2640726fe 100644 --- a/src/templates/core/HttpRequest.hbs +++ b/src/templates/core/HttpRequest.hbs @@ -37,25 +37,31 @@ export class {{httpRequest}} extends BaseHttpRequest { } {{/equals}} - {{#equals @root.httpClient 'angular'}} /** * Request method * @param options The request options from the service + * @param [configOverrides] Overrides OpenAPIConfig + {{#equals @root.httpClient 'angular'}} * @returns Observable - * @throws ApiError - */ - public override request(options: ApiRequestOptions): Observable { - return __request(this.config, this.http, options); - } {{else}} - /** - * Request method - * @param options The request options from the service * @returns CancelablePromise + {{/equals}} * @throws ApiError */ - public override request(options: ApiRequestOptions): CancelablePromise { - return __request(this.config, options); - } + public override request( + options: ApiRequestOptions, + configOverrides?: OpenAPIConfig + {{#equals @root.httpClient 'angular'}} + ): Observable { + {{else}} + ): CancelablePromise { {{/equals}} + return __request( + {...this.config, ...configOverrides}, + {{#equals @root.httpClient 'angular'}} + this.http, + {{/equals}} + options + ); + } } diff --git a/src/templates/exportService.hbs b/src/templates/exportService.hbs index d6bccbbeb..b7c81c83d 100644 --- a/src/templates/exportService.hbs +++ b/src/templates/exportService.hbs @@ -26,7 +26,9 @@ import { BaseHttpRequest } from '../core/BaseHttpRequest'; {{else}} import type { BaseHttpRequest } from '../core/BaseHttpRequest'; {{/equals}} +import type { OpenAPIConfig } from '../core/OpenAPI'; {{else}} +import type { OpenAPIConfig } from '../core/OpenAPI'; import { OpenAPI } from '../core/OpenAPI'; import { request as __request } from '../core/request'; {{/if}} @@ -63,6 +65,7 @@ export class {{{name}}}{{{@root.postfix}}} { {{#each parameters}} * @param {{{name}}} {{#if description}}{{{escapeComment description}}}{{/if}} {{/each}} + * @param [configOverrides] Overrides OpenAPIConfig {{/if}} {{/unless}} {{#each results}} @@ -71,81 +74,105 @@ export class {{{name}}}{{{@root.postfix}}} { * @throws ApiError */ {{#if @root.exportClient}} + public {{{name}}}( + {{>parameters}} + configOverrides?: OpenAPIConfig, {{#equals @root.httpClient 'angular'}} - public {{{name}}}({{>parameters}}): Observable<{{>result}}> { - return this.httpRequest.request({ + ): Observable<{{>result}}> { {{else}} - public {{{name}}}({{>parameters}}): CancelablePromise<{{>result}}> { - return this.httpRequest.request({ + ): CancelablePromise<{{>result}}> { {{/equals}} + return this.httpRequest.request( {{else}} {{#equals @root.httpClient 'angular'}} - public {{{name}}}({{>parameters}}): Observable<{{>result}}> { - return __request(OpenAPI, this.http, { + public {{{name}}}( + {{>parameters}} + configOverrides?: OpenAPIConfig, + ): Observable<{{>result}}> { + return __request( + { + ...OpenAPI, + ...configOverrides, + }, + this.http, {{else}} - public static {{{name}}}({{>parameters}}): CancelablePromise<{{>result}}> { - return __request(OpenAPI, { + public static {{{name}}}( + {{>parameters}} + configOverrides?: OpenAPIConfig, + ): CancelablePromise<{{>result}}> { + return __request( + { + ...OpenAPI, + ...configOverrides, + }, {{/equals}} {{/if}} - method: '{{{method}}}', - url: '{{{path}}}', - {{#if parametersPath}} - path: { - {{#each parametersPath}} - '{{{prop}}}': {{{name}}}, - {{/each}} - }, - {{/if}} - {{#if parametersCookie}} - cookies: { - {{#each parametersCookie}} - '{{{prop}}}': {{{name}}}, - {{/each}} - }, - {{/if}} - {{#if parametersHeader}} - headers: { - {{#each parametersHeader}} - '{{{prop}}}': {{{name}}}, - {{/each}} - }, - {{/if}} - {{#if parametersQuery}} - query: { - {{#each parametersQuery}} - '{{{prop}}}': {{{name}}}, - {{/each}} - }, - {{/if}} - {{#if parametersForm}} - formData: { - {{#each parametersForm}} - '{{{prop}}}': {{{name}}}, - {{/each}} - }, - {{/if}} - {{#if parametersBody}} - {{#equals parametersBody.in 'formData'}} - formData: {{{parametersBody.name}}}, - {{/equals}} - {{#equals parametersBody.in 'body'}} - body: {{{parametersBody.name}}}, - {{/equals}} - {{#if parametersBody.mediaType}} - mediaType: '{{{parametersBody.mediaType}}}', - {{/if}} - {{/if}} - {{#if responseHeader}} - responseHeader: '{{{responseHeader}}}', - {{/if}} - {{#if errors}} - errors: { - {{#each errors}} - {{{code}}}: `{{{escapeDescription description}}}`, - {{/each}} + { + method: '{{{method}}}', + url: '{{{path}}}', + {{#if parametersPath}} + path: { + {{#each parametersPath}} + '{{{prop}}}': {{{name}}}, + {{/each}} + }, + {{/if}} + {{#if parametersCookie}} + cookies: { + {{#each parametersCookie}} + '{{{prop}}}': {{{name}}}, + {{/each}} + }, + {{/if}} + {{#if parametersHeader}} + headers: { + {{#each parametersHeader}} + '{{{prop}}}': {{{name}}}, + {{/each}} + }, + {{/if}} + {{#if parametersQuery}} + query: { + {{#each parametersQuery}} + '{{{prop}}}': {{{name}}}, + {{/each}} + }, + {{/if}} + {{#if parametersForm}} + formData: { + {{#each parametersForm}} + '{{{prop}}}': {{{name}}}, + {{/each}} + }, + {{/if}} + {{#if parametersBody}} + {{#equals parametersBody.in 'formData'}} + formData: {{{parametersBody.name}}}, + {{/equals}} + {{#equals parametersBody.in 'body'}} + body: {{{parametersBody.name}}}, + {{/equals}} + {{#if parametersBody.mediaType}} + mediaType: '{{{parametersBody.mediaType}}}', + {{/if}} + {{/if}} + {{#if responseHeader}} + responseHeader: '{{{responseHeader}}}', + {{/if}} + {{#if errors}} + errors: { + {{#each errors}} + {{{code}}}: `{{{escapeDescription description}}}`, + {{/each}} + }, + {{/if}} + {{#if @root.exportClient}} }, - {{/if}} - }); + configOverrides, + {{else}} + } + {{/if}} + ); } {{/each}} diff --git a/src/templates/partials/parameters.hbs b/src/templates/partials/parameters.hbs index 57ab5a7d1..e67bc26f9 100644 --- a/src/templates/partials/parameters.hbs +++ b/src/templates/partials/parameters.hbs @@ -1,5 +1,5 @@ {{#if parameters}} -{{#if @root.useOptions~}} +{{#if @root.useOptions}} { {{#each parameters}} {{{name}}}{{#if default}} = {{{default}}}{{/if}}, @@ -18,9 +18,8 @@ {{/ifdef}} {{{name}}}{{>isRequired}}: {{>type}}, {{/each}} -} -{{~else}} - +}, +{{else}} {{#each parameters}} {{{name}}}{{>isRequired}}: {{>type}}{{#if default}} = {{{default}}}{{/if}}, {{/each}} diff --git a/test/__snapshots__/index.spec.ts.snap b/test/__snapshots__/index.spec.ts.snap index ef6b18554..1d8a7bada 100644 --- a/test/__snapshots__/index.spec.ts.snap +++ b/test/__snapshots__/index.spec.ts.snap @@ -1,5 +1,4672 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`client should generate: test/generated/client/Api.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { BaseHttpRequest } from './core/BaseHttpRequest'; +import type { OpenAPIConfig } from './core/OpenAPI'; +import { FetchHttpRequest } from './core/FetchHttpRequest'; +import { CollectionFormatService } from './services/CollectionFormatService'; +import { ComplexService } from './services/ComplexService'; +import { DefaultService } from './services/DefaultService'; +import { DefaultsService } from './services/DefaultsService'; +import { DeprecatedService } from './services/DeprecatedService'; +import { DescriptionsService } from './services/DescriptionsService'; +import { DuplicateService } from './services/DuplicateService'; +import { ErrorService } from './services/ErrorService'; +import { FormDataService } from './services/FormDataService'; +import { HeaderService } from './services/HeaderService'; +import { MultipartService } from './services/MultipartService'; +import { MultipleTags1Service } from './services/MultipleTags1Service'; +import { MultipleTags2Service } from './services/MultipleTags2Service'; +import { MultipleTags3Service } from './services/MultipleTags3Service'; +import { NoContentService } from './services/NoContentService'; +import { ParametersService } from './services/ParametersService'; +import { RequestBodyService } from './services/RequestBodyService'; +import { ResponseService } from './services/ResponseService'; +import { SimpleService } from './services/SimpleService'; +import { TypesService } from './services/TypesService'; +import { UploadService } from './services/UploadService'; +type HttpRequestConstructor = new (config: OpenAPIConfig) => BaseHttpRequest; +export class Api { + public readonly collectionFormat: CollectionFormatService; + public readonly complex: ComplexService; + public readonly default: DefaultService; + public readonly defaults: DefaultsService; + public readonly deprecated: DeprecatedService; + public readonly descriptions: DescriptionsService; + public readonly duplicate: DuplicateService; + public readonly error: ErrorService; + public readonly formData: FormDataService; + public readonly header: HeaderService; + public readonly multipart: MultipartService; + public readonly multipleTags1: MultipleTags1Service; + public readonly multipleTags2: MultipleTags2Service; + public readonly multipleTags3: MultipleTags3Service; + public readonly noContent: NoContentService; + public readonly parameters: ParametersService; + public readonly requestBody: RequestBodyService; + public readonly response: ResponseService; + public readonly simple: SimpleService; + public readonly types: TypesService; + public readonly upload: UploadService; + public readonly request: BaseHttpRequest; + constructor(config?: Partial, HttpRequest: HttpRequestConstructor = FetchHttpRequest) { + this.request = new HttpRequest({ + BASE: config?.BASE ?? 'http://localhost:3000/base', + VERSION: config?.VERSION ?? '1.0', + WITH_CREDENTIALS: config?.WITH_CREDENTIALS ?? false, + CREDENTIALS: config?.CREDENTIALS ?? 'include', + TOKEN: config?.TOKEN, + USERNAME: config?.USERNAME, + PASSWORD: config?.PASSWORD, + HEADERS: config?.HEADERS, + ENCODE_PATH: config?.ENCODE_PATH, + }); + this.collectionFormat = new CollectionFormatService(this.request); + this.complex = new ComplexService(this.request); + this.default = new DefaultService(this.request); + this.defaults = new DefaultsService(this.request); + this.deprecated = new DeprecatedService(this.request); + this.descriptions = new DescriptionsService(this.request); + this.duplicate = new DuplicateService(this.request); + this.error = new ErrorService(this.request); + this.formData = new FormDataService(this.request); + this.header = new HeaderService(this.request); + this.multipart = new MultipartService(this.request); + this.multipleTags1 = new MultipleTags1Service(this.request); + this.multipleTags2 = new MultipleTags2Service(this.request); + this.multipleTags3 = new MultipleTags3Service(this.request); + this.noContent = new NoContentService(this.request); + this.parameters = new ParametersService(this.request); + this.requestBody = new RequestBodyService(this.request); + this.response = new ResponseService(this.request); + this.simple = new SimpleService(this.request); + this.types = new TypesService(this.request); + this.upload = new UploadService(this.request); + } +} + +" +`; + +exports[`client should generate: test/generated/client/core/ApiError.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ApiRequestOptions } from './ApiRequestOptions'; +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; + public readonly request: ApiRequestOptions; + + constructor(request: ApiRequestOptions, response: ApiResult, message: string) { + super(message); + + this.name = 'ApiError'; + this.url = response.url; + this.status = response.status; + this.statusText = response.statusText; + this.body = response.body; + this.request = request; + } +} +" +`; + +exports[`client should generate: test/generated/client/core/ApiRequestOptions.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type ApiRequestOptions = { + readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH'; + readonly url: string; + readonly path?: Record; + 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[`client should generate: test/generated/client/core/ApiResult.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type ApiResult = { + readonly url: string; + readonly ok: boolean; + readonly status: number; + readonly statusText: string; + readonly body: any; +}; +" +`; + +exports[`client should generate: test/generated/client/core/BaseHttpRequest.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ApiRequestOptions } from './ApiRequestOptions'; +import type { CancelablePromise } from './CancelablePromise'; +import type { OpenAPIConfig } from './OpenAPI'; + +export abstract class BaseHttpRequest { + + constructor(public readonly config: OpenAPIConfig) {} + + public abstract request( + options: ApiRequestOptions, + configOverrides?: OpenAPIConfig + ): CancelablePromise; +} +" +`; + +exports[`client should generate: test/generated/client/core/CancelablePromise.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export class CancelError extends Error { + + constructor(message: string) { + super(message); + this.name = 'CancelError'; + } + + public get isCancelled(): boolean { + return true; + } +} + +export interface OnCancel { + readonly isResolved: boolean; + readonly isRejected: boolean; + readonly isCancelled: boolean; + + (cancelHandler: () => void): void; +} + +export class CancelablePromise implements Promise { + #isResolved: boolean; + #isRejected: boolean; + #isCancelled: boolean; + readonly #cancelHandlers: (() => void)[]; + readonly #promise: Promise; + #resolve?: (value: T | PromiseLike) => void; + #reject?: (reason?: any) => void; + + constructor( + executor: ( + resolve: (value: T | PromiseLike) => void, + reject: (reason?: any) => void, + onCancel: OnCancel + ) => void + ) { + this.#isResolved = false; + this.#isRejected = false; + this.#isCancelled = false; + this.#cancelHandlers = []; + this.#promise = new Promise((resolve, reject) => { + this.#resolve = resolve; + this.#reject = reject; + + const onResolve = (value: T | PromiseLike): void => { + if (this.#isResolved || this.#isRejected || this.#isCancelled) { + return; + } + this.#isResolved = true; + if (this.#resolve) this.#resolve(value); + }; + + const onReject = (reason?: any): void => { + if (this.#isResolved || this.#isRejected || this.#isCancelled) { + return; + } + this.#isRejected = true; + if (this.#reject) this.#reject(reason); + }; + + const onCancel = (cancelHandler: () => void): void => { + if (this.#isResolved || this.#isRejected || this.#isCancelled) { + return; + } + this.#cancelHandlers.push(cancelHandler); + }; + + Object.defineProperty(onCancel, 'isResolved', { + get: (): boolean => this.#isResolved, + }); + + Object.defineProperty(onCancel, 'isRejected', { + get: (): boolean => this.#isRejected, + }); + + Object.defineProperty(onCancel, 'isCancelled', { + get: (): boolean => this.#isCancelled, + }); + + return executor(onResolve, onReject, onCancel as OnCancel); + }); + } + + get [Symbol.toStringTag]() { + return "Cancellable Promise"; + } + + public then( + onFulfilled?: ((value: T) => TResult1 | PromiseLike) | null, + onRejected?: ((reason: any) => TResult2 | PromiseLike) | null + ): Promise { + return this.#promise.then(onFulfilled, onRejected); + } + + public catch( + onRejected?: ((reason: any) => TResult | PromiseLike) | null + ): Promise { + return this.#promise.catch(onRejected); + } + + public finally(onFinally?: (() => void) | null): Promise { + return this.#promise.finally(onFinally); + } + + public cancel(): void { + if (this.#isResolved || this.#isRejected || this.#isCancelled) { + return; + } + this.#isCancelled = true; + if (this.#cancelHandlers.length) { + try { + for (const cancelHandler of this.#cancelHandlers) { + cancelHandler(); + } + } catch (error) { + console.warn('Cancellation threw an error', error); + return; + } + } + this.#cancelHandlers.length = 0; + if (this.#reject) this.#reject(new CancelError('Request aborted')); + } + + public get isCancelled(): boolean { + return this.#isCancelled; + } +} +" +`; + +exports[`client should generate: test/generated/client/core/FetchHttpRequest.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ApiRequestOptions } from './ApiRequestOptions'; +import { BaseHttpRequest } from './BaseHttpRequest'; +import type { CancelablePromise } from './CancelablePromise'; +import type { OpenAPIConfig } from './OpenAPI'; +import { request as __request } from './request'; + +export class FetchHttpRequest extends BaseHttpRequest { + + constructor(config: OpenAPIConfig) { + super(config); + } + + /** + * Request method + * @param options The request options from the service + * @param [configOverrides] Overrides OpenAPIConfig + * @returns CancelablePromise + * @throws ApiError + */ + public override request( + options: ApiRequestOptions, + configOverrides?: OpenAPIConfig + ): CancelablePromise { + return __request( + {...this.config, ...configOverrides}, + options + ); + } +} +" +`; + +exports[`client should generate: test/generated/client/core/OpenAPI.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ApiRequestOptions } from './ApiRequestOptions'; + +type Resolver = (options: ApiRequestOptions) => Promise; +type Headers = Record; + +export type OpenAPIConfig = { + BASE: string; + VERSION: string; + WITH_CREDENTIALS: boolean; + CREDENTIALS: 'include' | 'omit' | 'same-origin'; + TOKEN?: string | Resolver | undefined; + USERNAME?: string | Resolver | undefined; + PASSWORD?: string | Resolver | undefined; + HEADERS?: Headers | Resolver | undefined; + ENCODE_PATH?: ((path: string) => string) | undefined; +}; + +export const OpenAPI: OpenAPIConfig = { + BASE: 'http://localhost:3000/base', + VERSION: '1.0', + WITH_CREDENTIALS: false, + CREDENTIALS: 'include', + TOKEN: undefined, + USERNAME: undefined, + PASSWORD: undefined, + HEADERS: undefined, + ENCODE_PATH: undefined, +}; +" +`; + +exports[`client should generate: test/generated/client/core/request.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import { ApiError } from './ApiError'; +import type { ApiRequestOptions } from './ApiRequestOptions'; +import type { ApiResult } from './ApiResult'; +import { CancelablePromise } from './CancelablePromise'; +import type { OnCancel } from './CancelablePromise'; +import type { OpenAPIConfig } from './OpenAPI'; + +export const isDefined = (value: T | null | undefined): value is Exclude => { + return value !== undefined && value !== null; +}; + +export const isString = (value: any): value is string => { + return typeof value === 'string'; +}; + +export const isStringWithValue = (value: any): value is string => { + return isString(value) && value !== ''; +}; + +export const isBlob = (value: any): value is Blob => { + return ( + typeof value === 'object' && + typeof value.type === 'string' && + typeof value.stream === 'function' && + typeof value.arrayBuffer === 'function' && + typeof value.constructor === 'function' && + typeof value.constructor.name === 'string' && + /^(Blob|File)$/.test(value.constructor.name) && + /^(Blob|File)$/.test(value[Symbol.toStringTag]) + ); +}; + +export const isFormData = (value: any): value is FormData => { + return value instanceof FormData; +}; + +export const base64 = (str: string): string => { + try { + return btoa(str); + } catch (err) { + // @ts-ignore + return Buffer.from(str).toString('base64'); + } +}; + +export const getQueryString = (params: Record): string => { + const qs: string[] = []; + + const append = (key: string, value: any) => { + qs.push(\`\${encodeURIComponent(key)}=\${encodeURIComponent(String(value))}\`); + }; + + const process = (key: string, value: any) => { + if (isDefined(value)) { + if (Array.isArray(value)) { + value.forEach(v => { + process(key, v); + }); + } else if (typeof value === 'object') { + Object.entries(value).forEach(([k, v]) => { + process(\`\${key}[\${k}]\`, v); + }); + } else { + append(key, value); + } + } + }; + + Object.entries(params).forEach(([key, value]) => { + process(key, value); + }); + + if (qs.length > 0) { + return \`?\${qs.join('&')}\`; + } + + return ''; +}; + +const getUrl = (config: OpenAPIConfig, options: ApiRequestOptions): string => { + const encoder = config.ENCODE_PATH || encodeURI; + + const path = options.url + .replace('{api-version}', config.VERSION) + .replace(/{(.*?)}/g, (substring: string, group: string) => { + if (options.path?.hasOwnProperty(group)) { + return encoder(String(options.path[group])); + } + return substring; + }); + + const url = \`\${config.BASE}\${path}\`; + if (options.query) { + return \`\${url}\${getQueryString(options.query)}\`; + } + return url; +}; + +export const getFormData = (options: ApiRequestOptions): FormData | undefined => { + if (options.formData) { + const formData = new FormData(); + + const process = (key: string, value: any) => { + if (isString(value) || isBlob(value)) { + formData.append(key, value); + } else { + formData.append(key, JSON.stringify(value)); + } + }; + + Object.entries(options.formData) + .filter(([_, value]) => isDefined(value)) + .forEach(([key, value]) => { + if (Array.isArray(value)) { + value.forEach(v => process(key, v)); + } else { + process(key, value); + } + }); + + return formData; + } + return undefined; +}; + +type Resolver = (options: ApiRequestOptions) => Promise; + +export const resolve = async (options: ApiRequestOptions, resolver?: T | Resolver): Promise => { + if (typeof resolver === 'function') { + return (resolver as Resolver)(options); + } + return resolver; +}; + +export const getHeaders = async (config: OpenAPIConfig, options: ApiRequestOptions): Promise => { + const token = await resolve(options, config.TOKEN); + const username = await resolve(options, config.USERNAME); + const password = await resolve(options, config.PASSWORD); + const additionalHeaders = await resolve(options, config.HEADERS); + + const headers = Object.entries({ + Accept: 'application/json', + ...additionalHeaders, + ...options.headers, + }) + .filter(([_, value]) => isDefined(value)) + .reduce((headers, [key, value]) => ({ + ...headers, + [key]: String(value), + }), {} as Record); + + if (isStringWithValue(token)) { + headers['Authorization'] = \`Bearer \${token}\`; + } + + if (isStringWithValue(username) && isStringWithValue(password)) { + const credentials = base64(\`\${username}:\${password}\`); + headers['Authorization'] = \`Basic \${credentials}\`; + } + + if (options.body) { + if (options.mediaType) { + headers['Content-Type'] = options.mediaType; + } else if (isBlob(options.body)) { + headers['Content-Type'] = options.body.type || 'application/octet-stream'; + } else if (isString(options.body)) { + headers['Content-Type'] = 'text/plain'; + } else if (!isFormData(options.body)) { + headers['Content-Type'] = 'application/json'; + } + } + + return new Headers(headers); +}; + +export const getRequestBody = (options: ApiRequestOptions): any => { + if (options.body !== undefined) { + if (options.mediaType?.includes('/json')) { + return JSON.stringify(options.body) + } else if (isString(options.body) || isBlob(options.body) || isFormData(options.body)) { + return options.body; + } else { + return JSON.stringify(options.body); + } + } + return undefined; +}; + +export const sendRequest = async ( + config: OpenAPIConfig, + options: ApiRequestOptions, + url: string, + body: any, + formData: FormData | undefined, + headers: Headers, + onCancel: OnCancel +): Promise => { + const controller = new AbortController(); + + const request: RequestInit = { + headers, + body: body ?? formData, + method: options.method, + signal: controller.signal, + }; + + if (config.WITH_CREDENTIALS) { + request.credentials = config.CREDENTIALS; + } + + onCancel(() => controller.abort()); + + return await fetch(url, request); +}; + +export const getResponseHeader = (response: Response, responseHeader?: string): string | undefined => { + if (responseHeader) { + const content = response.headers.get(responseHeader); + if (isString(content)) { + return content; + } + } + return undefined; +}; + +export const getResponseBody = async (response: Response): Promise => { + if (response.status !== 204) { + try { + const contentType = response.headers.get('Content-Type'); + if (contentType) { + const jsonTypes = ['application/json', 'application/problem+json'] + const isJSON = jsonTypes.some(type => contentType.toLowerCase().startsWith(type)); + if (isJSON) { + return await response.json(); + } else { + return await response.text(); + } + } + } catch (error) { + console.error(error); + } + } + return undefined; +}; + +export const catchErrorCodes = (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(options, result, error); + } + + if (!result.ok) { + const errorStatus = result.status ?? 'unknown'; + const errorStatusText = result.statusText ?? 'unknown'; + const errorBody = (() => { + try { + return JSON.stringify(result.body, null, 2); + } catch (e) { + return undefined; + } + })(); + + throw new ApiError(options, result, + \`Generic Error: status: \${errorStatus}; status text: \${errorStatusText}; body: \${errorBody}\` + ); + } +}; + +/** + * Request method + * @param config The OpenAPI configuration object + * @param options The request options from the service + * @returns CancelablePromise + * @throws ApiError + */ +export const request = (config: OpenAPIConfig, options: ApiRequestOptions): CancelablePromise => { + return new CancelablePromise(async (resolve, reject, onCancel) => { + try { + const url = getUrl(config, options); + const formData = getFormData(options); + const body = getRequestBody(options); + const headers = await getHeaders(config, options); + + if (!onCancel.isCancelled) { + const response = await sendRequest(config, options, url, body, formData, headers, onCancel); + 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, + }; + + catchErrorCodes(options, result); + + resolve(result.body); + } + } catch (error) { + reject(error); + } + }); +}; +" +`; + +exports[`client should generate: test/generated/client/index.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export { Api } from './Api'; + +export { ApiError } from './core/ApiError'; +export { BaseHttpRequest } from './core/BaseHttpRequest'; +export { CancelablePromise, CancelError } from './core/CancelablePromise'; +export { OpenAPI } from './core/OpenAPI'; +export type { OpenAPIConfig } from './core/OpenAPI'; + +export type { _default } from './models/_default'; +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 { CommentWithBackticks } from './models/CommentWithBackticks'; +export type { CommentWithBreaks } from './models/CommentWithBreaks'; +export type { CommentWithExpressionPlaceholders } from './models/CommentWithExpressionPlaceholders'; +export type { CommentWithQuotes } from './models/CommentWithQuotes'; +export type { CommentWithReservedCharacters } from './models/CommentWithReservedCharacters'; +export type { CommentWithSlashes } from './models/CommentWithSlashes'; +export type { CompositionBaseModel } from './models/CompositionBaseModel'; +export type { CompositionExtendedModel } from './models/CompositionExtendedModel'; +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 { CompositionWithOneOfAndComplexArrayDictionary } from './models/CompositionWithOneOfAndComplexArrayDictionary'; +export type { CompositionWithOneOfAndNullable } from './models/CompositionWithOneOfAndNullable'; +export type { CompositionWithOneOfAndSimpleArrayDictionary } from './models/CompositionWithOneOfAndSimpleArrayDictionary'; +export type { CompositionWithOneOfAndSimpleDictionary } from './models/CompositionWithOneOfAndSimpleDictionary'; +export type { CompositionWithOneOfAnonymous } from './models/CompositionWithOneOfAnonymous'; +export type { CompositionWithOneOfDiscriminator } from './models/CompositionWithOneOfDiscriminator'; +export type { DeprecatedModel } from './models/DeprecatedModel'; +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 type { EnumFromDescription } from './models/EnumFromDescription'; +export { EnumWithExtensions } from './models/EnumWithExtensions'; +export { EnumWithNumbers } from './models/EnumWithNumbers'; +export { EnumWithStrings } from './models/EnumWithStrings'; +export type { File } from './models/File'; +export type { FreeFormObjectWithAdditionalPropertiesEqEmptyObject } from './models/FreeFormObjectWithAdditionalPropertiesEqEmptyObject'; +export type { FreeFormObjectWithAdditionalPropertiesEqTrue } from './models/FreeFormObjectWithAdditionalPropertiesEqTrue'; +export type { FreeFormObjectWithoutAdditionalProperties } from './models/FreeFormObjectWithoutAdditionalProperties'; +export type { ModelCircle } from './models/ModelCircle'; +export type { ModelSquare } from './models/ModelSquare'; +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 type { 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 { Pageable } from './models/Pageable'; +export type { SimpleBoolean } from './models/SimpleBoolean'; +export type { SimpleFile } from './models/SimpleFile'; +export type { SimpleInteger } from './models/SimpleInteger'; +export type { SimpleParameter } from './models/SimpleParameter'; +export type { SimpleReference } from './models/SimpleReference'; +export type { SimpleString } from './models/SimpleString'; +export type { SimpleStringWithPattern } from './models/SimpleStringWithPattern'; + +export { $_default } from './schemas/$_default'; +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 { $CommentWithBackticks } from './schemas/$CommentWithBackticks'; +export { $CommentWithBreaks } from './schemas/$CommentWithBreaks'; +export { $CommentWithExpressionPlaceholders } from './schemas/$CommentWithExpressionPlaceholders'; +export { $CommentWithQuotes } from './schemas/$CommentWithQuotes'; +export { $CommentWithReservedCharacters } from './schemas/$CommentWithReservedCharacters'; +export { $CommentWithSlashes } from './schemas/$CommentWithSlashes'; +export { $CompositionBaseModel } from './schemas/$CompositionBaseModel'; +export { $CompositionExtendedModel } from './schemas/$CompositionExtendedModel'; +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 { $CompositionWithOneOfAndComplexArrayDictionary } from './schemas/$CompositionWithOneOfAndComplexArrayDictionary'; +export { $CompositionWithOneOfAndNullable } from './schemas/$CompositionWithOneOfAndNullable'; +export { $CompositionWithOneOfAndSimpleArrayDictionary } from './schemas/$CompositionWithOneOfAndSimpleArrayDictionary'; +export { $CompositionWithOneOfAndSimpleDictionary } from './schemas/$CompositionWithOneOfAndSimpleDictionary'; +export { $CompositionWithOneOfAnonymous } from './schemas/$CompositionWithOneOfAnonymous'; +export { $CompositionWithOneOfDiscriminator } from './schemas/$CompositionWithOneOfDiscriminator'; +export { $DeprecatedModel } from './schemas/$DeprecatedModel'; +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 { $File } from './schemas/$File'; +export { $FreeFormObjectWithAdditionalPropertiesEqEmptyObject } from './schemas/$FreeFormObjectWithAdditionalPropertiesEqEmptyObject'; +export { $FreeFormObjectWithAdditionalPropertiesEqTrue } from './schemas/$FreeFormObjectWithAdditionalPropertiesEqTrue'; +export { $FreeFormObjectWithoutAdditionalProperties } from './schemas/$FreeFormObjectWithoutAdditionalProperties'; +export { $ModelCircle } from './schemas/$ModelCircle'; +export { $ModelSquare } from './schemas/$ModelSquare'; +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 { $Pageable } from './schemas/$Pageable'; +export { $SimpleBoolean } from './schemas/$SimpleBoolean'; +export { $SimpleFile } from './schemas/$SimpleFile'; +export { $SimpleInteger } from './schemas/$SimpleInteger'; +export { $SimpleParameter } from './schemas/$SimpleParameter'; +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 { DefaultService } from './services/DefaultService'; +export { DefaultsService } from './services/DefaultsService'; +export { DeprecatedService } from './services/DeprecatedService'; +export { DescriptionsService } from './services/DescriptionsService'; +export { DuplicateService } from './services/DuplicateService'; +export { ErrorService } from './services/ErrorService'; +export { FormDataService } from './services/FormDataService'; +export { HeaderService } from './services/HeaderService'; +export { MultipartService } from './services/MultipartService'; +export { MultipleTags1Service } from './services/MultipleTags1Service'; +export { MultipleTags2Service } from './services/MultipleTags2Service'; +export { MultipleTags3Service } from './services/MultipleTags3Service'; +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'; +" +`; + +exports[`client should generate: test/generated/client/models/_default.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type _default = { + name?: string; +}; + +" +`; + +exports[`client should generate: test/generated/client/models/ArrayWithArray.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* 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[`client should generate: test/generated/client/models/ArrayWithBooleans.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/** + * This is a simple array with booleans + */ +export type ArrayWithBooleans = Array; +" +`; + +exports[`client should generate: test/generated/client/models/ArrayWithNumbers.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/** + * This is a simple array with numbers + */ +export type ArrayWithNumbers = Array; +" +`; + +exports[`client should generate: test/generated/client/models/ArrayWithProperties.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/** + * This is a simple array with properties + */ +export type ArrayWithProperties = Array<{ + foo?: string; + bar?: string; +}>; +" +`; + +exports[`client should generate: test/generated/client/models/ArrayWithReferences.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ModelWithString } from './ModelWithString'; +/** + * This is a simple array with references + */ +export type ArrayWithReferences = Array; +" +`; + +exports[`client should generate: test/generated/client/models/ArrayWithStrings.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/** + * This is a simple array with strings + */ +export type ArrayWithStrings = Array; +" +`; + +exports[`client should generate: test/generated/client/models/CommentWithBackticks.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/** + * Testing backticks in string: \`backticks\` and \`\`\`multiple backticks\`\`\` should work + */ +export type CommentWithBackticks = number; +" +`; + +exports[`client should generate: test/generated/client/models/CommentWithBreaks.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CommentWithBreaks = number; +" +`; + +exports[`client should generate: test/generated/client/models/CommentWithExpressionPlaceholders.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/** + * Testing expression placeholders in string: \${expression} should work + */ +export type CommentWithExpressionPlaceholders = number; +" +`; + +exports[`client should generate: test/generated/client/models/CommentWithQuotes.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ +export type CommentWithQuotes = number; +" +`; + +exports[`client should generate: test/generated/client/models/CommentWithReservedCharacters.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ +export type CommentWithReservedCharacters = number; +" +`; + +exports[`client should generate: test/generated/client/models/CommentWithSlashes.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/** + * Testing slashes in string: \\backwards\\\\\\ and /forwards/// should work + */ +export type CommentWithSlashes = number; +" +`; + +exports[`client should generate: test/generated/client/models/CompositionBaseModel.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/** + * This is a base model with two simple optional properties + */ +export type CompositionBaseModel = { + firstName?: string; + lastname?: string; +}; + +" +`; + +exports[`client should generate: test/generated/client/models/CompositionExtendedModel.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { CompositionBaseModel } from './CompositionBaseModel'; +/** + * This is a model that extends the base model + */ +export type CompositionExtendedModel = (CompositionBaseModel & { + firstName: string; + lastname: string; + age: number; +}); + +" +`; + +exports[`client should generate: test/generated/client/models/CompositionWithAllOfAndNullable.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* 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[`client should generate: test/generated/client/models/CompositionWithAnyOf.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* 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[`client should generate: test/generated/client/models/CompositionWithAnyOfAndNullable.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* 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[`client should generate: test/generated/client/models/CompositionWithAnyOfAnonymous.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* 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?: string; + } | string | number); +}; + +" +`; + +exports[`client should generate: test/generated/client/models/CompositionWithOneOf.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* 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[`client should generate: test/generated/client/models/CompositionWithOneOfAndComplexArrayDictionary.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/** + * This is a model that contains a dictionary of complex arrays (composited) within composition + */ +export type CompositionWithOneOfAndComplexArrayDictionary = { + propA?: (boolean | Record>); +}; + +" +`; + +exports[`client should generate: test/generated/client/models/CompositionWithOneOfAndNullable.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* 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[`client should generate: test/generated/client/models/CompositionWithOneOfAndSimpleArrayDictionary.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/** + * This is a model that contains a dictionary of simple arrays within composition + */ +export type CompositionWithOneOfAndSimpleArrayDictionary = { + propA?: (boolean | Record>); +}; + +" +`; + +exports[`client should generate: test/generated/client/models/CompositionWithOneOfAndSimpleDictionary.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/** + * This is a model that contains a simple dictionary within composition + */ +export type CompositionWithOneOfAndSimpleDictionary = { + propA?: (boolean | Record); +}; + +" +`; + +exports[`client should generate: test/generated/client/models/CompositionWithOneOfAnonymous.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* 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?: string; + } | string | number); +}; + +" +`; + +exports[`client should generate: test/generated/client/models/CompositionWithOneOfDiscriminator.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ModelCircle } from './ModelCircle'; +import type { ModelSquare } from './ModelSquare'; +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfDiscriminator = (ModelCircle | ModelSquare); + +" +`; + +exports[`client should generate: test/generated/client/models/DeprecatedModel.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/** + * This is a deprecated model with a deprecated property + * @deprecated + */ +export type DeprecatedModel = { + /** + * This is a deprecated property + * @deprecated + */ + prop?: string; +}; + +" +`; + +exports[`client should generate: test/generated/client/models/DictionaryWithArray.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ModelWithString } from './ModelWithString'; +/** + * This is a complex dictionary + */ +export type DictionaryWithArray = Record>; +" +`; + +exports[`client should generate: test/generated/client/models/DictionaryWithDictionary.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/** + * This is a string dictionary + */ +export type DictionaryWithDictionary = Record>; +" +`; + +exports[`client should generate: test/generated/client/models/DictionaryWithProperties.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/** + * This is a complex dictionary + */ +export type DictionaryWithProperties = Record; +" +`; + +exports[`client should generate: test/generated/client/models/DictionaryWithReference.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ModelWithString } from './ModelWithString'; +/** + * This is a string reference + */ +export type DictionaryWithReference = Record; +" +`; + +exports[`client should generate: test/generated/client/models/DictionaryWithString.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/** + * This is a string dictionary + */ +export type DictionaryWithString = Record; +" +`; + +exports[`client should generate: test/generated/client/models/EnumFromDescription.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/** + * Success=1,Warning=2,Error=3 + */ +export type EnumFromDescription = number; +" +`; + +exports[`client should generate: test/generated/client/models/EnumWithExtensions.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* 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[`client should generate: test/generated/client/models/EnumWithNumbers.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* 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[`client should generate: test/generated/client/models/EnumWithStrings.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/** + * This is a simple enum with strings + */ +export enum EnumWithStrings { + SUCCESS = 'Success', + WARNING = 'Warning', + ERROR = 'Error', + _SINGLE_QUOTE_ = '\\'Single Quote\\'', + _DOUBLE_QUOTES_ = '"Double Quotes"', +} +" +`; + +exports[`client should generate: test/generated/client/models/File.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type File = { + readonly id?: string; + readonly updated_at?: string; + readonly created_at?: string; + mime: string; + readonly file?: string; +}; + +" +`; + +exports[`client should generate: test/generated/client/models/FreeFormObjectWithAdditionalPropertiesEqEmptyObject.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/** + * This is a free-form object with additionalProperties: {}. + */ +export type FreeFormObjectWithAdditionalPropertiesEqEmptyObject = Record; +" +`; + +exports[`client should generate: test/generated/client/models/FreeFormObjectWithAdditionalPropertiesEqTrue.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/** + * This is a free-form object with additionalProperties: true. + */ +export type FreeFormObjectWithAdditionalPropertiesEqTrue = Record; +" +`; + +exports[`client should generate: test/generated/client/models/FreeFormObjectWithoutAdditionalProperties.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/** + * This is a free-form object without additionalProperties. + */ +export type FreeFormObjectWithoutAdditionalProperties = Record; +" +`; + +exports[`client should generate: test/generated/client/models/ModelCircle.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/** + * Circle + */ +export type ModelCircle = { + kind: 'circle'; + radius?: number; +}; + +" +`; + +exports[`client should generate: test/generated/client/models/ModelSquare.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/** + * Square + */ +export type ModelSquare = { + kind: 'square'; + sideLength?: number; +}; + +" +`; + +exports[`client should generate: test/generated/client/models/ModelThatExtends.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* 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[`client should generate: test/generated/client/models/ModelThatExtendsExtends.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* 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[`client should generate: test/generated/client/models/ModelWithArray.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* 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[`client should generate: test/generated/client/models/ModelWithBoolean.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* 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[`client should generate: test/generated/client/models/ModelWithCircularReference.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/** + * This is a model with one property containing a circular reference + */ +export type ModelWithCircularReference = { + prop?: ModelWithCircularReference; +}; + +" +`; + +exports[`client should generate: test/generated/client/models/ModelWithDictionary.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/** + * This is a model with one property containing a dictionary + */ +export type ModelWithDictionary = { + prop?: Record; +}; + +" +`; + +exports[`client should generate: test/generated/client/models/ModelWithDuplicateImports.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* 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[`client should generate: test/generated/client/models/ModelWithDuplicateProperties.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* 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[`client should generate: test/generated/client/models/ModelWithEnum.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* 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[`client should generate: test/generated/client/models/ModelWithEnumFromDescription.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/** + * This is a model with one enum + */ +export type ModelWithEnumFromDescription = { + /** + * Success=1,Warning=2,Error=3 + */ + test?: number; +}; + +" +`; + +exports[`client should generate: test/generated/client/models/ModelWithInteger.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* 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[`client should generate: test/generated/client/models/ModelWithNestedEnums.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* 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; +}; + +" +`; + +exports[`client should generate: test/generated/client/models/ModelWithNestedProperties.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* 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[`client should generate: test/generated/client/models/ModelWithNullableString.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/** + * This is a model with one string property + */ +export type ModelWithNullableString = { + /** + * This is a simple string property + */ + nullableProp1?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp1: string | null; + /** + * This is a simple string property + */ + nullableProp2?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp2: string | null; +}; + +" +`; + +exports[`client should generate: test/generated/client/models/ModelWithOrderedProperties.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/** + * This is a model with ordered properties + */ +export type ModelWithOrderedProperties = { + zebra?: string; + apple?: string; + hawaii?: string; +}; + +" +`; + +exports[`client should generate: test/generated/client/models/ModelWithPattern.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* 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; + patternWithSingleQuotes?: string; +}; + +" +`; + +exports[`client should generate: test/generated/client/models/ModelWithProperties.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* 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[`client should generate: test/generated/client/models/ModelWithReference.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* 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[`client should generate: test/generated/client/models/ModelWithString.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* 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[`client should generate: test/generated/client/models/Pageable.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type Pageable = { + page?: number; + size?: number; + sort?: Array; +}; + +" +`; + +exports[`client should generate: test/generated/client/models/SimpleBoolean.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/** + * This is a simple boolean + */ +export type SimpleBoolean = boolean; +" +`; + +exports[`client should generate: test/generated/client/models/SimpleFile.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/** + * This is a simple file + */ +export type SimpleFile = Blob; +" +`; + +exports[`client should generate: test/generated/client/models/SimpleInteger.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/** + * This is a simple number + */ +export type SimpleInteger = number; +" +`; + +exports[`client should generate: test/generated/client/models/SimpleParameter.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/** + * This is a reusable parameter + */ +export type SimpleParameter = string; +" +`; + +exports[`client should generate: test/generated/client/models/SimpleReference.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ModelWithString } from './ModelWithString'; +/** + * This is a simple reference + */ +export type SimpleReference = ModelWithString; +" +`; + +exports[`client should generate: test/generated/client/models/SimpleString.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/** + * This is a simple string + */ +export type SimpleString = string; +" +`; + +exports[`client should generate: test/generated/client/models/SimpleStringWithPattern.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/** + * This is a simple string + */ +export type SimpleStringWithPattern = string | null; +" +`; + +exports[`client should generate: test/generated/client/schemas/$_default.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $_default = { + properties: { + name: { + type: 'string', + }, + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$ArrayWithArray.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ArrayWithArray = { + type: 'array', + contains: { + type: 'array', + contains: { + type: 'ModelWithString', + }, + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$ArrayWithBooleans.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ArrayWithBooleans = { + type: 'array', + contains: { + type: 'boolean', + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$ArrayWithNumbers.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ArrayWithNumbers = { + type: 'array', + contains: { + type: 'number', + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$ArrayWithProperties.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ArrayWithProperties = { + type: 'array', + contains: { + properties: { + foo: { + type: 'string', + }, + bar: { + type: 'string', + }, + }, + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$ArrayWithReferences.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ArrayWithReferences = { + type: 'array', + contains: { + type: 'ModelWithString', + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$ArrayWithStrings.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ArrayWithStrings = { + type: 'array', + contains: { + type: 'string', + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$CommentWithBackticks.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $CommentWithBackticks = { + type: 'number', + description: \`Testing backticks in string: \\\`backticks\\\` and \\\`\\\`\\\`multiple backticks\\\`\\\`\\\` should work\`, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$CommentWithBreaks.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $CommentWithBreaks = { + type: 'number', + description: \`Testing multiline comments in string: First line + Second line + Fourth line\`, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$CommentWithExpressionPlaceholders.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $CommentWithExpressionPlaceholders = { + type: 'number', + description: \`Testing expression placeholders in string: \\\${expression} should work\`, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$CommentWithQuotes.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $CommentWithQuotes = { + type: 'number', + description: \`Testing quotes in string: 'single quote''' and "double quotes""" should work\`, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$CommentWithReservedCharacters.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $CommentWithReservedCharacters = { + type: 'number', + description: \`Testing reserved characters in string: /* inline */ and /** inline **/ should work\`, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$CommentWithSlashes.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $CommentWithSlashes = { + type: 'number', + description: \`Testing slashes in string: \\\\backwards\\\\\\\\\\\\ and /forwards/// should work\`, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$CompositionBaseModel.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $CompositionBaseModel = { + description: \`This is a base model with two simple optional properties\`, + properties: { + firstName: { + type: 'string', + }, + lastname: { + type: 'string', + }, + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$CompositionExtendedModel.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $CompositionExtendedModel = { + type: 'all-of', + description: \`This is a model that extends the base model\`, + contains: [{ + type: 'CompositionBaseModel', + }, { + properties: { + firstName: { + type: 'string', + isRequired: true, + }, + lastname: { + type: 'string', + isRequired: true, + }, + age: { + type: 'number', + isRequired: true, + }, + }, + }], +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$CompositionWithAllOfAndNullable.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $CompositionWithAllOfAndNullable = { + description: \`This is a model with one property with a 'all of' relationship\`, + properties: { + propA: { + type: 'all-of', + contains: [{ + properties: { + boolean: { + type: 'boolean', + }, + }, + }, { + type: 'ModelWithEnum', + }, { + type: 'ModelWithArray', + }, { + type: 'ModelWithDictionary', + }], + isNullable: true, + }, + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$CompositionWithAnyOf.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $CompositionWithAnyOf = { + description: \`This is a model with one property with a 'any of' relationship\`, + properties: { + propA: { + type: 'any-of', + contains: [{ + type: 'ModelWithString', + }, { + type: 'ModelWithEnum', + }, { + type: 'ModelWithArray', + }, { + type: 'ModelWithDictionary', + }], + }, + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$CompositionWithAnyOfAndNullable.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $CompositionWithAnyOfAndNullable = { + description: \`This is a model with one property with a 'any of' relationship\`, + properties: { + propA: { + type: 'any-of', + contains: [{ + properties: { + boolean: { + type: 'boolean', + }, + }, + }, { + type: 'ModelWithEnum', + }, { + type: 'ModelWithArray', + }, { + type: 'ModelWithDictionary', + }], + isNullable: true, + }, + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$CompositionWithAnyOfAnonymous.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $CompositionWithAnyOfAnonymous = { + description: \`This is a model with one property with a 'any of' relationship where the options are not $ref\`, + properties: { + propA: { + type: 'any-of', + contains: [{ + description: \`Anonymous object type\`, + properties: { + propA: { + type: 'string', + }, + }, + }, { + type: 'string', + description: \`Anonymous string type\`, + }, { + type: 'number', + description: \`Anonymous integer type\`, + }], + }, + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$CompositionWithOneOf.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $CompositionWithOneOf = { + description: \`This is a model with one property with a 'one of' relationship\`, + properties: { + propA: { + type: 'one-of', + contains: [{ + type: 'ModelWithString', + }, { + type: 'ModelWithEnum', + }, { + type: 'ModelWithArray', + }, { + type: 'ModelWithDictionary', + }], + }, + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$CompositionWithOneOfAndComplexArrayDictionary.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $CompositionWithOneOfAndComplexArrayDictionary = { + description: \`This is a model that contains a dictionary of complex arrays (composited) within composition\`, + properties: { + propA: { + type: 'one-of', + contains: [{ + type: 'boolean', + }, { + type: 'dictionary', + contains: { + type: 'array', + contains: { + type: 'one-of', + contains: [{ + type: 'number', + }, { + type: 'string', + }], + }, + }, + }], + }, + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$CompositionWithOneOfAndNullable.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $CompositionWithOneOfAndNullable = { + description: \`This is a model with one property with a 'one of' relationship\`, + properties: { + propA: { + type: 'one-of', + contains: [{ + properties: { + boolean: { + type: 'boolean', + }, + }, + }, { + type: 'ModelWithEnum', + }, { + type: 'ModelWithArray', + }, { + type: 'ModelWithDictionary', + }], + isNullable: true, + }, + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$CompositionWithOneOfAndSimpleArrayDictionary.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $CompositionWithOneOfAndSimpleArrayDictionary = { + description: \`This is a model that contains a dictionary of simple arrays within composition\`, + properties: { + propA: { + type: 'one-of', + contains: [{ + type: 'boolean', + }, { + type: 'dictionary', + contains: { + type: 'array', + contains: { + type: 'boolean', + }, + }, + }], + }, + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$CompositionWithOneOfAndSimpleDictionary.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $CompositionWithOneOfAndSimpleDictionary = { + description: \`This is a model that contains a simple dictionary within composition\`, + properties: { + propA: { + type: 'one-of', + contains: [{ + type: 'boolean', + }, { + type: 'dictionary', + contains: { + type: 'number', + }, + }], + }, + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$CompositionWithOneOfAnonymous.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $CompositionWithOneOfAnonymous = { + description: \`This is a model with one property with a 'one of' relationship where the options are not $ref\`, + properties: { + propA: { + type: 'one-of', + contains: [{ + description: \`Anonymous object type\`, + properties: { + propA: { + type: 'string', + }, + }, + }, { + type: 'string', + description: \`Anonymous string type\`, + }, { + type: 'number', + description: \`Anonymous integer type\`, + }], + }, + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$CompositionWithOneOfDiscriminator.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $CompositionWithOneOfDiscriminator = { + type: 'one-of', + description: \`This is a model with one property with a 'one of' relationship where the options are not $ref\`, + contains: [{ + type: 'ModelCircle', + }, { + type: 'ModelSquare', + }], +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$DeprecatedModel.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $DeprecatedModel = { + description: \`This is a deprecated model with a deprecated property\`, + properties: { + prop: { + type: 'string', + description: \`This is a deprecated property\`, + }, + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$DictionaryWithArray.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $DictionaryWithArray = { + type: 'dictionary', + contains: { + type: 'array', + contains: { + type: 'ModelWithString', + }, + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$DictionaryWithDictionary.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $DictionaryWithDictionary = { + type: 'dictionary', + contains: { + type: 'dictionary', + contains: { + type: 'string', + }, + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$DictionaryWithProperties.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $DictionaryWithProperties = { + type: 'dictionary', + contains: { + properties: { + foo: { + type: 'string', + }, + bar: { + type: 'string', + }, + }, + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$DictionaryWithReference.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $DictionaryWithReference = { + type: 'dictionary', + contains: { + type: 'ModelWithString', + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$DictionaryWithString.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $DictionaryWithString = { + type: 'dictionary', + contains: { + type: 'string', + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$EnumFromDescription.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $EnumFromDescription = { + type: 'number', + description: \`Success=1,Warning=2,Error=3\`, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$EnumWithExtensions.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $EnumWithExtensions = { + type: 'Enum', +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$EnumWithNumbers.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $EnumWithNumbers = { + type: 'Enum', +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$EnumWithStrings.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $EnumWithStrings = { + type: 'Enum', +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$File.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $File = { + properties: { + id: { + type: 'string', + isReadOnly: true, + minLength: 1, + }, + updated_at: { + type: 'string', + isReadOnly: true, + format: 'date-time', + }, + created_at: { + type: 'string', + isReadOnly: true, + format: 'date-time', + }, + mime: { + type: 'string', + isRequired: true, + maxLength: 24, + minLength: 1, + }, + file: { + type: 'string', + isReadOnly: true, + format: 'uri', + }, + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$FreeFormObjectWithAdditionalPropertiesEqEmptyObject.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { + type: 'dictionary', + contains: { + properties: { + }, + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$FreeFormObjectWithAdditionalPropertiesEqTrue.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $FreeFormObjectWithAdditionalPropertiesEqTrue = { + type: 'dictionary', + contains: { + properties: { + }, + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$FreeFormObjectWithoutAdditionalProperties.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $FreeFormObjectWithoutAdditionalProperties = { + type: 'dictionary', + contains: { + properties: { + }, + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$ModelCircle.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelCircle = { + description: \`Circle\`, + properties: { + kind: { + type: 'string', + isRequired: true, + }, + radius: { + type: 'number', + }, + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$ModelSquare.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelSquare = { + description: \`Square\`, + properties: { + kind: { + type: 'string', + isRequired: true, + }, + sideLength: { + type: 'number', + }, + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$ModelThatExtends.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelThatExtends = { + type: 'all-of', + description: \`This is a model that extends another model\`, + contains: [{ + type: 'ModelWithString', + }, { + properties: { + propExtendsA: { + type: 'string', + }, + propExtendsB: { + type: 'ModelWithString', + }, + }, + }], +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$ModelThatExtendsExtends.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelThatExtendsExtends = { + type: 'all-of', + description: \`This is a model that extends another model\`, + contains: [{ + type: 'ModelWithString', + }, { + type: 'ModelThatExtends', + }, { + properties: { + propExtendsC: { + type: 'string', + }, + propExtendsD: { + type: 'ModelWithString', + }, + }, + }], +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$ModelWithArray.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithArray = { + description: \`This is a model with one property containing an array\`, + properties: { + prop: { + type: 'array', + contains: { + type: 'ModelWithString', + }, + }, + propWithFile: { + type: 'array', + contains: { + type: 'binary', + }, + }, + propWithNumber: { + type: 'array', + contains: { + type: 'number', + }, + }, + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$ModelWithBoolean.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithBoolean = { + description: \`This is a model with one boolean property\`, + properties: { + prop: { + type: 'boolean', + description: \`This is a simple boolean property\`, + }, + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$ModelWithCircularReference.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithCircularReference = { + description: \`This is a model with one property containing a circular reference\`, + properties: { + prop: { + type: 'ModelWithCircularReference', + }, + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$ModelWithDictionary.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithDictionary = { + description: \`This is a model with one property containing a dictionary\`, + properties: { + prop: { + type: 'dictionary', + contains: { + type: 'string', + }, + }, + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$ModelWithDuplicateImports.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithDuplicateImports = { + description: \`This is a model with duplicated imports\`, + properties: { + propA: { + type: 'ModelWithString', + }, + propB: { + type: 'ModelWithString', + }, + propC: { + type: 'ModelWithString', + }, + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$ModelWithDuplicateProperties.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithDuplicateProperties = { + description: \`This is a model with duplicated properties\`, + properties: { + prop: { + type: 'ModelWithString', + }, + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$ModelWithEnum.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithEnum = { + description: \`This is a model with one enum\`, + properties: { + test: { + type: 'Enum', + }, + statusCode: { + type: 'Enum', + }, + bool: { + type: 'boolean', + description: \`Simple boolean enum\`, + }, + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$ModelWithEnumFromDescription.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithEnumFromDescription = { + description: \`This is a model with one enum\`, + properties: { + test: { + type: 'number', + description: \`Success=1,Warning=2,Error=3\`, + }, + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$ModelWithInteger.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithInteger = { + description: \`This is a model with one number property\`, + properties: { + prop: { + type: 'number', + description: \`This is a simple number property\`, + }, + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$ModelWithNestedEnums.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithNestedEnums = { + description: \`This is a model with nested enums\`, + properties: { + dictionaryWithEnum: { + type: 'dictionary', + contains: { + type: 'Enum', + }, + }, + dictionaryWithEnumFromDescription: { + type: 'dictionary', + contains: { + type: 'number', + description: \`Success=1,Warning=2,Error=3\`, + }, + }, + arrayWithEnum: { + type: 'array', + contains: { + type: 'Enum', + }, + }, + arrayWithDescription: { + type: 'array', + contains: { + type: 'number', + description: \`Success=1,Warning=2,Error=3\`, + }, + }, + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$ModelWithNestedProperties.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithNestedProperties = { + description: \`This is a model with one nested property\`, + 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, + }, + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$ModelWithNullableString.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithNullableString = { + description: \`This is a model with one string property\`, + properties: { + nullableProp1: { + type: 'string', + description: \`This is a simple string property\`, + isNullable: true, + }, + nullableRequiredProp1: { + type: 'string', + description: \`This is a simple string property\`, + isRequired: true, + isNullable: true, + }, + nullableProp2: { + type: 'string', + description: \`This is a simple string property\`, + isNullable: true, + }, + nullableRequiredProp2: { + type: 'string', + description: \`This is a simple string property\`, + isRequired: true, + isNullable: true, + }, + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$ModelWithOrderedProperties.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithOrderedProperties = { + description: \`This is a model with ordered properties\`, + properties: { + zebra: { + type: 'string', + }, + apple: { + type: 'string', + }, + hawaii: { + type: 'string', + }, + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$ModelWithPattern.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithPattern = { + description: \`This is a model that contains a some patterns\`, + 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+$', + }, + patternWithSingleQuotes: { + type: 'string', + pattern: '^[a-zA-Z0-9\\']*$', + }, + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$ModelWithProperties.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithProperties = { + description: \`This is a model with one nested property\`, + 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, + }, + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$ModelWithReference.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithReference = { + description: \`This is a model with one property containing a reference\`, + properties: { + prop: { + type: 'ModelWithProperties', + }, + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$ModelWithString.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithString = { + description: \`This is a model with one string property\`, + properties: { + prop: { + type: 'string', + description: \`This is a simple string property\`, + }, + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$Pageable.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $Pageable = { + properties: { + page: { + type: 'number', + format: 'int32', + }, + size: { + type: 'number', + format: 'int32', + minimum: 1, + }, + sort: { + type: 'array', + contains: { + type: 'string', + }, + }, + }, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$SimpleBoolean.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $SimpleBoolean = { + type: 'boolean', + description: \`This is a simple boolean\`, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$SimpleFile.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $SimpleFile = { + type: 'binary', + description: \`This is a simple file\`, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$SimpleInteger.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $SimpleInteger = { + type: 'number', + description: \`This is a simple number\`, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$SimpleParameter.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $SimpleParameter = { + type: 'string', + description: \`This is a reusable parameter\`, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$SimpleReference.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $SimpleReference = { + type: 'ModelWithString', + description: \`This is a simple reference\`, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$SimpleString.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $SimpleString = { + type: 'string', + description: \`This is a simple string\`, +} as const; +" +`; + +exports[`client should generate: test/generated/client/schemas/$SimpleStringWithPattern.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $SimpleStringWithPattern = { + type: 'string', + description: \`This is a simple string\`, + isNullable: true, + maxLength: 64, + pattern: '^[a-zA-Z0-9_]*$', +} as const; +" +`; + +exports[`client should generate: test/generated/client/services/CollectionFormatService.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { CancelablePromise } from '../core/CancelablePromise'; +import type { BaseHttpRequest } from '../core/BaseHttpRequest'; +import type { OpenAPIConfig } from '../core/OpenAPI'; +export class CollectionFormatService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + /** + * @param parameterArrayCsv This is an array parameter that is sent as csv format (comma-separated values) + * @param parameterArraySsv This is an array parameter that is sent as ssv format (space-separated values) + * @param parameterArrayTsv This is an array parameter that is sent as tsv format (tab-separated values) + * @param parameterArrayPipes This is an array parameter that is sent as pipes format (pipe-separated values) + * @param parameterArrayMulti This is an array parameter that is sent as multi format (multiple parameter instances) + * @param [configOverrides] Overrides OpenAPIConfig + * @throws ApiError + */ + public collectionFormat( + parameterArrayCsv: Array | null, + parameterArraySsv: Array | null, + parameterArrayTsv: Array | null, + parameterArrayPipes: Array | null, + parameterArrayMulti: Array | null, + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return this.httpRequest.request( + { + method: 'GET', + url: '/api/v{api-version}/collectionFormat', + query: { + 'parameterArrayCSV': parameterArrayCsv, + 'parameterArraySSV': parameterArraySsv, + 'parameterArrayTSV': parameterArrayTsv, + 'parameterArrayPipes': parameterArrayPipes, + 'parameterArrayMulti': parameterArrayMulti, + }, + }, + configOverrides, + ); + } +} +" +`; + +exports[`client should generate: test/generated/client/services/ComplexService.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* 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 type { CancelablePromise } from '../core/CancelablePromise'; +import type { BaseHttpRequest } from '../core/BaseHttpRequest'; +import type { OpenAPIConfig } from '../core/OpenAPI'; +export class ComplexService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + /** + * @param parameterObject Parameter containing object + * @param parameterReference Parameter containing reference + * @param [configOverrides] Overrides OpenAPIConfig + * @returns ModelWithString Successful response + * @throws ApiError + */ + public complexTypes( + parameterObject: { + first?: { + second?: { + third?: string; + }; + }; + }, + parameterReference: ModelWithString, + configOverrides?: OpenAPIConfig, + ): CancelablePromise> { + return this.httpRequest.request( + { + method: 'GET', + url: '/api/v{api-version}/complex', + query: { + 'parameterObject': parameterObject, + 'parameterReference': parameterReference, + }, + errors: { + 400: \`400 server error\`, + 500: \`500 server error\`, + }, + }, + configOverrides, + ); + } + /** + * @param id + * @param requestBody + * @param [configOverrides] Overrides OpenAPIConfig + * @returns ModelWithString Success + * @throws ApiError + */ + public 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; + }; + }, + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return this.httpRequest.request( + { + method: 'PUT', + url: '/api/v{api-version}/complex/{id}', + path: { + 'id': id, + }, + body: requestBody, + mediaType: 'application/json-patch+json', + }, + configOverrides, + ); + } +} +" +`; + +exports[`client should generate: test/generated/client/services/DefaultService.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { CancelablePromise } from '../core/CancelablePromise'; +import type { BaseHttpRequest } from '../core/BaseHttpRequest'; +import type { OpenAPIConfig } from '../core/OpenAPI'; +export class DefaultService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + /** + * @throws ApiError + */ + public serviceWithEmptyTag( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return this.httpRequest.request( + { + method: 'GET', + url: '/api/v{api-version}/no-tag', + }, + configOverrides, + ); + } +} +" +`; + +exports[`client should generate: test/generated/client/services/DefaultsService.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ModelWithString } from '../models/ModelWithString'; +import type { CancelablePromise } from '../core/CancelablePromise'; +import type { BaseHttpRequest } from '../core/BaseHttpRequest'; +import type { OpenAPIConfig } from '../core/OpenAPI'; +export class DefaultsService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + /** + * @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 [configOverrides] Overrides OpenAPIConfig + * @throws ApiError + */ + public 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!" + }, + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return this.httpRequest.request( + { + method: 'GET', + url: '/api/v{api-version}/defaults', + query: { + 'parameterString': parameterString, + 'parameterNumber': parameterNumber, + 'parameterBoolean': parameterBoolean, + 'parameterEnum': parameterEnum, + 'parameterModel': parameterModel, + }, + }, + configOverrides, + ); + } + /** + * @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 [configOverrides] Overrides OpenAPIConfig + * @throws ApiError + */ + public callWithDefaultOptionalParameters( + parameterString: string = 'Hello World!', + parameterNumber: number = 123, + parameterBoolean: boolean = true, + parameterEnum: 'Success' | 'Warning' | 'Error' = 'Success', + parameterModel: ModelWithString = { + "prop": "Hello World!" + }, + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return this.httpRequest.request( + { + method: 'POST', + url: '/api/v{api-version}/defaults', + query: { + 'parameterString': parameterString, + 'parameterNumber': parameterNumber, + 'parameterBoolean': parameterBoolean, + 'parameterEnum': parameterEnum, + 'parameterModel': parameterModel, + }, + }, + configOverrides, + ); + } + /** + * @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 parameterStringNullableWithNoDefault This is a string that can be null with no default + * @param parameterStringNullableWithDefault This is a string that can be null with default + * @param [configOverrides] Overrides OpenAPIConfig + * @throws ApiError + */ + public callToTestOrderOfParams( + parameterStringWithNoDefault: string, + parameterOptionalStringWithDefault: string = 'Hello World!', + parameterOptionalStringWithEmptyDefault: string = '', + parameterOptionalStringWithNoDefault?: string, + parameterStringWithDefault: string = 'Hello World!', + parameterStringWithEmptyDefault: string = '', + parameterStringNullableWithNoDefault?: string | null, + parameterStringNullableWithDefault: string | null = null, + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return this.httpRequest.request( + { + method: 'PUT', + url: '/api/v{api-version}/defaults', + query: { + 'parameterOptionalStringWithDefault': parameterOptionalStringWithDefault, + 'parameterOptionalStringWithEmptyDefault': parameterOptionalStringWithEmptyDefault, + 'parameterOptionalStringWithNoDefault': parameterOptionalStringWithNoDefault, + 'parameterStringWithDefault': parameterStringWithDefault, + 'parameterStringWithEmptyDefault': parameterStringWithEmptyDefault, + 'parameterStringWithNoDefault': parameterStringWithNoDefault, + 'parameterStringNullableWithNoDefault': parameterStringNullableWithNoDefault, + 'parameterStringNullableWithDefault': parameterStringNullableWithDefault, + }, + }, + configOverrides, + ); + } +} +" +`; + +exports[`client should generate: test/generated/client/services/DeprecatedService.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { DeprecatedModel } from '../models/DeprecatedModel'; +import type { CancelablePromise } from '../core/CancelablePromise'; +import type { BaseHttpRequest } from '../core/BaseHttpRequest'; +import type { OpenAPIConfig } from '../core/OpenAPI'; +export class DeprecatedService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + /** + * @deprecated + * @param parameter This parameter is deprecated + * @param [configOverrides] Overrides OpenAPIConfig + * @throws ApiError + */ + public deprecatedCall( + parameter: DeprecatedModel | null, + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return this.httpRequest.request( + { + method: 'POST', + url: '/api/v{api-version}/parameters/deprecated', + headers: { + 'parameter': parameter, + }, + }, + configOverrides, + ); + } +} +" +`; + +exports[`client should generate: test/generated/client/services/DescriptionsService.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { CancelablePromise } from '../core/CancelablePromise'; +import type { BaseHttpRequest } from '../core/BaseHttpRequest'; +import type { OpenAPIConfig } from '../core/OpenAPI'; +export class DescriptionsService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + /** + * @param parameterWithBreaks Testing multiline comments in string: First line + * Second line + * + * Fourth line + * @param parameterWithBackticks Testing backticks in string: \`backticks\` and \`\`\`multiple backticks\`\`\` should work + * @param parameterWithSlashes Testing slashes in string: \\backwards\\\\\\ and /forwards/// should work + * @param parameterWithExpressionPlaceholders Testing expression placeholders in string: \${expression} should work + * @param parameterWithQuotes Testing quotes in string: 'single quote''' and "double quotes""" should work + * @param parameterWithReservedCharacters Testing reserved characters in string: * inline * and ** inline ** should work + * @param [configOverrides] Overrides OpenAPIConfig + * @throws ApiError + */ + public callWithDescriptions( + parameterWithBreaks?: any, + parameterWithBackticks?: any, + parameterWithSlashes?: any, + parameterWithExpressionPlaceholders?: any, + parameterWithQuotes?: any, + parameterWithReservedCharacters?: any, + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return this.httpRequest.request( + { + method: 'POST', + url: '/api/v{api-version}/descriptions/', + query: { + 'parameterWithBreaks': parameterWithBreaks, + 'parameterWithBackticks': parameterWithBackticks, + 'parameterWithSlashes': parameterWithSlashes, + 'parameterWithExpressionPlaceholders': parameterWithExpressionPlaceholders, + 'parameterWithQuotes': parameterWithQuotes, + 'parameterWithReservedCharacters': parameterWithReservedCharacters, + }, + }, + configOverrides, + ); + } +} +" +`; + +exports[`client should generate: test/generated/client/services/DuplicateService.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { CancelablePromise } from '../core/CancelablePromise'; +import type { BaseHttpRequest } from '../core/BaseHttpRequest'; +import type { OpenAPIConfig } from '../core/OpenAPI'; +export class DuplicateService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + /** + * @throws ApiError + */ + public duplicateName( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return this.httpRequest.request( + { + method: 'GET', + url: '/api/v{api-version}/duplicate', + }, + configOverrides, + ); + } + /** + * @throws ApiError + */ + public duplicateName1( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return this.httpRequest.request( + { + method: 'POST', + url: '/api/v{api-version}/duplicate', + }, + configOverrides, + ); + } + /** + * @throws ApiError + */ + public duplicateName2( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return this.httpRequest.request( + { + method: 'PUT', + url: '/api/v{api-version}/duplicate', + }, + configOverrides, + ); + } + /** + * @throws ApiError + */ + public duplicateName3( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return this.httpRequest.request( + { + method: 'DELETE', + url: '/api/v{api-version}/duplicate', + }, + configOverrides, + ); + } +} +" +`; + +exports[`client should generate: test/generated/client/services/ErrorService.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { CancelablePromise } from '../core/CancelablePromise'; +import type { BaseHttpRequest } from '../core/BaseHttpRequest'; +import type { OpenAPIConfig } from '../core/OpenAPI'; +export class ErrorService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + /** + * @param status Status code to return + * @param [configOverrides] Overrides OpenAPIConfig + * @returns any Custom message: Successful response + * @throws ApiError + */ + public testErrorCode( + status: number, + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return this.httpRequest.request( + { + method: 'POST', + url: '/api/v{api-version}/error', + query: { + 'status': status, + }, + errors: { + 500: \`Custom message: Internal Server Error\`, + 501: \`Custom message: Not Implemented\`, + 502: \`Custom message: Bad Gateway\`, + 503: \`Custom message: Service Unavailable\`, + }, + }, + configOverrides, + ); + } +} +" +`; + +exports[`client should generate: test/generated/client/services/FormDataService.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ModelWithString } from '../models/ModelWithString'; +import type { CancelablePromise } from '../core/CancelablePromise'; +import type { BaseHttpRequest } from '../core/BaseHttpRequest'; +import type { OpenAPIConfig } from '../core/OpenAPI'; +export class FormDataService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + /** + * @param parameter This is a reusable parameter + * @param formData A reusable request body + * @param [configOverrides] Overrides OpenAPIConfig + * @throws ApiError + */ + public postApiFormData( + parameter?: string, + formData?: ModelWithString, + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return this.httpRequest.request( + { + method: 'POST', + url: '/api/v{api-version}/formData/', + query: { + 'parameter': parameter, + }, + formData: formData, + mediaType: 'multipart/form-data', + }, + configOverrides, + ); + } +} +" +`; + +exports[`client should generate: test/generated/client/services/HeaderService.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { CancelablePromise } from '../core/CancelablePromise'; +import type { BaseHttpRequest } from '../core/BaseHttpRequest'; +import type { OpenAPIConfig } from '../core/OpenAPI'; +export class HeaderService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + /** + * @returns string Successful response + * @throws ApiError + */ + public callWithResultFromHeader( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return this.httpRequest.request( + { + method: 'POST', + url: '/api/v{api-version}/header', + responseHeader: 'operation-location', + errors: { + 400: \`400 server error\`, + 500: \`500 server error\`, + }, + }, + configOverrides, + ); + } +} +" +`; + +exports[`client should generate: test/generated/client/services/MultipartService.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ModelWithString } from '../models/ModelWithString'; +import type { CancelablePromise } from '../core/CancelablePromise'; +import type { BaseHttpRequest } from '../core/BaseHttpRequest'; +import type { OpenAPIConfig } from '../core/OpenAPI'; +export class MultipartService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + /** + * @param formData + * @param [configOverrides] Overrides OpenAPIConfig + * @throws ApiError + */ + public multipartRequest( + formData?: { + content?: Blob; + data?: ModelWithString | null; + }, + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return this.httpRequest.request( + { + method: 'POST', + url: '/api/v{api-version}/multipart', + formData: formData, + mediaType: 'multipart/form-data', + }, + configOverrides, + ); + } + /** + * @returns any OK + * @throws ApiError + */ + public multipartResponse( + configOverrides?: OpenAPIConfig, + ): CancelablePromise<{ + file?: Blob; + metadata?: { + foo?: string; + bar?: string; + }; + }> { + return this.httpRequest.request( + { + method: 'GET', + url: '/api/v{api-version}/multipart', + }, + configOverrides, + ); + } +} +" +`; + +exports[`client should generate: test/generated/client/services/MultipleTags1Service.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { CancelablePromise } from '../core/CancelablePromise'; +import type { BaseHttpRequest } from '../core/BaseHttpRequest'; +import type { OpenAPIConfig } from '../core/OpenAPI'; +export class MultipleTags1Service { + constructor(public readonly httpRequest: BaseHttpRequest) {} + /** + * @returns void + * @throws ApiError + */ + public dummyA( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return this.httpRequest.request( + { + method: 'GET', + url: '/api/v{api-version}/multiple-tags/a', + }, + configOverrides, + ); + } + /** + * @returns void + * @throws ApiError + */ + public dummyB( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return this.httpRequest.request( + { + method: 'GET', + url: '/api/v{api-version}/multiple-tags/b', + }, + configOverrides, + ); + } +} +" +`; + +exports[`client should generate: test/generated/client/services/MultipleTags2Service.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { CancelablePromise } from '../core/CancelablePromise'; +import type { BaseHttpRequest } from '../core/BaseHttpRequest'; +import type { OpenAPIConfig } from '../core/OpenAPI'; +export class MultipleTags2Service { + constructor(public readonly httpRequest: BaseHttpRequest) {} + /** + * @returns void + * @throws ApiError + */ + public dummyA( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return this.httpRequest.request( + { + method: 'GET', + url: '/api/v{api-version}/multiple-tags/a', + }, + configOverrides, + ); + } + /** + * @returns void + * @throws ApiError + */ + public dummyB( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return this.httpRequest.request( + { + method: 'GET', + url: '/api/v{api-version}/multiple-tags/b', + }, + configOverrides, + ); + } +} +" +`; + +exports[`client should generate: test/generated/client/services/MultipleTags3Service.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { CancelablePromise } from '../core/CancelablePromise'; +import type { BaseHttpRequest } from '../core/BaseHttpRequest'; +import type { OpenAPIConfig } from '../core/OpenAPI'; +export class MultipleTags3Service { + constructor(public readonly httpRequest: BaseHttpRequest) {} + /** + * @returns void + * @throws ApiError + */ + public dummyB( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return this.httpRequest.request( + { + method: 'GET', + url: '/api/v{api-version}/multiple-tags/b', + }, + configOverrides, + ); + } +} +" +`; + +exports[`client should generate: test/generated/client/services/NoContentService.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { CancelablePromise } from '../core/CancelablePromise'; +import type { BaseHttpRequest } from '../core/BaseHttpRequest'; +import type { OpenAPIConfig } from '../core/OpenAPI'; +export class NoContentService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + /** + * @returns void + * @throws ApiError + */ + public callWithNoContentResponse( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return this.httpRequest.request( + { + method: 'GET', + url: '/api/v{api-version}/no-content', + }, + configOverrides, + ); + } +} +" +`; + +exports[`client should generate: test/generated/client/services/ParametersService.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ModelWithString } from '../models/ModelWithString'; +import type { Pageable } from '../models/Pageable'; +import type { CancelablePromise } from '../core/CancelablePromise'; +import type { BaseHttpRequest } from '../core/BaseHttpRequest'; +import type { OpenAPIConfig } from '../core/OpenAPI'; +export class ParametersService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + /** + * @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 [configOverrides] Overrides OpenAPIConfig + * @throws ApiError + */ + public callWithParameters( + parameterHeader: string | null, + parameterQuery: string | null, + parameterForm: string | null, + parameterCookie: string | null, + parameterPath: string | null, + requestBody: ModelWithString | null, + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return this.httpRequest.request( + { + method: 'POST', + url: '/api/v{api-version}/parameters/{parameterPath}', + path: { + 'parameterPath': parameterPath, + }, + cookies: { + 'parameterCookie': parameterCookie, + }, + headers: { + 'parameterHeader': parameterHeader, + }, + query: { + 'parameterQuery': parameterQuery, + }, + formData: { + 'parameterForm': parameterForm, + }, + body: requestBody, + mediaType: 'application/json', + }, + configOverrides, + ); + } + /** + * @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 [configOverrides] Overrides OpenAPIConfig + * @throws ApiError + */ + public callWithWeirdParameterNames( + parameterHeader: string | null, + parameterQuery: string | null, + parameterForm: string | null, + parameterCookie: string | null, + requestBody: ModelWithString | null, + parameterPath1?: string, + parameterPath2?: string, + parameterPath3?: string, + _default?: string, + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return this.httpRequest.request( + { + method: 'POST', + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', + path: { + 'parameter.path.1': parameterPath1, + 'parameter-path-2': parameterPath2, + 'PARAMETER-PATH-3': parameterPath3, + }, + cookies: { + 'PARAMETER-COOKIE': parameterCookie, + }, + headers: { + 'parameter.header': parameterHeader, + }, + query: { + 'default': _default, + 'parameter-query': parameterQuery, + }, + formData: { + 'parameter_form': parameterForm, + }, + body: requestBody, + mediaType: 'application/json', + }, + configOverrides, + ); + } + /** + * @param requestBody This is a required parameter + * @param parameter This is an optional parameter + * @param [configOverrides] Overrides OpenAPIConfig + * @throws ApiError + */ + public getCallWithOptionalParam( + requestBody: ModelWithString, + parameter?: string, + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return this.httpRequest.request( + { + method: 'GET', + url: '/api/v{api-version}/parameters/', + query: { + 'parameter': parameter, + }, + body: requestBody, + mediaType: 'application/json', + }, + configOverrides, + ); + } + /** + * @param parameter This is a required parameter + * @param requestBody This is an optional parameter + * @param [configOverrides] Overrides OpenAPIConfig + * @throws ApiError + */ + public postCallWithOptionalParam( + parameter: Pageable, + requestBody?: ModelWithString, + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return this.httpRequest.request( + { + method: 'POST', + url: '/api/v{api-version}/parameters/', + query: { + 'parameter': parameter, + }, + body: requestBody, + mediaType: 'application/json', + }, + configOverrides, + ); + } +} +" +`; + +exports[`client should generate: test/generated/client/services/RequestBodyService.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ModelWithString } from '../models/ModelWithString'; +import type { CancelablePromise } from '../core/CancelablePromise'; +import type { BaseHttpRequest } from '../core/BaseHttpRequest'; +import type { OpenAPIConfig } from '../core/OpenAPI'; +export class RequestBodyService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + /** + * @param parameter This is a reusable parameter + * @param requestBody A reusable request body + * @param [configOverrides] Overrides OpenAPIConfig + * @throws ApiError + */ + public postApiRequestBody( + parameter?: string, + requestBody?: ModelWithString, + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return this.httpRequest.request( + { + method: 'POST', + url: '/api/v{api-version}/requestBody/', + query: { + 'parameter': parameter, + }, + body: requestBody, + mediaType: 'application/json', + }, + configOverrides, + ); + } +} +" +`; + +exports[`client should generate: test/generated/client/services/ResponseService.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* 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 type { CancelablePromise } from '../core/CancelablePromise'; +import type { BaseHttpRequest } from '../core/BaseHttpRequest'; +import type { OpenAPIConfig } from '../core/OpenAPI'; +export class ResponseService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + /** + * @returns ModelWithString + * @throws ApiError + */ + public callWithResponse( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return this.httpRequest.request( + { + method: 'GET', + url: '/api/v{api-version}/response', + }, + configOverrides, + ); + } + /** + * @returns ModelWithString Message for default response + * @throws ApiError + */ + public callWithDuplicateResponses( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return this.httpRequest.request( + { + method: 'POST', + url: '/api/v{api-version}/response', + errors: { + 500: \`Message for 500 error\`, + 501: \`Message for 501 error\`, + 502: \`Message for 502 error\`, + }, + }, + configOverrides, + ); + } + /** + * @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 callWithResponses( + configOverrides?: OpenAPIConfig, + ): CancelablePromise<{ + readonly '@namespace.string'?: string; + readonly '@namespace.integer'?: number; + readonly value?: Array; + } | ModelWithString | ModelThatExtends | ModelThatExtendsExtends> { + return this.httpRequest.request( + { + method: 'PUT', + url: '/api/v{api-version}/response', + errors: { + 500: \`Message for 500 error\`, + 501: \`Message for 501 error\`, + 502: \`Message for 502 error\`, + }, + }, + configOverrides, + ); + } +} +" +`; + +exports[`client should generate: test/generated/client/services/SimpleService.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { CancelablePromise } from '../core/CancelablePromise'; +import type { BaseHttpRequest } from '../core/BaseHttpRequest'; +import type { OpenAPIConfig } from '../core/OpenAPI'; +export class SimpleService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + /** + * @throws ApiError + */ + public getCallWithoutParametersAndResponse( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return this.httpRequest.request( + { + method: 'GET', + url: '/api/v{api-version}/simple', + }, + configOverrides, + ); + } + /** + * @throws ApiError + */ + public putCallWithoutParametersAndResponse( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return this.httpRequest.request( + { + method: 'PUT', + url: '/api/v{api-version}/simple', + }, + configOverrides, + ); + } + /** + * @throws ApiError + */ + public postCallWithoutParametersAndResponse( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return this.httpRequest.request( + { + method: 'POST', + url: '/api/v{api-version}/simple', + }, + configOverrides, + ); + } + /** + * @throws ApiError + */ + public deleteCallWithoutParametersAndResponse( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return this.httpRequest.request( + { + method: 'DELETE', + url: '/api/v{api-version}/simple', + }, + configOverrides, + ); + } + /** + * @throws ApiError + */ + public optionsCallWithoutParametersAndResponse( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return this.httpRequest.request( + { + method: 'OPTIONS', + url: '/api/v{api-version}/simple', + }, + configOverrides, + ); + } + /** + * @throws ApiError + */ + public headCallWithoutParametersAndResponse( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return this.httpRequest.request( + { + method: 'HEAD', + url: '/api/v{api-version}/simple', + }, + configOverrides, + ); + } + /** + * @throws ApiError + */ + public patchCallWithoutParametersAndResponse( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return this.httpRequest.request( + { + method: 'PATCH', + url: '/api/v{api-version}/simple', + }, + configOverrides, + ); + } +} +" +`; + +exports[`client should generate: test/generated/client/services/TypesService.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { CancelablePromise } from '../core/CancelablePromise'; +import type { BaseHttpRequest } from '../core/BaseHttpRequest'; +import type { OpenAPIConfig } from '../core/OpenAPI'; +export class TypesService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + /** + * @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 [configOverrides] Overrides OpenAPIConfig + * @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 types( + parameterArray: Array | null, + parameterDictionary: Record | null, + parameterEnum: 'Success' | 'Warning' | 'Error' | null, + parameterNumber: number = 123, + parameterString: string | null = 'default', + parameterBoolean: boolean | null = true, + parameterObject: Record | null = null, + id?: number, + configOverrides?: OpenAPIConfig, + ): CancelablePromise> { + return this.httpRequest.request( + { + method: 'GET', + url: '/api/v{api-version}/types', + path: { + 'id': id, + }, + query: { + 'parameterNumber': parameterNumber, + 'parameterString': parameterString, + 'parameterBoolean': parameterBoolean, + 'parameterObject': parameterObject, + 'parameterArray': parameterArray, + 'parameterDictionary': parameterDictionary, + 'parameterEnum': parameterEnum, + }, + }, + configOverrides, + ); + } +} +" +`; + +exports[`client should generate: test/generated/client/services/UploadService.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { CancelablePromise } from '../core/CancelablePromise'; +import type { BaseHttpRequest } from '../core/BaseHttpRequest'; +import type { OpenAPIConfig } from '../core/OpenAPI'; +export class UploadService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + /** + * @param file Supply a file reference for upload + * @param [configOverrides] Overrides OpenAPIConfig + * @returns boolean + * @throws ApiError + */ + public uploadFile( + file: Blob, + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return this.httpRequest.request( + { + method: 'POST', + url: '/api/v{api-version}/upload', + formData: { + 'file': file, + }, + }, + configOverrides, + ); + } +} +" +`; + exports[`v2 should generate: test/generated/v2/core/ApiError.ts 1`] = ` "/* generated using openapi-typescript-codegen -- do no edit */ /* istanbul ignore file */ @@ -2334,6 +7001,7 @@ exports[`v2 should generate: test/generated/v2/services/CollectionFormatService. /* tslint:disable */ /* eslint-disable */ import type { CancelablePromise } from '../core/CancelablePromise'; +import type { OpenAPIConfig } from '../core/OpenAPI'; import { OpenAPI } from '../core/OpenAPI'; import { request as __request } from '../core/request'; export class CollectionFormatService { @@ -2343,6 +7011,7 @@ export class CollectionFormatService { * @param parameterArrayTsv This is an array parameter that is sent as tsv format (tab-separated values) * @param parameterArrayPipes This is an array parameter that is sent as pipes format (pipe-separated values) * @param parameterArrayMulti This is an array parameter that is sent as multi format (multiple parameter instances) + * @param [configOverrides] Overrides OpenAPIConfig * @throws ApiError */ public static collectionFormat( @@ -2351,18 +7020,25 @@ export class CollectionFormatService { parameterArrayTsv: Array, parameterArrayPipes: Array, parameterArrayMulti: Array, + configOverrides?: OpenAPIConfig, ): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/api/v{api-version}/collectionFormat', - query: { - 'parameterArrayCSV': parameterArrayCsv, - 'parameterArraySSV': parameterArraySsv, - 'parameterArrayTSV': parameterArrayTsv, - 'parameterArrayPipes': parameterArrayPipes, - 'parameterArrayMulti': parameterArrayMulti, + return __request( + { + ...OpenAPI, + ...configOverrides, }, - }); + { + method: 'GET', + url: '/api/v{api-version}/collectionFormat', + query: { + 'parameterArrayCSV': parameterArrayCsv, + 'parameterArraySSV': parameterArraySsv, + 'parameterArrayTSV': parameterArrayTsv, + 'parameterArrayPipes': parameterArrayPipes, + 'parameterArrayMulti': parameterArrayMulti, + }, + } + ); } } " @@ -2375,12 +7051,14 @@ exports[`v2 should generate: test/generated/v2/services/ComplexService.ts 1`] = /* eslint-disable */ import type { ModelWithString } from '../models/ModelWithString'; import type { CancelablePromise } from '../core/CancelablePromise'; +import type { OpenAPIConfig } from '../core/OpenAPI'; import { OpenAPI } from '../core/OpenAPI'; import { request as __request } from '../core/request'; export class ComplexService { /** * @param parameterObject Parameter containing object * @param parameterReference Parameter containing reference + * @param [configOverrides] Overrides OpenAPIConfig * @returns ModelWithString Successful response * @throws ApiError */ @@ -2393,19 +7071,26 @@ export class ComplexService { }; }, parameterReference: ModelWithString, + configOverrides?: OpenAPIConfig, ): CancelablePromise> { - return __request(OpenAPI, { - method: 'GET', - url: '/api/v{api-version}/complex', - query: { - 'parameterObject': parameterObject, - 'parameterReference': parameterReference, - }, - errors: { - 400: \`400 server error\`, - 500: \`500 server error\`, + return __request( + { + ...OpenAPI, + ...configOverrides, }, - }); + { + method: 'GET', + url: '/api/v{api-version}/complex', + query: { + 'parameterObject': parameterObject, + 'parameterReference': parameterReference, + }, + errors: { + 400: \`400 server error\`, + 500: \`500 server error\`, + }, + } + ); } } " @@ -2417,17 +7102,26 @@ exports[`v2 should generate: test/generated/v2/services/DefaultService.ts 1`] = /* tslint:disable */ /* eslint-disable */ import type { CancelablePromise } from '../core/CancelablePromise'; +import type { OpenAPIConfig } from '../core/OpenAPI'; import { OpenAPI } from '../core/OpenAPI'; import { request as __request } from '../core/request'; export class DefaultService { /** * @throws ApiError */ - public static serviceWithEmptyTag(): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/api/v{api-version}/no-tag', - }); + public static serviceWithEmptyTag( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return __request( + { + ...OpenAPI, + ...configOverrides, + }, + { + method: 'GET', + url: '/api/v{api-version}/no-tag', + } + ); } } " @@ -2440,6 +7134,7 @@ exports[`v2 should generate: test/generated/v2/services/DefaultsService.ts 1`] = /* eslint-disable */ import type { ModelWithString } from '../models/ModelWithString'; import type { CancelablePromise } from '../core/CancelablePromise'; +import type { OpenAPIConfig } from '../core/OpenAPI'; import { OpenAPI } from '../core/OpenAPI'; import { request as __request } from '../core/request'; export class DefaultsService { @@ -2449,6 +7144,7 @@ export class DefaultsService { * @param parameterBoolean This is a simple boolean with default value * @param parameterEnum This is a simple enum with default value * @param parameterModel This is a simple model with default value + * @param [configOverrides] Overrides OpenAPIConfig * @throws ApiError */ public static callWithDefaultParameters( @@ -2459,18 +7155,25 @@ export class DefaultsService { parameterModel: ModelWithString = { "prop": "Hello World!" }, + configOverrides?: OpenAPIConfig, ): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/api/v{api-version}/defaults', - query: { - 'parameterString': parameterString, - 'parameterNumber': parameterNumber, - 'parameterBoolean': parameterBoolean, - 'parameterEnum': parameterEnum, - 'parameterModel': parameterModel, + return __request( + { + ...OpenAPI, + ...configOverrides, }, - }); + { + method: 'GET', + url: '/api/v{api-version}/defaults', + query: { + 'parameterString': parameterString, + 'parameterNumber': parameterNumber, + 'parameterBoolean': parameterBoolean, + 'parameterEnum': parameterEnum, + 'parameterModel': parameterModel, + }, + } + ); } /** * @param parameterString This is a simple string that is optional with default value @@ -2478,6 +7181,7 @@ export class DefaultsService { * @param parameterBoolean This is a simple boolean that is optional with default value * @param parameterEnum This is a simple enum that is optional with default value * @param parameterModel This is a simple model that is optional with default value + * @param [configOverrides] Overrides OpenAPIConfig * @throws ApiError */ public static callWithDefaultOptionalParameters( @@ -2488,18 +7192,25 @@ export class DefaultsService { parameterModel: ModelWithString = { "prop": "Hello World!" }, + configOverrides?: OpenAPIConfig, ): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/api/v{api-version}/defaults', - query: { - 'parameterString': parameterString, - 'parameterNumber': parameterNumber, - 'parameterBoolean': parameterBoolean, - 'parameterEnum': parameterEnum, - 'parameterModel': parameterModel, + return __request( + { + ...OpenAPI, + ...configOverrides, }, - }); + { + method: 'POST', + url: '/api/v{api-version}/defaults', + query: { + 'parameterString': parameterString, + 'parameterNumber': parameterNumber, + 'parameterBoolean': parameterBoolean, + 'parameterEnum': parameterEnum, + 'parameterModel': parameterModel, + }, + } + ); } /** * @param parameterStringWithNoDefault This is a string with no default @@ -2510,6 +7221,7 @@ export class DefaultsService { * @param parameterStringWithEmptyDefault This is a string with empty default * @param parameterStringNullableWithNoDefault This is a string that can be null with no default * @param parameterStringNullableWithDefault This is a string that can be null with default + * @param [configOverrides] Overrides OpenAPIConfig * @throws ApiError */ public static callToTestOrderOfParams( @@ -2521,21 +7233,28 @@ export class DefaultsService { parameterStringWithEmptyDefault: string = '', parameterStringNullableWithNoDefault?: string | null, parameterStringNullableWithDefault: string | null = null, + configOverrides?: OpenAPIConfig, ): CancelablePromise { - return __request(OpenAPI, { - method: 'PUT', - url: '/api/v{api-version}/defaults', - query: { - 'parameterOptionalStringWithDefault': parameterOptionalStringWithDefault, - 'parameterOptionalStringWithEmptyDefault': parameterOptionalStringWithEmptyDefault, - 'parameterOptionalStringWithNoDefault': parameterOptionalStringWithNoDefault, - 'parameterStringWithDefault': parameterStringWithDefault, - 'parameterStringWithEmptyDefault': parameterStringWithEmptyDefault, - 'parameterStringWithNoDefault': parameterStringWithNoDefault, - 'parameterStringNullableWithNoDefault': parameterStringNullableWithNoDefault, - 'parameterStringNullableWithDefault': parameterStringNullableWithDefault, + return __request( + { + ...OpenAPI, + ...configOverrides, }, - }); + { + method: 'PUT', + url: '/api/v{api-version}/defaults', + query: { + 'parameterOptionalStringWithDefault': parameterOptionalStringWithDefault, + 'parameterOptionalStringWithEmptyDefault': parameterOptionalStringWithEmptyDefault, + 'parameterOptionalStringWithNoDefault': parameterOptionalStringWithNoDefault, + 'parameterStringWithDefault': parameterStringWithDefault, + 'parameterStringWithEmptyDefault': parameterStringWithEmptyDefault, + 'parameterStringWithNoDefault': parameterStringWithNoDefault, + 'parameterStringNullableWithNoDefault': parameterStringNullableWithNoDefault, + 'parameterStringNullableWithDefault': parameterStringNullableWithDefault, + }, + } + ); } } " @@ -2547,6 +7266,7 @@ exports[`v2 should generate: test/generated/v2/services/DescriptionsService.ts 1 /* tslint:disable */ /* eslint-disable */ import type { CancelablePromise } from '../core/CancelablePromise'; +import type { OpenAPIConfig } from '../core/OpenAPI'; import { OpenAPI } from '../core/OpenAPI'; import { request as __request } from '../core/request'; export class DescriptionsService { @@ -2560,6 +7280,7 @@ export class DescriptionsService { * @param parameterWithExpressionPlaceholders Testing expression placeholders in string: \${expression} should work * @param parameterWithQuotes Testing quotes in string: 'single quote''' and "double quotes""" should work * @param parameterWithReservedCharacters Testing reserved characters in string: * inline * and ** inline ** should work + * @param [configOverrides] Overrides OpenAPIConfig * @throws ApiError */ public static callWithDescriptions( @@ -2569,19 +7290,26 @@ export class DescriptionsService { parameterWithExpressionPlaceholders?: string, parameterWithQuotes?: string, parameterWithReservedCharacters?: string, + configOverrides?: OpenAPIConfig, ): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/api/v{api-version}/descriptions/', - query: { - 'parameterWithBreaks': parameterWithBreaks, - 'parameterWithBackticks': parameterWithBackticks, - 'parameterWithSlashes': parameterWithSlashes, - 'parameterWithExpressionPlaceholders': parameterWithExpressionPlaceholders, - 'parameterWithQuotes': parameterWithQuotes, - 'parameterWithReservedCharacters': parameterWithReservedCharacters, + return __request( + { + ...OpenAPI, + ...configOverrides, }, - }); + { + method: 'POST', + url: '/api/v{api-version}/descriptions/', + query: { + 'parameterWithBreaks': parameterWithBreaks, + 'parameterWithBackticks': parameterWithBackticks, + 'parameterWithSlashes': parameterWithSlashes, + 'parameterWithExpressionPlaceholders': parameterWithExpressionPlaceholders, + 'parameterWithQuotes': parameterWithQuotes, + 'parameterWithReservedCharacters': parameterWithReservedCharacters, + }, + } + ); } } " @@ -2593,44 +7321,77 @@ exports[`v2 should generate: test/generated/v2/services/DuplicateService.ts 1`] /* tslint:disable */ /* eslint-disable */ import type { CancelablePromise } from '../core/CancelablePromise'; +import type { OpenAPIConfig } from '../core/OpenAPI'; import { OpenAPI } from '../core/OpenAPI'; import { request as __request } from '../core/request'; export class DuplicateService { /** * @throws ApiError */ - public static duplicateName(): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/api/v{api-version}/duplicate', - }); + public static duplicateName( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return __request( + { + ...OpenAPI, + ...configOverrides, + }, + { + method: 'GET', + url: '/api/v{api-version}/duplicate', + } + ); } /** * @throws ApiError */ - public static duplicateName1(): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/api/v{api-version}/duplicate', - }); + public static duplicateName1( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return __request( + { + ...OpenAPI, + ...configOverrides, + }, + { + method: 'POST', + url: '/api/v{api-version}/duplicate', + } + ); } /** * @throws ApiError */ - public static duplicateName2(): CancelablePromise { - return __request(OpenAPI, { - method: 'PUT', - url: '/api/v{api-version}/duplicate', - }); + public static duplicateName2( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return __request( + { + ...OpenAPI, + ...configOverrides, + }, + { + method: 'PUT', + url: '/api/v{api-version}/duplicate', + } + ); } /** * @throws ApiError */ - public static duplicateName3(): CancelablePromise { - return __request(OpenAPI, { - method: 'DELETE', - url: '/api/v{api-version}/duplicate', - }); + public static duplicateName3( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return __request( + { + ...OpenAPI, + ...configOverrides, + }, + { + method: 'DELETE', + url: '/api/v{api-version}/duplicate', + } + ); } } " @@ -2642,30 +7403,39 @@ exports[`v2 should generate: test/generated/v2/services/ErrorService.ts 1`] = ` /* tslint:disable */ /* eslint-disable */ import type { CancelablePromise } from '../core/CancelablePromise'; +import type { OpenAPIConfig } from '../core/OpenAPI'; import { OpenAPI } from '../core/OpenAPI'; import { request as __request } from '../core/request'; export class ErrorService { /** * @param status Status code to return + * @param [configOverrides] Overrides OpenAPIConfig * @returns any Custom message: Successful response * @throws ApiError */ public static testErrorCode( status: string, + configOverrides?: OpenAPIConfig, ): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/api/v{api-version}/error', - query: { - 'status': status, - }, - errors: { - 500: \`Custom message: Internal Server Error\`, - 501: \`Custom message: Not Implemented\`, - 502: \`Custom message: Bad Gateway\`, - 503: \`Custom message: Service Unavailable\`, + return __request( + { + ...OpenAPI, + ...configOverrides, }, - }); + { + method: 'POST', + url: '/api/v{api-version}/error', + query: { + 'status': status, + }, + errors: { + 500: \`Custom message: Internal Server Error\`, + 501: \`Custom message: Not Implemented\`, + 502: \`Custom message: Bad Gateway\`, + 503: \`Custom message: Service Unavailable\`, + }, + } + ); } } " @@ -2677,6 +7447,7 @@ exports[`v2 should generate: test/generated/v2/services/HeaderService.ts 1`] = ` /* tslint:disable */ /* eslint-disable */ import type { CancelablePromise } from '../core/CancelablePromise'; +import type { OpenAPIConfig } from '../core/OpenAPI'; import { OpenAPI } from '../core/OpenAPI'; import { request as __request } from '../core/request'; export class HeaderService { @@ -2684,16 +7455,24 @@ export class HeaderService { * @returns string Successful response * @throws ApiError */ - public static callWithResultFromHeader(): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/api/v{api-version}/header', - responseHeader: 'operation-location', - errors: { - 400: \`400 server error\`, - 500: \`500 server error\`, + public static callWithResultFromHeader( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return __request( + { + ...OpenAPI, + ...configOverrides, }, - }); + { + method: 'POST', + url: '/api/v{api-version}/header', + responseHeader: 'operation-location', + errors: { + 400: \`400 server error\`, + 500: \`500 server error\`, + }, + } + ); } } " @@ -2705,6 +7484,7 @@ exports[`v2 should generate: test/generated/v2/services/MultipleTags1Service.ts /* tslint:disable */ /* eslint-disable */ import type { CancelablePromise } from '../core/CancelablePromise'; +import type { OpenAPIConfig } from '../core/OpenAPI'; import { OpenAPI } from '../core/OpenAPI'; import { request as __request } from '../core/request'; export class MultipleTags1Service { @@ -2712,21 +7492,37 @@ export class MultipleTags1Service { * @returns void * @throws ApiError */ - public static dummyA(): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/api/v{api-version}/multiple-tags/a', - }); + public static dummyA( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return __request( + { + ...OpenAPI, + ...configOverrides, + }, + { + method: 'GET', + url: '/api/v{api-version}/multiple-tags/a', + } + ); } /** * @returns void * @throws ApiError */ - public static dummyB(): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/api/v{api-version}/multiple-tags/b', - }); + public static dummyB( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return __request( + { + ...OpenAPI, + ...configOverrides, + }, + { + method: 'GET', + url: '/api/v{api-version}/multiple-tags/b', + } + ); } } " @@ -2738,6 +7534,7 @@ exports[`v2 should generate: test/generated/v2/services/MultipleTags2Service.ts /* tslint:disable */ /* eslint-disable */ import type { CancelablePromise } from '../core/CancelablePromise'; +import type { OpenAPIConfig } from '../core/OpenAPI'; import { OpenAPI } from '../core/OpenAPI'; import { request as __request } from '../core/request'; export class MultipleTags2Service { @@ -2745,21 +7542,37 @@ export class MultipleTags2Service { * @returns void * @throws ApiError */ - public static dummyA(): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/api/v{api-version}/multiple-tags/a', - }); + public static dummyA( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return __request( + { + ...OpenAPI, + ...configOverrides, + }, + { + method: 'GET', + url: '/api/v{api-version}/multiple-tags/a', + } + ); } /** * @returns void * @throws ApiError */ - public static dummyB(): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/api/v{api-version}/multiple-tags/b', - }); + public static dummyB( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return __request( + { + ...OpenAPI, + ...configOverrides, + }, + { + method: 'GET', + url: '/api/v{api-version}/multiple-tags/b', + } + ); } } " @@ -2771,6 +7584,7 @@ exports[`v2 should generate: test/generated/v2/services/MultipleTags3Service.ts /* tslint:disable */ /* eslint-disable */ import type { CancelablePromise } from '../core/CancelablePromise'; +import type { OpenAPIConfig } from '../core/OpenAPI'; import { OpenAPI } from '../core/OpenAPI'; import { request as __request } from '../core/request'; export class MultipleTags3Service { @@ -2778,11 +7592,19 @@ export class MultipleTags3Service { * @returns void * @throws ApiError */ - public static dummyB(): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/api/v{api-version}/multiple-tags/b', - }); + public static dummyB( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return __request( + { + ...OpenAPI, + ...configOverrides, + }, + { + method: 'GET', + url: '/api/v{api-version}/multiple-tags/b', + } + ); } } " @@ -2794,6 +7616,7 @@ exports[`v2 should generate: test/generated/v2/services/NoContentService.ts 1`] /* tslint:disable */ /* eslint-disable */ import type { CancelablePromise } from '../core/CancelablePromise'; +import type { OpenAPIConfig } from '../core/OpenAPI'; import { OpenAPI } from '../core/OpenAPI'; import { request as __request } from '../core/request'; export class NoContentService { @@ -2801,11 +7624,19 @@ export class NoContentService { * @returns void * @throws ApiError */ - public static callWithNoContentResponse(): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/api/v{api-version}/no-content', - }); + public static callWithNoContentResponse( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return __request( + { + ...OpenAPI, + ...configOverrides, + }, + { + method: 'GET', + url: '/api/v{api-version}/no-content', + } + ); } } " @@ -2817,6 +7648,7 @@ exports[`v2 should generate: test/generated/v2/services/ParametersService.ts 1`] /* tslint:disable */ /* eslint-disable */ import type { CancelablePromise } from '../core/CancelablePromise'; +import type { OpenAPIConfig } from '../core/OpenAPI'; import { OpenAPI } from '../core/OpenAPI'; import { request as __request } from '../core/request'; export class ParametersService { @@ -2826,6 +7658,7 @@ export class ParametersService { * @param parameterForm This is the parameter that goes into the form data * @param parameterBody This is the parameter that is sent as request body * @param parameterPath This is the parameter that goes into the path + * @param [configOverrides] Overrides OpenAPIConfig * @throws ApiError */ public static callWithParameters( @@ -2834,24 +7667,31 @@ export class ParametersService { parameterForm: string, parameterBody: string, parameterPath: string, + configOverrides?: OpenAPIConfig, ): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/api/v{api-version}/parameters/{parameterPath}', - path: { - 'parameterPath': parameterPath, - }, - headers: { - 'parameterHeader': parameterHeader, - }, - query: { - 'parameterQuery': parameterQuery, - }, - formData: { - 'parameterForm': parameterForm, + return __request( + { + ...OpenAPI, + ...configOverrides, }, - body: parameterBody, - }); + { + method: 'POST', + url: '/api/v{api-version}/parameters/{parameterPath}', + path: { + 'parameterPath': parameterPath, + }, + headers: { + 'parameterHeader': parameterHeader, + }, + query: { + 'parameterQuery': parameterQuery, + }, + formData: { + 'parameterForm': parameterForm, + }, + body: parameterBody, + } + ); } /** * @param parameterHeader This is the parameter that goes into the request header @@ -2862,6 +7702,7 @@ export class ParametersService { * @param parameterPath2 This is the parameter that goes into the path * @param parameterPath3 This is the parameter that goes into the path * @param _default This is the parameter with a reserved keyword + * @param [configOverrides] Overrides OpenAPIConfig * @throws ApiError */ public static callWithWeirdParameterNames( @@ -2873,27 +7714,34 @@ export class ParametersService { parameterPath2?: string, parameterPath3?: string, _default?: string, + configOverrides?: OpenAPIConfig, ): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', - path: { - 'parameter.path.1': parameterPath1, - 'parameter-path-2': parameterPath2, - 'PARAMETER-PATH-3': parameterPath3, - }, - headers: { - 'parameter.header': parameterHeader, + return __request( + { + ...OpenAPI, + ...configOverrides, }, - query: { - 'default': _default, - 'parameter-query': parameterQuery, - }, - formData: { - 'parameter_form': parameterForm, - }, - body: parameterBody, - }); + { + method: 'POST', + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', + path: { + 'parameter.path.1': parameterPath1, + 'parameter-path-2': parameterPath2, + 'PARAMETER-PATH-3': parameterPath3, + }, + headers: { + 'parameter.header': parameterHeader, + }, + query: { + 'default': _default, + 'parameter-query': parameterQuery, + }, + formData: { + 'parameter_form': parameterForm, + }, + body: parameterBody, + } + ); } } " @@ -2908,6 +7756,7 @@ import type { ModelThatExtends } from '../models/ModelThatExtends'; import type { ModelThatExtendsExtends } from '../models/ModelThatExtendsExtends'; import type { ModelWithString } from '../models/ModelWithString'; import type { CancelablePromise } from '../core/CancelablePromise'; +import type { OpenAPIConfig } from '../core/OpenAPI'; import { OpenAPI } from '../core/OpenAPI'; import { request as __request } from '../core/request'; export class ResponseService { @@ -2915,26 +7764,42 @@ export class ResponseService { * @returns ModelWithString Message for default response * @throws ApiError */ - public static callWithResponse(): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/api/v{api-version}/response', - }); + public static callWithResponse( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return __request( + { + ...OpenAPI, + ...configOverrides, + }, + { + method: 'GET', + url: '/api/v{api-version}/response', + } + ); } /** * @returns ModelWithString Message for default response * @throws ApiError */ - public static callWithDuplicateResponses(): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/api/v{api-version}/response', - errors: { - 500: \`Message for 500 error\`, - 501: \`Message for 501 error\`, - 502: \`Message for 502 error\`, + public static callWithDuplicateResponses( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return __request( + { + ...OpenAPI, + ...configOverrides, }, - }); + { + method: 'POST', + url: '/api/v{api-version}/response', + errors: { + 500: \`Message for 500 error\`, + 501: \`Message for 501 error\`, + 502: \`Message for 502 error\`, + }, + } + ); } /** * @returns any Message for 200 response @@ -2943,20 +7808,28 @@ export class ResponseService { * @returns ModelThatExtendsExtends Message for 202 response * @throws ApiError */ - public static callWithResponses(): CancelablePromise<{ + public static callWithResponses( + configOverrides?: OpenAPIConfig, + ): CancelablePromise<{ readonly '@namespace.string'?: string; readonly '@namespace.integer'?: number; readonly value?: Array; } | ModelWithString | ModelThatExtends | ModelThatExtendsExtends> { - return __request(OpenAPI, { - method: 'PUT', - url: '/api/v{api-version}/response', - errors: { - 500: \`Message for 500 error\`, - 501: \`Message for 501 error\`, - 502: \`Message for 502 error\`, + return __request( + { + ...OpenAPI, + ...configOverrides, }, - }); + { + method: 'PUT', + url: '/api/v{api-version}/response', + errors: { + 500: \`Message for 500 error\`, + 501: \`Message for 501 error\`, + 502: \`Message for 502 error\`, + }, + } + ); } } " @@ -2968,71 +7841,128 @@ exports[`v2 should generate: test/generated/v2/services/SimpleService.ts 1`] = ` /* tslint:disable */ /* eslint-disable */ import type { CancelablePromise } from '../core/CancelablePromise'; +import type { OpenAPIConfig } from '../core/OpenAPI'; import { OpenAPI } from '../core/OpenAPI'; import { request as __request } from '../core/request'; export class SimpleService { /** * @throws ApiError */ - public static getCallWithoutParametersAndResponse(): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/api/v{api-version}/simple', - }); + public static getCallWithoutParametersAndResponse( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return __request( + { + ...OpenAPI, + ...configOverrides, + }, + { + method: 'GET', + url: '/api/v{api-version}/simple', + } + ); } /** * @throws ApiError */ - public static putCallWithoutParametersAndResponse(): CancelablePromise { - return __request(OpenAPI, { - method: 'PUT', - url: '/api/v{api-version}/simple', - }); + public static putCallWithoutParametersAndResponse( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return __request( + { + ...OpenAPI, + ...configOverrides, + }, + { + method: 'PUT', + url: '/api/v{api-version}/simple', + } + ); } /** * @throws ApiError */ - public static postCallWithoutParametersAndResponse(): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/api/v{api-version}/simple', - }); + public static postCallWithoutParametersAndResponse( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return __request( + { + ...OpenAPI, + ...configOverrides, + }, + { + method: 'POST', + url: '/api/v{api-version}/simple', + } + ); } /** * @throws ApiError */ - public static deleteCallWithoutParametersAndResponse(): CancelablePromise { - return __request(OpenAPI, { - method: 'DELETE', - url: '/api/v{api-version}/simple', - }); + public static deleteCallWithoutParametersAndResponse( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return __request( + { + ...OpenAPI, + ...configOverrides, + }, + { + method: 'DELETE', + url: '/api/v{api-version}/simple', + } + ); } /** * @throws ApiError */ - public static optionsCallWithoutParametersAndResponse(): CancelablePromise { - return __request(OpenAPI, { - method: 'OPTIONS', - url: '/api/v{api-version}/simple', - }); + public static optionsCallWithoutParametersAndResponse( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return __request( + { + ...OpenAPI, + ...configOverrides, + }, + { + method: 'OPTIONS', + url: '/api/v{api-version}/simple', + } + ); } /** * @throws ApiError */ - public static headCallWithoutParametersAndResponse(): CancelablePromise { - return __request(OpenAPI, { - method: 'HEAD', - url: '/api/v{api-version}/simple', - }); + public static headCallWithoutParametersAndResponse( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return __request( + { + ...OpenAPI, + ...configOverrides, + }, + { + method: 'HEAD', + url: '/api/v{api-version}/simple', + } + ); } /** * @throws ApiError */ - public static patchCallWithoutParametersAndResponse(): CancelablePromise { - return __request(OpenAPI, { - method: 'PATCH', - url: '/api/v{api-version}/simple', - }); + public static patchCallWithoutParametersAndResponse( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return __request( + { + ...OpenAPI, + ...configOverrides, + }, + { + method: 'PATCH', + url: '/api/v{api-version}/simple', + } + ); } } " @@ -3044,6 +7974,7 @@ exports[`v2 should generate: test/generated/v2/services/TypesService.ts 1`] = ` /* tslint:disable */ /* eslint-disable */ import type { CancelablePromise } from '../core/CancelablePromise'; +import type { OpenAPIConfig } from '../core/OpenAPI'; import { OpenAPI } from '../core/OpenAPI'; import { request as __request } from '../core/request'; export class TypesService { @@ -3056,6 +7987,7 @@ export class TypesService { * @param parameterBoolean This is a boolean parameter * @param parameterObject This is an object parameter * @param id This is a number parameter + * @param [configOverrides] Overrides OpenAPIConfig * @returns number Response is a simple number * @returns string Response is a simple string * @returns boolean Response is a simple boolean @@ -3071,23 +8003,30 @@ export class TypesService { parameterBoolean: boolean = true, parameterObject: any = null, id?: number, + configOverrides?: OpenAPIConfig, ): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/api/v{api-version}/types', - path: { - 'id': id, - }, - query: { - 'parameterNumber': parameterNumber, - 'parameterString': parameterString, - 'parameterBoolean': parameterBoolean, - 'parameterObject': parameterObject, - 'parameterArray': parameterArray, - 'parameterDictionary': parameterDictionary, - 'parameterEnum': parameterEnum, + return __request( + { + ...OpenAPI, + ...configOverrides, }, - }); + { + method: 'GET', + url: '/api/v{api-version}/types', + path: { + 'id': id, + }, + query: { + 'parameterNumber': parameterNumber, + 'parameterString': parameterString, + 'parameterBoolean': parameterBoolean, + 'parameterObject': parameterObject, + 'parameterArray': parameterArray, + 'parameterDictionary': parameterDictionary, + 'parameterEnum': parameterEnum, + }, + } + ); } } " @@ -6363,6 +11302,7 @@ exports[`v3 should generate: test/generated/v3/services/CollectionFormatService. /* tslint:disable */ /* eslint-disable */ import type { CancelablePromise } from '../core/CancelablePromise'; +import type { OpenAPIConfig } from '../core/OpenAPI'; import { OpenAPI } from '../core/OpenAPI'; import { request as __request } from '../core/request'; export class CollectionFormatService { @@ -6372,6 +11312,7 @@ export class CollectionFormatService { * @param parameterArrayTsv This is an array parameter that is sent as tsv format (tab-separated values) * @param parameterArrayPipes This is an array parameter that is sent as pipes format (pipe-separated values) * @param parameterArrayMulti This is an array parameter that is sent as multi format (multiple parameter instances) + * @param [configOverrides] Overrides OpenAPIConfig * @throws ApiError */ public static collectionFormat( @@ -6380,18 +11321,25 @@ export class CollectionFormatService { parameterArrayTsv: Array | null, parameterArrayPipes: Array | null, parameterArrayMulti: Array | null, + configOverrides?: OpenAPIConfig, ): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/api/v{api-version}/collectionFormat', - query: { - 'parameterArrayCSV': parameterArrayCsv, - 'parameterArraySSV': parameterArraySsv, - 'parameterArrayTSV': parameterArrayTsv, - 'parameterArrayPipes': parameterArrayPipes, - 'parameterArrayMulti': parameterArrayMulti, + return __request( + { + ...OpenAPI, + ...configOverrides, }, - }); + { + method: 'GET', + url: '/api/v{api-version}/collectionFormat', + query: { + 'parameterArrayCSV': parameterArrayCsv, + 'parameterArraySSV': parameterArraySsv, + 'parameterArrayTSV': parameterArrayTsv, + 'parameterArrayPipes': parameterArrayPipes, + 'parameterArrayMulti': parameterArrayMulti, + }, + } + ); } } " @@ -6407,12 +11355,14 @@ import type { ModelWithDictionary } from '../models/ModelWithDictionary'; import type { ModelWithEnum } from '../models/ModelWithEnum'; import type { ModelWithString } from '../models/ModelWithString'; import type { CancelablePromise } from '../core/CancelablePromise'; +import type { OpenAPIConfig } from '../core/OpenAPI'; import { OpenAPI } from '../core/OpenAPI'; import { request as __request } from '../core/request'; export class ComplexService { /** * @param parameterObject Parameter containing object * @param parameterReference Parameter containing reference + * @param [configOverrides] Overrides OpenAPIConfig * @returns ModelWithString Successful response * @throws ApiError */ @@ -6425,23 +11375,31 @@ export class ComplexService { }; }, parameterReference: ModelWithString, + configOverrides?: OpenAPIConfig, ): CancelablePromise> { - return __request(OpenAPI, { - method: 'GET', - url: '/api/v{api-version}/complex', - query: { - 'parameterObject': parameterObject, - 'parameterReference': parameterReference, - }, - errors: { - 400: \`400 server error\`, - 500: \`500 server error\`, + return __request( + { + ...OpenAPI, + ...configOverrides, }, - }); + { + method: 'GET', + url: '/api/v{api-version}/complex', + query: { + 'parameterObject': parameterObject, + 'parameterReference': parameterReference, + }, + errors: { + 400: \`400 server error\`, + 500: \`500 server error\`, + }, + } + ); } /** * @param id * @param requestBody + * @param [configOverrides] Overrides OpenAPIConfig * @returns ModelWithString Success * @throws ApiError */ @@ -6460,16 +11418,23 @@ export class ComplexService { readonly name?: string | null; }; }, + configOverrides?: OpenAPIConfig, ): CancelablePromise { - return __request(OpenAPI, { - method: 'PUT', - url: '/api/v{api-version}/complex/{id}', - path: { - 'id': id, - }, - body: requestBody, - mediaType: 'application/json-patch+json', - }); + return __request( + { + ...OpenAPI, + ...configOverrides, + }, + { + method: 'PUT', + url: '/api/v{api-version}/complex/{id}', + path: { + 'id': id, + }, + body: requestBody, + mediaType: 'application/json-patch+json', + } + ); } } " @@ -6481,17 +11446,26 @@ exports[`v3 should generate: test/generated/v3/services/DefaultService.ts 1`] = /* tslint:disable */ /* eslint-disable */ import type { CancelablePromise } from '../core/CancelablePromise'; +import type { OpenAPIConfig } from '../core/OpenAPI'; import { OpenAPI } from '../core/OpenAPI'; import { request as __request } from '../core/request'; export class DefaultService { /** * @throws ApiError */ - public static serviceWithEmptyTag(): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/api/v{api-version}/no-tag', - }); + public static serviceWithEmptyTag( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return __request( + { + ...OpenAPI, + ...configOverrides, + }, + { + method: 'GET', + url: '/api/v{api-version}/no-tag', + } + ); } } " @@ -6504,6 +11478,7 @@ exports[`v3 should generate: test/generated/v3/services/DefaultsService.ts 1`] = /* eslint-disable */ import type { ModelWithString } from '../models/ModelWithString'; import type { CancelablePromise } from '../core/CancelablePromise'; +import type { OpenAPIConfig } from '../core/OpenAPI'; import { OpenAPI } from '../core/OpenAPI'; import { request as __request } from '../core/request'; export class DefaultsService { @@ -6513,6 +11488,7 @@ export class DefaultsService { * @param parameterBoolean This is a simple boolean with default value * @param parameterEnum This is a simple enum with default value * @param parameterModel This is a simple model with default value + * @param [configOverrides] Overrides OpenAPIConfig * @throws ApiError */ public static callWithDefaultParameters( @@ -6523,18 +11499,25 @@ export class DefaultsService { parameterModel: ModelWithString | null = { "prop": "Hello World!" }, + configOverrides?: OpenAPIConfig, ): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/api/v{api-version}/defaults', - query: { - 'parameterString': parameterString, - 'parameterNumber': parameterNumber, - 'parameterBoolean': parameterBoolean, - 'parameterEnum': parameterEnum, - 'parameterModel': parameterModel, + return __request( + { + ...OpenAPI, + ...configOverrides, }, - }); + { + method: 'GET', + url: '/api/v{api-version}/defaults', + query: { + 'parameterString': parameterString, + 'parameterNumber': parameterNumber, + 'parameterBoolean': parameterBoolean, + 'parameterEnum': parameterEnum, + 'parameterModel': parameterModel, + }, + } + ); } /** * @param parameterString This is a simple string that is optional with default value @@ -6542,6 +11525,7 @@ export class DefaultsService { * @param parameterBoolean This is a simple boolean that is optional with default value * @param parameterEnum This is a simple enum that is optional with default value * @param parameterModel This is a simple model that is optional with default value + * @param [configOverrides] Overrides OpenAPIConfig * @throws ApiError */ public static callWithDefaultOptionalParameters( @@ -6552,18 +11536,25 @@ export class DefaultsService { parameterModel: ModelWithString = { "prop": "Hello World!" }, + configOverrides?: OpenAPIConfig, ): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/api/v{api-version}/defaults', - query: { - 'parameterString': parameterString, - 'parameterNumber': parameterNumber, - 'parameterBoolean': parameterBoolean, - 'parameterEnum': parameterEnum, - 'parameterModel': parameterModel, + return __request( + { + ...OpenAPI, + ...configOverrides, }, - }); + { + method: 'POST', + url: '/api/v{api-version}/defaults', + query: { + 'parameterString': parameterString, + 'parameterNumber': parameterNumber, + 'parameterBoolean': parameterBoolean, + 'parameterEnum': parameterEnum, + 'parameterModel': parameterModel, + }, + } + ); } /** * @param parameterStringWithNoDefault This is a string with no default @@ -6574,6 +11565,7 @@ export class DefaultsService { * @param parameterStringWithEmptyDefault This is a string with empty default * @param parameterStringNullableWithNoDefault This is a string that can be null with no default * @param parameterStringNullableWithDefault This is a string that can be null with default + * @param [configOverrides] Overrides OpenAPIConfig * @throws ApiError */ public static callToTestOrderOfParams( @@ -6585,21 +11577,28 @@ export class DefaultsService { parameterStringWithEmptyDefault: string = '', parameterStringNullableWithNoDefault?: string | null, parameterStringNullableWithDefault: string | null = null, + configOverrides?: OpenAPIConfig, ): CancelablePromise { - return __request(OpenAPI, { - method: 'PUT', - url: '/api/v{api-version}/defaults', - query: { - 'parameterOptionalStringWithDefault': parameterOptionalStringWithDefault, - 'parameterOptionalStringWithEmptyDefault': parameterOptionalStringWithEmptyDefault, - 'parameterOptionalStringWithNoDefault': parameterOptionalStringWithNoDefault, - 'parameterStringWithDefault': parameterStringWithDefault, - 'parameterStringWithEmptyDefault': parameterStringWithEmptyDefault, - 'parameterStringWithNoDefault': parameterStringWithNoDefault, - 'parameterStringNullableWithNoDefault': parameterStringNullableWithNoDefault, - 'parameterStringNullableWithDefault': parameterStringNullableWithDefault, + return __request( + { + ...OpenAPI, + ...configOverrides, }, - }); + { + method: 'PUT', + url: '/api/v{api-version}/defaults', + query: { + 'parameterOptionalStringWithDefault': parameterOptionalStringWithDefault, + 'parameterOptionalStringWithEmptyDefault': parameterOptionalStringWithEmptyDefault, + 'parameterOptionalStringWithNoDefault': parameterOptionalStringWithNoDefault, + 'parameterStringWithDefault': parameterStringWithDefault, + 'parameterStringWithEmptyDefault': parameterStringWithEmptyDefault, + 'parameterStringWithNoDefault': parameterStringWithNoDefault, + 'parameterStringNullableWithNoDefault': parameterStringNullableWithNoDefault, + 'parameterStringNullableWithDefault': parameterStringNullableWithDefault, + }, + } + ); } } " @@ -6612,24 +11611,33 @@ exports[`v3 should generate: test/generated/v3/services/DeprecatedService.ts 1`] /* eslint-disable */ import type { DeprecatedModel } from '../models/DeprecatedModel'; import type { CancelablePromise } from '../core/CancelablePromise'; +import type { OpenAPIConfig } from '../core/OpenAPI'; import { OpenAPI } from '../core/OpenAPI'; import { request as __request } from '../core/request'; export class DeprecatedService { /** * @deprecated * @param parameter This parameter is deprecated + * @param [configOverrides] Overrides OpenAPIConfig * @throws ApiError */ public static deprecatedCall( parameter: DeprecatedModel | null, + configOverrides?: OpenAPIConfig, ): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/api/v{api-version}/parameters/deprecated', - headers: { - 'parameter': parameter, + return __request( + { + ...OpenAPI, + ...configOverrides, }, - }); + { + method: 'POST', + url: '/api/v{api-version}/parameters/deprecated', + headers: { + 'parameter': parameter, + }, + } + ); } } " @@ -6641,6 +11649,7 @@ exports[`v3 should generate: test/generated/v3/services/DescriptionsService.ts 1 /* tslint:disable */ /* eslint-disable */ import type { CancelablePromise } from '../core/CancelablePromise'; +import type { OpenAPIConfig } from '../core/OpenAPI'; import { OpenAPI } from '../core/OpenAPI'; import { request as __request } from '../core/request'; export class DescriptionsService { @@ -6654,6 +11663,7 @@ export class DescriptionsService { * @param parameterWithExpressionPlaceholders Testing expression placeholders in string: \${expression} should work * @param parameterWithQuotes Testing quotes in string: 'single quote''' and "double quotes""" should work * @param parameterWithReservedCharacters Testing reserved characters in string: * inline * and ** inline ** should work + * @param [configOverrides] Overrides OpenAPIConfig * @throws ApiError */ public static callWithDescriptions( @@ -6663,19 +11673,26 @@ export class DescriptionsService { parameterWithExpressionPlaceholders?: any, parameterWithQuotes?: any, parameterWithReservedCharacters?: any, + configOverrides?: OpenAPIConfig, ): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/api/v{api-version}/descriptions/', - query: { - 'parameterWithBreaks': parameterWithBreaks, - 'parameterWithBackticks': parameterWithBackticks, - 'parameterWithSlashes': parameterWithSlashes, - 'parameterWithExpressionPlaceholders': parameterWithExpressionPlaceholders, - 'parameterWithQuotes': parameterWithQuotes, - 'parameterWithReservedCharacters': parameterWithReservedCharacters, + return __request( + { + ...OpenAPI, + ...configOverrides, }, - }); + { + method: 'POST', + url: '/api/v{api-version}/descriptions/', + query: { + 'parameterWithBreaks': parameterWithBreaks, + 'parameterWithBackticks': parameterWithBackticks, + 'parameterWithSlashes': parameterWithSlashes, + 'parameterWithExpressionPlaceholders': parameterWithExpressionPlaceholders, + 'parameterWithQuotes': parameterWithQuotes, + 'parameterWithReservedCharacters': parameterWithReservedCharacters, + }, + } + ); } } " @@ -6687,44 +11704,77 @@ exports[`v3 should generate: test/generated/v3/services/DuplicateService.ts 1`] /* tslint:disable */ /* eslint-disable */ import type { CancelablePromise } from '../core/CancelablePromise'; +import type { OpenAPIConfig } from '../core/OpenAPI'; import { OpenAPI } from '../core/OpenAPI'; import { request as __request } from '../core/request'; export class DuplicateService { /** * @throws ApiError */ - public static duplicateName(): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/api/v{api-version}/duplicate', - }); + public static duplicateName( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return __request( + { + ...OpenAPI, + ...configOverrides, + }, + { + method: 'GET', + url: '/api/v{api-version}/duplicate', + } + ); } /** * @throws ApiError */ - public static duplicateName1(): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/api/v{api-version}/duplicate', - }); + public static duplicateName1( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return __request( + { + ...OpenAPI, + ...configOverrides, + }, + { + method: 'POST', + url: '/api/v{api-version}/duplicate', + } + ); } /** * @throws ApiError */ - public static duplicateName2(): CancelablePromise { - return __request(OpenAPI, { - method: 'PUT', - url: '/api/v{api-version}/duplicate', - }); + public static duplicateName2( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return __request( + { + ...OpenAPI, + ...configOverrides, + }, + { + method: 'PUT', + url: '/api/v{api-version}/duplicate', + } + ); } /** * @throws ApiError */ - public static duplicateName3(): CancelablePromise { - return __request(OpenAPI, { - method: 'DELETE', - url: '/api/v{api-version}/duplicate', - }); + public static duplicateName3( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return __request( + { + ...OpenAPI, + ...configOverrides, + }, + { + method: 'DELETE', + url: '/api/v{api-version}/duplicate', + } + ); } } " @@ -6736,30 +11786,39 @@ exports[`v3 should generate: test/generated/v3/services/ErrorService.ts 1`] = ` /* tslint:disable */ /* eslint-disable */ import type { CancelablePromise } from '../core/CancelablePromise'; +import type { OpenAPIConfig } from '../core/OpenAPI'; import { OpenAPI } from '../core/OpenAPI'; import { request as __request } from '../core/request'; export class ErrorService { /** * @param status Status code to return + * @param [configOverrides] Overrides OpenAPIConfig * @returns any Custom message: Successful response * @throws ApiError */ public static testErrorCode( status: number, + configOverrides?: OpenAPIConfig, ): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/api/v{api-version}/error', - query: { - 'status': status, - }, - errors: { - 500: \`Custom message: Internal Server Error\`, - 501: \`Custom message: Not Implemented\`, - 502: \`Custom message: Bad Gateway\`, - 503: \`Custom message: Service Unavailable\`, + return __request( + { + ...OpenAPI, + ...configOverrides, }, - }); + { + method: 'POST', + url: '/api/v{api-version}/error', + query: { + 'status': status, + }, + errors: { + 500: \`Custom message: Internal Server Error\`, + 501: \`Custom message: Not Implemented\`, + 502: \`Custom message: Bad Gateway\`, + 503: \`Custom message: Service Unavailable\`, + }, + } + ); } } " @@ -6772,27 +11831,36 @@ exports[`v3 should generate: test/generated/v3/services/FormDataService.ts 1`] = /* eslint-disable */ import type { ModelWithString } from '../models/ModelWithString'; import type { CancelablePromise } from '../core/CancelablePromise'; +import type { OpenAPIConfig } from '../core/OpenAPI'; import { OpenAPI } from '../core/OpenAPI'; import { request as __request } from '../core/request'; export class FormDataService { /** * @param parameter This is a reusable parameter * @param formData A reusable request body + * @param [configOverrides] Overrides OpenAPIConfig * @throws ApiError */ public static postApiFormData( parameter?: string, formData?: ModelWithString, + configOverrides?: OpenAPIConfig, ): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/api/v{api-version}/formData/', - query: { - 'parameter': parameter, - }, - formData: formData, - mediaType: 'multipart/form-data', - }); + return __request( + { + ...OpenAPI, + ...configOverrides, + }, + { + method: 'POST', + url: '/api/v{api-version}/formData/', + query: { + 'parameter': parameter, + }, + formData: formData, + mediaType: 'multipart/form-data', + } + ); } } " @@ -6804,6 +11872,7 @@ exports[`v3 should generate: test/generated/v3/services/HeaderService.ts 1`] = ` /* tslint:disable */ /* eslint-disable */ import type { CancelablePromise } from '../core/CancelablePromise'; +import type { OpenAPIConfig } from '../core/OpenAPI'; import { OpenAPI } from '../core/OpenAPI'; import { request as __request } from '../core/request'; export class HeaderService { @@ -6811,16 +11880,24 @@ export class HeaderService { * @returns string Successful response * @throws ApiError */ - public static callWithResultFromHeader(): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/api/v{api-version}/header', - responseHeader: 'operation-location', - errors: { - 400: \`400 server error\`, - 500: \`500 server error\`, + public static callWithResultFromHeader( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return __request( + { + ...OpenAPI, + ...configOverrides, }, - }); + { + method: 'POST', + url: '/api/v{api-version}/header', + responseHeader: 'operation-location', + errors: { + 400: \`400 server error\`, + 500: \`500 server error\`, + }, + } + ); } } " @@ -6833,11 +11910,13 @@ exports[`v3 should generate: test/generated/v3/services/MultipartService.ts 1`] /* eslint-disable */ import type { ModelWithString } from '../models/ModelWithString'; import type { CancelablePromise } from '../core/CancelablePromise'; +import type { OpenAPIConfig } from '../core/OpenAPI'; import { OpenAPI } from '../core/OpenAPI'; import { request as __request } from '../core/request'; export class MultipartService { /** * @param formData + * @param [configOverrides] Overrides OpenAPIConfig * @throws ApiError */ public static multipartRequest( @@ -6845,29 +11924,44 @@ export class MultipartService { content?: Blob; data?: ModelWithString | null; }, + configOverrides?: OpenAPIConfig, ): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/api/v{api-version}/multipart', - formData: formData, - mediaType: 'multipart/form-data', - }); + return __request( + { + ...OpenAPI, + ...configOverrides, + }, + { + method: 'POST', + url: '/api/v{api-version}/multipart', + formData: formData, + mediaType: 'multipart/form-data', + } + ); } /** * @returns any OK * @throws ApiError */ - public static multipartResponse(): CancelablePromise<{ + public static multipartResponse( + configOverrides?: OpenAPIConfig, + ): CancelablePromise<{ file?: Blob; metadata?: { foo?: string; bar?: string; }; }> { - return __request(OpenAPI, { - method: 'GET', - url: '/api/v{api-version}/multipart', - }); + return __request( + { + ...OpenAPI, + ...configOverrides, + }, + { + method: 'GET', + url: '/api/v{api-version}/multipart', + } + ); } } " @@ -6879,6 +11973,7 @@ exports[`v3 should generate: test/generated/v3/services/MultipleTags1Service.ts /* tslint:disable */ /* eslint-disable */ import type { CancelablePromise } from '../core/CancelablePromise'; +import type { OpenAPIConfig } from '../core/OpenAPI'; import { OpenAPI } from '../core/OpenAPI'; import { request as __request } from '../core/request'; export class MultipleTags1Service { @@ -6886,21 +11981,37 @@ export class MultipleTags1Service { * @returns void * @throws ApiError */ - public static dummyA(): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/api/v{api-version}/multiple-tags/a', - }); + public static dummyA( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return __request( + { + ...OpenAPI, + ...configOverrides, + }, + { + method: 'GET', + url: '/api/v{api-version}/multiple-tags/a', + } + ); } /** * @returns void * @throws ApiError */ - public static dummyB(): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/api/v{api-version}/multiple-tags/b', - }); + public static dummyB( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return __request( + { + ...OpenAPI, + ...configOverrides, + }, + { + method: 'GET', + url: '/api/v{api-version}/multiple-tags/b', + } + ); } } " @@ -6912,6 +12023,7 @@ exports[`v3 should generate: test/generated/v3/services/MultipleTags2Service.ts /* tslint:disable */ /* eslint-disable */ import type { CancelablePromise } from '../core/CancelablePromise'; +import type { OpenAPIConfig } from '../core/OpenAPI'; import { OpenAPI } from '../core/OpenAPI'; import { request as __request } from '../core/request'; export class MultipleTags2Service { @@ -6919,21 +12031,37 @@ export class MultipleTags2Service { * @returns void * @throws ApiError */ - public static dummyA(): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/api/v{api-version}/multiple-tags/a', - }); + public static dummyA( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return __request( + { + ...OpenAPI, + ...configOverrides, + }, + { + method: 'GET', + url: '/api/v{api-version}/multiple-tags/a', + } + ); } /** * @returns void * @throws ApiError */ - public static dummyB(): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/api/v{api-version}/multiple-tags/b', - }); + public static dummyB( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return __request( + { + ...OpenAPI, + ...configOverrides, + }, + { + method: 'GET', + url: '/api/v{api-version}/multiple-tags/b', + } + ); } } " @@ -6945,6 +12073,7 @@ exports[`v3 should generate: test/generated/v3/services/MultipleTags3Service.ts /* tslint:disable */ /* eslint-disable */ import type { CancelablePromise } from '../core/CancelablePromise'; +import type { OpenAPIConfig } from '../core/OpenAPI'; import { OpenAPI } from '../core/OpenAPI'; import { request as __request } from '../core/request'; export class MultipleTags3Service { @@ -6952,11 +12081,19 @@ export class MultipleTags3Service { * @returns void * @throws ApiError */ - public static dummyB(): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/api/v{api-version}/multiple-tags/b', - }); + public static dummyB( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return __request( + { + ...OpenAPI, + ...configOverrides, + }, + { + method: 'GET', + url: '/api/v{api-version}/multiple-tags/b', + } + ); } } " @@ -6968,6 +12105,7 @@ exports[`v3 should generate: test/generated/v3/services/NoContentService.ts 1`] /* tslint:disable */ /* eslint-disable */ import type { CancelablePromise } from '../core/CancelablePromise'; +import type { OpenAPIConfig } from '../core/OpenAPI'; import { OpenAPI } from '../core/OpenAPI'; import { request as __request } from '../core/request'; export class NoContentService { @@ -6975,11 +12113,19 @@ export class NoContentService { * @returns void * @throws ApiError */ - public static callWithNoContentResponse(): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/api/v{api-version}/no-content', - }); + public static callWithNoContentResponse( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return __request( + { + ...OpenAPI, + ...configOverrides, + }, + { + method: 'GET', + url: '/api/v{api-version}/no-content', + } + ); } } " @@ -6993,6 +12139,7 @@ exports[`v3 should generate: test/generated/v3/services/ParametersService.ts 1`] import type { ModelWithString } from '../models/ModelWithString'; import type { Pageable } from '../models/Pageable'; import type { CancelablePromise } from '../core/CancelablePromise'; +import type { OpenAPIConfig } from '../core/OpenAPI'; import { OpenAPI } from '../core/OpenAPI'; import { request as __request } from '../core/request'; export class ParametersService { @@ -7003,6 +12150,7 @@ export class ParametersService { * @param parameterCookie This is the parameter that goes into the cookie * @param parameterPath This is the parameter that goes into the path * @param requestBody This is the parameter that goes into the body + * @param [configOverrides] Overrides OpenAPIConfig * @throws ApiError */ public static callWithParameters( @@ -7012,28 +12160,35 @@ export class ParametersService { parameterCookie: string | null, parameterPath: string | null, requestBody: ModelWithString | null, + configOverrides?: OpenAPIConfig, ): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/api/v{api-version}/parameters/{parameterPath}', - path: { - 'parameterPath': parameterPath, - }, - cookies: { - 'parameterCookie': parameterCookie, + return __request( + { + ...OpenAPI, + ...configOverrides, }, - headers: { - 'parameterHeader': parameterHeader, - }, - query: { - 'parameterQuery': parameterQuery, - }, - formData: { - 'parameterForm': parameterForm, - }, - body: requestBody, - mediaType: 'application/json', - }); + { + method: 'POST', + url: '/api/v{api-version}/parameters/{parameterPath}', + path: { + 'parameterPath': parameterPath, + }, + cookies: { + 'parameterCookie': parameterCookie, + }, + headers: { + 'parameterHeader': parameterHeader, + }, + query: { + 'parameterQuery': parameterQuery, + }, + formData: { + 'parameterForm': parameterForm, + }, + body: requestBody, + mediaType: 'application/json', + } + ); } /** * @param parameterHeader This is the parameter that goes into the request header @@ -7045,6 +12200,7 @@ export class ParametersService { * @param parameterPath2 This is the parameter that goes into the path * @param parameterPath3 This is the parameter that goes into the path * @param _default This is the parameter with a reserved keyword + * @param [configOverrides] Overrides OpenAPIConfig * @throws ApiError */ public static callWithWeirdParameterNames( @@ -7057,69 +12213,92 @@ export class ParametersService { parameterPath2?: string, parameterPath3?: string, _default?: string, + configOverrides?: OpenAPIConfig, ): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', - path: { - 'parameter.path.1': parameterPath1, - 'parameter-path-2': parameterPath2, - 'PARAMETER-PATH-3': parameterPath3, - }, - cookies: { - 'PARAMETER-COOKIE': parameterCookie, + return __request( + { + ...OpenAPI, + ...configOverrides, }, - headers: { - 'parameter.header': parameterHeader, - }, - query: { - 'default': _default, - 'parameter-query': parameterQuery, - }, - formData: { - 'parameter_form': parameterForm, - }, - body: requestBody, - mediaType: 'application/json', - }); + { + method: 'POST', + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', + path: { + 'parameter.path.1': parameterPath1, + 'parameter-path-2': parameterPath2, + 'PARAMETER-PATH-3': parameterPath3, + }, + cookies: { + 'PARAMETER-COOKIE': parameterCookie, + }, + headers: { + 'parameter.header': parameterHeader, + }, + query: { + 'default': _default, + 'parameter-query': parameterQuery, + }, + formData: { + 'parameter_form': parameterForm, + }, + body: requestBody, + mediaType: 'application/json', + } + ); } /** * @param requestBody This is a required parameter * @param parameter This is an optional parameter + * @param [configOverrides] Overrides OpenAPIConfig * @throws ApiError */ public static getCallWithOptionalParam( requestBody: ModelWithString, parameter?: string, + configOverrides?: OpenAPIConfig, ): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/api/v{api-version}/parameters/', - query: { - 'parameter': parameter, - }, - body: requestBody, - mediaType: 'application/json', - }); + return __request( + { + ...OpenAPI, + ...configOverrides, + }, + { + method: 'GET', + url: '/api/v{api-version}/parameters/', + query: { + 'parameter': parameter, + }, + body: requestBody, + mediaType: 'application/json', + } + ); } /** * @param parameter This is a required parameter * @param requestBody This is an optional parameter + * @param [configOverrides] Overrides OpenAPIConfig * @throws ApiError */ public static postCallWithOptionalParam( parameter: Pageable, requestBody?: ModelWithString, + configOverrides?: OpenAPIConfig, ): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/api/v{api-version}/parameters/', - query: { - 'parameter': parameter, - }, - body: requestBody, - mediaType: 'application/json', - }); + return __request( + { + ...OpenAPI, + ...configOverrides, + }, + { + method: 'POST', + url: '/api/v{api-version}/parameters/', + query: { + 'parameter': parameter, + }, + body: requestBody, + mediaType: 'application/json', + } + ); } } " @@ -7132,27 +12311,36 @@ exports[`v3 should generate: test/generated/v3/services/RequestBodyService.ts 1` /* eslint-disable */ import type { ModelWithString } from '../models/ModelWithString'; import type { CancelablePromise } from '../core/CancelablePromise'; +import type { OpenAPIConfig } from '../core/OpenAPI'; import { OpenAPI } from '../core/OpenAPI'; import { request as __request } from '../core/request'; export class RequestBodyService { /** * @param parameter This is a reusable parameter * @param requestBody A reusable request body + * @param [configOverrides] Overrides OpenAPIConfig * @throws ApiError */ public static postApiRequestBody( parameter?: string, requestBody?: ModelWithString, + configOverrides?: OpenAPIConfig, ): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/api/v{api-version}/requestBody/', - query: { - 'parameter': parameter, - }, - body: requestBody, - mediaType: 'application/json', - }); + return __request( + { + ...OpenAPI, + ...configOverrides, + }, + { + method: 'POST', + url: '/api/v{api-version}/requestBody/', + query: { + 'parameter': parameter, + }, + body: requestBody, + mediaType: 'application/json', + } + ); } } " @@ -7167,6 +12355,7 @@ import type { ModelThatExtends } from '../models/ModelThatExtends'; import type { ModelThatExtendsExtends } from '../models/ModelThatExtendsExtends'; import type { ModelWithString } from '../models/ModelWithString'; import type { CancelablePromise } from '../core/CancelablePromise'; +import type { OpenAPIConfig } from '../core/OpenAPI'; import { OpenAPI } from '../core/OpenAPI'; import { request as __request } from '../core/request'; export class ResponseService { @@ -7174,26 +12363,42 @@ export class ResponseService { * @returns ModelWithString * @throws ApiError */ - public static callWithResponse(): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/api/v{api-version}/response', - }); + public static callWithResponse( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return __request( + { + ...OpenAPI, + ...configOverrides, + }, + { + method: 'GET', + url: '/api/v{api-version}/response', + } + ); } /** * @returns ModelWithString Message for default response * @throws ApiError */ - public static callWithDuplicateResponses(): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/api/v{api-version}/response', - errors: { - 500: \`Message for 500 error\`, - 501: \`Message for 501 error\`, - 502: \`Message for 502 error\`, + public static callWithDuplicateResponses( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return __request( + { + ...OpenAPI, + ...configOverrides, }, - }); + { + method: 'POST', + url: '/api/v{api-version}/response', + errors: { + 500: \`Message for 500 error\`, + 501: \`Message for 501 error\`, + 502: \`Message for 502 error\`, + }, + } + ); } /** * @returns any Message for 200 response @@ -7202,20 +12407,28 @@ export class ResponseService { * @returns ModelThatExtendsExtends Message for 202 response * @throws ApiError */ - public static callWithResponses(): CancelablePromise<{ + public static callWithResponses( + configOverrides?: OpenAPIConfig, + ): CancelablePromise<{ readonly '@namespace.string'?: string; readonly '@namespace.integer'?: number; readonly value?: Array; } | ModelWithString | ModelThatExtends | ModelThatExtendsExtends> { - return __request(OpenAPI, { - method: 'PUT', - url: '/api/v{api-version}/response', - errors: { - 500: \`Message for 500 error\`, - 501: \`Message for 501 error\`, - 502: \`Message for 502 error\`, + return __request( + { + ...OpenAPI, + ...configOverrides, }, - }); + { + method: 'PUT', + url: '/api/v{api-version}/response', + errors: { + 500: \`Message for 500 error\`, + 501: \`Message for 501 error\`, + 502: \`Message for 502 error\`, + }, + } + ); } } " @@ -7227,71 +12440,128 @@ exports[`v3 should generate: test/generated/v3/services/SimpleService.ts 1`] = ` /* tslint:disable */ /* eslint-disable */ import type { CancelablePromise } from '../core/CancelablePromise'; +import type { OpenAPIConfig } from '../core/OpenAPI'; import { OpenAPI } from '../core/OpenAPI'; import { request as __request } from '../core/request'; export class SimpleService { /** * @throws ApiError */ - public static getCallWithoutParametersAndResponse(): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/api/v{api-version}/simple', - }); + public static getCallWithoutParametersAndResponse( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return __request( + { + ...OpenAPI, + ...configOverrides, + }, + { + method: 'GET', + url: '/api/v{api-version}/simple', + } + ); } /** * @throws ApiError */ - public static putCallWithoutParametersAndResponse(): CancelablePromise { - return __request(OpenAPI, { - method: 'PUT', - url: '/api/v{api-version}/simple', - }); + public static putCallWithoutParametersAndResponse( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return __request( + { + ...OpenAPI, + ...configOverrides, + }, + { + method: 'PUT', + url: '/api/v{api-version}/simple', + } + ); } /** * @throws ApiError */ - public static postCallWithoutParametersAndResponse(): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/api/v{api-version}/simple', - }); + public static postCallWithoutParametersAndResponse( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return __request( + { + ...OpenAPI, + ...configOverrides, + }, + { + method: 'POST', + url: '/api/v{api-version}/simple', + } + ); } /** * @throws ApiError */ - public static deleteCallWithoutParametersAndResponse(): CancelablePromise { - return __request(OpenAPI, { - method: 'DELETE', - url: '/api/v{api-version}/simple', - }); + public static deleteCallWithoutParametersAndResponse( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return __request( + { + ...OpenAPI, + ...configOverrides, + }, + { + method: 'DELETE', + url: '/api/v{api-version}/simple', + } + ); } /** * @throws ApiError */ - public static optionsCallWithoutParametersAndResponse(): CancelablePromise { - return __request(OpenAPI, { - method: 'OPTIONS', - url: '/api/v{api-version}/simple', - }); + public static optionsCallWithoutParametersAndResponse( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return __request( + { + ...OpenAPI, + ...configOverrides, + }, + { + method: 'OPTIONS', + url: '/api/v{api-version}/simple', + } + ); } /** * @throws ApiError */ - public static headCallWithoutParametersAndResponse(): CancelablePromise { - return __request(OpenAPI, { - method: 'HEAD', - url: '/api/v{api-version}/simple', - }); + public static headCallWithoutParametersAndResponse( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return __request( + { + ...OpenAPI, + ...configOverrides, + }, + { + method: 'HEAD', + url: '/api/v{api-version}/simple', + } + ); } /** * @throws ApiError */ - public static patchCallWithoutParametersAndResponse(): CancelablePromise { - return __request(OpenAPI, { - method: 'PATCH', - url: '/api/v{api-version}/simple', - }); + public static patchCallWithoutParametersAndResponse( + configOverrides?: OpenAPIConfig, + ): CancelablePromise { + return __request( + { + ...OpenAPI, + ...configOverrides, + }, + { + method: 'PATCH', + url: '/api/v{api-version}/simple', + } + ); } } " @@ -7303,6 +12573,7 @@ exports[`v3 should generate: test/generated/v3/services/TypesService.ts 1`] = ` /* tslint:disable */ /* eslint-disable */ import type { CancelablePromise } from '../core/CancelablePromise'; +import type { OpenAPIConfig } from '../core/OpenAPI'; import { OpenAPI } from '../core/OpenAPI'; import { request as __request } from '../core/request'; export class TypesService { @@ -7315,6 +12586,7 @@ export class TypesService { * @param parameterBoolean This is a boolean parameter * @param parameterObject This is an object parameter * @param id This is a number parameter + * @param [configOverrides] Overrides OpenAPIConfig * @returns number Response is a simple number * @returns string Response is a simple string * @returns boolean Response is a simple boolean @@ -7330,23 +12602,30 @@ export class TypesService { parameterBoolean: boolean | null = true, parameterObject: Record | null = null, id?: number, + configOverrides?: OpenAPIConfig, ): CancelablePromise> { - return __request(OpenAPI, { - method: 'GET', - url: '/api/v{api-version}/types', - path: { - 'id': id, - }, - query: { - 'parameterNumber': parameterNumber, - 'parameterString': parameterString, - 'parameterBoolean': parameterBoolean, - 'parameterObject': parameterObject, - 'parameterArray': parameterArray, - 'parameterDictionary': parameterDictionary, - 'parameterEnum': parameterEnum, + return __request( + { + ...OpenAPI, + ...configOverrides, }, - }); + { + method: 'GET', + url: '/api/v{api-version}/types', + path: { + 'id': id, + }, + query: { + 'parameterNumber': parameterNumber, + 'parameterString': parameterString, + 'parameterBoolean': parameterBoolean, + 'parameterObject': parameterObject, + 'parameterArray': parameterArray, + 'parameterDictionary': parameterDictionary, + 'parameterEnum': parameterEnum, + }, + } + ); } } " @@ -7358,24 +12637,33 @@ exports[`v3 should generate: test/generated/v3/services/UploadService.ts 1`] = ` /* tslint:disable */ /* eslint-disable */ import type { CancelablePromise } from '../core/CancelablePromise'; +import type { OpenAPIConfig } from '../core/OpenAPI'; import { OpenAPI } from '../core/OpenAPI'; import { request as __request } from '../core/request'; export class UploadService { /** * @param file Supply a file reference for upload + * @param [configOverrides] Overrides OpenAPIConfig * @returns boolean * @throws ApiError */ public static uploadFile( file: Blob, + configOverrides?: OpenAPIConfig, ): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/api/v{api-version}/upload', - formData: { - 'file': file, + return __request( + { + ...OpenAPI, + ...configOverrides, }, - }); + { + method: 'POST', + url: '/api/v{api-version}/upload', + formData: { + 'file': file, + }, + } + ); } } " diff --git a/test/e2e/client.angular.spec.ts b/test/e2e/client.angular.spec.ts index 54dd5bc89..d94266b3a 100644 --- a/test/e2e/client.angular.spec.ts +++ b/test/e2e/client.angular.spec.ts @@ -36,6 +36,22 @@ describe('client.angular', () => { expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); }); + it('overrides token', async () => { + await browser.exposeFunction('tokenRequest', jest.fn().mockResolvedValue('MY_TOKEN')); + const result = await browser.evaluate(async () => { + return await new Promise(resolve => { + const { SimpleService } = (window as any).api; + SimpleService.httpRequest.config.TOKEN = 'BAD_TOKEN'; + SimpleService.httpRequest.config.USERNAME = undefined; + SimpleService.httpRequest.config.PASSWORD = undefined; + SimpleService.getCallWithoutParametersAndResponse({ + TOKEN: (window as any).tokenRequest, + }).subscribe(resolve); + }); + }); + expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); + }); + it('uses credentials', async () => { const result = await browser.evaluate(async () => { return await new Promise(resolve => { diff --git a/test/e2e/client.axios.spec.ts b/test/e2e/client.axios.spec.ts index a0ba54750..51f4f40f7 100644 --- a/test/e2e/client.axios.spec.ts +++ b/test/e2e/client.axios.spec.ts @@ -28,6 +28,21 @@ describe('client.axios', () => { expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); }); + it('overrides token', async () => { + const { ApiClient } = require('./generated/client/axios/index.js'); + const tokenRequest = jest.fn().mockResolvedValue('MY_TOKEN'); + const client = new ApiClient({ + TOKEN: 'BAD_TOKEN', + USERNAME: undefined, + PASSWORD: undefined, + }); + const result = await client.simple.getCallWithoutParametersAndResponse({ + TOKEN: tokenRequest, + }); + expect(tokenRequest.mock.calls.length).toBe(1); + expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); + }); + it('uses credentials', async () => { const { ApiClient } = require('./generated/client/axios/index.js'); const client = new ApiClient({ diff --git a/test/e2e/client.babel.spec.ts b/test/e2e/client.babel.spec.ts index 82320d1f9..28da0fad2 100644 --- a/test/e2e/client.babel.spec.ts +++ b/test/e2e/client.babel.spec.ts @@ -35,6 +35,22 @@ describe('client.babel', () => { expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); }); + it('overrides token', async () => { + await browser.exposeFunction('tokenRequest', jest.fn().mockResolvedValue('MY_TOKEN')); + const result = await browser.evaluate(async () => { + const { ApiClient } = (window as any).api; + const client = new ApiClient({ + TOKEN: 'BAD_TOKEN', + USERNAME: undefined, + PASSWORD: undefined, + }); + return await client.simple.getCallWithoutParametersAndResponse({ + TOKEN: (window as any).tokenRequest, + }); + }); + expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); + }); + it('uses credentials', async () => { const result = await browser.evaluate(async () => { const { ApiClient } = (window as any).api; diff --git a/test/e2e/client.fetch.spec.ts b/test/e2e/client.fetch.spec.ts index 9a64284bd..594144507 100644 --- a/test/e2e/client.fetch.spec.ts +++ b/test/e2e/client.fetch.spec.ts @@ -35,6 +35,22 @@ describe('client.fetch', () => { expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); }); + it('overrides token', async () => { + await browser.exposeFunction('tokenRequest', jest.fn().mockResolvedValue('MY_TOKEN')); + const result = await browser.evaluate(async () => { + const { ApiClient } = (window as any).api; + const client = new ApiClient({ + TOKEN: 'BAD_TOKEN', + USERNAME: undefined, + PASSWORD: undefined, + }); + return await client.simple.getCallWithoutParametersAndResponse({ + TOKEN: (window as any).tokenRequest, + }); + }); + expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); + }); + it('uses credentials', async () => { const result = await browser.evaluate(async () => { const { ApiClient } = (window as any).api; diff --git a/test/e2e/client.node.spec.ts b/test/e2e/client.node.spec.ts index 0d915919b..7a193da0b 100644 --- a/test/e2e/client.node.spec.ts +++ b/test/e2e/client.node.spec.ts @@ -28,6 +28,21 @@ describe('client.node', () => { expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); }); + it('overrides token', async () => { + const { ApiClient } = require('./generated/client/node/index.js'); + const tokenRequest = jest.fn().mockResolvedValue('MY_TOKEN'); + const client = new ApiClient({ + TOKEN: 'BAD_TOKEN', + USERNAME: undefined, + PASSWORD: undefined, + }); + const result = await client.simple.getCallWithoutParametersAndResponse({ + TOKEN: tokenRequest, + }); + expect(tokenRequest.mock.calls.length).toBe(1); + expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); + }); + it('uses credentials', async () => { const { ApiClient } = require('./generated/client/node/index.js'); const client = new ApiClient({ diff --git a/test/e2e/client.xhr.spec.ts b/test/e2e/client.xhr.spec.ts index e0b516f39..21001a0ff 100644 --- a/test/e2e/client.xhr.spec.ts +++ b/test/e2e/client.xhr.spec.ts @@ -35,6 +35,22 @@ describe('client.xhr', () => { expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); }); + it('overrides token', async () => { + await browser.exposeFunction('tokenRequest', jest.fn().mockResolvedValue('MY_TOKEN')); + const result = await browser.evaluate(async () => { + const { ApiClient } = (window as any).api; + const client = new ApiClient({ + TOKEN: 'BAD_TOKEN', + USERNAME: undefined, + PASSWORD: undefined, + }); + return await client.simple.getCallWithoutParametersAndResponse({ + TOKEN: (window as any).tokenRequest, + }); + }); + expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); + }); + it('uses credentials', async () => { const result = await browser.evaluate(async () => { const { ApiClient } = (window as any).api; diff --git a/test/e2e/v2.angular.spec.ts b/test/e2e/v2.angular.spec.ts index fa19f4357..329080be1 100644 --- a/test/e2e/v2.angular.spec.ts +++ b/test/e2e/v2.angular.spec.ts @@ -34,6 +34,20 @@ describe('v2.angular', () => { expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); }); + it('overrides token', async () => { + await browser.exposeFunction('tokenRequest', jest.fn().mockResolvedValue('MY_TOKEN')); + const result = await browser.evaluate(async () => { + return await new Promise(resolve => { + const { OpenAPI, SimpleService } = (window as any).api; + OpenAPI.TOKEN = 'BAD_TOKEN'; + SimpleService.getCallWithoutParametersAndResponse({ + TOKEN: (window as any).tokenRequest, + }).subscribe(resolve); + }); + }); + expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); + }); + it('supports complex params', async () => { const result = await browser.evaluate(async () => { return await new Promise(resolve => { diff --git a/test/e2e/v2.axios.spec.ts b/test/e2e/v2.axios.spec.ts index 940c740dd..bd3703e57 100644 --- a/test/e2e/v2.axios.spec.ts +++ b/test/e2e/v2.axios.spec.ts @@ -24,6 +24,17 @@ describe('v2.axios', () => { expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); }); + it('overrides token', async () => { + const { OpenAPI, SimpleService } = require('./generated/v2/axios/index.js'); + const tokenRequest = jest.fn().mockResolvedValue('MY_TOKEN'); + OpenAPI.TOKEN = 'BAD_TOKEN'; + const result = await SimpleService.getCallWithoutParametersAndResponse({ + TOKEN: tokenRequest, + }); + expect(tokenRequest.mock.calls.length).toBe(1); + expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); + }); + it('supports complex params', async () => { const { ComplexService } = require('./generated/v2/axios/index.js'); const result = await ComplexService.complexTypes({ diff --git a/test/e2e/v2.babel.spec.ts b/test/e2e/v2.babel.spec.ts index 63f7461c4..9f3a0d1b8 100644 --- a/test/e2e/v2.babel.spec.ts +++ b/test/e2e/v2.babel.spec.ts @@ -31,6 +31,18 @@ describe('v2.babel', () => { expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); }); + it('overrides token', async () => { + await browser.exposeFunction('tokenRequest', jest.fn().mockResolvedValue('MY_TOKEN')); + const result = await browser.evaluate(async () => { + const { OpenAPI, SimpleService } = (window as any).api; + OpenAPI.TOKEN = 'BAD_TOKEN'; + return await SimpleService.getCallWithoutParametersAndResponse({ + TOKEN: (window as any).tokenRequest, + }); + }); + expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); + }); + it('supports complex params', async () => { const result = await browser.evaluate(async () => { const { ComplexService } = (window as any).api; diff --git a/test/e2e/v2.fetch.spec.ts b/test/e2e/v2.fetch.spec.ts index 54c6311a4..fa544fb5a 100644 --- a/test/e2e/v2.fetch.spec.ts +++ b/test/e2e/v2.fetch.spec.ts @@ -31,6 +31,16 @@ describe('v2.fetch', () => { expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); }); + it('overrides token', async () => { + await browser.exposeFunction('tokenRequest', jest.fn().mockResolvedValue('MY_TOKEN')); + const result = await browser.evaluate(async () => { + const { OpenAPI, SimpleService } = (window as any).api; + OpenAPI.TOKEN = 'BAD_TOKEN'; + return await SimpleService.getCallWithoutParametersAndResponse({ TOKEN: (window as any).tokenRequest }); + }); + expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); + }); + it('supports complex params', async () => { const result = await browser.evaluate(async () => { const { ComplexService } = (window as any).api; diff --git a/test/e2e/v2.node.spec.ts b/test/e2e/v2.node.spec.ts index e38176ee5..6802f90ad 100644 --- a/test/e2e/v2.node.spec.ts +++ b/test/e2e/v2.node.spec.ts @@ -24,6 +24,17 @@ describe('v2.node', () => { expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); }); + it('overrides token', async () => { + const { OpenAPI, SimpleService } = require('./generated/v2/node/index.js'); + const tokenRequest = jest.fn().mockResolvedValue('MY_TOKEN'); + OpenAPI.TOKEN = 'BAD_TOKEN'; + const result = await SimpleService.getCallWithoutParametersAndResponse({ + TOKEN: tokenRequest, + }); + expect(tokenRequest.mock.calls.length).toBe(1); + expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); + }); + it('supports complex params', async () => { const { ComplexService } = require('./generated/v2/node/index.js'); const result = await ComplexService.complexTypes({ diff --git a/test/e2e/v2.xhr.spec.ts b/test/e2e/v2.xhr.spec.ts index d6149757e..66cc6d20c 100644 --- a/test/e2e/v2.xhr.spec.ts +++ b/test/e2e/v2.xhr.spec.ts @@ -31,6 +31,18 @@ describe('v2.xhr', () => { expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); }); + it('overrides token', async () => { + await browser.exposeFunction('tokenRequest', jest.fn().mockResolvedValue('MY_TOKEN')); + const result = await browser.evaluate(async () => { + const { OpenAPI, SimpleService } = (window as any).api; + OpenAPI.TOKEN = 'BAD_TOKEN'; + return await SimpleService.getCallWithoutParametersAndResponse({ + TOKEN: (window as any).tokenRequest, + }); + }); + expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); + }); + it('supports complex params', async () => { const result = await browser.evaluate(async () => { const { ComplexService } = (window as any).api; diff --git a/test/e2e/v3.angular.spec.ts b/test/e2e/v3.angular.spec.ts index 85e87b583..d3dc52010 100644 --- a/test/e2e/v3.angular.spec.ts +++ b/test/e2e/v3.angular.spec.ts @@ -36,6 +36,22 @@ describe('v3.angular', () => { expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); }); + it('overrides token', async () => { + await browser.exposeFunction('tokenRequest', jest.fn().mockResolvedValue('MY_TOKEN')); + const result = await browser.evaluate(async () => { + return await new Promise(resolve => { + const { OpenAPI, SimpleService } = (window as any).api; + OpenAPI.TOKEN = 'BAD_TOKEN'; + OpenAPI.USERNAME = undefined; + OpenAPI.PASSWORD = undefined; + SimpleService.getCallWithoutParametersAndResponse({ + TOKEN: (window as any).tokenRequest, + }).subscribe(resolve); + }); + }); + expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); + }); + it('uses credentials', async () => { const result = await browser.evaluate(async () => { return await new Promise(resolve => { diff --git a/test/e2e/v3.axios.spec.ts b/test/e2e/v3.axios.spec.ts index 56b21be3e..978cf9f65 100644 --- a/test/e2e/v3.axios.spec.ts +++ b/test/e2e/v3.axios.spec.ts @@ -26,6 +26,19 @@ describe('v3.axios', () => { expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); }); + it('overrides token', async () => { + const { OpenAPI, SimpleService } = require('./generated/v3/axios/index.js'); + const tokenRequest = jest.fn().mockResolvedValue('MY_TOKEN'); + OpenAPI.TOKEN = 'BAD_TOKEN'; + OpenAPI.USERNAME = undefined; + OpenAPI.PASSWORD = undefined; + const result = await SimpleService.getCallWithoutParametersAndResponse({ + TOKEN: tokenRequest, + }); + expect(tokenRequest.mock.calls.length).toBe(1); + expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); + }); + it('uses credentials', async () => { const { OpenAPI, SimpleService } = require('./generated/v3/axios/index.js'); OpenAPI.TOKEN = undefined; diff --git a/test/e2e/v3.babel.spec.ts b/test/e2e/v3.babel.spec.ts index 5ce2a366e..c6697dc83 100644 --- a/test/e2e/v3.babel.spec.ts +++ b/test/e2e/v3.babel.spec.ts @@ -33,6 +33,20 @@ describe('v3.babel', () => { expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); }); + it('overrides token', async () => { + await browser.exposeFunction('tokenRequest', jest.fn().mockResolvedValue('MY_TOKEN')); + const result = await browser.evaluate(async () => { + const { OpenAPI, SimpleService } = (window as any).api; + OpenAPI.TOKEN = 'BAD_TOKEN'; + OpenAPI.USERNAME = undefined; + OpenAPI.PASSWORD = undefined; + return await SimpleService.getCallWithoutParametersAndResponse({ + TOKEN: (window as any).tokenRequest, + }); + }); + expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); + }); + it('uses credentials', async () => { const result = await browser.evaluate(async () => { const { OpenAPI, SimpleService } = (window as any).api; diff --git a/test/e2e/v3.fetch.spec.ts b/test/e2e/v3.fetch.spec.ts index 547853a70..350a70464 100644 --- a/test/e2e/v3.fetch.spec.ts +++ b/test/e2e/v3.fetch.spec.ts @@ -33,6 +33,20 @@ describe('v3.fetch', () => { expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); }); + it('overrides token', async () => { + await browser.exposeFunction('tokenRequest', jest.fn().mockResolvedValue('MY_TOKEN')); + const result = await browser.evaluate(async () => { + const { OpenAPI, SimpleService } = (window as any).api; + OpenAPI.TOKEN = 'BAD_TOKEN'; + OpenAPI.USERNAME = undefined; + OpenAPI.PASSWORD = undefined; + return await SimpleService.getCallWithoutParametersAndResponse({ + TOKEN: (window as any).tokenRequest, + }); + }); + expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); + }); + it('uses credentials', async () => { const result = await browser.evaluate(async () => { const { OpenAPI, SimpleService } = (window as any).api; diff --git a/test/e2e/v3.node.spec.ts b/test/e2e/v3.node.spec.ts index 6d6a484ce..83f363a5d 100644 --- a/test/e2e/v3.node.spec.ts +++ b/test/e2e/v3.node.spec.ts @@ -26,6 +26,19 @@ describe('v3.node', () => { expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); }); + it('overrides token', async () => { + const { OpenAPI, SimpleService } = require('./generated/v3/node/index.js'); + const tokenRequest = jest.fn().mockResolvedValue('MY_TOKEN'); + OpenAPI.TOKEN = 'BAD_TOKEN'; + OpenAPI.USERNAME = undefined; + OpenAPI.PASSWORD = undefined; + const result = await SimpleService.getCallWithoutParametersAndResponse({ + TOKEN: tokenRequest, + }); + expect(tokenRequest.mock.calls.length).toBe(1); + expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); + }); + it('uses credentials', async () => { const { OpenAPI, SimpleService } = require('./generated/v3/node/index.js'); OpenAPI.TOKEN = undefined; diff --git a/test/e2e/v3.xhr.spec.ts b/test/e2e/v3.xhr.spec.ts index d1fac6e1c..9642bf462 100644 --- a/test/e2e/v3.xhr.spec.ts +++ b/test/e2e/v3.xhr.spec.ts @@ -33,6 +33,20 @@ describe('v3.xhr', () => { expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); }); + it('overrides token', async () => { + await browser.exposeFunction('tokenRequest', jest.fn().mockResolvedValue('MY_TOKEN')); + const result = await browser.evaluate(async () => { + const { OpenAPI, SimpleService } = (window as any).api; + OpenAPI.TOKEN = 'BAD_TOKEN'; + OpenAPI.USERNAME = undefined; + OpenAPI.PASSWORD = undefined; + return await SimpleService.getCallWithoutParametersAndResponse({ + TOKEN: (window as any).tokenRequest, + }); + }); + expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); + }); + it('uses credentials', async () => { const result = await browser.evaluate(async () => { const { OpenAPI, SimpleService } = (window as any).api; diff --git a/test/index.spec.ts b/test/index.spec.ts index 78a0197d5..2035fda93 100644 --- a/test/index.spec.ts +++ b/test/index.spec.ts @@ -3,6 +3,28 @@ import { sync } from 'glob'; import { generate, HttpClient } from '../'; +describe('client', () => { + it('should generate', async () => { + await generate({ + input: './test/spec/v3.json', + output: './test/generated/client/', + httpClient: HttpClient.FETCH, + useOptions: false, + useUnionTypes: false, + exportCore: true, + exportSchemas: true, + exportModels: true, + exportServices: true, + clientName: 'Api', + }); + + sync('./test/generated/client/**/*.ts').forEach(file => { + const content = readFileSync(file, 'utf8').toString(); + expect(content).toMatchSnapshot(file); + }); + }); +}); + describe('v2', () => { it('should generate', async () => { await generate({