diff --git a/test/__snapshots__/index.spec.js.snap b/test/__snapshots__/index.spec.js.snap new file mode 100644 index 00000000..42b24b66 --- /dev/null +++ b/test/__snapshots__/index.spec.js.snap @@ -0,0 +1,5136 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`v2 should generate: ./test/generated/v2/core/ApiError.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ApiResult } from './ApiResult'; + +export class ApiError extends Error { + public readonly url: string; + public readonly status: number; + public readonly statusText: string; + public readonly body: any; + + constructor(response: ApiResult, message: string) { + super(message); + + this.url = response.url; + this.status = response.status; + this.statusText = response.statusText; + this.body = response.body; + } +}" +`; + +exports[`v2 should generate: ./test/generated/v2/core/ApiRequestOptions.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export interface ApiRequestOptions { + readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH'; + readonly path: string; + readonly cookies?: Record; + readonly headers?: Record; + readonly query?: Record; + readonly formData?: Record; + readonly body?: any; + readonly responseHeader?: string; + readonly errors?: Record; +}" +`; + +exports[`v2 should generate: ./test/generated/v2/core/ApiResult.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export interface ApiResult { + readonly url: string; + readonly ok: boolean; + readonly status: number; + readonly statusText: string; + readonly body: any; +}" +`; + +exports[`v2 should generate: ./test/generated/v2/core/OpenAPI.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +type Resolver = () => Promise; +type Headers = Record; + +interface Config { + BASE: string; + VERSION: string; + WITH_CREDENTIALS: boolean; + TOKEN?: string | Resolver; + USERNAME?: string | Resolver; + PASSWORD?: string | Resolver; + HEADERS?: Headers | Resolver; +} + +export const OpenAPI: Config = { + BASE: 'http://localhost:3000/base', + VERSION: '1.0', + WITH_CREDENTIALS: false, + TOKEN: undefined, + USERNAME: undefined, + PASSWORD: undefined, + HEADERS: undefined, +};" +`; + +exports[`v2 should generate: ./test/generated/v2/core/request.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import { ApiError } from './ApiError'; +import type { ApiRequestOptions } from './ApiRequestOptions'; +import type { ApiResult } from './ApiResult'; +import { OpenAPI } from './OpenAPI'; + +function isDefined(value: T | null | undefined): value is Exclude { + return value !== undefined && value !== null; +} + +function isString(value: any): value is string { + return typeof value === 'string'; +} + +function isStringWithValue(value: any): value is string { + return isString(value) && value !== ''; +} + +function isBlob(value: any): value is Blob { + return value instanceof Blob; +} + +function getQueryString(params: Record): string { + const qs: string[] = []; + Object.keys(params).forEach(key => { + const value = params[key]; + if (isDefined(value)) { + if (Array.isArray(value)) { + value.forEach(value => { + qs.push(\`\${encodeURIComponent(key)}=\${encodeURIComponent(String(value))}\`); + }); + } else { + qs.push(\`\${encodeURIComponent(key)}=\${encodeURIComponent(String(value))}\`); + } + } + }); + if (qs.length > 0) { + return \`?\${qs.join('&')}\`; + } + return ''; +} + +function getUrl(options: ApiRequestOptions): string { + const path = options.path.replace(/[:]/g, '_'); + const url = \`\${OpenAPI.BASE}\${path}\`; + + if (options.query) { + return \`\${url}\${getQueryString(options.query)}\`; + } + return url; +} + +function getFormData(params: Record): FormData { + const formData = new FormData(); + Object.keys(params).forEach(key => { + const value = params[key]; + if (isDefined(value)) { + formData.append(key, value); + } + }); + return formData; +} + +type Resolver = () => Promise; + +async function resolve(resolver?: T | Resolver): Promise { + if (typeof resolver === 'function') { + return (resolver as Resolver)(); + } + return resolver; +} + +async function getHeaders(options: ApiRequestOptions): Promise { + const headers = new Headers({ + Accept: 'application/json', + ...OpenAPI.HEADERS, + ...options.headers, + }); + + const token = await resolve(OpenAPI.TOKEN); + const username = await resolve(OpenAPI.USERNAME); + const password = await resolve(OpenAPI.PASSWORD); + + if (isStringWithValue(token)) { + headers.append('Authorization', \`Bearer \${token}\`); + } + + if (isStringWithValue(username) && isStringWithValue(password)) { + const credentials = btoa(\`\${username}:\${password}\`); + headers.append('Authorization', \`Basic \${credentials}\`); + } + + if (options.body) { + if (isBlob(options.body)) { + headers.append('Content-Type', options.body.type || 'application/octet-stream'); + } else if (isString(options.body)) { + headers.append('Content-Type', 'text/plain'); + } else { + headers.append('Content-Type', 'application/json'); + } + } + return headers; +} + +function getRequestBody(options: ApiRequestOptions): BodyInit | undefined { + if (options.formData) { + return getFormData(options.formData); + } + if (options.body) { + if (isString(options.body) || isBlob(options.body)) { + return options.body; + } else { + return JSON.stringify(options.body); + } + } + return undefined; +} + +async function sendRequest(options: ApiRequestOptions, url: string): Promise { + const request: RequestInit = { + method: options.method, + headers: await getHeaders(options), + body: getRequestBody(options), + }; + return await fetch(url, request); +} + +function getResponseHeader(response: Response, responseHeader?: string): string | null { + if (responseHeader) { + const content = response.headers.get(responseHeader); + if (isString(content)) { + return content; + } + } + return null; +} + +async function getResponseBody(response: Response): Promise { + try { + const contentType = response.headers.get('Content-Type'); + if (contentType) { + const isJSON = contentType.toLowerCase().startsWith('application/json'); + if (isJSON) { + return await response.json(); + } else { + return await response.text(); + } + } + } catch (error) { + console.error(error); + } + return null; +} + +function catchErrors(options: ApiRequestOptions, result: ApiResult): void { + const errors: Record = { + 400: 'Bad Request', + 401: 'Unauthorized', + 403: 'Forbidden', + 404: 'Not Found', + 500: 'Internal Server Error', + 502: 'Bad Gateway', + 503: 'Service Unavailable', + ...options.errors, + } + + const error = errors[result.status]; + if (error) { + throw new ApiError(result, error); + } + + if (!result.ok) { + throw new ApiError(result, 'Generic Error'); + } +} + +/** + * Request using fetch client + * @param options The request options from the the service + * @result ApiResult + * @throws ApiError + */ +export async function request(options: ApiRequestOptions): Promise { + const url = getUrl(options); + const response = await sendRequest(options, url); + const responseBody = await getResponseBody(response); + const responseHeader = getResponseHeader(response, options.responseHeader); + + const result: ApiResult = { + url, + ok: response.ok, + status: response.status, + statusText: response.statusText, + body: responseHeader || responseBody, + }; + + catchErrors(options, result); + return result; +} + +" +`; + +exports[`v2 should generate: ./test/generated/v2/index.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export { ApiError } from './core/ApiError'; +export { OpenAPI } from './core/OpenAPI'; + +export type { ArrayWithArray } from './models/ArrayWithArray'; +export type { ArrayWithBooleans } from './models/ArrayWithBooleans'; +export type { ArrayWithNumbers } from './models/ArrayWithNumbers'; +export type { ArrayWithProperties } from './models/ArrayWithProperties'; +export type { ArrayWithReferences } from './models/ArrayWithReferences'; +export type { ArrayWithStrings } from './models/ArrayWithStrings'; +export type { Date } from './models/Date'; +export type { DictionaryWithArray } from './models/DictionaryWithArray'; +export type { DictionaryWithDictionary } from './models/DictionaryWithDictionary'; +export type { DictionaryWithProperties } from './models/DictionaryWithProperties'; +export type { DictionaryWithReference } from './models/DictionaryWithReference'; +export type { DictionaryWithString } from './models/DictionaryWithString'; +export { EnumFromDescription } from './models/EnumFromDescription'; +export { EnumWithExtensions } from './models/EnumWithExtensions'; +export { EnumWithNumbers } from './models/EnumWithNumbers'; +export { EnumWithStrings } from './models/EnumWithStrings'; +export type { ModelLink } from './models/ModelLink'; +export type { ModelThatExtends } from './models/ModelThatExtends'; +export type { ModelThatExtendsExtends } from './models/ModelThatExtendsExtends'; +export type { ModelWithArray } from './models/ModelWithArray'; +export type { ModelWithBoolean } from './models/ModelWithBoolean'; +export type { ModelWithCircularReference } from './models/ModelWithCircularReference'; +export type { ModelWithDictionary } from './models/ModelWithDictionary'; +export type { ModelWithDuplicateImports } from './models/ModelWithDuplicateImports'; +export type { ModelWithDuplicateProperties } from './models/ModelWithDuplicateProperties'; +export { ModelWithEnum } from './models/ModelWithEnum'; +export { ModelWithEnumFromDescription } from './models/ModelWithEnumFromDescription'; +export type { ModelWithInteger } from './models/ModelWithInteger'; +export type { ModelWithLink } from './models/ModelWithLink'; +export type { ModelWithNestedEnums } from './models/ModelWithNestedEnums'; +export type { ModelWithNestedProperties } from './models/ModelWithNestedProperties'; +export type { ModelWithNullableString } from './models/ModelWithNullableString'; +export type { ModelWithOrderedProperties } from './models/ModelWithOrderedProperties'; +export type { ModelWithPattern } from './models/ModelWithPattern'; +export type { ModelWithProperties } from './models/ModelWithProperties'; +export type { ModelWithReference } from './models/ModelWithReference'; +export type { ModelWithString } from './models/ModelWithString'; +export type { MultilineComment } from './models/MultilineComment'; +export type { SimpleBoolean } from './models/SimpleBoolean'; +export type { SimpleFile } from './models/SimpleFile'; +export type { SimpleInteger } from './models/SimpleInteger'; +export type { SimpleReference } from './models/SimpleReference'; +export type { SimpleString } from './models/SimpleString'; +export type { SimpleStringWithPattern } from './models/SimpleStringWithPattern'; + +export { $ArrayWithArray } from './schemas/$ArrayWithArray'; +export { $ArrayWithBooleans } from './schemas/$ArrayWithBooleans'; +export { $ArrayWithNumbers } from './schemas/$ArrayWithNumbers'; +export { $ArrayWithProperties } from './schemas/$ArrayWithProperties'; +export { $ArrayWithReferences } from './schemas/$ArrayWithReferences'; +export { $ArrayWithStrings } from './schemas/$ArrayWithStrings'; +export { $Date } from './schemas/$Date'; +export { $DictionaryWithArray } from './schemas/$DictionaryWithArray'; +export { $DictionaryWithDictionary } from './schemas/$DictionaryWithDictionary'; +export { $DictionaryWithProperties } from './schemas/$DictionaryWithProperties'; +export { $DictionaryWithReference } from './schemas/$DictionaryWithReference'; +export { $DictionaryWithString } from './schemas/$DictionaryWithString'; +export { $EnumFromDescription } from './schemas/$EnumFromDescription'; +export { $EnumWithExtensions } from './schemas/$EnumWithExtensions'; +export { $EnumWithNumbers } from './schemas/$EnumWithNumbers'; +export { $EnumWithStrings } from './schemas/$EnumWithStrings'; +export { $ModelLink } from './schemas/$ModelLink'; +export { $ModelThatExtends } from './schemas/$ModelThatExtends'; +export { $ModelThatExtendsExtends } from './schemas/$ModelThatExtendsExtends'; +export { $ModelWithArray } from './schemas/$ModelWithArray'; +export { $ModelWithBoolean } from './schemas/$ModelWithBoolean'; +export { $ModelWithCircularReference } from './schemas/$ModelWithCircularReference'; +export { $ModelWithDictionary } from './schemas/$ModelWithDictionary'; +export { $ModelWithDuplicateImports } from './schemas/$ModelWithDuplicateImports'; +export { $ModelWithDuplicateProperties } from './schemas/$ModelWithDuplicateProperties'; +export { $ModelWithEnum } from './schemas/$ModelWithEnum'; +export { $ModelWithEnumFromDescription } from './schemas/$ModelWithEnumFromDescription'; +export { $ModelWithInteger } from './schemas/$ModelWithInteger'; +export { $ModelWithLink } from './schemas/$ModelWithLink'; +export { $ModelWithNestedEnums } from './schemas/$ModelWithNestedEnums'; +export { $ModelWithNestedProperties } from './schemas/$ModelWithNestedProperties'; +export { $ModelWithNullableString } from './schemas/$ModelWithNullableString'; +export { $ModelWithOrderedProperties } from './schemas/$ModelWithOrderedProperties'; +export { $ModelWithPattern } from './schemas/$ModelWithPattern'; +export { $ModelWithProperties } from './schemas/$ModelWithProperties'; +export { $ModelWithReference } from './schemas/$ModelWithReference'; +export { $ModelWithString } from './schemas/$ModelWithString'; +export { $MultilineComment } from './schemas/$MultilineComment'; +export { $SimpleBoolean } from './schemas/$SimpleBoolean'; +export { $SimpleFile } from './schemas/$SimpleFile'; +export { $SimpleInteger } from './schemas/$SimpleInteger'; +export { $SimpleReference } from './schemas/$SimpleReference'; +export { $SimpleString } from './schemas/$SimpleString'; +export { $SimpleStringWithPattern } from './schemas/$SimpleStringWithPattern'; + +export { ComplexService } from './services/ComplexService'; +export { DefaultsService } from './services/DefaultsService'; +export { DuplicateService } from './services/DuplicateService'; +export { HeaderService } from './services/HeaderService'; +export { ParametersService } from './services/ParametersService'; +export { ResponseService } from './services/ResponseService'; +export { SimpleService } from './services/SimpleService'; +export { TypesService } from './services/TypesService'; +" +`; + +exports[`v2 should generate: ./test/generated/v2/models/ArrayWithArray.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a simple array containing an array + */ +export type ArrayWithArray = Array>;" +`; + +exports[`v2 should generate: ./test/generated/v2/models/ArrayWithBooleans.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a simple array with booleans + */ +export type ArrayWithBooleans = Array;" +`; + +exports[`v2 should generate: ./test/generated/v2/models/ArrayWithNumbers.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a simple array with numbers + */ +export type ArrayWithNumbers = Array;" +`; + +exports[`v2 should generate: ./test/generated/v2/models/ArrayWithProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a simple array with properties + */ +export type ArrayWithProperties = Array<{ + foo?: string, + bar?: string, +}>;" +`; + +exports[`v2 should generate: ./test/generated/v2/models/ArrayWithReferences.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a simple array with references + */ +export type ArrayWithReferences = Array;" +`; + +exports[`v2 should generate: ./test/generated/v2/models/ArrayWithStrings.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a simple array with strings + */ +export type ArrayWithStrings = Array;" +`; + +exports[`v2 should generate: ./test/generated/v2/models/Date.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a type-only model that defines Date as a string + */ +export type Date = string;" +`; + +exports[`v2 should generate: ./test/generated/v2/models/DictionaryWithArray.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a complex dictionary + */ +export type DictionaryWithArray = Record>;" +`; + +exports[`v2 should generate: ./test/generated/v2/models/DictionaryWithDictionary.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a string dictionary + */ +export type DictionaryWithDictionary = Record>;" +`; + +exports[`v2 should generate: ./test/generated/v2/models/DictionaryWithProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a complex dictionary + */ +export type DictionaryWithProperties = Record;" +`; + +exports[`v2 should generate: ./test/generated/v2/models/DictionaryWithReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a string reference + */ +export type DictionaryWithReference = Record;" +`; + +exports[`v2 should generate: ./test/generated/v2/models/DictionaryWithString.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a string dictionary + */ +export type DictionaryWithString = Record;" +`; + +exports[`v2 should generate: ./test/generated/v2/models/EnumFromDescription.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * Success=1,Warning=2,Error=3 + */ +export enum EnumFromDescription { + SUCCESS = 1, + WARNING = 2, + ERROR = 3, +}" +`; + +exports[`v2 should generate: ./test/generated/v2/models/EnumWithExtensions.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a simple enum with numbers + */ +export enum EnumWithExtensions { + /** + * Used when the status of something is successful + */ + CUSTOM_SUCCESS = 200, + /** + * Used when the status of something has a warning + */ + CUSTOM_WARNING = 400, + /** + * Used when the status of something has an error + */ + CUSTOM_ERROR = 500, +}" +`; + +exports[`v2 should generate: ./test/generated/v2/models/EnumWithNumbers.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a simple enum with numbers + */ +export enum EnumWithNumbers { + _1 = 1, + _2 = 2, + _3 = 3, +}" +`; + +exports[`v2 should generate: ./test/generated/v2/models/EnumWithStrings.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a simple enum with strings + */ +export enum EnumWithStrings { + SUCCESS = 'Success', + WARNING = 'Warning', + ERROR = 'Error', +}" +`; + +exports[`v2 should generate: ./test/generated/v2/models/ModelLink.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model that can have a template?? + */ +export interface ModelLink { + id?: string; +} +" +`; + +exports[`v2 should generate: ./test/generated/v2/models/ModelThatExtends.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model that extends another model + */ +export interface ModelThatExtends extends ModelWithString { + propExtendsA?: string; + propExtendsB?: ModelWithString; +} +" +`; + +exports[`v2 should generate: ./test/generated/v2/models/ModelThatExtendsExtends.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelThatExtends } from './ModelThatExtends'; +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model that extends another model + */ +export interface ModelThatExtendsExtends extends ModelWithString, ModelThatExtends { + propExtendsC?: string; + propExtendsD?: ModelWithString; +} +" +`; + +exports[`v2 should generate: ./test/generated/v2/models/ModelWithArray.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model with one property containing an array + */ +export interface ModelWithArray { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +} +" +`; + +exports[`v2 should generate: ./test/generated/v2/models/ModelWithBoolean.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one boolean property + */ +export interface ModelWithBoolean { + /** + * This is a simple boolean property + */ + prop?: boolean; +} +" +`; + +exports[`v2 should generate: ./test/generated/v2/models/ModelWithCircularReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one property containing a circular reference + */ +export interface ModelWithCircularReference { + prop?: ModelWithCircularReference; +} +" +`; + +exports[`v2 should generate: ./test/generated/v2/models/ModelWithDictionary.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one property containing a dictionary + */ +export interface ModelWithDictionary { + prop?: Record; +} +" +`; + +exports[`v2 should generate: ./test/generated/v2/models/ModelWithDuplicateImports.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model with duplicated imports + */ +export interface ModelWithDuplicateImports { + propA?: ModelWithString; + propB?: ModelWithString; + propC?: ModelWithString; +} +" +`; + +exports[`v2 should generate: ./test/generated/v2/models/ModelWithDuplicateProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model with duplicated properties + */ +export interface ModelWithDuplicateProperties { + prop?: ModelWithString; +} +" +`; + +exports[`v2 should generate: ./test/generated/v2/models/ModelWithEnum.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one enum + */ +export interface ModelWithEnum { + /** + * This is a simple enum with strings + */ + test?: ModelWithEnum.test; + /** + * These are the HTTP error code enums + */ + statusCode?: ModelWithEnum.statusCode; +} + +export namespace ModelWithEnum { + + /** + * This is a simple enum with strings + */ + export enum test { + SUCCESS = 'Success', + WARNING = 'Warning', + ERROR = 'Error', + } + + /** + * These are the HTTP error code enums + */ + export enum statusCode { + _100 = '100', + _200_FOO = '200 FOO', + _300_FOO_BAR = '300 FOO_BAR', + _400_FOO_BAR = '400 foo-bar', + _500_FOO_BAR = '500 foo.bar', + _600_FOO_BAR = '600 foo&bar', + } + + +} +" +`; + +exports[`v2 should generate: ./test/generated/v2/models/ModelWithEnumFromDescription.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one enum + */ +export interface ModelWithEnumFromDescription { + /** + * Success=1,Warning=2,Error=3 + */ + test?: ModelWithEnumFromDescription.test; +} + +export namespace ModelWithEnumFromDescription { + + /** + * Success=1,Warning=2,Error=3 + */ + export enum test { + SUCCESS = 1, + WARNING = 2, + ERROR = 3, + } + + +} +" +`; + +exports[`v2 should generate: ./test/generated/v2/models/ModelWithInteger.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one number property + */ +export interface ModelWithInteger { + /** + * This is a simple number property + */ + prop?: number; +} +" +`; + +exports[`v2 should generate: ./test/generated/v2/models/ModelWithLink.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelLink } from './ModelLink'; +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model that can have a template?? + */ +export interface ModelWithLink { + prop?: ModelLink; +} +" +`; + +exports[`v2 should generate: ./test/generated/v2/models/ModelWithNestedEnums.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with nested enums + */ +export interface ModelWithNestedEnums { + dictionaryWithEnum?: Record; + dictionaryWithEnumFromDescription?: Record; + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; + arrayWithDescription?: Array<1 | 2 | 3>; +} +" +`; + +exports[`v2 should generate: ./test/generated/v2/models/ModelWithNestedProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one nested property + */ +export interface ModelWithNestedProperties { + readonly first: { + readonly second: { + readonly third: string, + }, + }; +} +" +`; + +exports[`v2 should generate: ./test/generated/v2/models/ModelWithNullableString.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one string property + */ +export interface ModelWithNullableString { + /** + * This is a simple string property + */ + nullableProp?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp: string | null; +} +" +`; + +exports[`v2 should generate: ./test/generated/v2/models/ModelWithOrderedProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with ordered properties + */ +export interface ModelWithOrderedProperties { + zebra?: string; + apple?: string; + hawaii?: string; +} +" +`; + +exports[`v2 should generate: ./test/generated/v2/models/ModelWithPattern.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model that contains a some patterns + */ +export interface ModelWithPattern { + key: string; + name: string; + readonly enabled?: boolean; + readonly modified?: string; + id?: string; + text?: string; +} +" +`; + +exports[`v2 should generate: ./test/generated/v2/models/ModelWithProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model with one nested property + */ +export interface ModelWithProperties { + required: string; + readonly requiredAndReadOnly: string; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + readonly '@namespace.string'?: string; + readonly '@namespace.integer'?: number; +} +" +`; + +exports[`v2 should generate: ./test/generated/v2/models/ModelWithReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithProperties } from './ModelWithProperties'; + +/** + * This is a model with one property containing a reference + */ +export interface ModelWithReference { + prop?: ModelWithProperties; +} +" +`; + +exports[`v2 should generate: ./test/generated/v2/models/ModelWithString.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one string property + */ +export interface ModelWithString { + /** + * This is a simple string property + */ + prop?: string; +} +" +`; + +exports[`v2 should generate: ./test/generated/v2/models/MultilineComment.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * Testing multiline comments. + * This must go to the next line. + * + * This will contain a break. + */ +export type MultilineComment = number;" +`; + +exports[`v2 should generate: ./test/generated/v2/models/SimpleBoolean.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a simple boolean + */ +export type SimpleBoolean = boolean;" +`; + +exports[`v2 should generate: ./test/generated/v2/models/SimpleFile.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a simple file + */ +export type SimpleFile = Blob;" +`; + +exports[`v2 should generate: ./test/generated/v2/models/SimpleInteger.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a simple number + */ +export type SimpleInteger = number;" +`; + +exports[`v2 should generate: ./test/generated/v2/models/SimpleReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a simple reference + */ +export type SimpleReference = ModelWithString;" +`; + +exports[`v2 should generate: ./test/generated/v2/models/SimpleString.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a simple string + */ +export type SimpleString = string;" +`; + +exports[`v2 should generate: ./test/generated/v2/models/SimpleStringWithPattern.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a simple string + */ +export type SimpleStringWithPattern = string;" +`; + +exports[`v2 should generate: ./test/generated/v2/schemas/$ArrayWithArray.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ArrayWithArray = { + type: 'array', + contains: { + type: 'array', + contains: { + type: 'ModelWithString', + }, + }, +};" +`; + +exports[`v2 should generate: ./test/generated/v2/schemas/$ArrayWithBooleans.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ArrayWithBooleans = { + type: 'array', + contains: { + type: 'boolean', + }, +};" +`; + +exports[`v2 should generate: ./test/generated/v2/schemas/$ArrayWithNumbers.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ArrayWithNumbers = { + type: 'array', + contains: { + type: 'number', + }, +};" +`; + +exports[`v2 should generate: ./test/generated/v2/schemas/$ArrayWithProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ArrayWithProperties = { + type: 'array', + contains: { + properties: { + foo: { + type: 'string', + }, + bar: { + type: 'string', + }, + }, + }, +};" +`; + +exports[`v2 should generate: ./test/generated/v2/schemas/$ArrayWithReferences.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ArrayWithReferences = { + type: 'array', + contains: { + type: 'ModelWithString', + }, +};" +`; + +exports[`v2 should generate: ./test/generated/v2/schemas/$ArrayWithStrings.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ArrayWithStrings = { + type: 'array', + contains: { + type: 'string', + }, +};" +`; + +exports[`v2 should generate: ./test/generated/v2/schemas/$Date.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $Date = { + type: 'string', +};" +`; + +exports[`v2 should generate: ./test/generated/v2/schemas/$DictionaryWithArray.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $DictionaryWithArray = { + type: 'dictionary', + contains: { + type: 'array', + contains: { + type: 'ModelWithString', + }, + }, +};" +`; + +exports[`v2 should generate: ./test/generated/v2/schemas/$DictionaryWithDictionary.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $DictionaryWithDictionary = { + type: 'dictionary', + contains: { + type: 'dictionary', + contains: { + type: 'string', + }, + }, +};" +`; + +exports[`v2 should generate: ./test/generated/v2/schemas/$DictionaryWithProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $DictionaryWithProperties = { + type: 'dictionary', + contains: { + properties: { + foo: { + type: 'string', + }, + bar: { + type: 'string', + }, + }, + }, +};" +`; + +exports[`v2 should generate: ./test/generated/v2/schemas/$DictionaryWithReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $DictionaryWithReference = { + type: 'dictionary', + contains: { + type: 'ModelWithString', + }, +};" +`; + +exports[`v2 should generate: ./test/generated/v2/schemas/$DictionaryWithString.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $DictionaryWithString = { + type: 'dictionary', + contains: { + type: 'string', + }, +};" +`; + +exports[`v2 should generate: ./test/generated/v2/schemas/$EnumFromDescription.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $EnumFromDescription = { + type: 'Enum', +};" +`; + +exports[`v2 should generate: ./test/generated/v2/schemas/$EnumWithExtensions.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $EnumWithExtensions = { + type: 'Enum', +};" +`; + +exports[`v2 should generate: ./test/generated/v2/schemas/$EnumWithNumbers.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $EnumWithNumbers = { + type: 'Enum', +};" +`; + +exports[`v2 should generate: ./test/generated/v2/schemas/$EnumWithStrings.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $EnumWithStrings = { + type: 'Enum', +};" +`; + +exports[`v2 should generate: ./test/generated/v2/schemas/$ModelLink.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelLink = { + properties: { + id: { + type: 'string', + }, + }, +};" +`; + +exports[`v2 should generate: ./test/generated/v2/schemas/$ModelThatExtends.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { $ModelWithString } from './$ModelWithString'; + +export const $ModelThatExtends = { + properties: { + ...$ModelWithString.properties, + propExtendsA: { + type: 'string', + }, + propExtendsB: { + type: 'ModelWithString', + }, + }, +};" +`; + +exports[`v2 should generate: ./test/generated/v2/schemas/$ModelThatExtendsExtends.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import { $ModelWithString } from './$ModelWithString'; +import { $ModelThatExtends } from './$ModelThatExtends'; + +export const $ModelThatExtendsExtends = { + properties: { + ...$ModelWithString.properties, + ...$ModelThatExtends.properties, + propExtendsC: { + type: 'string', + }, + propExtendsD: { + type: 'ModelWithString', + }, + }, +};" +`; + +exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithArray.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithArray = { + properties: { + prop: { + type: 'array', + contains: { + type: 'ModelWithString', + }, + }, + propWithFile: { + type: 'array', + contains: { + type: 'File', + }, + }, + propWithNumber: { + type: 'array', + contains: { + type: 'number', + }, + }, + }, +};" +`; + +exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithBoolean.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithBoolean = { + properties: { + prop: { + type: 'boolean', + }, + }, +};" +`; + +exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithCircularReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithCircularReference = { + properties: { + prop: { + type: 'ModelWithCircularReference', + }, + }, +};" +`; + +exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithDictionary.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithDictionary = { + properties: { + prop: { + type: 'dictionary', + contains: { + type: 'string', + }, + }, + }, +};" +`; + +exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithDuplicateImports.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithDuplicateImports = { + properties: { + propA: { + type: 'ModelWithString', + }, + propB: { + type: 'ModelWithString', + }, + propC: { + type: 'ModelWithString', + }, + }, +};" +`; + +exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithDuplicateProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithDuplicateProperties = { + properties: { + prop: { + type: 'ModelWithString', + }, + }, +};" +`; + +exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithEnum.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithEnum = { + properties: { + test: { + type: 'Enum', + }, + statusCode: { + type: 'Enum', + }, + }, +};" +`; + +exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithEnumFromDescription.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithEnumFromDescription = { + properties: { + test: { + type: 'Enum', + }, + }, +};" +`; + +exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithInteger.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithInteger = { + properties: { + prop: { + type: 'number', + }, + }, +};" +`; + +exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithLink.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithLink = { + properties: { + prop: { + type: 'ModelLink', + }, + }, +};" +`; + +exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithNestedEnums.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithNestedEnums = { + properties: { + dictionaryWithEnum: { + type: 'dictionary', + contains: { + type: 'Enum', + }, + }, + dictionaryWithEnumFromDescription: { + type: 'dictionary', + contains: { + type: 'Enum', + }, + }, + arrayWithEnum: { + type: 'array', + contains: { + type: 'Enum', + }, + }, + arrayWithDescription: { + type: 'array', + contains: { + type: 'Enum', + }, + }, + }, +};" +`; + +exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithNestedProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithNestedProperties = { + properties: { + first: { + properties: { + second: { + properties: { + third: { + type: 'string', + isReadOnly: true, + isRequired: true, + }, + }, + isReadOnly: true, + isRequired: true, + }, + }, + isReadOnly: true, + isRequired: true, + }, + }, +};" +`; + +exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithNullableString.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithNullableString = { + properties: { + nullableProp: { + type: 'string', + isNullable: true, + }, + nullableRequiredProp: { + type: 'string', + isRequired: true, + isNullable: true, + }, + }, +};" +`; + +exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithOrderedProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithOrderedProperties = { + properties: { + zebra: { + type: 'string', + }, + apple: { + type: 'string', + }, + hawaii: { + type: 'string', + }, + }, +};" +`; + +exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithPattern.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithPattern = { + properties: { + key: { + type: 'string', + isRequired: true, + maxLength: 64, + pattern: '^[a-zA-Z0-9_]*$', + }, + name: { + type: 'string', + isRequired: true, + maxLength: 255, + }, + enabled: { + type: 'boolean', + isReadOnly: true, + }, + modified: { + type: 'string', + isReadOnly: true, + format: 'date-time', + }, + id: { + type: 'string', + pattern: '^\\\\\\\\d{2}-\\\\\\\\d{3}-\\\\\\\\d{4}$', + }, + text: { + type: 'string', + pattern: '^\\\\\\\\w+$', + }, + }, +};" +`; + +exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithProperties = { + properties: { + required: { + type: 'string', + isRequired: true, + }, + requiredAndReadOnly: { + type: 'string', + isReadOnly: true, + isRequired: true, + }, + string: { + type: 'string', + }, + number: { + type: 'number', + }, + boolean: { + type: 'boolean', + }, + reference: { + type: 'ModelWithString', + }, + '@namespace.string': { + type: 'string', + isReadOnly: true, + }, + '@namespace.integer': { + type: 'number', + isReadOnly: true, + }, + }, +};" +`; + +exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithReference = { + properties: { + prop: { + type: 'ModelWithProperties', + }, + }, +};" +`; + +exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithString.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithString = { + properties: { + prop: { + type: 'string', + }, + }, +};" +`; + +exports[`v2 should generate: ./test/generated/v2/schemas/$MultilineComment.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $MultilineComment = { + type: 'number', +};" +`; + +exports[`v2 should generate: ./test/generated/v2/schemas/$SimpleBoolean.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $SimpleBoolean = { + type: 'boolean', +};" +`; + +exports[`v2 should generate: ./test/generated/v2/schemas/$SimpleFile.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $SimpleFile = { + type: 'File', +};" +`; + +exports[`v2 should generate: ./test/generated/v2/schemas/$SimpleInteger.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $SimpleInteger = { + type: 'number', +};" +`; + +exports[`v2 should generate: ./test/generated/v2/schemas/$SimpleReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $SimpleReference = { + type: 'ModelWithString', +};" +`; + +exports[`v2 should generate: ./test/generated/v2/schemas/$SimpleString.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $SimpleString = { + type: 'string', +};" +`; + +exports[`v2 should generate: ./test/generated/v2/schemas/$SimpleStringWithPattern.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $SimpleStringWithPattern = { + type: 'string', + maxLength: 64, + pattern: '^[a-zA-Z0-9_]*$', +};" +`; + +exports[`v2 should generate: ./test/generated/v2/services/ComplexService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ModelWithString } from '../models/ModelWithString'; +import { request as __request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class ComplexService { + + /** + * @param parameterObject Parameter containing object + * @param parameterReference Parameter containing reference + * @result ModelWithString Successful response + * @throws ApiError + */ + public static async complexTypes( + parameterObject: { + first?: { + second?: { + third?: string, + }, + }, + }, + parameterReference: ModelWithString, + ): Promise> { + const result = await __request({ + method: 'GET', + path: \`/api/v\${OpenAPI.VERSION}/complex\`, + query: { + 'parameterObject': parameterObject, + 'parameterReference': parameterReference, + }, + errors: { + 400: \`400 server error\`, + 500: \`500 server error\`, + }, + }); + return result.body; + } + +}" +`; + +exports[`v2 should generate: ./test/generated/v2/services/DefaultsService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ModelWithString } from '../models/ModelWithString'; +import { request as __request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class DefaultsService { + + /** + * @param parameterString This is a simple string with default value + * @param parameterNumber This is a simple number with default value + * @param parameterBoolean This is a simple boolean with default value + * @param parameterEnum This is a simple enum with default value + * @param parameterModel This is a simple model with default value + * @throws ApiError + */ + public static async callWithDefaultParameters( + parameterString: string = 'Hello World!', + parameterNumber: number = 123, + parameterBoolean: boolean = true, + parameterEnum: 'Success' | 'Warning' | 'Error' = 'Success', + parameterModel: ModelWithString = { + \\"prop\\": \\"Hello World!\\" + }, + ): Promise { + const result = await __request({ + method: 'GET', + path: \`/api/v\${OpenAPI.VERSION}/defaults\`, + query: { + 'parameterString': parameterString, + 'parameterNumber': parameterNumber, + 'parameterBoolean': parameterBoolean, + 'parameterEnum': parameterEnum, + 'parameterModel': parameterModel, + }, + }); + return result.body; + } + + /** + * @param parameterString This is a simple string that is optional with default value + * @param parameterNumber This is a simple number that is optional with default value + * @param parameterBoolean This is a simple boolean that is optional with default value + * @param parameterEnum This is a simple enum that is optional with default value + * @param parameterModel This is a simple model that is optional with default value + * @throws ApiError + */ + public static async callWithDefaultOptionalParameters( + parameterString: string = 'Hello World!', + parameterNumber: number = 123, + parameterBoolean: boolean = true, + parameterEnum: 'Success' | 'Warning' | 'Error' = 'Success', + parameterModel: ModelWithString = { + \\"prop\\": \\"Hello World!\\" + }, + ): Promise { + const result = await __request({ + method: 'POST', + path: \`/api/v\${OpenAPI.VERSION}/defaults\`, + query: { + 'parameterString': parameterString, + 'parameterNumber': parameterNumber, + 'parameterBoolean': parameterBoolean, + 'parameterEnum': parameterEnum, + 'parameterModel': parameterModel, + }, + }); + return result.body; + } + + /** + * @param parameterStringWithNoDefault This is a string with no default + * @param parameterOptionalStringWithDefault This is a optional string with default + * @param parameterOptionalStringWithEmptyDefault This is a optional string with empty default + * @param parameterOptionalStringWithNoDefault This is a optional string with no default + * @param parameterStringWithDefault This is a string with default + * @param parameterStringWithEmptyDefault This is a string with empty default + * @throws ApiError + */ + public static async callToTestOrderOfParams( + parameterStringWithNoDefault: string, + parameterOptionalStringWithDefault: string = 'Hello World!', + parameterOptionalStringWithEmptyDefault: string = '', + parameterOptionalStringWithNoDefault?: string, + parameterStringWithDefault: string = 'Hello World!', + parameterStringWithEmptyDefault: string = '', + ): Promise { + const result = await __request({ + method: 'PUT', + path: \`/api/v\${OpenAPI.VERSION}/defaults\`, + query: { + 'parameterStringWithNoDefault': parameterStringWithNoDefault, + 'parameterOptionalStringWithDefault': parameterOptionalStringWithDefault, + 'parameterOptionalStringWithEmptyDefault': parameterOptionalStringWithEmptyDefault, + 'parameterOptionalStringWithNoDefault': parameterOptionalStringWithNoDefault, + 'parameterStringWithDefault': parameterStringWithDefault, + 'parameterStringWithEmptyDefault': parameterStringWithEmptyDefault, + }, + }); + return result.body; + } + +}" +`; + +exports[`v2 should generate: ./test/generated/v2/services/DuplicateService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import { request as __request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class DuplicateService { + + /** + * @throws ApiError + */ + public static async duplicateName(): Promise { + const result = await __request({ + method: 'GET', + path: \`/api/v\${OpenAPI.VERSION}/duplicate\`, + }); + return result.body; + } + + /** + * @throws ApiError + */ + public static async duplicateName1(): Promise { + const result = await __request({ + method: 'POST', + path: \`/api/v\${OpenAPI.VERSION}/duplicate\`, + }); + return result.body; + } + + /** + * @throws ApiError + */ + public static async duplicateName2(): Promise { + const result = await __request({ + method: 'PUT', + path: \`/api/v\${OpenAPI.VERSION}/duplicate\`, + }); + return result.body; + } + + /** + * @throws ApiError + */ + public static async duplicateName3(): Promise { + const result = await __request({ + method: 'DELETE', + path: \`/api/v\${OpenAPI.VERSION}/duplicate\`, + }); + return result.body; + } + +}" +`; + +exports[`v2 should generate: ./test/generated/v2/services/HeaderService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import { request as __request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class HeaderService { + + /** + * @result string Successful response + * @throws ApiError + */ + public static async callWithResultFromHeader(): Promise { + const result = await __request({ + method: 'POST', + path: \`/api/v\${OpenAPI.VERSION}/header\`, + responseHeader: 'operation-location', + errors: { + 400: \`400 server error\`, + 500: \`500 server error\`, + }, + }); + return result.body; + } + +}" +`; + +exports[`v2 should generate: ./test/generated/v2/services/ParametersService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import { request as __request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class ParametersService { + + /** + * @param parameterHeader This is the parameter that goes into the header + * @param parameterQuery This is the parameter that goes into the query params + * @param parameterForm This is the parameter that goes into the form data + * @param parameterBody This is the parameter that is send as request body + * @param parameterPath This is the parameter that goes into the path + * @throws ApiError + */ + public static async callWithParameters( + parameterHeader: string, + parameterQuery: string, + parameterForm: string, + parameterBody: string, + parameterPath: string, + ): Promise { + const result = await __request({ + method: 'GET', + path: \`/api/v\${OpenAPI.VERSION}/parameters/\${parameterPath}\`, + headers: { + 'parameterHeader': parameterHeader, + }, + query: { + 'parameterQuery': parameterQuery, + }, + formData: { + 'parameterForm': parameterForm, + }, + body: parameterBody, + }); + return result.body; + } + + /** + * @param parameterHeader This is the parameter that goes into the request header + * @param parameterQuery This is the parameter that goes into the request query params + * @param parameterForm This is the parameter that goes into the request form data + * @param parameterBody This is the parameter that is send as request body + * @param parameterPath1 This is the parameter that goes into the path + * @param parameterPath2 This is the parameter that goes into the path + * @param parameterPath3 This is the parameter that goes into the path + * @throws ApiError + */ + public static async callWithWeirdParameterNames( + parameterHeader: string, + parameterQuery: string, + parameterForm: string, + parameterBody: string, + parameterPath1?: string, + parameterPath2?: string, + parameterPath3?: string, + ): Promise { + const result = await __request({ + method: 'GET', + path: \`/api/v\${OpenAPI.VERSION}/parameters/\${parameterPath1}/\${parameterPath2}/\${parameterPath3}\`, + headers: { + 'parameter.header': parameterHeader, + }, + query: { + 'parameter-query': parameterQuery, + }, + formData: { + 'parameter_form': parameterForm, + }, + body: parameterBody, + }); + return result.body; + } + +}" +`; + +exports[`v2 should generate: ./test/generated/v2/services/ResponseService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ModelThatExtends } from '../models/ModelThatExtends'; +import type { ModelThatExtendsExtends } from '../models/ModelThatExtendsExtends'; +import type { ModelWithString } from '../models/ModelWithString'; +import { request as __request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class ResponseService { + + /** + * @result ModelWithString Message for default response + * @throws ApiError + */ + public static async callWithResponse(): Promise { + const result = await __request({ + method: 'GET', + path: \`/api/v\${OpenAPI.VERSION}/response\`, + }); + return result.body; + } + + /** + * @result ModelWithString Message for default response + * @throws ApiError + */ + public static async callWithDuplicateResponses(): Promise { + const result = await __request({ + method: 'POST', + path: \`/api/v\${OpenAPI.VERSION}/response\`, + errors: { + 500: \`Message for 500 error\`, + 501: \`Message for 501 error\`, + 502: \`Message for 502 error\`, + }, + }); + return result.body; + } + + /** + * @result any Message for 200 response + * @result ModelWithString Message for default response + * @result ModelThatExtends Message for 201 response + * @result ModelThatExtendsExtends Message for 202 response + * @throws ApiError + */ + public static async callWithResponses(): Promise<{ + readonly '@namespace.string'?: string, + readonly '@namespace.integer'?: number, + readonly value?: Array, + } | ModelWithString | ModelThatExtends | ModelThatExtendsExtends> { + const result = await __request({ + method: 'PUT', + path: \`/api/v\${OpenAPI.VERSION}/response\`, + errors: { + 500: \`Message for 500 error\`, + 501: \`Message for 501 error\`, + 502: \`Message for 502 error\`, + }, + }); + return result.body; + } + +}" +`; + +exports[`v2 should generate: ./test/generated/v2/services/SimpleService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import { request as __request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class SimpleService { + + /** + * @throws ApiError + */ + public static async getCallWithoutParametersAndResponse(): Promise { + const result = await __request({ + method: 'GET', + path: \`/api/v\${OpenAPI.VERSION}/simple\`, + }); + return result.body; + } + + /** + * @throws ApiError + */ + public static async putCallWithoutParametersAndResponse(): Promise { + const result = await __request({ + method: 'PUT', + path: \`/api/v\${OpenAPI.VERSION}/simple\`, + }); + return result.body; + } + + /** + * @throws ApiError + */ + public static async postCallWithoutParametersAndResponse(): Promise { + const result = await __request({ + method: 'POST', + path: \`/api/v\${OpenAPI.VERSION}/simple\`, + }); + return result.body; + } + + /** + * @throws ApiError + */ + public static async deleteCallWithoutParametersAndResponse(): Promise { + const result = await __request({ + method: 'DELETE', + path: \`/api/v\${OpenAPI.VERSION}/simple\`, + }); + return result.body; + } + + /** + * @throws ApiError + */ + public static async optionsCallWithoutParametersAndResponse(): Promise { + const result = await __request({ + method: 'OPTIONS', + path: \`/api/v\${OpenAPI.VERSION}/simple\`, + }); + return result.body; + } + + /** + * @throws ApiError + */ + public static async headCallWithoutParametersAndResponse(): Promise { + const result = await __request({ + method: 'HEAD', + path: \`/api/v\${OpenAPI.VERSION}/simple\`, + }); + return result.body; + } + + /** + * @throws ApiError + */ + public static async patchCallWithoutParametersAndResponse(): Promise { + const result = await __request({ + method: 'PATCH', + path: \`/api/v\${OpenAPI.VERSION}/simple\`, + }); + return result.body; + } + +}" +`; + +exports[`v2 should generate: ./test/generated/v2/services/TypesService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import { request as __request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class TypesService { + + /** + * @param parameterArray This is an array parameter + * @param parameterDictionary This is a dictionary parameter + * @param parameterEnum This is an enum parameter + * @param parameterNumber This is a number parameter + * @param parameterString This is a string parameter + * @param parameterBoolean This is a boolean parameter + * @param parameterObject This is an object parameter + * @param id This is a number parameter + * @result number Response is a simple number + * @result string Response is a simple string + * @result boolean Response is a simple boolean + * @result any Response is a simple object + * @throws ApiError + */ + public static async types( + parameterArray: Array, + parameterDictionary: Record, + parameterEnum: 'Success' | 'Warning' | 'Error', + parameterNumber: number = 123, + parameterString: string = 'default', + parameterBoolean: boolean = true, + parameterObject: any = null, + id?: number, + ): Promise { + const result = await __request({ + method: 'GET', + path: \`/api/v\${OpenAPI.VERSION}/types\`, + query: { + 'parameterArray': parameterArray, + 'parameterDictionary': parameterDictionary, + 'parameterEnum': parameterEnum, + 'parameterNumber': parameterNumber, + 'parameterString': parameterString, + 'parameterBoolean': parameterBoolean, + 'parameterObject': parameterObject, + }, + }); + return result.body; + } + +}" +`; + +exports[`v3 should generate: ./test/generated/v3/core/ApiError.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ApiResult } from './ApiResult'; + +export class ApiError extends Error { + public readonly url: string; + public readonly status: number; + public readonly statusText: string; + public readonly body: any; + + constructor(response: ApiResult, message: string) { + super(message); + + this.url = response.url; + this.status = response.status; + this.statusText = response.statusText; + this.body = response.body; + } +}" +`; + +exports[`v3 should generate: ./test/generated/v3/core/ApiRequestOptions.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export interface ApiRequestOptions { + readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH'; + readonly path: string; + readonly cookies?: Record; + readonly headers?: Record; + readonly query?: Record; + readonly formData?: Record; + readonly body?: any; + readonly responseHeader?: string; + readonly errors?: Record; +}" +`; + +exports[`v3 should generate: ./test/generated/v3/core/ApiResult.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export interface ApiResult { + readonly url: string; + readonly ok: boolean; + readonly status: number; + readonly statusText: string; + readonly body: any; +}" +`; + +exports[`v3 should generate: ./test/generated/v3/core/OpenAPI.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +type Resolver = () => Promise; +type Headers = Record; + +interface Config { + BASE: string; + VERSION: string; + WITH_CREDENTIALS: boolean; + TOKEN?: string | Resolver; + USERNAME?: string | Resolver; + PASSWORD?: string | Resolver; + HEADERS?: Headers | Resolver; +} + +export const OpenAPI: Config = { + BASE: 'http://localhost:3000/base', + VERSION: '1.0', + WITH_CREDENTIALS: false, + TOKEN: undefined, + USERNAME: undefined, + PASSWORD: undefined, + HEADERS: undefined, +};" +`; + +exports[`v3 should generate: ./test/generated/v3/core/request.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import { ApiError } from './ApiError'; +import type { ApiRequestOptions } from './ApiRequestOptions'; +import type { ApiResult } from './ApiResult'; +import { OpenAPI } from './OpenAPI'; + +function isDefined(value: T | null | undefined): value is Exclude { + return value !== undefined && value !== null; +} + +function isString(value: any): value is string { + return typeof value === 'string'; +} + +function isStringWithValue(value: any): value is string { + return isString(value) && value !== ''; +} + +function isBlob(value: any): value is Blob { + return value instanceof Blob; +} + +function getQueryString(params: Record): string { + const qs: string[] = []; + Object.keys(params).forEach(key => { + const value = params[key]; + if (isDefined(value)) { + if (Array.isArray(value)) { + value.forEach(value => { + qs.push(\`\${encodeURIComponent(key)}=\${encodeURIComponent(String(value))}\`); + }); + } else { + qs.push(\`\${encodeURIComponent(key)}=\${encodeURIComponent(String(value))}\`); + } + } + }); + if (qs.length > 0) { + return \`?\${qs.join('&')}\`; + } + return ''; +} + +function getUrl(options: ApiRequestOptions): string { + const path = options.path.replace(/[:]/g, '_'); + const url = \`\${OpenAPI.BASE}\${path}\`; + + if (options.query) { + return \`\${url}\${getQueryString(options.query)}\`; + } + return url; +} + +function getFormData(params: Record): FormData { + const formData = new FormData(); + Object.keys(params).forEach(key => { + const value = params[key]; + if (isDefined(value)) { + formData.append(key, value); + } + }); + return formData; +} + +type Resolver = () => Promise; + +async function resolve(resolver?: T | Resolver): Promise { + if (typeof resolver === 'function') { + return (resolver as Resolver)(); + } + return resolver; +} + +async function getHeaders(options: ApiRequestOptions): Promise { + const headers = new Headers({ + Accept: 'application/json', + ...OpenAPI.HEADERS, + ...options.headers, + }); + + const token = await resolve(OpenAPI.TOKEN); + const username = await resolve(OpenAPI.USERNAME); + const password = await resolve(OpenAPI.PASSWORD); + + if (isStringWithValue(token)) { + headers.append('Authorization', \`Bearer \${token}\`); + } + + if (isStringWithValue(username) && isStringWithValue(password)) { + const credentials = btoa(\`\${username}:\${password}\`); + headers.append('Authorization', \`Basic \${credentials}\`); + } + + if (options.body) { + if (isBlob(options.body)) { + headers.append('Content-Type', options.body.type || 'application/octet-stream'); + } else if (isString(options.body)) { + headers.append('Content-Type', 'text/plain'); + } else { + headers.append('Content-Type', 'application/json'); + } + } + return headers; +} + +function getRequestBody(options: ApiRequestOptions): BodyInit | undefined { + if (options.formData) { + return getFormData(options.formData); + } + if (options.body) { + if (isString(options.body) || isBlob(options.body)) { + return options.body; + } else { + return JSON.stringify(options.body); + } + } + return undefined; +} + +async function sendRequest(options: ApiRequestOptions, url: string): Promise { + const request: RequestInit = { + method: options.method, + headers: await getHeaders(options), + body: getRequestBody(options), + }; + return await fetch(url, request); +} + +function getResponseHeader(response: Response, responseHeader?: string): string | null { + if (responseHeader) { + const content = response.headers.get(responseHeader); + if (isString(content)) { + return content; + } + } + return null; +} + +async function getResponseBody(response: Response): Promise { + try { + const contentType = response.headers.get('Content-Type'); + if (contentType) { + const isJSON = contentType.toLowerCase().startsWith('application/json'); + if (isJSON) { + return await response.json(); + } else { + return await response.text(); + } + } + } catch (error) { + console.error(error); + } + return null; +} + +function catchErrors(options: ApiRequestOptions, result: ApiResult): void { + const errors: Record = { + 400: 'Bad Request', + 401: 'Unauthorized', + 403: 'Forbidden', + 404: 'Not Found', + 500: 'Internal Server Error', + 502: 'Bad Gateway', + 503: 'Service Unavailable', + ...options.errors, + } + + const error = errors[result.status]; + if (error) { + throw new ApiError(result, error); + } + + if (!result.ok) { + throw new ApiError(result, 'Generic Error'); + } +} + +/** + * Request using fetch client + * @param options The request options from the the service + * @result ApiResult + * @throws ApiError + */ +export async function request(options: ApiRequestOptions): Promise { + const url = getUrl(options); + const response = await sendRequest(options, url); + const responseBody = await getResponseBody(response); + const responseHeader = getResponseHeader(response, options.responseHeader); + + const result: ApiResult = { + url, + ok: response.ok, + status: response.status, + statusText: response.statusText, + body: responseHeader || responseBody, + }; + + catchErrors(options, result); + return result; +} + +" +`; + +exports[`v3 should generate: ./test/generated/v3/index.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export { ApiError } from './core/ApiError'; +export { OpenAPI } from './core/OpenAPI'; + +export type { ArrayWithArray } from './models/ArrayWithArray'; +export type { ArrayWithBooleans } from './models/ArrayWithBooleans'; +export type { ArrayWithNumbers } from './models/ArrayWithNumbers'; +export type { ArrayWithProperties } from './models/ArrayWithProperties'; +export type { ArrayWithReferences } from './models/ArrayWithReferences'; +export type { ArrayWithStrings } from './models/ArrayWithStrings'; +export type { CompositionWithAllOfAndNullable } from './models/CompositionWithAllOfAndNullable'; +export type { CompositionWithAnyOf } from './models/CompositionWithAnyOf'; +export type { CompositionWithAnyOfAndNullable } from './models/CompositionWithAnyOfAndNullable'; +export type { CompositionWithAnyOfAnonymous } from './models/CompositionWithAnyOfAnonymous'; +export type { CompositionWithOneOf } from './models/CompositionWithOneOf'; +export type { CompositionWithOneOfAndNullable } from './models/CompositionWithOneOfAndNullable'; +export type { CompositionWithOneOfAnonymous } from './models/CompositionWithOneOfAnonymous'; +export type { DictionaryWithArray } from './models/DictionaryWithArray'; +export type { DictionaryWithDictionary } from './models/DictionaryWithDictionary'; +export type { DictionaryWithProperties } from './models/DictionaryWithProperties'; +export type { DictionaryWithReference } from './models/DictionaryWithReference'; +export type { DictionaryWithString } from './models/DictionaryWithString'; +export { EnumFromDescription } from './models/EnumFromDescription'; +export { EnumWithExtensions } from './models/EnumWithExtensions'; +export { EnumWithNumbers } from './models/EnumWithNumbers'; +export { EnumWithStrings } from './models/EnumWithStrings'; +export type { ModelLink } from './models/ModelLink'; +export type { ModelThatExtends } from './models/ModelThatExtends'; +export type { ModelThatExtendsExtends } from './models/ModelThatExtendsExtends'; +export type { ModelWithArray } from './models/ModelWithArray'; +export type { ModelWithBoolean } from './models/ModelWithBoolean'; +export type { ModelWithCircularReference } from './models/ModelWithCircularReference'; +export type { ModelWithDictionary } from './models/ModelWithDictionary'; +export type { ModelWithDuplicateImports } from './models/ModelWithDuplicateImports'; +export type { ModelWithDuplicateProperties } from './models/ModelWithDuplicateProperties'; +export { ModelWithEnum } from './models/ModelWithEnum'; +export { ModelWithEnumFromDescription } from './models/ModelWithEnumFromDescription'; +export type { ModelWithInteger } from './models/ModelWithInteger'; +export type { ModelWithLink } from './models/ModelWithLink'; +export type { ModelWithNestedEnums } from './models/ModelWithNestedEnums'; +export type { ModelWithNestedProperties } from './models/ModelWithNestedProperties'; +export type { ModelWithOrderedProperties } from './models/ModelWithOrderedProperties'; +export type { ModelWithPattern } from './models/ModelWithPattern'; +export type { ModelWithProperties } from './models/ModelWithProperties'; +export type { ModelWithReference } from './models/ModelWithReference'; +export type { ModelWithString } from './models/ModelWithString'; +export type { MultilineComment } from './models/MultilineComment'; +export type { SimpleBoolean } from './models/SimpleBoolean'; +export type { SimpleFile } from './models/SimpleFile'; +export type { SimpleInteger } from './models/SimpleInteger'; +export type { SimpleReference } from './models/SimpleReference'; +export type { SimpleString } from './models/SimpleString'; +export type { SimpleStringWithPattern } from './models/SimpleStringWithPattern'; + +export { $ArrayWithArray } from './schemas/$ArrayWithArray'; +export { $ArrayWithBooleans } from './schemas/$ArrayWithBooleans'; +export { $ArrayWithNumbers } from './schemas/$ArrayWithNumbers'; +export { $ArrayWithProperties } from './schemas/$ArrayWithProperties'; +export { $ArrayWithReferences } from './schemas/$ArrayWithReferences'; +export { $ArrayWithStrings } from './schemas/$ArrayWithStrings'; +export { $CompositionWithAllOfAndNullable } from './schemas/$CompositionWithAllOfAndNullable'; +export { $CompositionWithAnyOf } from './schemas/$CompositionWithAnyOf'; +export { $CompositionWithAnyOfAndNullable } from './schemas/$CompositionWithAnyOfAndNullable'; +export { $CompositionWithAnyOfAnonymous } from './schemas/$CompositionWithAnyOfAnonymous'; +export { $CompositionWithOneOf } from './schemas/$CompositionWithOneOf'; +export { $CompositionWithOneOfAndNullable } from './schemas/$CompositionWithOneOfAndNullable'; +export { $CompositionWithOneOfAnonymous } from './schemas/$CompositionWithOneOfAnonymous'; +export { $DictionaryWithArray } from './schemas/$DictionaryWithArray'; +export { $DictionaryWithDictionary } from './schemas/$DictionaryWithDictionary'; +export { $DictionaryWithProperties } from './schemas/$DictionaryWithProperties'; +export { $DictionaryWithReference } from './schemas/$DictionaryWithReference'; +export { $DictionaryWithString } from './schemas/$DictionaryWithString'; +export { $EnumFromDescription } from './schemas/$EnumFromDescription'; +export { $EnumWithExtensions } from './schemas/$EnumWithExtensions'; +export { $EnumWithNumbers } from './schemas/$EnumWithNumbers'; +export { $EnumWithStrings } from './schemas/$EnumWithStrings'; +export { $ModelLink } from './schemas/$ModelLink'; +export { $ModelThatExtends } from './schemas/$ModelThatExtends'; +export { $ModelThatExtendsExtends } from './schemas/$ModelThatExtendsExtends'; +export { $ModelWithArray } from './schemas/$ModelWithArray'; +export { $ModelWithBoolean } from './schemas/$ModelWithBoolean'; +export { $ModelWithCircularReference } from './schemas/$ModelWithCircularReference'; +export { $ModelWithDictionary } from './schemas/$ModelWithDictionary'; +export { $ModelWithDuplicateImports } from './schemas/$ModelWithDuplicateImports'; +export { $ModelWithDuplicateProperties } from './schemas/$ModelWithDuplicateProperties'; +export { $ModelWithEnum } from './schemas/$ModelWithEnum'; +export { $ModelWithEnumFromDescription } from './schemas/$ModelWithEnumFromDescription'; +export { $ModelWithInteger } from './schemas/$ModelWithInteger'; +export { $ModelWithLink } from './schemas/$ModelWithLink'; +export { $ModelWithNestedEnums } from './schemas/$ModelWithNestedEnums'; +export { $ModelWithNestedProperties } from './schemas/$ModelWithNestedProperties'; +export { $ModelWithOrderedProperties } from './schemas/$ModelWithOrderedProperties'; +export { $ModelWithPattern } from './schemas/$ModelWithPattern'; +export { $ModelWithProperties } from './schemas/$ModelWithProperties'; +export { $ModelWithReference } from './schemas/$ModelWithReference'; +export { $ModelWithString } from './schemas/$ModelWithString'; +export { $MultilineComment } from './schemas/$MultilineComment'; +export { $SimpleBoolean } from './schemas/$SimpleBoolean'; +export { $SimpleFile } from './schemas/$SimpleFile'; +export { $SimpleInteger } from './schemas/$SimpleInteger'; +export { $SimpleReference } from './schemas/$SimpleReference'; +export { $SimpleString } from './schemas/$SimpleString'; +export { $SimpleStringWithPattern } from './schemas/$SimpleStringWithPattern'; + +export { ComplexService } from './services/ComplexService'; +export { DefaultsService } from './services/DefaultsService'; +export { DuplicateService } from './services/DuplicateService'; +export { HeaderService } from './services/HeaderService'; +export { MultipartService } from './services/MultipartService'; +export { ParametersService } from './services/ParametersService'; +export { 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[`v3 should generate: ./test/generated/v3/models/ArrayWithArray.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a simple array containing an array + */ +export type ArrayWithArray = Array>;" +`; + +exports[`v3 should generate: ./test/generated/v3/models/ArrayWithBooleans.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a simple array with booleans + */ +export type ArrayWithBooleans = Array;" +`; + +exports[`v3 should generate: ./test/generated/v3/models/ArrayWithNumbers.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a simple array with numbers + */ +export type ArrayWithNumbers = Array;" +`; + +exports[`v3 should generate: ./test/generated/v3/models/ArrayWithProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a simple array with properties + */ +export type ArrayWithProperties = Array<{ + foo?: string, + bar?: string, +}>;" +`; + +exports[`v3 should generate: ./test/generated/v3/models/ArrayWithReferences.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a simple array with references + */ +export type ArrayWithReferences = Array;" +`; + +exports[`v3 should generate: ./test/generated/v3/models/ArrayWithStrings.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a simple array with strings + */ +export type ArrayWithStrings = Array;" +`; + +exports[`v3 should generate: ./test/generated/v3/models/CompositionWithAllOfAndNullable.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithArray } from './ModelWithArray'; +import type { ModelWithDictionary } from './ModelWithDictionary'; +import type { ModelWithEnum } from './ModelWithEnum'; + +/** + * This is a model with one property with a 'all of' relationship + */ +export interface CompositionWithAllOfAndNullable { + propA?: ({ + boolean?: boolean, + } & ModelWithEnum & ModelWithArray & ModelWithDictionary) | null; +} +" +`; + +exports[`v3 should generate: ./test/generated/v3/models/CompositionWithAnyOf.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithArray } from './ModelWithArray'; +import type { ModelWithDictionary } from './ModelWithDictionary'; +import type { ModelWithEnum } from './ModelWithEnum'; +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model with one property with a 'any of' relationship + */ +export interface CompositionWithAnyOf { + propA?: (ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary); +} +" +`; + +exports[`v3 should generate: ./test/generated/v3/models/CompositionWithAnyOfAndNullable.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithArray } from './ModelWithArray'; +import type { ModelWithDictionary } from './ModelWithDictionary'; +import type { ModelWithEnum } from './ModelWithEnum'; + +/** + * This is a model with one property with a 'any of' relationship + */ +export interface CompositionWithAnyOfAndNullable { + propA?: ({ + boolean?: boolean, + } | ModelWithEnum | ModelWithArray | ModelWithDictionary) | null; +} +" +`; + +exports[`v3 should generate: ./test/generated/v3/models/CompositionWithAnyOfAnonymous.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export interface CompositionWithAnyOfAnonymous { + propA?: ({ + propA?: any, + } | string | number); +} +" +`; + +exports[`v3 should generate: ./test/generated/v3/models/CompositionWithOneOf.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithArray } from './ModelWithArray'; +import type { ModelWithDictionary } from './ModelWithDictionary'; +import type { ModelWithEnum } from './ModelWithEnum'; +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model with one property with a 'one of' relationship + */ +export interface CompositionWithOneOf { + propA?: (ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary); +} +" +`; + +exports[`v3 should generate: ./test/generated/v3/models/CompositionWithOneOfAndNullable.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithArray } from './ModelWithArray'; +import type { ModelWithDictionary } from './ModelWithDictionary'; +import type { ModelWithEnum } from './ModelWithEnum'; + +/** + * This is a model with one property with a 'one of' relationship + */ +export interface CompositionWithOneOfAndNullable { + propA?: ({ + boolean?: boolean, + } | ModelWithEnum | ModelWithArray | ModelWithDictionary) | null; +} +" +`; + +exports[`v3 should generate: ./test/generated/v3/models/CompositionWithOneOfAnonymous.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export interface CompositionWithOneOfAnonymous { + propA?: ({ + propA?: any, + } | string | number); +} +" +`; + +exports[`v3 should generate: ./test/generated/v3/models/DictionaryWithArray.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a complex dictionary + */ +export type DictionaryWithArray = Record>;" +`; + +exports[`v3 should generate: ./test/generated/v3/models/DictionaryWithDictionary.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a string dictionary + */ +export type DictionaryWithDictionary = Record>;" +`; + +exports[`v3 should generate: ./test/generated/v3/models/DictionaryWithProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a complex dictionary + */ +export type DictionaryWithProperties = Record;" +`; + +exports[`v3 should generate: ./test/generated/v3/models/DictionaryWithReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a string reference + */ +export type DictionaryWithReference = Record;" +`; + +exports[`v3 should generate: ./test/generated/v3/models/DictionaryWithString.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a string dictionary + */ +export type DictionaryWithString = Record;" +`; + +exports[`v3 should generate: ./test/generated/v3/models/EnumFromDescription.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * Success=1,Warning=2,Error=3 + */ +export enum EnumFromDescription { + SUCCESS = 1, + WARNING = 2, + ERROR = 3, +}" +`; + +exports[`v3 should generate: ./test/generated/v3/models/EnumWithExtensions.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a simple enum with numbers + */ +export enum EnumWithExtensions { + /** + * Used when the status of something is successful + */ + CUSTOM_SUCCESS = 200, + /** + * Used when the status of something has a warning + */ + CUSTOM_WARNING = 400, + /** + * Used when the status of something has an error + */ + CUSTOM_ERROR = 500, +}" +`; + +exports[`v3 should generate: ./test/generated/v3/models/EnumWithNumbers.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a simple enum with numbers + */ +export enum EnumWithNumbers { + _1 = 1, + _2 = 2, + _3 = 3, +}" +`; + +exports[`v3 should generate: ./test/generated/v3/models/EnumWithStrings.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a simple enum with strings + */ +export enum EnumWithStrings { + SUCCESS = 'Success', + WARNING = 'Warning', + ERROR = 'Error', +}" +`; + +exports[`v3 should generate: ./test/generated/v3/models/ModelLink.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model that can have a template?? + */ +export interface ModelLink { + id?: string; +} +" +`; + +exports[`v3 should generate: ./test/generated/v3/models/ModelThatExtends.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model that extends another model + */ +export type ModelThatExtends = (ModelWithString & { + propExtendsA?: string, + propExtendsB?: ModelWithString, +});" +`; + +exports[`v3 should generate: ./test/generated/v3/models/ModelThatExtendsExtends.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelThatExtends } from './ModelThatExtends'; +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model that extends another model + */ +export type ModelThatExtendsExtends = (ModelWithString & ModelThatExtends & { + propExtendsC?: string, + propExtendsD?: ModelWithString, +});" +`; + +exports[`v3 should generate: ./test/generated/v3/models/ModelWithArray.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model with one property containing an array + */ +export interface ModelWithArray { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +} +" +`; + +exports[`v3 should generate: ./test/generated/v3/models/ModelWithBoolean.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one boolean property + */ +export interface ModelWithBoolean { + /** + * This is a simple boolean property + */ + prop?: boolean; +} +" +`; + +exports[`v3 should generate: ./test/generated/v3/models/ModelWithCircularReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one property containing a circular reference + */ +export interface ModelWithCircularReference { + prop?: ModelWithCircularReference; +} +" +`; + +exports[`v3 should generate: ./test/generated/v3/models/ModelWithDictionary.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one property containing a dictionary + */ +export interface ModelWithDictionary { + prop?: Record; +} +" +`; + +exports[`v3 should generate: ./test/generated/v3/models/ModelWithDuplicateImports.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model with duplicated imports + */ +export interface ModelWithDuplicateImports { + propA?: ModelWithString; + propB?: ModelWithString; + propC?: ModelWithString; +} +" +`; + +exports[`v3 should generate: ./test/generated/v3/models/ModelWithDuplicateProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model with duplicated properties + */ +export interface ModelWithDuplicateProperties { + prop?: ModelWithString; +} +" +`; + +exports[`v3 should generate: ./test/generated/v3/models/ModelWithEnum.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one enum + */ +export interface ModelWithEnum { + /** + * This is a simple enum with strings + */ + test?: ModelWithEnum.test; + /** + * These are the HTTP error code enums + */ + statusCode?: ModelWithEnum.statusCode; +} + +export namespace ModelWithEnum { + + /** + * This is a simple enum with strings + */ + export enum test { + SUCCESS = 'Success', + WARNING = 'Warning', + ERROR = 'Error', + } + + /** + * These are the HTTP error code enums + */ + export enum statusCode { + _100 = '100', + _200_FOO = '200 FOO', + _300_FOO_BAR = '300 FOO_BAR', + _400_FOO_BAR = '400 foo-bar', + _500_FOO_BAR = '500 foo.bar', + _600_FOO_BAR = '600 foo&bar', + } + + +} +" +`; + +exports[`v3 should generate: ./test/generated/v3/models/ModelWithEnumFromDescription.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one enum + */ +export interface ModelWithEnumFromDescription { + /** + * Success=1,Warning=2,Error=3 + */ + test?: ModelWithEnumFromDescription.test; +} + +export namespace ModelWithEnumFromDescription { + + /** + * Success=1,Warning=2,Error=3 + */ + export enum test { + SUCCESS = 1, + WARNING = 2, + ERROR = 3, + } + + +} +" +`; + +exports[`v3 should generate: ./test/generated/v3/models/ModelWithInteger.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one number property + */ +export interface ModelWithInteger { + /** + * This is a simple number property + */ + prop?: number; +} +" +`; + +exports[`v3 should generate: ./test/generated/v3/models/ModelWithLink.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelLink } from './ModelLink'; +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model that can have a template?? + */ +export interface ModelWithLink { + prop?: ModelLink; +} +" +`; + +exports[`v3 should generate: ./test/generated/v3/models/ModelWithNestedEnums.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with nested enums + */ +export interface ModelWithNestedEnums { + dictionaryWithEnum?: Record; + dictionaryWithEnumFromDescription?: Record; + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; + arrayWithDescription?: Array<1 | 2 | 3>; +} +" +`; + +exports[`v3 should generate: ./test/generated/v3/models/ModelWithNestedProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one nested property + */ +export interface ModelWithNestedProperties { + readonly first: { + readonly second: { + readonly third: string | null, + } | null, + } | null; +} +" +`; + +exports[`v3 should generate: ./test/generated/v3/models/ModelWithOrderedProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with ordered properties + */ +export interface ModelWithOrderedProperties { + zebra?: string; + apple?: string; + hawaii?: string; +} +" +`; + +exports[`v3 should generate: ./test/generated/v3/models/ModelWithPattern.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model that contains a some patterns + */ +export interface ModelWithPattern { + key: string; + name: string; + readonly enabled?: boolean; + readonly modified?: string; + id?: string; + text?: string; +} +" +`; + +exports[`v3 should generate: ./test/generated/v3/models/ModelWithProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model with one nested property + */ +export interface ModelWithProperties { + required: string; + readonly requiredAndReadOnly: string; + requiredAndNullable: string | null; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + readonly '@namespace.string'?: string; + readonly '@namespace.integer'?: number; +} +" +`; + +exports[`v3 should generate: ./test/generated/v3/models/ModelWithReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithProperties } from './ModelWithProperties'; + +/** + * This is a model with one property containing a reference + */ +export interface ModelWithReference { + prop?: ModelWithProperties; +} +" +`; + +exports[`v3 should generate: ./test/generated/v3/models/ModelWithString.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a model with one string property + */ +export interface ModelWithString { + /** + * This is a simple string property + */ + prop?: string; +} +" +`; + +exports[`v3 should generate: ./test/generated/v3/models/MultilineComment.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * Testing multiline comments. + * This must go to the next line. + * + * This will contain a break. + */ +export type MultilineComment = number;" +`; + +exports[`v3 should generate: ./test/generated/v3/models/SimpleBoolean.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a simple boolean + */ +export type SimpleBoolean = boolean;" +`; + +exports[`v3 should generate: ./test/generated/v3/models/SimpleFile.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a simple file + */ +export type SimpleFile = Blob;" +`; + +exports[`v3 should generate: ./test/generated/v3/models/SimpleInteger.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a simple number + */ +export type SimpleInteger = number;" +`; + +exports[`v3 should generate: ./test/generated/v3/models/SimpleReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a simple reference + */ +export type SimpleReference = ModelWithString;" +`; + +exports[`v3 should generate: ./test/generated/v3/models/SimpleString.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a simple string + */ +export type SimpleString = string;" +`; + +exports[`v3 should generate: ./test/generated/v3/models/SimpleStringWithPattern.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * This is a simple string + */ +export type SimpleStringWithPattern = string | null;" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$ArrayWithArray.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ArrayWithArray = { + type: 'array', + contains: { + type: 'array', + contains: { + type: 'ModelWithString', + }, + }, +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$ArrayWithBooleans.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ArrayWithBooleans = { + type: 'array', + contains: { + type: 'boolean', + }, +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$ArrayWithNumbers.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ArrayWithNumbers = { + type: 'array', + contains: { + type: 'number', + }, +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$ArrayWithProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ArrayWithProperties = { + type: 'array', + contains: { + properties: { + foo: { + type: 'string', + }, + bar: { + type: 'string', + }, + }, + }, +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$ArrayWithReferences.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ArrayWithReferences = { + type: 'array', + contains: { + type: 'ModelWithString', + }, +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$ArrayWithStrings.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ArrayWithStrings = { + type: 'array', + contains: { + type: 'string', + }, +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$CompositionWithAllOfAndNullable.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $CompositionWithAllOfAndNullable = { + properties: { + propA: { + type: 'all-of', + contains: [{ + properties: { + boolean: { + type: 'boolean', + }, + }, + }, { + type: 'ModelWithEnum', + }, { + type: 'ModelWithArray', + }, { + type: 'ModelWithDictionary', + }, ] + isNullable: true, + }, + }, +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$CompositionWithAnyOf.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $CompositionWithAnyOf = { + properties: { + propA: { + type: 'any-of', + contains: [{ + type: 'ModelWithString', + }, { + type: 'ModelWithEnum', + }, { + type: 'ModelWithArray', + }, { + type: 'ModelWithDictionary', + }, ] + }, + }, +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$CompositionWithAnyOfAndNullable.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $CompositionWithAnyOfAndNullable = { + properties: { + propA: { + type: 'any-of', + contains: [{ + properties: { + boolean: { + type: 'boolean', + }, + }, + }, { + type: 'ModelWithEnum', + }, { + type: 'ModelWithArray', + }, { + type: 'ModelWithDictionary', + }, ] + isNullable: true, + }, + }, +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$CompositionWithAnyOfAnonymous.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $CompositionWithAnyOfAnonymous = { + properties: { + propA: { + type: 'any-of', + contains: [{ + properties: { + propA: { + properties: { + }, + }, + }, + }, { + type: 'string', + }, { + type: 'number', + }, ] + }, + }, +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$CompositionWithOneOf.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $CompositionWithOneOf = { + properties: { + propA: { + type: 'one-of', + contains: [{ + type: 'ModelWithString', + }, { + type: 'ModelWithEnum', + }, { + type: 'ModelWithArray', + }, { + type: 'ModelWithDictionary', + }, ] + }, + }, +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$CompositionWithOneOfAndNullable.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $CompositionWithOneOfAndNullable = { + properties: { + propA: { + type: 'one-of', + contains: [{ + properties: { + boolean: { + type: 'boolean', + }, + }, + }, { + type: 'ModelWithEnum', + }, { + type: 'ModelWithArray', + }, { + type: 'ModelWithDictionary', + }, ] + isNullable: true, + }, + }, +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$CompositionWithOneOfAnonymous.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $CompositionWithOneOfAnonymous = { + properties: { + propA: { + type: 'one-of', + contains: [{ + properties: { + propA: { + properties: { + }, + }, + }, + }, { + type: 'string', + }, { + type: 'number', + }, ] + }, + }, +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$DictionaryWithArray.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $DictionaryWithArray = { + type: 'dictionary', + contains: { + type: 'array', + contains: { + type: 'ModelWithString', + }, + }, +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$DictionaryWithDictionary.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $DictionaryWithDictionary = { + type: 'dictionary', + contains: { + type: 'dictionary', + contains: { + type: 'string', + }, + }, +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$DictionaryWithProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $DictionaryWithProperties = { + type: 'dictionary', + contains: { + properties: { + foo: { + type: 'string', + }, + bar: { + type: 'string', + }, + }, + }, +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$DictionaryWithReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $DictionaryWithReference = { + type: 'dictionary', + contains: { + type: 'ModelWithString', + }, +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$DictionaryWithString.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $DictionaryWithString = { + type: 'dictionary', + contains: { + type: 'string', + }, +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$EnumFromDescription.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $EnumFromDescription = { + type: 'Enum', +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$EnumWithExtensions.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $EnumWithExtensions = { + type: 'Enum', +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$EnumWithNumbers.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $EnumWithNumbers = { + type: 'Enum', +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$EnumWithStrings.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $EnumWithStrings = { + type: 'Enum', +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$ModelLink.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelLink = { + properties: { + id: { + type: 'string', + }, + }, +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$ModelThatExtends.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelThatExtends = { + type: 'all-of', + contains: [{ + type: 'ModelWithString', + }, { + properties: { + propExtendsA: { + type: 'string', + }, + propExtendsB: { + type: 'ModelWithString', + }, + }, + }, ] +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$ModelThatExtendsExtends.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelThatExtendsExtends = { + type: 'all-of', + contains: [{ + type: 'ModelWithString', + }, { + type: 'ModelThatExtends', + }, { + properties: { + propExtendsC: { + type: 'string', + }, + propExtendsD: { + type: 'ModelWithString', + }, + }, + }, ] +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithArray.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithArray = { + properties: { + prop: { + type: 'array', + contains: { + type: 'ModelWithString', + }, + }, + propWithFile: { + type: 'array', + contains: { + type: 'File', + }, + }, + propWithNumber: { + type: 'array', + contains: { + type: 'number', + }, + }, + }, +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithBoolean.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithBoolean = { + properties: { + prop: { + type: 'boolean', + }, + }, +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithCircularReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithCircularReference = { + properties: { + prop: { + type: 'ModelWithCircularReference', + }, + }, +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithDictionary.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithDictionary = { + properties: { + prop: { + type: 'dictionary', + contains: { + type: 'string', + }, + }, + }, +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithDuplicateImports.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithDuplicateImports = { + properties: { + propA: { + type: 'ModelWithString', + }, + propB: { + type: 'ModelWithString', + }, + propC: { + type: 'ModelWithString', + }, + }, +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithDuplicateProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithDuplicateProperties = { + properties: { + prop: { + type: 'ModelWithString', + }, + }, +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithEnum.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithEnum = { + properties: { + test: { + type: 'Enum', + }, + statusCode: { + type: 'Enum', + }, + }, +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithEnumFromDescription.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithEnumFromDescription = { + properties: { + test: { + type: 'Enum', + }, + }, +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithInteger.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithInteger = { + properties: { + prop: { + type: 'number', + }, + }, +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithLink.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithLink = { + properties: { + prop: { + type: 'ModelLink', + }, + }, +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithNestedEnums.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithNestedEnums = { + properties: { + dictionaryWithEnum: { + type: 'dictionary', + contains: { + type: 'Enum', + }, + }, + dictionaryWithEnumFromDescription: { + type: 'dictionary', + contains: { + type: 'Enum', + }, + }, + arrayWithEnum: { + type: 'array', + contains: { + type: 'Enum', + }, + }, + arrayWithDescription: { + type: 'array', + contains: { + type: 'Enum', + }, + }, + }, +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithNestedProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithNestedProperties = { + properties: { + first: { + properties: { + second: { + properties: { + third: { + type: 'string', + isReadOnly: true, + isRequired: true, + isNullable: true, + }, + }, + isReadOnly: true, + isRequired: true, + isNullable: true, + }, + }, + isReadOnly: true, + isRequired: true, + isNullable: true, + }, + }, +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithOrderedProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithOrderedProperties = { + properties: { + zebra: { + type: 'string', + }, + apple: { + type: 'string', + }, + hawaii: { + type: 'string', + }, + }, +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithPattern.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithPattern = { + properties: { + key: { + type: 'string', + isRequired: true, + maxLength: 64, + pattern: '^[a-zA-Z0-9_]*$', + }, + name: { + type: 'string', + isRequired: true, + maxLength: 255, + }, + enabled: { + type: 'boolean', + isReadOnly: true, + }, + modified: { + type: 'string', + isReadOnly: true, + format: 'date-time', + }, + id: { + type: 'string', + pattern: '^\\\\\\\\d{2}-\\\\\\\\d{3}-\\\\\\\\d{4}$', + }, + text: { + type: 'string', + pattern: '^\\\\\\\\w+$', + }, + }, +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithProperties.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithProperties = { + properties: { + required: { + type: 'string', + isRequired: true, + }, + requiredAndReadOnly: { + type: 'string', + isReadOnly: true, + isRequired: true, + }, + requiredAndNullable: { + type: 'string', + isRequired: true, + isNullable: true, + }, + string: { + type: 'string', + }, + number: { + type: 'number', + }, + boolean: { + type: 'boolean', + }, + reference: { + type: 'ModelWithString', + }, + '@namespace.string': { + type: 'string', + isReadOnly: true, + }, + '@namespace.integer': { + type: 'number', + isReadOnly: true, + }, + }, +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithReference = { + properties: { + prop: { + type: 'ModelWithProperties', + }, + }, +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithString.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $ModelWithString = { + properties: { + prop: { + type: 'string', + }, + }, +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$MultilineComment.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $MultilineComment = { + type: 'number', +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$SimpleBoolean.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $SimpleBoolean = { + type: 'boolean', +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$SimpleFile.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $SimpleFile = { + type: 'File', +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$SimpleInteger.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $SimpleInteger = { + type: 'number', +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$SimpleReference.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $SimpleReference = { + type: 'ModelWithString', +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$SimpleString.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $SimpleString = { + type: 'string', +};" +`; + +exports[`v3 should generate: ./test/generated/v3/schemas/$SimpleStringWithPattern.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export const $SimpleStringWithPattern = { + type: 'string', + isNullable: true, + maxLength: 64, + pattern: '^[a-zA-Z0-9_]*$', +};" +`; + +exports[`v3 should generate: ./test/generated/v3/services/ComplexService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ModelWithArray } from '../models/ModelWithArray'; +import type { ModelWithDictionary } from '../models/ModelWithDictionary'; +import type { ModelWithEnum } from '../models/ModelWithEnum'; +import type { ModelWithString } from '../models/ModelWithString'; +import { request as __request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class ComplexService { + + /** + * @param parameterObject Parameter containing object + * @param parameterReference Parameter containing reference + * @result ModelWithString Successful response + * @throws ApiError + */ + public static async complexTypes( + parameterObject: { + first?: { + second?: { + third?: string, + }, + }, + }, + parameterReference: ModelWithString, + ): Promise> { + const result = await __request({ + method: 'GET', + path: \`/api/v\${OpenAPI.VERSION}/complex\`, + query: { + 'parameterObject': parameterObject, + 'parameterReference': parameterReference, + }, + errors: { + 400: \`400 server error\`, + 500: \`500 server error\`, + }, + }); + return result.body; + } + + /** + * @param id + * @param requestBody + * @result ModelWithString Success + * @throws ApiError + */ + public static async complexParams( + id: number, + requestBody?: { + readonly key: string | null, + name: string | null, + enabled?: boolean, + readonly type: 'Monkey' | 'Horse' | 'Bird', + listOfModels?: Array | null, + listOfStrings?: Array | null, + parameters: (ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary), + readonly user?: { + readonly id?: number, + readonly name?: string | null, + }, + }, + ): Promise { + const result = await __request({ + method: 'PUT', + path: \`/api/v\${OpenAPI.VERSION}/complex/\${id}\`, + body: requestBody, + }); + return result.body; + } + +}" +`; + +exports[`v3 should generate: ./test/generated/v3/services/DefaultsService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ModelWithString } from '../models/ModelWithString'; +import { request as __request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class DefaultsService { + + /** + * @param parameterString This is a simple string with default value + * @param parameterNumber This is a simple number with default value + * @param parameterBoolean This is a simple boolean with default value + * @param parameterEnum This is a simple enum with default value + * @param parameterModel This is a simple model with default value + * @throws ApiError + */ + public static async callWithDefaultParameters( + parameterString: string | null = 'Hello World!', + parameterNumber: number | null = 123, + parameterBoolean: boolean | null = true, + parameterEnum: 'Success' | 'Warning' | 'Error' = 'Success', + parameterModel: ModelWithString | null = { + \\"prop\\": \\"Hello World!\\" + }, + ): Promise { + const result = await __request({ + method: 'GET', + path: \`/api/v\${OpenAPI.VERSION}/defaults\`, + query: { + 'parameterString': parameterString, + 'parameterNumber': parameterNumber, + 'parameterBoolean': parameterBoolean, + 'parameterEnum': parameterEnum, + 'parameterModel': parameterModel, + }, + }); + return result.body; + } + + /** + * @param parameterString This is a simple string that is optional with default value + * @param parameterNumber This is a simple number that is optional with default value + * @param parameterBoolean This is a simple boolean that is optional with default value + * @param parameterEnum This is a simple enum that is optional with default value + * @param parameterModel This is a simple model that is optional with default value + * @throws ApiError + */ + public static async callWithDefaultOptionalParameters( + parameterString: string = 'Hello World!', + parameterNumber: number = 123, + parameterBoolean: boolean = true, + parameterEnum: 'Success' | 'Warning' | 'Error' = 'Success', + parameterModel: ModelWithString = { + \\"prop\\": \\"Hello World!\\" + }, + ): Promise { + const result = await __request({ + method: 'POST', + path: \`/api/v\${OpenAPI.VERSION}/defaults\`, + query: { + 'parameterString': parameterString, + 'parameterNumber': parameterNumber, + 'parameterBoolean': parameterBoolean, + 'parameterEnum': parameterEnum, + 'parameterModel': parameterModel, + }, + }); + return result.body; + } + + /** + * @param parameterStringWithNoDefault This is a string with no default + * @param parameterOptionalStringWithDefault This is a optional string with default + * @param parameterOptionalStringWithEmptyDefault This is a optional string with empty default + * @param parameterOptionalStringWithNoDefault This is a optional string with no default + * @param parameterStringWithDefault This is a string with default + * @param parameterStringWithEmptyDefault This is a string with empty default + * @throws ApiError + */ + public static async callToTestOrderOfParams( + parameterStringWithNoDefault: string, + parameterOptionalStringWithDefault: string = 'Hello World!', + parameterOptionalStringWithEmptyDefault: string = '', + parameterOptionalStringWithNoDefault?: string, + parameterStringWithDefault: string = 'Hello World!', + parameterStringWithEmptyDefault: string = '', + ): Promise { + const result = await __request({ + method: 'PUT', + path: \`/api/v\${OpenAPI.VERSION}/defaults\`, + query: { + 'parameterStringWithNoDefault': parameterStringWithNoDefault, + 'parameterOptionalStringWithDefault': parameterOptionalStringWithDefault, + 'parameterOptionalStringWithEmptyDefault': parameterOptionalStringWithEmptyDefault, + 'parameterOptionalStringWithNoDefault': parameterOptionalStringWithNoDefault, + 'parameterStringWithDefault': parameterStringWithDefault, + 'parameterStringWithEmptyDefault': parameterStringWithEmptyDefault, + }, + }); + return result.body; + } + +}" +`; + +exports[`v3 should generate: ./test/generated/v3/services/DuplicateService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import { request as __request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class DuplicateService { + + /** + * @throws ApiError + */ + public static async duplicateName(): Promise { + const result = await __request({ + method: 'GET', + path: \`/api/v\${OpenAPI.VERSION}/duplicate\`, + }); + return result.body; + } + + /** + * @throws ApiError + */ + public static async duplicateName1(): Promise { + const result = await __request({ + method: 'POST', + path: \`/api/v\${OpenAPI.VERSION}/duplicate\`, + }); + return result.body; + } + + /** + * @throws ApiError + */ + public static async duplicateName2(): Promise { + const result = await __request({ + method: 'PUT', + path: \`/api/v\${OpenAPI.VERSION}/duplicate\`, + }); + return result.body; + } + + /** + * @throws ApiError + */ + public static async duplicateName3(): Promise { + const result = await __request({ + method: 'DELETE', + path: \`/api/v\${OpenAPI.VERSION}/duplicate\`, + }); + return result.body; + } + +}" +`; + +exports[`v3 should generate: ./test/generated/v3/services/HeaderService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import { request as __request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class HeaderService { + + /** + * @result string Successful response + * @throws ApiError + */ + public static async callWithResultFromHeader(): Promise { + const result = await __request({ + method: 'POST', + path: \`/api/v\${OpenAPI.VERSION}/header\`, + responseHeader: 'operation-location', + errors: { + 400: \`400 server error\`, + 500: \`500 server error\`, + }, + }); + return result.body; + } + +}" +`; + +exports[`v3 should generate: ./test/generated/v3/services/MultipartService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import { request as __request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class MultipartService { + + /** + * @result any OK + * @throws ApiError + */ + public static async multipartResponse(): Promise<{ + file?: string, + metadata?: { + foo?: string, + bar?: string, + }, + }> { + const result = await __request({ + method: 'GET', + path: \`/api/v\${OpenAPI.VERSION}/multipart\`, + }); + return result.body; + } + +}" +`; + +exports[`v3 should generate: ./test/generated/v3/services/ParametersService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ModelWithString } from '../models/ModelWithString'; +import { request as __request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class ParametersService { + + /** + * @param parameterHeader This is the parameter that goes into the header + * @param parameterQuery This is the parameter that goes into the query params + * @param parameterForm This is the parameter that goes into the form data + * @param parameterCookie This is the parameter that goes into the cookie + * @param parameterPath This is the parameter that goes into the path + * @param requestBody This is the parameter that goes into the body + * @throws ApiError + */ + public static async callWithParameters( + parameterHeader: string | null, + parameterQuery: string | null, + parameterForm: string | null, + parameterCookie: string | null, + parameterPath: string | null, + requestBody: ModelWithString | null, + ): Promise { + const result = await __request({ + method: 'GET', + path: \`/api/v\${OpenAPI.VERSION}/parameters/\${parameterPath}\`, + cookies: { + 'parameterCookie': parameterCookie, + }, + headers: { + 'parameterHeader': parameterHeader, + }, + query: { + 'parameterQuery': parameterQuery, + }, + formData: { + 'parameterForm': parameterForm, + }, + body: requestBody, + }); + return result.body; + } + + /** + * @param parameterHeader This is the parameter that goes into the request header + * @param parameterQuery This is the parameter that goes into the request query params + * @param parameterForm This is the parameter that goes into the request form data + * @param parameterCookie This is the parameter that goes into the cookie + * @param requestBody This is the parameter that goes into the body + * @param parameterPath1 This is the parameter that goes into the path + * @param parameterPath2 This is the parameter that goes into the path + * @param parameterPath3 This is the parameter that goes into the path + * @throws ApiError + */ + public static async callWithWeirdParameterNames( + parameterHeader: string | null, + parameterQuery: string | null, + parameterForm: string | null, + parameterCookie: string | null, + requestBody: ModelWithString | null, + parameterPath1?: string, + parameterPath2?: string, + parameterPath3?: string, + ): Promise { + const result = await __request({ + method: 'GET', + path: \`/api/v\${OpenAPI.VERSION}/parameters/\${parameterPath1}/\${parameterPath2}/\${parameterPath3}\`, + cookies: { + 'PARAMETER-COOKIE': parameterCookie, + }, + headers: { + 'parameter.header': parameterHeader, + }, + query: { + 'parameter-query': parameterQuery, + }, + formData: { + 'parameter_form': parameterForm, + }, + body: requestBody, + }); + return result.body; + } + + /** + * @param requestBody This is a required parameter + * @param parameter This is an optional parameter + * @throws ApiError + */ + public static async getCallWithOptionalParam( + requestBody: ModelWithString, + parameter?: string, + ): Promise { + const result = await __request({ + method: 'GET', + path: \`/api/v\${OpenAPI.VERSION}/parameters/\`, + query: { + 'parameter': parameter, + }, + body: requestBody, + }); + return result.body; + } + + /** + * @param parameter This is a required parameter + * @param requestBody This is an optional parameter + * @throws ApiError + */ + public static async postCallWithOptionalParam( + parameter: string, + requestBody?: ModelWithString, + ): Promise { + const result = await __request({ + method: 'POST', + path: \`/api/v\${OpenAPI.VERSION}/parameters/\`, + query: { + 'parameter': parameter, + }, + body: requestBody, + }); + return result.body; + } + +}" +`; + +exports[`v3 should generate: ./test/generated/v3/services/RequestBodyService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ModelWithString } from '../models/ModelWithString'; +import { request as __request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class RequestBodyService { + + /** + * @param requestBody A reusable request body + * @throws ApiError + */ + public static async postRequestBodyService( + requestBody?: ModelWithString, + ): Promise { + const result = await __request({ + method: 'POST', + path: \`/api/v\${OpenAPI.VERSION}/requestBody/\`, + body: requestBody, + }); + return result.body; + } + +}" +`; + +exports[`v3 should generate: ./test/generated/v3/services/ResponseService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ModelThatExtends } from '../models/ModelThatExtends'; +import type { ModelThatExtendsExtends } from '../models/ModelThatExtendsExtends'; +import type { ModelWithString } from '../models/ModelWithString'; +import { request as __request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class ResponseService { + + /** + * @result ModelWithString + * @throws ApiError + */ + public static async callWithResponse(): Promise { + const result = await __request({ + method: 'GET', + path: \`/api/v\${OpenAPI.VERSION}/response\`, + }); + return result.body; + } + + /** + * @result ModelWithString Message for default response + * @throws ApiError + */ + public static async callWithDuplicateResponses(): Promise { + const result = await __request({ + method: 'POST', + path: \`/api/v\${OpenAPI.VERSION}/response\`, + errors: { + 500: \`Message for 500 error\`, + 501: \`Message for 501 error\`, + 502: \`Message for 502 error\`, + }, + }); + return result.body; + } + + /** + * @result any Message for 200 response + * @result ModelWithString Message for default response + * @result ModelThatExtends Message for 201 response + * @result ModelThatExtendsExtends Message for 202 response + * @throws ApiError + */ + public static async callWithResponses(): Promise<{ + readonly '@namespace.string'?: string, + readonly '@namespace.integer'?: number, + readonly value?: Array, + } | ModelWithString | ModelThatExtends | ModelThatExtendsExtends> { + const result = await __request({ + method: 'PUT', + path: \`/api/v\${OpenAPI.VERSION}/response\`, + errors: { + 500: \`Message for 500 error\`, + 501: \`Message for 501 error\`, + 502: \`Message for 502 error\`, + }, + }); + return result.body; + } + +}" +`; + +exports[`v3 should generate: ./test/generated/v3/services/SimpleService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import { request as __request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class SimpleService { + + /** + * @throws ApiError + */ + public static async getCallWithoutParametersAndResponse(): Promise { + const result = await __request({ + method: 'GET', + path: \`/api/v\${OpenAPI.VERSION}/simple\`, + }); + return result.body; + } + + /** + * @throws ApiError + */ + public static async putCallWithoutParametersAndResponse(): Promise { + const result = await __request({ + method: 'PUT', + path: \`/api/v\${OpenAPI.VERSION}/simple\`, + }); + return result.body; + } + + /** + * @throws ApiError + */ + public static async postCallWithoutParametersAndResponse(): Promise { + const result = await __request({ + method: 'POST', + path: \`/api/v\${OpenAPI.VERSION}/simple\`, + }); + return result.body; + } + + /** + * @throws ApiError + */ + public static async deleteCallWithoutParametersAndResponse(): Promise { + const result = await __request({ + method: 'DELETE', + path: \`/api/v\${OpenAPI.VERSION}/simple\`, + }); + return result.body; + } + + /** + * @throws ApiError + */ + public static async optionsCallWithoutParametersAndResponse(): Promise { + const result = await __request({ + method: 'OPTIONS', + path: \`/api/v\${OpenAPI.VERSION}/simple\`, + }); + return result.body; + } + + /** + * @throws ApiError + */ + public static async headCallWithoutParametersAndResponse(): Promise { + const result = await __request({ + method: 'HEAD', + path: \`/api/v\${OpenAPI.VERSION}/simple\`, + }); + return result.body; + } + + /** + * @throws ApiError + */ + public static async patchCallWithoutParametersAndResponse(): Promise { + const result = await __request({ + method: 'PATCH', + path: \`/api/v\${OpenAPI.VERSION}/simple\`, + }); + return result.body; + } + +}" +`; + +exports[`v3 should generate: ./test/generated/v3/services/TypesService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import { request as __request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class TypesService { + + /** + * @param parameterArray This is an array parameter + * @param parameterDictionary This is a dictionary parameter + * @param parameterEnum This is an enum parameter + * @param parameterNumber This is a number parameter + * @param parameterString This is a string parameter + * @param parameterBoolean This is a boolean parameter + * @param parameterObject This is an object parameter + * @param id This is a number parameter + * @result number Response is a simple number + * @result string Response is a simple string + * @result boolean Response is a simple boolean + * @result any Response is a simple object + * @throws ApiError + */ + public static async types( + parameterArray: Array | null, + parameterDictionary: any, + parameterEnum: 'Success' | 'Warning' | 'Error' | null, + parameterNumber: number = 123, + parameterString: string | null = 'default', + parameterBoolean: boolean | null = true, + parameterObject: any = null, + id?: number, + ): Promise { + const result = await __request({ + method: 'GET', + path: \`/api/v\${OpenAPI.VERSION}/types\`, + query: { + 'parameterArray': parameterArray, + 'parameterDictionary': parameterDictionary, + 'parameterEnum': parameterEnum, + 'parameterNumber': parameterNumber, + 'parameterString': parameterString, + 'parameterBoolean': parameterBoolean, + 'parameterObject': parameterObject, + }, + }); + return result.body; + } + +}" +`; + +exports[`v3 should generate: ./test/generated/v3/services/UploadService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import { request as __request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class UploadService { + + /** + * @param file Supply a file reference for upload + * @result boolean + * @throws ApiError + */ + public static async uploadFile( + file: Blob, + ): Promise { + const result = await __request({ + method: 'POST', + path: \`/api/v\${OpenAPI.VERSION}/upload\`, + formData: { + 'file': file, + }, + }); + return result.body; + } + +}" +`;