fork of hey-api/openapi-ts because I need some additional things

Merge pull request #973 from jacobinu/fix/angular-tree-shakeable

authored by

Lubos and committed by
GitHub
26f2b68f 7e849607

+3176 -2
+5
.changeset/ninety-windows-accept.md
··· 1 + --- 2 + '@hey-api/openapi-ts': patch 3 + --- 4 + 5 + fix: handle tree-shakeable angular client case
+1
packages/openapi-ts/src/compiler/index.ts
··· 168 168 } 169 169 170 170 export const compiler = { 171 + anonymousFunction: types.createAnonymousFunction, 171 172 arrayLiteralExpression: types.createArrayLiteralExpression, 172 173 arrowFunction: types.createArrowFunction, 173 174 awaitExpression: types.createAwaitExpression,
+38
packages/openapi-ts/src/compiler/types.ts
··· 299 299 }; 300 300 301 301 /** 302 + * Create anonymous function type expression. 303 + */ 304 + export const createAnonymousFunction = ({ 305 + async, 306 + comment, 307 + multiLine, 308 + parameters = [], 309 + returnType, 310 + statements = [], 311 + types = [], 312 + }: { 313 + async?: boolean; 314 + comment?: Comments; 315 + multiLine?: boolean; 316 + parameters?: FunctionParameter[]; 317 + returnType?: string | ts.TypeNode; 318 + statements?: ts.Statement[]; 319 + types?: FunctionTypeParameter[]; 320 + }) => { 321 + const expression = ts.factory.createFunctionExpression( 322 + async ? [ts.factory.createModifier(ts.SyntaxKind.AsyncKeyword)] : undefined, 323 + undefined, 324 + undefined, 325 + types ? toTypeParameters(types) : undefined, 326 + toParameterDeclarations(parameters), 327 + returnType ? createTypeNode(returnType) : undefined, 328 + ts.factory.createBlock(statements, multiLine), 329 + ); 330 + 331 + addLeadingComments({ 332 + comments: comment, 333 + node: expression, 334 + }); 335 + 336 + return expression; 337 + }; 338 + 339 + /** 302 340 * Create Array type expression. 303 341 * @param arr - The array to create. 304 342 * @param multiLine - if the array should be multiline.
+6 -2
packages/openapi-ts/src/generate/services.ts
··· 610 610 611 611 if (!config.services.asClass && !config.name) { 612 612 for (const operation of service.operations) { 613 - const expression = compiler.arrowFunction({ 613 + const compileFunctionParams = { 614 614 parameters: toOperationParamType(client, operation), 615 615 returnType: isStandalone 616 616 ? undefined ··· 622 622 onClientImport, 623 623 ), 624 624 types: isStandalone ? [throwOnErrorTypeGeneric] : undefined, 625 - }); 625 + }; 626 + const expression = 627 + config.client.name === 'angular' 628 + ? compiler.anonymousFunction(compileFunctionParams) 629 + : compiler.arrowFunction(compileFunctionParams); 626 630 const statement = compiler.constVariable({ 627 631 comment: toOperationComment(operation), 628 632 exportConst: true,
+21
packages/openapi-ts/test/__snapshots__/test/generated/v3_angular_tree_shakeable/core/ApiError.ts.snap
··· 1 + import type { ApiRequestOptions } from './ApiRequestOptions'; 2 + import type { ApiResult } from './ApiResult'; 3 + 4 + export class ApiError extends Error { 5 + public readonly url: string; 6 + public readonly status: number; 7 + public readonly statusText: string; 8 + public readonly body: unknown; 9 + public readonly request: ApiRequestOptions; 10 + 11 + constructor(request: ApiRequestOptions, response: ApiResult, message: string) { 12 + super(message); 13 + 14 + this.name = 'ApiError'; 15 + this.url = response.url; 16 + this.status = response.status; 17 + this.statusText = response.statusText; 18 + this.body = response.body; 19 + this.request = request; 20 + } 21 + }
+21
packages/openapi-ts/test/__snapshots__/test/generated/v3_angular_tree_shakeable/core/ApiRequestOptions.ts.snap
··· 1 + export type ApiRequestOptions<T = unknown> = { 2 + readonly body?: any; 3 + readonly cookies?: Record<string, unknown>; 4 + readonly errors?: Record<number | string, string>; 5 + readonly formData?: Record<string, unknown> | any[] | Blob | File; 6 + readonly headers?: Record<string, unknown>; 7 + readonly mediaType?: string; 8 + readonly method: 9 + | 'DELETE' 10 + | 'GET' 11 + | 'HEAD' 12 + | 'OPTIONS' 13 + | 'PATCH' 14 + | 'POST' 15 + | 'PUT'; 16 + readonly path?: Record<string, unknown>; 17 + readonly query?: Record<string, unknown>; 18 + readonly responseHeader?: string; 19 + readonly responseTransformer?: (data: unknown) => Promise<T>; 20 + readonly url: string; 21 + };
+7
packages/openapi-ts/test/__snapshots__/test/generated/v3_angular_tree_shakeable/core/ApiResult.ts.snap
··· 1 + export type ApiResult<TData = any> = { 2 + readonly body: TData; 3 + readonly ok: boolean; 4 + readonly status: number; 5 + readonly statusText: string; 6 + readonly url: string; 7 + };
+55
packages/openapi-ts/test/__snapshots__/test/generated/v3_angular_tree_shakeable/core/OpenAPI.ts.snap
··· 1 + import type { HttpResponse } from '@angular/common/http'; 2 + import type { ApiRequestOptions } from './ApiRequestOptions'; 3 + 4 + type Headers = Record<string, string>; 5 + type Middleware<T> = (value: T) => T | Promise<T>; 6 + type Resolver<T> = (options: ApiRequestOptions<T>) => Promise<T>; 7 + 8 + export class Interceptors<T> { 9 + _fns: Middleware<T>[]; 10 + 11 + constructor() { 12 + this._fns = []; 13 + } 14 + 15 + eject(fn: Middleware<T>): void { 16 + const index = this._fns.indexOf(fn); 17 + if (index !== -1) { 18 + this._fns = [...this._fns.slice(0, index), ...this._fns.slice(index + 1)]; 19 + } 20 + } 21 + 22 + use(fn: Middleware<T>): void { 23 + this._fns = [...this._fns, fn]; 24 + } 25 + } 26 + 27 + export type OpenAPIConfig = { 28 + BASE: string; 29 + CREDENTIALS: 'include' | 'omit' | 'same-origin'; 30 + ENCODE_PATH?: ((path: string) => string) | undefined; 31 + HEADERS?: Headers | Resolver<Headers> | undefined; 32 + PASSWORD?: string | Resolver<string> | undefined; 33 + TOKEN?: string | Resolver<string> | undefined; 34 + USERNAME?: string | Resolver<string> | undefined; 35 + VERSION: string; 36 + WITH_CREDENTIALS: boolean; 37 + interceptors: { 38 + response: Interceptors<HttpResponse<any>>; 39 + }; 40 + }; 41 + 42 + export const OpenAPI: OpenAPIConfig = { 43 + BASE: 'http://localhost:3000/base', 44 + CREDENTIALS: 'include', 45 + ENCODE_PATH: undefined, 46 + HEADERS: undefined, 47 + PASSWORD: undefined, 48 + TOKEN: undefined, 49 + USERNAME: undefined, 50 + VERSION: '1.0', 51 + WITH_CREDENTIALS: false, 52 + interceptors: { 53 + response: new Interceptors(), 54 + }, 55 + };
+337
packages/openapi-ts/test/__snapshots__/test/generated/v3_angular_tree_shakeable/core/request.ts.snap
··· 1 + import { HttpClient, HttpHeaders } from '@angular/common/http'; 2 + import type { HttpResponse, HttpErrorResponse } from '@angular/common/http'; 3 + import { forkJoin, of, throwError } from 'rxjs'; 4 + import { catchError, map, switchMap } from 'rxjs/operators'; 5 + import type { Observable } from 'rxjs'; 6 + 7 + import { ApiError } from './ApiError'; 8 + import type { ApiRequestOptions } from './ApiRequestOptions'; 9 + import type { ApiResult } from './ApiResult'; 10 + import type { OpenAPIConfig } from './OpenAPI'; 11 + 12 + export const isString = (value: unknown): value is string => { 13 + return typeof value === 'string'; 14 + }; 15 + 16 + export const isStringWithValue = (value: unknown): value is string => { 17 + return isString(value) && value !== ''; 18 + }; 19 + 20 + export const isBlob = (value: any): value is Blob => { 21 + return value instanceof Blob; 22 + }; 23 + 24 + export const isFormData = (value: unknown): value is FormData => { 25 + return value instanceof FormData; 26 + }; 27 + 28 + export const base64 = (str: string): string => { 29 + try { 30 + return btoa(str); 31 + } catch (err) { 32 + // @ts-ignore 33 + return Buffer.from(str).toString('base64'); 34 + } 35 + }; 36 + 37 + export const getQueryString = (params: Record<string, unknown>): string => { 38 + const qs: string[] = []; 39 + 40 + const append = (key: string, value: unknown) => { 41 + qs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`); 42 + }; 43 + 44 + const encodePair = (key: string, value: unknown) => { 45 + if (value === undefined || value === null) { 46 + return; 47 + } 48 + 49 + if (value instanceof Date) { 50 + append(key, value.toISOString()); 51 + } else if (Array.isArray(value)) { 52 + value.forEach(v => encodePair(key, v)); 53 + } else if (typeof value === 'object') { 54 + Object.entries(value).forEach(([k, v]) => encodePair(`${key}[${k}]`, v)); 55 + } else { 56 + append(key, value); 57 + } 58 + }; 59 + 60 + Object.entries(params).forEach(([key, value]) => encodePair(key, value)); 61 + 62 + return qs.length ? `?${qs.join('&')}` : ''; 63 + }; 64 + 65 + const getUrl = (config: OpenAPIConfig, options: ApiRequestOptions): string => { 66 + const encoder = config.ENCODE_PATH || encodeURI; 67 + 68 + const path = options.url 69 + .replace('{api-version}', config.VERSION) 70 + .replace(/{(.*?)}/g, (substring: string, group: string) => { 71 + if (options.path?.hasOwnProperty(group)) { 72 + return encoder(String(options.path[group])); 73 + } 74 + return substring; 75 + }); 76 + 77 + const url = config.BASE + path; 78 + return options.query ? url + getQueryString(options.query) : url; 79 + }; 80 + 81 + export const getFormData = (options: ApiRequestOptions): FormData | undefined => { 82 + if (options.formData) { 83 + const formData = new FormData(); 84 + 85 + const process = (key: string, value: unknown) => { 86 + if (isString(value) || isBlob(value)) { 87 + formData.append(key, value); 88 + } else { 89 + formData.append(key, JSON.stringify(value)); 90 + } 91 + }; 92 + 93 + Object.entries(options.formData) 94 + .filter(([, value]) => value !== undefined && value !== null) 95 + .forEach(([key, value]) => { 96 + if (Array.isArray(value)) { 97 + value.forEach(v => process(key, v)); 98 + } else { 99 + process(key, value); 100 + } 101 + }); 102 + 103 + return formData; 104 + } 105 + return undefined; 106 + }; 107 + 108 + type Resolver<T> = (options: ApiRequestOptions<T>) => Promise<T>; 109 + 110 + export const resolve = async <T>(options: ApiRequestOptions<T>, resolver?: T | Resolver<T>): Promise<T | undefined> => { 111 + if (typeof resolver === 'function') { 112 + return (resolver as Resolver<T>)(options); 113 + } 114 + return resolver; 115 + }; 116 + 117 + export const getHeaders = <T>(config: OpenAPIConfig, options: ApiRequestOptions<T>): Observable<HttpHeaders> => { 118 + return forkJoin({ 119 + // @ts-ignore 120 + token: resolve(options, config.TOKEN), 121 + // @ts-ignore 122 + username: resolve(options, config.USERNAME), 123 + // @ts-ignore 124 + password: resolve(options, config.PASSWORD), 125 + // @ts-ignore 126 + additionalHeaders: resolve(options, config.HEADERS), 127 + }).pipe( 128 + map(({ token, username, password, additionalHeaders }) => { 129 + const headers = Object.entries({ 130 + Accept: 'application/json', 131 + ...additionalHeaders, 132 + ...options.headers, 133 + }) 134 + .filter(([, value]) => value !== undefined && value !== null) 135 + .reduce((headers, [key, value]) => ({ 136 + ...headers, 137 + [key]: String(value), 138 + }), {} as Record<string, string>); 139 + 140 + if (isStringWithValue(token)) { 141 + headers['Authorization'] = `Bearer ${token}`; 142 + } 143 + 144 + if (isStringWithValue(username) && isStringWithValue(password)) { 145 + const credentials = base64(`${username}:${password}`); 146 + headers['Authorization'] = `Basic ${credentials}`; 147 + } 148 + 149 + if (options.body !== undefined) { 150 + if (options.mediaType) { 151 + headers['Content-Type'] = options.mediaType; 152 + } else if (isBlob(options.body)) { 153 + headers['Content-Type'] = options.body.type || 'application/octet-stream'; 154 + } else if (isString(options.body)) { 155 + headers['Content-Type'] = 'text/plain'; 156 + } else if (!isFormData(options.body)) { 157 + headers['Content-Type'] = 'application/json'; 158 + } 159 + } 160 + 161 + return new HttpHeaders(headers); 162 + }), 163 + ); 164 + }; 165 + 166 + export const getRequestBody = (options: ApiRequestOptions): unknown => { 167 + if (options.body) { 168 + if (options.mediaType?.includes('application/json') || options.mediaType?.includes('+json')) { 169 + return JSON.stringify(options.body); 170 + } else if (isString(options.body) || isBlob(options.body) || isFormData(options.body)) { 171 + return options.body; 172 + } else { 173 + return JSON.stringify(options.body); 174 + } 175 + } 176 + return undefined; 177 + }; 178 + 179 + export const sendRequest = <T>( 180 + config: OpenAPIConfig, 181 + options: ApiRequestOptions<T>, 182 + http: HttpClient, 183 + url: string, 184 + body: unknown, 185 + formData: FormData | undefined, 186 + headers: HttpHeaders 187 + ): Observable<HttpResponse<T>> => { 188 + return http.request<T>(options.method, url, { 189 + headers, 190 + body: body ?? formData, 191 + withCredentials: config.WITH_CREDENTIALS, 192 + observe: 'response', 193 + }); 194 + }; 195 + 196 + export const getResponseHeader = <T>(response: HttpResponse<T>, responseHeader?: string): string | undefined => { 197 + if (responseHeader) { 198 + const value = response.headers.get(responseHeader); 199 + if (isString(value)) { 200 + return value; 201 + } 202 + } 203 + return undefined; 204 + }; 205 + 206 + export const getResponseBody = <T>(response: HttpResponse<T>): T | undefined => { 207 + if (response.status !== 204 && response.body !== null) { 208 + return response.body; 209 + } 210 + return undefined; 211 + }; 212 + 213 + export const catchErrorCodes = (options: ApiRequestOptions, result: ApiResult): void => { 214 + const errors: Record<number, string> = { 215 + 400: 'Bad Request', 216 + 401: 'Unauthorized', 217 + 402: 'Payment Required', 218 + 403: 'Forbidden', 219 + 404: 'Not Found', 220 + 405: 'Method Not Allowed', 221 + 406: 'Not Acceptable', 222 + 407: 'Proxy Authentication Required', 223 + 408: 'Request Timeout', 224 + 409: 'Conflict', 225 + 410: 'Gone', 226 + 411: 'Length Required', 227 + 412: 'Precondition Failed', 228 + 413: 'Payload Too Large', 229 + 414: 'URI Too Long', 230 + 415: 'Unsupported Media Type', 231 + 416: 'Range Not Satisfiable', 232 + 417: 'Expectation Failed', 233 + 418: 'Im a teapot', 234 + 421: 'Misdirected Request', 235 + 422: 'Unprocessable Content', 236 + 423: 'Locked', 237 + 424: 'Failed Dependency', 238 + 425: 'Too Early', 239 + 426: 'Upgrade Required', 240 + 428: 'Precondition Required', 241 + 429: 'Too Many Requests', 242 + 431: 'Request Header Fields Too Large', 243 + 451: 'Unavailable For Legal Reasons', 244 + 500: 'Internal Server Error', 245 + 501: 'Not Implemented', 246 + 502: 'Bad Gateway', 247 + 503: 'Service Unavailable', 248 + 504: 'Gateway Timeout', 249 + 505: 'HTTP Version Not Supported', 250 + 506: 'Variant Also Negotiates', 251 + 507: 'Insufficient Storage', 252 + 508: 'Loop Detected', 253 + 510: 'Not Extended', 254 + 511: 'Network Authentication Required', 255 + ...options.errors, 256 + } 257 + 258 + const error = errors[result.status]; 259 + if (error) { 260 + throw new ApiError(options, result, error); 261 + } 262 + 263 + if (!result.ok) { 264 + const errorStatus = result.status ?? 'unknown'; 265 + const errorStatusText = result.statusText ?? 'unknown'; 266 + const errorBody = (() => { 267 + try { 268 + return JSON.stringify(result.body, null, 2); 269 + } catch (e) { 270 + return undefined; 271 + } 272 + })(); 273 + 274 + throw new ApiError(options, result, 275 + `Generic Error: status: ${errorStatus}; status text: ${errorStatusText}; body: ${errorBody}` 276 + ); 277 + } 278 + }; 279 + 280 + /** 281 + * Request method 282 + * @param config The OpenAPI configuration object 283 + * @param http The Angular HTTP client 284 + * @param options The request options from the service 285 + * @returns Observable<T> 286 + * @throws ApiError 287 + */ 288 + export const request = <T>(config: OpenAPIConfig, http: HttpClient, options: ApiRequestOptions<T>): Observable<T> => { 289 + const url = getUrl(config, options); 290 + const formData = getFormData(options); 291 + const body = getRequestBody(options); 292 + 293 + return getHeaders(config, options).pipe( 294 + switchMap(headers => { 295 + return sendRequest<T>(config, options, http, url, body, formData, headers); 296 + }), 297 + switchMap(async response => { 298 + for (const fn of config.interceptors.response._fns) { 299 + response = await fn(response); 300 + } 301 + const responseBody = getResponseBody(response); 302 + const responseHeader = getResponseHeader(response, options.responseHeader); 303 + 304 + let transformedBody = responseBody; 305 + if (options.responseTransformer && response.ok) { 306 + transformedBody = await options.responseTransformer(responseBody) 307 + } 308 + 309 + return { 310 + url, 311 + ok: response.ok, 312 + status: response.status, 313 + statusText: response.statusText, 314 + body: responseHeader ?? transformedBody, 315 + } as ApiResult; 316 + }), 317 + catchError((error: HttpErrorResponse) => { 318 + if (!error.status) { 319 + return throwError(() => error); 320 + } 321 + return of({ 322 + url, 323 + ok: error.ok, 324 + status: error.status, 325 + statusText: error.statusText, 326 + body: error.error ?? error.statusText, 327 + } as ApiResult); 328 + }), 329 + map(result => { 330 + catchErrorCodes(options, result); 331 + return result.body as T; 332 + }), 333 + catchError((error: ApiError) => { 334 + return throwError(() => error); 335 + }), 336 + ); 337 + };
+5
packages/openapi-ts/test/__snapshots__/test/generated/v3_angular_tree_shakeable/index.ts.snap
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + export { ApiError } from './core/ApiError'; 3 + export { OpenAPI, type OpenAPIConfig } from './core/OpenAPI'; 4 + export * from './services.gen'; 5 + export * from './types.gen';
+668
packages/openapi-ts/test/__snapshots__/test/generated/v3_angular_tree_shakeable/services.gen.ts.snap
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { Injectable } from '@angular/core'; 4 + import { HttpClient } from '@angular/common/http'; 5 + import type { Observable } from 'rxjs'; 6 + import { OpenAPI } from './core/OpenAPI'; 7 + import { request as __request } from './core/request'; 8 + import type { ImportData, ImportResponse, ApiVversionOdataControllerCountResponse, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiRequestBodyData, PostApiFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, CallWithNoContentResponseResponse, CallWithResponseAndNoContentResponseResponse, DummyAResponse, DummyBResponse, CallWithResponseResponse, CallWithDuplicateResponsesResponse, CallWithResponsesResponse, CollectionFormatData, TypesData, TypesResponse, UploadFileData, UploadFileResponse, FileResponseData, FileResponseResponse, ComplexTypesData, ComplexTypesResponse, MultipartRequestData, MultipartResponseResponse, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderResponse, TestErrorCodeData, TestErrorCodeResponse, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from './types.gen'; 9 + 10 + /** 11 + * @throws ApiError 12 + */ 13 + export const export_ = function (): Observable<void> { return __request(OpenAPI, this.http, { 14 + method: 'GET', 15 + url: '/api/v{api-version}/no-tag' 16 + }); }; 17 + 18 + /** 19 + * @param data The data for the request. 20 + * @param data.requestBody 21 + * @returns Model_From_Zendesk Success 22 + * @returns ModelWithReadOnlyAndWriteOnly Default success response 23 + * @throws ApiError 24 + */ 25 + export const import_ = function (data: ImportData): Observable<ImportResponse> { return __request(OpenAPI, this.http, { 26 + method: 'POST', 27 + url: '/api/v{api-version}/no-tag', 28 + body: data.requestBody, 29 + mediaType: 'application/json' 30 + }); }; 31 + 32 + /** 33 + * @returns Model_From_Zendesk Success 34 + * @throws ApiError 35 + */ 36 + export const apiVVersionOdataControllerCount = function (): Observable<ApiVversionOdataControllerCountResponse> { return __request(OpenAPI, this.http, { 37 + method: 'GET', 38 + url: '/api/v{api-version}/simple/$count' 39 + }); }; 40 + 41 + /** 42 + * @throws ApiError 43 + */ 44 + export const getCallWithoutParametersAndResponse = function (): Observable<void> { return __request(OpenAPI, this.http, { 45 + method: 'GET', 46 + url: '/api/v{api-version}/simple' 47 + }); }; 48 + 49 + /** 50 + * @throws ApiError 51 + */ 52 + export const putCallWithoutParametersAndResponse = function (): Observable<void> { return __request(OpenAPI, this.http, { 53 + method: 'PUT', 54 + url: '/api/v{api-version}/simple' 55 + }); }; 56 + 57 + /** 58 + * @throws ApiError 59 + */ 60 + export const postCallWithoutParametersAndResponse = function (): Observable<void> { return __request(OpenAPI, this.http, { 61 + method: 'POST', 62 + url: '/api/v{api-version}/simple' 63 + }); }; 64 + 65 + /** 66 + * @throws ApiError 67 + */ 68 + export const deleteCallWithoutParametersAndResponse = function (): Observable<void> { return __request(OpenAPI, this.http, { 69 + method: 'DELETE', 70 + url: '/api/v{api-version}/simple' 71 + }); }; 72 + 73 + /** 74 + * @throws ApiError 75 + */ 76 + export const optionsCallWithoutParametersAndResponse = function (): Observable<void> { return __request(OpenAPI, this.http, { 77 + method: 'OPTIONS', 78 + url: '/api/v{api-version}/simple' 79 + }); }; 80 + 81 + /** 82 + * @throws ApiError 83 + */ 84 + export const headCallWithoutParametersAndResponse = function (): Observable<void> { return __request(OpenAPI, this.http, { 85 + method: 'HEAD', 86 + url: '/api/v{api-version}/simple' 87 + }); }; 88 + 89 + /** 90 + * @throws ApiError 91 + */ 92 + export const patchCallWithoutParametersAndResponse = function (): Observable<void> { return __request(OpenAPI, this.http, { 93 + method: 'PATCH', 94 + url: '/api/v{api-version}/simple' 95 + }); }; 96 + 97 + /** 98 + * @param data The data for the request. 99 + * @param data.fooParam foo in method 100 + * @param data.barParam bar in method 101 + * @param data.xFooBar Parameter with illegal characters 102 + * @throws ApiError 103 + */ 104 + export const deleteFoo = function (data: DeleteFooData3): Observable<void> { return __request(OpenAPI, this.http, { 105 + method: 'DELETE', 106 + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', 107 + path: { 108 + foo_param: data.fooParam, 109 + BarParam: data.barParam 110 + }, 111 + headers: { 112 + 'x-Foo-Bar': data.xFooBar 113 + } 114 + }); }; 115 + 116 + /** 117 + * @param data The data for the request. 118 + * @param data.parameterWithBreaks Testing multiline comments in string: First line 119 + * Second line 120 + * 121 + * Fourth line 122 + * @param data.parameterWithBackticks Testing backticks in string: `backticks` and ```multiple backticks``` should work 123 + * @param data.parameterWithSlashes Testing slashes in string: \backwards\\\ and /forwards/// should work 124 + * @param data.parameterWithExpressionPlaceholders Testing expression placeholders in string: ${expression} should work 125 + * @param data.parameterWithQuotes Testing quotes in string: 'single quote''' and "double quotes""" should work 126 + * @param data.parameterWithReservedCharacters Testing reserved characters in string: * inline * and ** inline ** should work 127 + * @throws ApiError 128 + */ 129 + export const callWithDescriptions = function (data: CallWithDescriptionsData = {}): Observable<void> { return __request(OpenAPI, this.http, { 130 + method: 'POST', 131 + url: '/api/v{api-version}/descriptions/', 132 + query: { 133 + parameterWithBreaks: data.parameterWithBreaks, 134 + parameterWithBackticks: data.parameterWithBackticks, 135 + parameterWithSlashes: data.parameterWithSlashes, 136 + parameterWithExpressionPlaceholders: data.parameterWithExpressionPlaceholders, 137 + parameterWithQuotes: data.parameterWithQuotes, 138 + parameterWithReservedCharacters: data.parameterWithReservedCharacters 139 + } 140 + }); }; 141 + 142 + /** 143 + * @deprecated 144 + * @param data The data for the request. 145 + * @param data.parameter This parameter is deprecated 146 + * @throws ApiError 147 + */ 148 + export const deprecatedCall = function (data: DeprecatedCallData): Observable<void> { return __request(OpenAPI, this.http, { 149 + method: 'POST', 150 + url: '/api/v{api-version}/parameters/deprecated', 151 + headers: { 152 + parameter: data.parameter 153 + } 154 + }); }; 155 + 156 + /** 157 + * @param data The data for the request. 158 + * @param data.parameterHeader This is the parameter that goes into the header 159 + * @param data.fooAllOfEnum 160 + * @param data.cursor This is the parameter that goes into the query params 161 + * @param data.parameterCookie This is the parameter that goes into the cookie 162 + * @param data.parameterPath This is the parameter that goes into the path 163 + * @param data.requestBody This is the parameter that goes into the body 164 + * @param data.fooRefEnum 165 + * @throws ApiError 166 + */ 167 + export const callWithParameters = function (data: CallWithParametersData): Observable<void> { return __request(OpenAPI, this.http, { 168 + method: 'POST', 169 + url: '/api/v{api-version}/parameters/{parameterPath}', 170 + path: { 171 + parameterPath: data.parameterPath 172 + }, 173 + cookies: { 174 + parameterCookie: data.parameterCookie 175 + }, 176 + headers: { 177 + parameterHeader: data.parameterHeader 178 + }, 179 + query: { 180 + foo_ref_enum: data.fooRefEnum, 181 + foo_all_of_enum: data.fooAllOfEnum, 182 + cursor: data.cursor 183 + }, 184 + body: data.requestBody, 185 + mediaType: 'application/json' 186 + }); }; 187 + 188 + /** 189 + * @param data The data for the request. 190 + * @param data.parameterHeader This is the parameter that goes into the request header 191 + * @param data.parameterQuery This is the parameter that goes into the request query params 192 + * @param data.parameterCookie This is the parameter that goes into the cookie 193 + * @param data.requestBody This is the parameter that goes into the body 194 + * @param data.parameterPath1 This is the parameter that goes into the path 195 + * @param data.parameterPath2 This is the parameter that goes into the path 196 + * @param data.parameterPath3 This is the parameter that goes into the path 197 + * @param data._default This is the parameter with a reserved keyword 198 + * @throws ApiError 199 + */ 200 + export const callWithWeirdParameterNames = function (data: CallWithWeirdParameterNamesData): Observable<void> { return __request(OpenAPI, this.http, { 201 + method: 'POST', 202 + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', 203 + path: { 204 + 'parameter.path.1': data.parameterPath1, 205 + 'parameter-path-2': data.parameterPath2, 206 + 'PARAMETER-PATH-3': data.parameterPath3 207 + }, 208 + cookies: { 209 + 'PARAMETER-COOKIE': data.parameterCookie 210 + }, 211 + headers: { 212 + 'parameter.header': data.parameterHeader 213 + }, 214 + query: { 215 + default: data._default, 216 + 'parameter-query': data.parameterQuery 217 + }, 218 + body: data.requestBody, 219 + mediaType: 'application/json' 220 + }); }; 221 + 222 + /** 223 + * @param data The data for the request. 224 + * @param data.requestBody This is a required parameter 225 + * @param data.page This is an optional parameter 226 + * @throws ApiError 227 + */ 228 + export const getCallWithOptionalParam = function (data: GetCallWithOptionalParamData): Observable<void> { return __request(OpenAPI, this.http, { 229 + method: 'GET', 230 + url: '/api/v{api-version}/parameters/', 231 + query: { 232 + page: data.page 233 + }, 234 + body: data.requestBody, 235 + mediaType: 'application/json' 236 + }); }; 237 + 238 + /** 239 + * @param data The data for the request. 240 + * @param data.parameter This is a required parameter 241 + * @param data.requestBody This is an optional parameter 242 + * @returns number Response is a simple number 243 + * @returns void Success 244 + * @throws ApiError 245 + */ 246 + export const postCallWithOptionalParam = function (data: PostCallWithOptionalParamData): Observable<PostCallWithOptionalParamResponse> { return __request(OpenAPI, this.http, { 247 + method: 'POST', 248 + url: '/api/v{api-version}/parameters/', 249 + query: { 250 + parameter: data.parameter 251 + }, 252 + body: data.requestBody, 253 + mediaType: 'application/json' 254 + }); }; 255 + 256 + /** 257 + * @param data The data for the request. 258 + * @param data.parameter This is a reusable parameter 259 + * @param data.foo A reusable request body 260 + * @throws ApiError 261 + */ 262 + export const postApiRequestBody = function (data: PostApiRequestBodyData = {}): Observable<void> { return __request(OpenAPI, this.http, { 263 + method: 'POST', 264 + url: '/api/v{api-version}/requestBody/', 265 + query: { 266 + parameter: data.parameter 267 + }, 268 + body: data.foo, 269 + mediaType: 'application/json' 270 + }); }; 271 + 272 + /** 273 + * @param data The data for the request. 274 + * @param data.parameter This is a reusable parameter 275 + * @param data.formData A reusable request body 276 + * @throws ApiError 277 + */ 278 + export const postApiFormData = function (data: PostApiFormDataData = {}): Observable<void> { return __request(OpenAPI, this.http, { 279 + method: 'POST', 280 + url: '/api/v{api-version}/formData/', 281 + query: { 282 + parameter: data.parameter 283 + }, 284 + formData: data.formData, 285 + mediaType: 'multipart/form-data' 286 + }); }; 287 + 288 + /** 289 + * @param data The data for the request. 290 + * @param data.parameterString This is a simple string with default value 291 + * @param data.parameterNumber This is a simple number with default value 292 + * @param data.parameterBoolean This is a simple boolean with default value 293 + * @param data.parameterEnum This is a simple enum with default value 294 + * @param data.parameterModel This is a simple model with default value 295 + * @throws ApiError 296 + */ 297 + export const callWithDefaultParameters = function (data: CallWithDefaultParametersData = {}): Observable<void> { return __request(OpenAPI, this.http, { 298 + method: 'GET', 299 + url: '/api/v{api-version}/defaults', 300 + query: { 301 + parameterString: data.parameterString, 302 + parameterNumber: data.parameterNumber, 303 + parameterBoolean: data.parameterBoolean, 304 + parameterEnum: data.parameterEnum, 305 + parameterModel: data.parameterModel 306 + } 307 + }); }; 308 + 309 + /** 310 + * @param data The data for the request. 311 + * @param data.parameterString This is a simple string that is optional with default value 312 + * @param data.parameterNumber This is a simple number that is optional with default value 313 + * @param data.parameterBoolean This is a simple boolean that is optional with default value 314 + * @param data.parameterEnum This is a simple enum that is optional with default value 315 + * @param data.parameterModel This is a simple model that is optional with default value 316 + * @throws ApiError 317 + */ 318 + export const callWithDefaultOptionalParameters = function (data: CallWithDefaultOptionalParametersData = {}): Observable<void> { return __request(OpenAPI, this.http, { 319 + method: 'POST', 320 + url: '/api/v{api-version}/defaults', 321 + query: { 322 + parameterString: data.parameterString, 323 + parameterNumber: data.parameterNumber, 324 + parameterBoolean: data.parameterBoolean, 325 + parameterEnum: data.parameterEnum, 326 + parameterModel: data.parameterModel 327 + } 328 + }); }; 329 + 330 + /** 331 + * @param data The data for the request. 332 + * @param data.parameterStringWithNoDefault This is a string with no default 333 + * @param data.parameterOptionalStringWithDefault This is a optional string with default 334 + * @param data.parameterOptionalStringWithEmptyDefault This is a optional string with empty default 335 + * @param data.parameterOptionalStringWithNoDefault This is a optional string with no default 336 + * @param data.parameterStringWithDefault This is a string with default 337 + * @param data.parameterStringWithEmptyDefault This is a string with empty default 338 + * @param data.parameterStringNullableWithNoDefault This is a string that can be null with no default 339 + * @param data.parameterStringNullableWithDefault This is a string that can be null with default 340 + * @throws ApiError 341 + */ 342 + export const callToTestOrderOfParams = function (data: CallToTestOrderOfParamsData): Observable<void> { return __request(OpenAPI, this.http, { 343 + method: 'PUT', 344 + url: '/api/v{api-version}/defaults', 345 + query: { 346 + parameterOptionalStringWithDefault: data.parameterOptionalStringWithDefault, 347 + parameterOptionalStringWithEmptyDefault: data.parameterOptionalStringWithEmptyDefault, 348 + parameterOptionalStringWithNoDefault: data.parameterOptionalStringWithNoDefault, 349 + parameterStringWithDefault: data.parameterStringWithDefault, 350 + parameterStringWithEmptyDefault: data.parameterStringWithEmptyDefault, 351 + parameterStringWithNoDefault: data.parameterStringWithNoDefault, 352 + parameterStringNullableWithNoDefault: data.parameterStringNullableWithNoDefault, 353 + parameterStringNullableWithDefault: data.parameterStringNullableWithDefault 354 + } 355 + }); }; 356 + 357 + /** 358 + * @throws ApiError 359 + */ 360 + export const duplicateName = function (): Observable<void> { return __request(OpenAPI, this.http, { 361 + method: 'GET', 362 + url: '/api/v{api-version}/duplicate' 363 + }); }; 364 + 365 + /** 366 + * @throws ApiError 367 + */ 368 + export const duplicateName1 = function (): Observable<void> { return __request(OpenAPI, this.http, { 369 + method: 'POST', 370 + url: '/api/v{api-version}/duplicate' 371 + }); }; 372 + 373 + /** 374 + * @throws ApiError 375 + */ 376 + export const duplicateName2 = function (): Observable<void> { return __request(OpenAPI, this.http, { 377 + method: 'PUT', 378 + url: '/api/v{api-version}/duplicate' 379 + }); }; 380 + 381 + /** 382 + * @throws ApiError 383 + */ 384 + export const duplicateName3 = function (): Observable<void> { return __request(OpenAPI, this.http, { 385 + method: 'DELETE', 386 + url: '/api/v{api-version}/duplicate' 387 + }); }; 388 + 389 + /** 390 + * @returns void Success 391 + * @throws ApiError 392 + */ 393 + export const callWithNoContentResponse = function (): Observable<CallWithNoContentResponseResponse> { return __request(OpenAPI, this.http, { 394 + method: 'GET', 395 + url: '/api/v{api-version}/no-content' 396 + }); }; 397 + 398 + /** 399 + * @returns number Response is a simple number 400 + * @returns void Success 401 + * @throws ApiError 402 + */ 403 + export const callWithResponseAndNoContentResponse = function (): Observable<CallWithResponseAndNoContentResponseResponse> { return __request(OpenAPI, this.http, { 404 + method: 'GET', 405 + url: '/api/v{api-version}/multiple-tags/response-and-no-content' 406 + }); }; 407 + 408 + /** 409 + * @returns _400 410 + * @throws ApiError 411 + */ 412 + export const dummyA = function (): Observable<DummyAResponse> { return __request(OpenAPI, this.http, { 413 + method: 'GET', 414 + url: '/api/v{api-version}/multiple-tags/a' 415 + }); }; 416 + 417 + /** 418 + * @returns void Success 419 + * @throws ApiError 420 + */ 421 + export const dummyB = function (): Observable<DummyBResponse> { return __request(OpenAPI, this.http, { 422 + method: 'GET', 423 + url: '/api/v{api-version}/multiple-tags/b' 424 + }); }; 425 + 426 + /** 427 + * @returns import 428 + * @throws ApiError 429 + */ 430 + export const callWithResponse = function (): Observable<CallWithResponseResponse> { return __request(OpenAPI, this.http, { 431 + method: 'GET', 432 + url: '/api/v{api-version}/response' 433 + }); }; 434 + 435 + /** 436 + * @returns unknown Message for 200 response 437 + * @returns ModelWithString Message for 201 response 438 + * @returns ModelWithString Message for 202 response 439 + * @throws ApiError 440 + */ 441 + export const callWithDuplicateResponses = function (): Observable<CallWithDuplicateResponsesResponse> { return __request(OpenAPI, this.http, { 442 + method: 'POST', 443 + url: '/api/v{api-version}/response', 444 + errors: { 445 + 500: 'Message for 500 error', 446 + 501: 'Message for 501 error', 447 + 502: 'Message for 502 error', 448 + '4XX': 'Message for 4XX errors', 449 + default: 'Default error response' 450 + } 451 + }); }; 452 + 453 + /** 454 + * @returns unknown Message for 200 response 455 + * @returns ModelThatExtends Message for 201 response 456 + * @returns ModelThatExtendsExtends Message for 202 response 457 + * @throws ApiError 458 + */ 459 + export const callWithResponses = function (): Observable<CallWithResponsesResponse> { return __request(OpenAPI, this.http, { 460 + method: 'PUT', 461 + url: '/api/v{api-version}/response', 462 + errors: { 463 + 500: 'Message for 500 error', 464 + 501: 'Message for 501 error', 465 + 502: 'Message for 502 error', 466 + default: 'Message for default response' 467 + } 468 + }); }; 469 + 470 + /** 471 + * @param data The data for the request. 472 + * @param data.parameterArrayCsv This is an array parameter that is sent as csv format (comma-separated values) 473 + * @param data.parameterArraySsv This is an array parameter that is sent as ssv format (space-separated values) 474 + * @param data.parameterArrayTsv This is an array parameter that is sent as tsv format (tab-separated values) 475 + * @param data.parameterArrayPipes This is an array parameter that is sent as pipes format (pipe-separated values) 476 + * @param data.parameterArrayMulti This is an array parameter that is sent as multi format (multiple parameter instances) 477 + * @throws ApiError 478 + */ 479 + export const collectionFormat = function (data: CollectionFormatData): Observable<void> { return __request(OpenAPI, this.http, { 480 + method: 'GET', 481 + url: '/api/v{api-version}/collectionFormat', 482 + query: { 483 + parameterArrayCSV: data.parameterArrayCsv, 484 + parameterArraySSV: data.parameterArraySsv, 485 + parameterArrayTSV: data.parameterArrayTsv, 486 + parameterArrayPipes: data.parameterArrayPipes, 487 + parameterArrayMulti: data.parameterArrayMulti 488 + } 489 + }); }; 490 + 491 + /** 492 + * @param data The data for the request. 493 + * @param data.parameterArray This is an array parameter 494 + * @param data.parameterDictionary This is a dictionary parameter 495 + * @param data.parameterEnum This is an enum parameter 496 + * @param data.parameterNumber This is a number parameter 497 + * @param data.parameterString This is a string parameter 498 + * @param data.parameterBoolean This is a boolean parameter 499 + * @param data.parameterObject This is an object parameter 500 + * @param data.id This is a number parameter 501 + * @returns number Response is a simple number 502 + * @returns string Response is a simple string 503 + * @returns boolean Response is a simple boolean 504 + * @returns unknown Response is a simple object 505 + * @throws ApiError 506 + */ 507 + export const types = function (data: TypesData): Observable<TypesResponse> { return __request(OpenAPI, this.http, { 508 + method: 'GET', 509 + url: '/api/v{api-version}/types', 510 + path: { 511 + id: data.id 512 + }, 513 + query: { 514 + parameterNumber: data.parameterNumber, 515 + parameterString: data.parameterString, 516 + parameterBoolean: data.parameterBoolean, 517 + parameterObject: data.parameterObject, 518 + parameterArray: data.parameterArray, 519 + parameterDictionary: data.parameterDictionary, 520 + parameterEnum: data.parameterEnum 521 + } 522 + }); }; 523 + 524 + /** 525 + * @param data The data for the request. 526 + * @param data.formData 527 + * @returns boolean 528 + * @throws ApiError 529 + */ 530 + export const uploadFile = function (data: UploadFileData): Observable<UploadFileResponse> { return __request(OpenAPI, this.http, { 531 + method: 'POST', 532 + url: '/api/v{api-version}/upload', 533 + formData: data.formData, 534 + mediaType: 'application/x-www-form-urlencoded' 535 + }); }; 536 + 537 + /** 538 + * @param data The data for the request. 539 + * @param data.id 540 + * @returns binary Success 541 + * @throws ApiError 542 + */ 543 + export const fileResponse = function (data: FileResponseData): Observable<FileResponseResponse> { return __request(OpenAPI, this.http, { 544 + method: 'GET', 545 + url: '/api/v{api-version}/file/{id}', 546 + path: { 547 + id: data.id 548 + } 549 + }); }; 550 + 551 + /** 552 + * @param data The data for the request. 553 + * @param data.parameterObject Parameter containing object 554 + * @param data.parameterReference Parameter containing reference 555 + * @returns ModelWithString Successful response 556 + * @throws ApiError 557 + */ 558 + export const complexTypes = function (data: ComplexTypesData): Observable<ComplexTypesResponse> { return __request(OpenAPI, this.http, { 559 + method: 'GET', 560 + url: '/api/v{api-version}/complex', 561 + query: { 562 + parameterObject: data.parameterObject, 563 + parameterReference: data.parameterReference 564 + }, 565 + errors: { 566 + 400: '400 `server` error', 567 + 500: '500 server error' 568 + } 569 + }); }; 570 + 571 + /** 572 + * @param data The data for the request. 573 + * @param data.formData 574 + * @throws ApiError 575 + */ 576 + export const multipartRequest = function (data: MultipartRequestData = {}): Observable<void> { return __request(OpenAPI, this.http, { 577 + method: 'POST', 578 + url: '/api/v{api-version}/multipart', 579 + formData: data.formData, 580 + mediaType: 'multipart/form-data' 581 + }); }; 582 + 583 + /** 584 + * @returns unknown OK 585 + * @throws ApiError 586 + */ 587 + export const multipartResponse = function (): Observable<MultipartResponseResponse> { return __request(OpenAPI, this.http, { 588 + method: 'GET', 589 + url: '/api/v{api-version}/multipart' 590 + }); }; 591 + 592 + /** 593 + * @param data The data for the request. 594 + * @param data.id 595 + * @param data.requestBody 596 + * @returns ModelWithString Success 597 + * @throws ApiError 598 + */ 599 + export const complexParams = function (data: ComplexParamsData): Observable<ComplexParamsResponse> { return __request(OpenAPI, this.http, { 600 + method: 'PUT', 601 + url: '/api/v{api-version}/complex/{id}', 602 + path: { 603 + id: data.id 604 + }, 605 + body: data.requestBody, 606 + mediaType: 'application/json-patch+json' 607 + }); }; 608 + 609 + /** 610 + * @returns string Successful response 611 + * @throws ApiError 612 + */ 613 + export const callWithResultFromHeader = function (): Observable<CallWithResultFromHeaderResponse> { return __request(OpenAPI, this.http, { 614 + method: 'POST', 615 + url: '/api/v{api-version}/header', 616 + responseHeader: 'operation-location', 617 + errors: { 618 + 400: '400 server error', 619 + 500: '500 server error' 620 + } 621 + }); }; 622 + 623 + /** 624 + * @param data The data for the request. 625 + * @param data.status Status code to return 626 + * @returns unknown Custom message: Successful response 627 + * @throws ApiError 628 + */ 629 + export const testErrorCode = function (data: TestErrorCodeData): Observable<TestErrorCodeResponse> { return __request(OpenAPI, this.http, { 630 + method: 'POST', 631 + url: '/api/v{api-version}/error', 632 + query: { 633 + status: data.status 634 + }, 635 + errors: { 636 + 500: 'Custom message: Internal Server Error', 637 + 501: 'Custom message: Not Implemented', 638 + 502: 'Custom message: Bad Gateway', 639 + 503: 'Custom message: Service Unavailable' 640 + } 641 + }); }; 642 + 643 + /** 644 + * @param data The data for the request. 645 + * @param data.nonAsciiParamæøåÆøÅöôêÊ Dummy input param 646 + * @returns NonAsciiStringæøåÆØÅöôêÊ字符串 Successful response 647 + * @throws ApiError 648 + */ 649 + export const nonAsciiæøåÆøÅöôêÊ字符串 = function (data: NonAsciiæøåÆøÅöôêÊ字符串Data): Observable<NonAsciiæøåÆøÅöôêÊ字符串Response> { return __request(OpenAPI, this.http, { 650 + method: 'POST', 651 + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', 652 + query: { 653 + 'nonAsciiParamæøåÆØÅöôêÊ': data.nonAsciiParamæøåÆøÅöôêÊ 654 + } 655 + }); }; 656 + 657 + /** 658 + * Login User 659 + * @param data The data for the request. 660 + * @param data.formData 661 + * @throws ApiError 662 + */ 663 + export const putWithFormUrlEncoded = function (data: PutWithFormUrlEncodedData): Observable<void> { return __request(OpenAPI, this.http, { 664 + method: 'PUT', 665 + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', 666 + formData: data.formData, 667 + mediaType: 'application/x-www-form-urlencoded' 668 + }); };
+1389
packages/openapi-ts/test/__snapshots__/test/generated/v3_angular_tree_shakeable/types.gen.ts.snap
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + /** 4 + * Model with number-only name 5 + */ 6 + export type _400 = string; 7 + 8 + /** 9 + * Testing multiline comments in string: First line 10 + * Second line 11 + * 12 + * Fourth line 13 + */ 14 + export type camelCaseCommentWithBreaks = number; 15 + 16 + /** 17 + * Testing multiline comments in string: First line 18 + * Second line 19 + * 20 + * Fourth line 21 + */ 22 + export type CommentWithBreaks = number; 23 + 24 + /** 25 + * Testing backticks in string: `backticks` and ```multiple backticks``` should work 26 + */ 27 + export type CommentWithBackticks = number; 28 + 29 + /** 30 + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work 31 + */ 32 + export type CommentWithBackticksAndQuotes = number; 33 + 34 + /** 35 + * Testing slashes in string: \backwards\\\ and /forwards/// should work 36 + */ 37 + export type CommentWithSlashes = number; 38 + 39 + /** 40 + * Testing expression placeholders in string: ${expression} should work 41 + */ 42 + export type CommentWithExpressionPlaceholders = number; 43 + 44 + /** 45 + * Testing quotes in string: 'single quote''' and "double quotes""" should work 46 + */ 47 + export type CommentWithQuotes = number; 48 + 49 + /** 50 + * Testing reserved characters in string: * inline * and ** inline ** should work 51 + */ 52 + export type CommentWithReservedCharacters = number; 53 + 54 + /** 55 + * This is a simple number 56 + */ 57 + export type SimpleInteger = number; 58 + 59 + /** 60 + * This is a simple boolean 61 + */ 62 + export type SimpleBoolean = boolean; 63 + 64 + /** 65 + * This is a simple string 66 + */ 67 + export type SimpleString = string; 68 + 69 + /** 70 + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) 71 + */ 72 + export type NonAsciiStringæøåÆØÅöôêÊ字符串 = string; 73 + 74 + /** 75 + * This is a simple file 76 + */ 77 + export type SimpleFile = (Blob | File); 78 + 79 + /** 80 + * This is a simple reference 81 + */ 82 + export type SimpleReference = ModelWithString; 83 + 84 + /** 85 + * This is a simple string 86 + */ 87 + export type SimpleStringWithPattern = (string) | null; 88 + 89 + /** 90 + * This is a simple enum with strings 91 + */ 92 + export type EnumWithStrings = 'Success' | 'Warning' | 'Error' | "'Single Quote'" | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; 93 + 94 + export type EnumWithReplacedCharacters = "'Single Quote'" | '"Double Quotes"' | 'øæåôöØÆÅÔÖ字符串' | 3.1 | ''; 95 + 96 + /** 97 + * This is a simple enum with numbers 98 + */ 99 + export type EnumWithNumbers = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; 100 + 101 + /** 102 + * Success=1,Warning=2,Error=3 103 + */ 104 + export type EnumFromDescription = number; 105 + 106 + /** 107 + * This is a simple enum with numbers 108 + */ 109 + export type EnumWithExtensions = 200 | 400 | 500; 110 + 111 + export type EnumWithXEnumNames = 0 | 1 | 2; 112 + 113 + /** 114 + * This is a simple array with numbers 115 + */ 116 + export type ArrayWithNumbers = Array<(number)>; 117 + 118 + /** 119 + * This is a simple array with booleans 120 + */ 121 + export type ArrayWithBooleans = Array<(boolean)>; 122 + 123 + /** 124 + * This is a simple array with strings 125 + */ 126 + export type ArrayWithStrings = Array<(string)>; 127 + 128 + /** 129 + * This is a simple array with references 130 + */ 131 + export type ArrayWithReferences = Array<ModelWithString>; 132 + 133 + /** 134 + * This is a simple array containing an array 135 + */ 136 + export type ArrayWithArray = Array<Array<ModelWithString>>; 137 + 138 + /** 139 + * This is a simple array with properties 140 + */ 141 + export type ArrayWithProperties = Array<{ 142 + '16x16'?: camelCaseCommentWithBreaks; 143 + bar?: string; 144 + }>; 145 + 146 + /** 147 + * This is a simple array with any of properties 148 + */ 149 + export type ArrayWithAnyOfProperties = Array<({ 150 + foo?: string; 151 + } | { 152 + bar?: string; 153 + })>; 154 + 155 + export type AnyOfAnyAndNull = { 156 + data?: (unknown | null); 157 + }; 158 + 159 + /** 160 + * This is a simple array with any of properties 161 + */ 162 + export type AnyOfArrays = { 163 + results?: Array<({ 164 + foo?: string; 165 + } | { 166 + bar?: string; 167 + })>; 168 + }; 169 + 170 + /** 171 + * This is a string dictionary 172 + */ 173 + export type DictionaryWithString = { 174 + [key: string]: (string); 175 + }; 176 + 177 + export type DictionaryWithPropertiesAndAdditionalProperties = { 178 + foo?: number; 179 + bar?: boolean; 180 + [key: string]: (string | number | boolean) | undefined; 181 + }; 182 + 183 + /** 184 + * This is a string reference 185 + */ 186 + export type DictionaryWithReference = { 187 + [key: string]: ModelWithString; 188 + }; 189 + 190 + /** 191 + * This is a complex dictionary 192 + */ 193 + export type DictionaryWithArray = { 194 + [key: string]: Array<ModelWithString>; 195 + }; 196 + 197 + /** 198 + * This is a string dictionary 199 + */ 200 + export type DictionaryWithDictionary = { 201 + [key: string]: { 202 + [key: string]: (string); 203 + }; 204 + }; 205 + 206 + /** 207 + * This is a complex dictionary 208 + */ 209 + export type DictionaryWithProperties = { 210 + [key: string]: { 211 + foo?: string; 212 + bar?: string; 213 + }; 214 + }; 215 + 216 + /** 217 + * This is a model with one number property 218 + */ 219 + export type ModelWithInteger = { 220 + /** 221 + * This is a simple number property 222 + */ 223 + prop?: number; 224 + }; 225 + 226 + /** 227 + * This is a model with one boolean property 228 + */ 229 + export type ModelWithBoolean = { 230 + /** 231 + * This is a simple boolean property 232 + */ 233 + prop?: boolean; 234 + }; 235 + 236 + /** 237 + * This is a model with one string property 238 + */ 239 + export type ModelWithString = { 240 + /** 241 + * This is a simple string property 242 + */ 243 + prop?: string; 244 + }; 245 + 246 + /** 247 + * This is a model with one string property 248 + */ 249 + export type ModelWithStringError = { 250 + /** 251 + * This is a simple string property 252 + */ 253 + prop?: string; 254 + }; 255 + 256 + /** 257 + * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) 258 + */ 259 + export type Model_From_Zendesk = string; 260 + 261 + /** 262 + * This is a model with one string property 263 + */ 264 + export type ModelWithNullableString = { 265 + /** 266 + * This is a simple string property 267 + */ 268 + nullableProp1?: (string) | null; 269 + /** 270 + * This is a simple string property 271 + */ 272 + nullableRequiredProp1: (string) | null; 273 + /** 274 + * This is a simple string property 275 + */ 276 + nullableProp2?: (string) | null; 277 + /** 278 + * This is a simple string property 279 + */ 280 + nullableRequiredProp2: (string) | null; 281 + /** 282 + * This is a simple enum with strings 283 + */ 284 + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; 285 + }; 286 + 287 + /** 288 + * This is a simple enum with strings 289 + */ 290 + export type foo_bar_enum = 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; 291 + 292 + /** 293 + * This is a model with one enum 294 + */ 295 + export type ModelWithEnum = { 296 + /** 297 + * This is a simple enum with strings 298 + */ 299 + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; 300 + /** 301 + * These are the HTTP error code enums 302 + */ 303 + statusCode?: '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; 304 + /** 305 + * Simple boolean enum 306 + */ 307 + bool?: boolean; 308 + }; 309 + 310 + /** 311 + * These are the HTTP error code enums 312 + */ 313 + export type statusCode = '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; 314 + 315 + /** 316 + * This is a model with one enum with escaped name 317 + */ 318 + export type ModelWithEnumWithHyphen = { 319 + 'foo-bar-baz-qux'?: '3.0'; 320 + }; 321 + 322 + export type foo_bar_baz_qux = '3.0'; 323 + 324 + /** 325 + * This is a model with one enum 326 + */ 327 + export type ModelWithEnumFromDescription = { 328 + /** 329 + * Success=1,Warning=2,Error=3 330 + */ 331 + test?: number; 332 + }; 333 + 334 + /** 335 + * This is a model with nested enums 336 + */ 337 + export type ModelWithNestedEnums = { 338 + dictionaryWithEnum?: { 339 + [key: string]: ('Success' | 'Warning' | 'Error'); 340 + }; 341 + dictionaryWithEnumFromDescription?: { 342 + [key: string]: (number); 343 + }; 344 + arrayWithEnum?: Array<('Success' | 'Warning' | 'Error')>; 345 + arrayWithDescription?: Array<(number)>; 346 + /** 347 + * This is a simple enum with strings 348 + */ 349 + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; 350 + }; 351 + 352 + /** 353 + * This is a model with one property containing a reference 354 + */ 355 + export type ModelWithReference = { 356 + prop?: ModelWithProperties; 357 + }; 358 + 359 + /** 360 + * This is a model with one property containing an array 361 + */ 362 + export type ModelWithArrayReadOnlyAndWriteOnly = { 363 + prop?: Array<ModelWithReadOnlyAndWriteOnly>; 364 + propWithFile?: Array<((Blob | File))>; 365 + propWithNumber?: Array<(number)>; 366 + }; 367 + 368 + /** 369 + * This is a model with one property containing an array 370 + */ 371 + export type ModelWithArray = { 372 + prop?: Array<ModelWithString>; 373 + propWithFile?: Array<((Blob | File))>; 374 + propWithNumber?: Array<(number)>; 375 + }; 376 + 377 + /** 378 + * This is a model with one property containing a dictionary 379 + */ 380 + export type ModelWithDictionary = { 381 + prop?: { 382 + [key: string]: (string); 383 + }; 384 + }; 385 + 386 + /** 387 + * This is a deprecated model with a deprecated property 388 + * @deprecated 389 + */ 390 + export type DeprecatedModel = { 391 + /** 392 + * This is a deprecated property 393 + * @deprecated 394 + */ 395 + prop?: string; 396 + }; 397 + 398 + /** 399 + * This is a model with one property containing a circular reference 400 + */ 401 + export type ModelWithCircularReference = { 402 + prop?: ModelWithCircularReference; 403 + }; 404 + 405 + /** 406 + * This is a model with one property with a 'one of' relationship 407 + */ 408 + export type CompositionWithOneOf = { 409 + propA?: (ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary); 410 + }; 411 + 412 + /** 413 + * This is a model with one property with a 'one of' relationship where the options are not $ref 414 + */ 415 + export type CompositionWithOneOfAnonymous = { 416 + propA?: ({ 417 + propA?: string; 418 + } | string | number); 419 + }; 420 + 421 + /** 422 + * Circle 423 + */ 424 + export type ModelCircle = { 425 + kind: 'circle'; 426 + radius?: number; 427 + }; 428 + 429 + /** 430 + * Square 431 + */ 432 + export type ModelSquare = { 433 + kind: 'square'; 434 + sideLength?: number; 435 + }; 436 + 437 + /** 438 + * This is a model with one property with a 'one of' relationship where the options are not $ref 439 + */ 440 + export type CompositionWithOneOfDiscriminator = ModelCircle | ModelSquare; 441 + 442 + /** 443 + * This is a model with one property with a 'any of' relationship 444 + */ 445 + export type CompositionWithAnyOf = { 446 + propA?: (ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary); 447 + }; 448 + 449 + /** 450 + * This is a model with one property with a 'any of' relationship where the options are not $ref 451 + */ 452 + export type CompositionWithAnyOfAnonymous = { 453 + propA?: ({ 454 + propA?: string; 455 + } | string | number); 456 + }; 457 + 458 + /** 459 + * This is a model with nested 'any of' property with a type null 460 + */ 461 + export type CompositionWithNestedAnyAndTypeNull = { 462 + propA?: (Array<(ModelWithDictionary | null)> | Array<(ModelWithArray | null)>); 463 + }; 464 + 465 + export type _3e_num_1Период = 'Bird' | 'Dog'; 466 + 467 + export type ConstValue = "ConstValue"; 468 + 469 + /** 470 + * This is a model with one property with a 'any of' relationship where the options are not $ref 471 + */ 472 + export type CompositionWithNestedAnyOfAndNull = { 473 + propA?: (Array<(_3e_num_1Период | ConstValue)> | null); 474 + }; 475 + 476 + /** 477 + * This is a model with one property with a 'one of' relationship 478 + */ 479 + export type CompositionWithOneOfAndNullable = { 480 + propA?: (({ 481 + boolean?: boolean; 482 + } | ModelWithEnum | ModelWithArray | ModelWithDictionary) | null); 483 + }; 484 + 485 + /** 486 + * This is a model that contains a simple dictionary within composition 487 + */ 488 + export type CompositionWithOneOfAndSimpleDictionary = { 489 + propA?: (boolean | { 490 + [key: string]: (number); 491 + }); 492 + }; 493 + 494 + /** 495 + * This is a model that contains a dictionary of simple arrays within composition 496 + */ 497 + export type CompositionWithOneOfAndSimpleArrayDictionary = { 498 + propA?: (boolean | { 499 + [key: string]: Array<(boolean)>; 500 + }); 501 + }; 502 + 503 + /** 504 + * This is a model that contains a dictionary of complex arrays (composited) within composition 505 + */ 506 + export type CompositionWithOneOfAndComplexArrayDictionary = { 507 + propA?: (boolean | { 508 + [key: string]: Array<(number | string)>; 509 + }); 510 + }; 511 + 512 + /** 513 + * This is a model with one property with a 'all of' relationship 514 + */ 515 + export type CompositionWithAllOfAndNullable = { 516 + propA?: (({ 517 + boolean?: boolean; 518 + } & ModelWithEnum & ModelWithArray & ModelWithDictionary) | null); 519 + }; 520 + 521 + /** 522 + * This is a model with one property with a 'any of' relationship 523 + */ 524 + export type CompositionWithAnyOfAndNullable = { 525 + propA?: (({ 526 + boolean?: boolean; 527 + } | ModelWithEnum | ModelWithArray | ModelWithDictionary) | null); 528 + }; 529 + 530 + /** 531 + * This is a base model with two simple optional properties 532 + */ 533 + export type CompositionBaseModel = { 534 + firstName?: string; 535 + lastname?: string; 536 + }; 537 + 538 + /** 539 + * This is a model that extends the base model 540 + */ 541 + export type CompositionExtendedModel = CompositionBaseModel & { 542 + firstName: string; 543 + lastname: string; 544 + age: number; 545 + }; 546 + 547 + /** 548 + * This is a model with one nested property 549 + */ 550 + export type ModelWithProperties = { 551 + required: string; 552 + readonly requiredAndReadOnly: string; 553 + requiredAndNullable: (string) | null; 554 + string?: string; 555 + number?: number; 556 + boolean?: boolean; 557 + reference?: ModelWithString; 558 + 'property with space'?: string; 559 + default?: string; 560 + try?: string; 561 + readonly '@namespace.string'?: string; 562 + readonly '@namespace.integer'?: number; 563 + }; 564 + 565 + /** 566 + * This is a model with one nested property 567 + */ 568 + export type ModelWithNestedProperties = { 569 + readonly first: { 570 + readonly second: { 571 + readonly third: (string) | null; 572 + } | null; 573 + } | null; 574 + }; 575 + 576 + /** 577 + * This is a model with duplicated properties 578 + */ 579 + export type ModelWithDuplicateProperties = { 580 + prop?: ModelWithString; 581 + }; 582 + 583 + /** 584 + * This is a model with ordered properties 585 + */ 586 + export type ModelWithOrderedProperties = { 587 + zebra?: string; 588 + apple?: string; 589 + hawaii?: string; 590 + }; 591 + 592 + /** 593 + * This is a model with duplicated imports 594 + */ 595 + export type ModelWithDuplicateImports = { 596 + propA?: ModelWithString; 597 + propB?: ModelWithString; 598 + propC?: ModelWithString; 599 + }; 600 + 601 + /** 602 + * This is a model that extends another model 603 + */ 604 + export type ModelThatExtends = ModelWithString & { 605 + propExtendsA?: string; 606 + propExtendsB?: ModelWithString; 607 + }; 608 + 609 + /** 610 + * This is a model that extends another model 611 + */ 612 + export type ModelThatExtendsExtends = ModelWithString & ModelThatExtends & { 613 + propExtendsC?: string; 614 + propExtendsD?: ModelWithString; 615 + }; 616 + 617 + /** 618 + * This is a model that contains a some patterns 619 + */ 620 + export type ModelWithPattern = { 621 + key: string; 622 + name: string; 623 + readonly enabled?: boolean; 624 + readonly modified?: string; 625 + id?: string; 626 + text?: string; 627 + patternWithSingleQuotes?: string; 628 + patternWithNewline?: string; 629 + patternWithBacktick?: string; 630 + }; 631 + 632 + export type File = { 633 + readonly id?: string; 634 + readonly updated_at?: string; 635 + readonly created_at?: string; 636 + mime: string; 637 + readonly file?: string; 638 + }; 639 + 640 + export type _default = { 641 + name?: string; 642 + }; 643 + 644 + export type Pageable = { 645 + page?: number; 646 + size?: number; 647 + sort?: Array<(string)>; 648 + }; 649 + 650 + /** 651 + * This is a free-form object without additionalProperties. 652 + */ 653 + export type FreeFormObjectWithoutAdditionalProperties = { 654 + [key: string]: unknown; 655 + }; 656 + 657 + /** 658 + * This is a free-form object with additionalProperties: true. 659 + */ 660 + export type FreeFormObjectWithAdditionalPropertiesEqTrue = { 661 + [key: string]: unknown; 662 + }; 663 + 664 + /** 665 + * This is a free-form object with additionalProperties: {}. 666 + */ 667 + export type FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { 668 + [key: string]: unknown; 669 + }; 670 + 671 + export type ModelWithConst = { 672 + String?: "String"; 673 + number?: 0; 674 + null?: null; 675 + withType?: "Some string"; 676 + }; 677 + 678 + /** 679 + * This is a model with one property and additionalProperties: true 680 + */ 681 + export type ModelWithAdditionalPropertiesEqTrue = { 682 + /** 683 + * This is a simple string property 684 + */ 685 + prop?: string; 686 + [key: string]: unknown | string; 687 + }; 688 + 689 + export type NestedAnyOfArraysNullable = { 690 + nullableArray?: (Array<(string | boolean)> | null); 691 + }; 692 + 693 + export type CompositionWithOneOfAndProperties = ({ 694 + foo: ParameterSimpleParameter; 695 + } | { 696 + bar: NonAsciiStringæøåÆØÅöôêÊ字符串; 697 + }) & { 698 + baz: (number) | null; 699 + qux: number; 700 + }; 701 + 702 + /** 703 + * An object that can be null 704 + */ 705 + export type NullableObject = { 706 + foo?: string; 707 + } | null; 708 + 709 + /** 710 + * Some % character 711 + */ 712 + export type CharactersInDescription = string; 713 + 714 + export type ModelWithNullableObject = { 715 + data?: NullableObject; 716 + }; 717 + 718 + export type ModelWithOneOfEnum = { 719 + foo: 'Bar'; 720 + } | { 721 + foo: 'Baz'; 722 + } | { 723 + foo: 'Qux'; 724 + } | { 725 + content: string; 726 + foo: 'Quux'; 727 + } | { 728 + content: [ 729 + (string), 730 + (string) 731 + ]; 732 + foo: 'Corge'; 733 + }; 734 + 735 + export type foo = 'Bar'; 736 + 737 + export type ModelWithNestedArrayEnumsDataFoo = 'foo' | 'bar'; 738 + 739 + export type ModelWithNestedArrayEnumsDataBar = 'baz' | 'qux'; 740 + 741 + export type ModelWithNestedArrayEnumsData = { 742 + foo?: Array<ModelWithNestedArrayEnumsDataFoo>; 743 + bar?: Array<ModelWithNestedArrayEnumsDataBar>; 744 + }; 745 + 746 + export type ModelWithNestedArrayEnums = { 747 + array_strings?: Array<(string)>; 748 + data?: (ModelWithNestedArrayEnumsData); 749 + }; 750 + 751 + export type ModelWithNestedCompositionEnums = { 752 + foo?: (ModelWithNestedArrayEnumsDataFoo); 753 + }; 754 + 755 + export type ModelWithReadOnlyAndWriteOnly = { 756 + foo: string; 757 + readonly bar: string; 758 + baz: string; 759 + }; 760 + 761 + export type ModelWithConstantSizeArray = [ 762 + number, 763 + number 764 + ]; 765 + 766 + export type ModelWithAnyOfConstantSizeArray = [ 767 + (number | string), 768 + (number | string), 769 + (number | string) 770 + ]; 771 + 772 + export type ModelWithPrefixItemsConstantSizeArray = [ 773 + ModelWithInteger, 774 + (number | string), 775 + string 776 + ]; 777 + 778 + export type ModelWithAnyOfConstantSizeArrayNullable = [ 779 + ((number) | null | string), 780 + ((number) | null | string), 781 + ((number) | null | string) 782 + ]; 783 + 784 + export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ 785 + (number | _import), 786 + (number | _import) 787 + ]; 788 + 789 + export type ModelWithAnyOfConstantSizeArrayAndIntersect = [ 790 + (number & string), 791 + (number & string) 792 + ]; 793 + 794 + export type ModelWithNumericEnumUnion = { 795 + /** 796 + * Период 797 + */ 798 + value?: -10 | -1 | 0 | 1 | 3 | 6 | 12; 799 + }; 800 + 801 + /** 802 + * Период 803 + */ 804 + export type value = -10 | -1 | 0 | 1 | 3 | 6 | 12; 805 + 806 + /** 807 + * Some description with `back ticks` 808 + */ 809 + export type ModelWithBackticksInDescription = { 810 + /** 811 + * The template `that` should be used for parsing and importing the contents of the CSV file. 812 + * 813 + * <br/><p>There is one placeholder currently supported:<ul> <li><b>${x}</b> - refers to the n-th column in the CSV file, e.g. ${1}, ${2}, ...)</li></ul><p>Example of a correct JSON template:</p> 814 + * <pre> 815 + * [ 816 + * { 817 + * "resourceType": "Asset", 818 + * "identifier": { 819 + * "name": "${1}", 820 + * "domain": { 821 + * "name": "${2}", 822 + * "community": { 823 + * "name": "Some Community" 824 + * } 825 + * } 826 + * }, 827 + * "attributes" : { 828 + * "00000000-0000-0000-0000-000000003115" : [ { 829 + * "value" : "${3}" 830 + * } ], 831 + * "00000000-0000-0000-0000-000000000222" : [ { 832 + * "value" : "${4}" 833 + * } ] 834 + * } 835 + * } 836 + * ] 837 + * </pre> 838 + */ 839 + template?: string; 840 + }; 841 + 842 + export type ModelWithOneOfAndProperties = (ParameterSimpleParameter | NonAsciiStringæøåÆØÅöôêÊ字符串) & { 843 + baz: (number) | null; 844 + qux: number; 845 + }; 846 + 847 + /** 848 + * Model used to test deduplication strategy (unused) 849 + */ 850 + export type ParameterSimpleParameterUnused = string; 851 + 852 + /** 853 + * Model used to test deduplication strategy 854 + */ 855 + export type PostServiceWithEmptyTagResponse = string; 856 + 857 + /** 858 + * Model used to test deduplication strategy 859 + */ 860 + export type PostServiceWithEmptyTagResponse2 = string; 861 + 862 + /** 863 + * Model used to test deduplication strategy 864 + */ 865 + export type DeleteFooData = string; 866 + 867 + /** 868 + * Model used to test deduplication strategy 869 + */ 870 + export type DeleteFooData2 = string; 871 + 872 + /** 873 + * Model with restricted keyword name 874 + */ 875 + export type _import = string; 876 + 877 + export type SchemaWithFormRestrictedKeys = { 878 + description?: string; 879 + 'x-enum-descriptions'?: string; 880 + 'x-enum-varnames'?: string; 881 + 'x-enumNames'?: string; 882 + title?: string; 883 + object?: { 884 + description?: string; 885 + 'x-enum-descriptions'?: string; 886 + 'x-enum-varnames'?: string; 887 + 'x-enumNames'?: string; 888 + title?: string; 889 + }; 890 + array?: Array<({ 891 + description?: string; 892 + 'x-enum-descriptions'?: string; 893 + 'x-enum-varnames'?: string; 894 + 'x-enumNames'?: string; 895 + title?: string; 896 + })>; 897 + }; 898 + 899 + /** 900 + * This schema was giving PascalCase transformations a hard time 901 + */ 902 + export type io_k8s_apimachinery_pkg_apis_meta_v1_DeleteOptions = { 903 + /** 904 + * Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned. 905 + */ 906 + preconditions?: (io_k8s_apimachinery_pkg_apis_meta_v1_Preconditions); 907 + }; 908 + 909 + /** 910 + * This schema was giving PascalCase transformations a hard time 911 + */ 912 + export type io_k8s_apimachinery_pkg_apis_meta_v1_Preconditions = { 913 + /** 914 + * Specifies the target ResourceVersion 915 + */ 916 + resourceVersion?: string; 917 + /** 918 + * Specifies the target UID. 919 + */ 920 + uid?: string; 921 + }; 922 + 923 + export type AdditionalPropertiesUnknownIssue = { 924 + [key: string]: (string | number); 925 + }; 926 + 927 + export type AdditionalPropertiesUnknownIssue2 = { 928 + [key: string]: (string | number); 929 + }; 930 + 931 + export type AdditionalPropertiesUnknownIssue3 = string & { 932 + entries: { 933 + [key: string]: AdditionalPropertiesUnknownIssue; 934 + }; 935 + }; 936 + 937 + export type AdditionalPropertiesIntegerIssue = { 938 + value: number; 939 + [key: string]: (number) | undefined; 940 + }; 941 + 942 + export type OneOfAllOfIssue = ((ConstValue | Generic_Schema_Duplicate_Issue_1_System_Boolean_) & _3e_num_1Период) | Generic_Schema_Duplicate_Issue_1_System_String_; 943 + 944 + export type Generic_Schema_Duplicate_Issue_1_System_Boolean_ = { 945 + item?: boolean; 946 + error?: (string) | null; 947 + readonly hasError?: boolean; 948 + }; 949 + 950 + export type Generic_Schema_Duplicate_Issue_1_System_String_ = { 951 + item?: (string) | null; 952 + error?: (string) | null; 953 + readonly hasError?: boolean; 954 + }; 955 + 956 + /** 957 + * This is a reusable parameter 958 + */ 959 + export type ParameterSimpleParameter = string; 960 + 961 + /** 962 + * Parameter with illegal characters 963 + */ 964 + export type Parameterx_Foo_Bar = ModelWithString; 965 + 966 + export type ImportData = { 967 + requestBody: (ModelWithReadOnlyAndWriteOnly | ModelWithArrayReadOnlyAndWriteOnly); 968 + }; 969 + 970 + export type ImportResponse = (Model_From_Zendesk | ModelWithReadOnlyAndWriteOnly); 971 + 972 + export type ApiVversionOdataControllerCountResponse = (Model_From_Zendesk); 973 + 974 + export type DeleteFooData3 = { 975 + /** 976 + * bar in method 977 + */ 978 + barParam: string; 979 + /** 980 + * foo in method 981 + */ 982 + fooParam: string; 983 + /** 984 + * Parameter with illegal characters 985 + */ 986 + xFooBar: ModelWithString; 987 + }; 988 + 989 + export type CallWithDescriptionsData = { 990 + /** 991 + * Testing backticks in string: `backticks` and ```multiple backticks``` should work 992 + */ 993 + parameterWithBackticks?: unknown; 994 + /** 995 + * Testing multiline comments in string: First line 996 + * Second line 997 + * 998 + * Fourth line 999 + */ 1000 + parameterWithBreaks?: unknown; 1001 + /** 1002 + * Testing expression placeholders in string: ${expression} should work 1003 + */ 1004 + parameterWithExpressionPlaceholders?: unknown; 1005 + /** 1006 + * Testing quotes in string: 'single quote''' and "double quotes""" should work 1007 + */ 1008 + parameterWithQuotes?: unknown; 1009 + /** 1010 + * Testing reserved characters in string: * inline * and ** inline ** should work 1011 + */ 1012 + parameterWithReservedCharacters?: unknown; 1013 + /** 1014 + * Testing slashes in string: \backwards\\\ and /forwards/// should work 1015 + */ 1016 + parameterWithSlashes?: unknown; 1017 + }; 1018 + 1019 + export type DeprecatedCallData = { 1020 + /** 1021 + * This parameter is deprecated 1022 + * @deprecated 1023 + */ 1024 + parameter: (DeprecatedModel) | null; 1025 + }; 1026 + 1027 + export type CallWithParametersData = { 1028 + /** 1029 + * This is the parameter that goes into the query params 1030 + */ 1031 + cursor: (string) | null; 1032 + fooAllOfEnum: (ModelWithNestedArrayEnumsDataFoo); 1033 + fooRefEnum?: ModelWithNestedArrayEnumsDataFoo; 1034 + /** 1035 + * This is the parameter that goes into the cookie 1036 + */ 1037 + parameterCookie: (string) | null; 1038 + /** 1039 + * This is the parameter that goes into the header 1040 + */ 1041 + parameterHeader: (string) | null; 1042 + /** 1043 + * This is the parameter that goes into the path 1044 + */ 1045 + parameterPath: (string) | null; 1046 + /** 1047 + * This is the parameter that goes into the body 1048 + */ 1049 + requestBody: { 1050 + [key: string]: unknown; 1051 + } | null; 1052 + }; 1053 + 1054 + export type CallWithWeirdParameterNamesData = { 1055 + /** 1056 + * This is the parameter with a reserved keyword 1057 + */ 1058 + _default?: string; 1059 + /** 1060 + * This is the parameter that goes into the cookie 1061 + */ 1062 + parameterCookie: (string) | null; 1063 + /** 1064 + * This is the parameter that goes into the request header 1065 + */ 1066 + parameterHeader: (string) | null; 1067 + /** 1068 + * This is the parameter that goes into the path 1069 + */ 1070 + parameterPath1?: string; 1071 + /** 1072 + * This is the parameter that goes into the path 1073 + */ 1074 + parameterPath2?: string; 1075 + /** 1076 + * This is the parameter that goes into the path 1077 + */ 1078 + parameterPath3?: string; 1079 + /** 1080 + * This is the parameter that goes into the request query params 1081 + */ 1082 + parameterQuery: (string) | null; 1083 + /** 1084 + * This is the parameter that goes into the body 1085 + */ 1086 + requestBody: (ModelWithString) | null; 1087 + }; 1088 + 1089 + export type GetCallWithOptionalParamData = { 1090 + /** 1091 + * This is an optional parameter 1092 + */ 1093 + page?: number; 1094 + /** 1095 + * This is a required parameter 1096 + */ 1097 + requestBody: ModelWithOneOfEnum; 1098 + }; 1099 + 1100 + export type PostCallWithOptionalParamData = { 1101 + /** 1102 + * This is a required parameter 1103 + */ 1104 + parameter: Pageable; 1105 + /** 1106 + * This is an optional parameter 1107 + */ 1108 + requestBody?: { 1109 + offset?: (number) | null; 1110 + }; 1111 + }; 1112 + 1113 + export type PostCallWithOptionalParamResponse = (number | void); 1114 + 1115 + export type PostApiRequestBodyData = { 1116 + /** 1117 + * A reusable request body 1118 + */ 1119 + foo?: ModelWithString; 1120 + /** 1121 + * This is a reusable parameter 1122 + */ 1123 + parameter?: string; 1124 + }; 1125 + 1126 + export type PostApiFormDataData = { 1127 + /** 1128 + * A reusable request body 1129 + */ 1130 + formData?: ModelWithString; 1131 + /** 1132 + * This is a reusable parameter 1133 + */ 1134 + parameter?: string; 1135 + }; 1136 + 1137 + export type CallWithDefaultParametersData = { 1138 + /** 1139 + * This is a simple boolean with default value 1140 + */ 1141 + parameterBoolean?: (boolean) | null; 1142 + /** 1143 + * This is a simple enum with default value 1144 + */ 1145 + parameterEnum?: 'Success' | 'Warning' | 'Error'; 1146 + /** 1147 + * This is a simple model with default value 1148 + */ 1149 + parameterModel?: (ModelWithString) | null; 1150 + /** 1151 + * This is a simple number with default value 1152 + */ 1153 + parameterNumber?: (number) | null; 1154 + /** 1155 + * This is a simple string with default value 1156 + */ 1157 + parameterString?: (string) | null; 1158 + }; 1159 + 1160 + export type CallWithDefaultOptionalParametersData = { 1161 + /** 1162 + * This is a simple boolean that is optional with default value 1163 + */ 1164 + parameterBoolean?: boolean; 1165 + /** 1166 + * This is a simple enum that is optional with default value 1167 + */ 1168 + parameterEnum?: 'Success' | 'Warning' | 'Error'; 1169 + /** 1170 + * This is a simple model that is optional with default value 1171 + */ 1172 + parameterModel?: ModelWithString; 1173 + /** 1174 + * This is a simple number that is optional with default value 1175 + */ 1176 + parameterNumber?: number; 1177 + /** 1178 + * This is a simple string that is optional with default value 1179 + */ 1180 + parameterString?: string; 1181 + }; 1182 + 1183 + export type CallToTestOrderOfParamsData = { 1184 + /** 1185 + * This is a optional string with default 1186 + */ 1187 + parameterOptionalStringWithDefault?: string; 1188 + /** 1189 + * This is a optional string with empty default 1190 + */ 1191 + parameterOptionalStringWithEmptyDefault?: string; 1192 + /** 1193 + * This is a optional string with no default 1194 + */ 1195 + parameterOptionalStringWithNoDefault?: string; 1196 + /** 1197 + * This is a string that can be null with default 1198 + */ 1199 + parameterStringNullableWithDefault?: (string) | null; 1200 + /** 1201 + * This is a string that can be null with no default 1202 + */ 1203 + parameterStringNullableWithNoDefault?: (string) | null; 1204 + /** 1205 + * This is a string with default 1206 + */ 1207 + parameterStringWithDefault: string; 1208 + /** 1209 + * This is a string with empty default 1210 + */ 1211 + parameterStringWithEmptyDefault: string; 1212 + /** 1213 + * This is a string with no default 1214 + */ 1215 + parameterStringWithNoDefault: string; 1216 + }; 1217 + 1218 + export type CallWithNoContentResponseResponse = (void); 1219 + 1220 + export type CallWithResponseAndNoContentResponseResponse = (number | void); 1221 + 1222 + export type DummyAResponse = (_400); 1223 + 1224 + export type DummyBResponse = (void); 1225 + 1226 + export type CallWithResponseResponse = (_import); 1227 + 1228 + export type CallWithDuplicateResponsesResponse = ((ModelWithBoolean & ModelWithInteger) | ModelWithString); 1229 + 1230 + export type CallWithResponsesResponse = ({ 1231 + readonly '@namespace.string'?: string; 1232 + readonly '@namespace.integer'?: number; 1233 + readonly value?: Array<ModelWithString>; 1234 + } | ModelThatExtends | ModelThatExtendsExtends); 1235 + 1236 + export type CollectionFormatData = { 1237 + /** 1238 + * This is an array parameter that is sent as csv format (comma-separated values) 1239 + */ 1240 + parameterArrayCsv: Array<(string)> | null; 1241 + /** 1242 + * This is an array parameter that is sent as multi format (multiple parameter instances) 1243 + */ 1244 + parameterArrayMulti: Array<(string)> | null; 1245 + /** 1246 + * This is an array parameter that is sent as pipes format (pipe-separated values) 1247 + */ 1248 + parameterArrayPipes: Array<(string)> | null; 1249 + /** 1250 + * This is an array parameter that is sent as ssv format (space-separated values) 1251 + */ 1252 + parameterArraySsv: Array<(string)> | null; 1253 + /** 1254 + * This is an array parameter that is sent as tsv format (tab-separated values) 1255 + */ 1256 + parameterArrayTsv: Array<(string)> | null; 1257 + }; 1258 + 1259 + export type TypesData = { 1260 + /** 1261 + * This is a number parameter 1262 + */ 1263 + id?: number; 1264 + /** 1265 + * This is an array parameter 1266 + */ 1267 + parameterArray: Array<(string)> | null; 1268 + /** 1269 + * This is a boolean parameter 1270 + */ 1271 + parameterBoolean: (boolean) | null; 1272 + /** 1273 + * This is a dictionary parameter 1274 + */ 1275 + parameterDictionary: { 1276 + [key: string]: unknown; 1277 + } | null; 1278 + /** 1279 + * This is an enum parameter 1280 + */ 1281 + parameterEnum: ('Success' | 'Warning' | 'Error') | null; 1282 + /** 1283 + * This is a number parameter 1284 + */ 1285 + parameterNumber: number; 1286 + /** 1287 + * This is an object parameter 1288 + */ 1289 + parameterObject: { 1290 + [key: string]: unknown; 1291 + } | null; 1292 + /** 1293 + * This is a string parameter 1294 + */ 1295 + parameterString: (string) | null; 1296 + }; 1297 + 1298 + export type TypesResponse = (number | string | boolean | { 1299 + [key: string]: unknown; 1300 + }); 1301 + 1302 + export type UploadFileData = { 1303 + formData: (Blob | File); 1304 + }; 1305 + 1306 + export type UploadFileResponse = (boolean); 1307 + 1308 + export type FileResponseData = { 1309 + id: string; 1310 + }; 1311 + 1312 + export type FileResponseResponse = ((Blob | File)); 1313 + 1314 + export type ComplexTypesData = { 1315 + /** 1316 + * Parameter containing object 1317 + */ 1318 + parameterObject: { 1319 + first?: { 1320 + second?: { 1321 + third?: string; 1322 + }; 1323 + }; 1324 + }; 1325 + /** 1326 + * Parameter containing reference 1327 + */ 1328 + parameterReference: ModelWithString; 1329 + }; 1330 + 1331 + export type ComplexTypesResponse = (Array<ModelWithString>); 1332 + 1333 + export type MultipartRequestData = { 1334 + formData?: { 1335 + content?: (Blob | File); 1336 + data?: ((ModelWithString) | null); 1337 + }; 1338 + }; 1339 + 1340 + export type MultipartResponseResponse = ({ 1341 + file?: (Blob | File); 1342 + metadata?: { 1343 + foo?: string; 1344 + bar?: string; 1345 + }; 1346 + }); 1347 + 1348 + export type ComplexParamsData = { 1349 + id: number; 1350 + requestBody?: { 1351 + readonly key: (string) | null; 1352 + name: (string) | null; 1353 + enabled?: boolean; 1354 + readonly type: 'Monkey' | 'Horse' | 'Bird'; 1355 + listOfModels?: Array<ModelWithString> | null; 1356 + listOfStrings?: Array<(string)> | null; 1357 + parameters: (ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary); 1358 + readonly user?: { 1359 + readonly id?: number; 1360 + readonly name?: (string) | null; 1361 + }; 1362 + }; 1363 + }; 1364 + 1365 + export type ComplexParamsResponse = (ModelWithString); 1366 + 1367 + export type CallWithResultFromHeaderResponse = (string); 1368 + 1369 + export type TestErrorCodeData = { 1370 + /** 1371 + * Status code to return 1372 + */ 1373 + status: number; 1374 + }; 1375 + 1376 + export type TestErrorCodeResponse = (unknown); 1377 + 1378 + export type NonAsciiæøåÆøÅöôêÊ字符串Data = { 1379 + /** 1380 + * Dummy input param 1381 + */ 1382 + nonAsciiParamæøåÆøÅöôêÊ: number; 1383 + }; 1384 + 1385 + export type NonAsciiæøåÆøÅöôêÊ字符串Response = (Array<NonAsciiStringæøåÆØÅöôêÊ字符串>); 1386 + 1387 + export type PutWithFormUrlEncodedData = { 1388 + formData: ArrayWithStrings; 1389 + };
+21
packages/openapi-ts/test/__snapshots__/test/generated/v3_angular_tree_shakeable_transform/core/ApiError.ts.snap
··· 1 + import type { ApiRequestOptions } from './ApiRequestOptions'; 2 + import type { ApiResult } from './ApiResult'; 3 + 4 + export class ApiError extends Error { 5 + public readonly url: string; 6 + public readonly status: number; 7 + public readonly statusText: string; 8 + public readonly body: unknown; 9 + public readonly request: ApiRequestOptions; 10 + 11 + constructor(request: ApiRequestOptions, response: ApiResult, message: string) { 12 + super(message); 13 + 14 + this.name = 'ApiError'; 15 + this.url = response.url; 16 + this.status = response.status; 17 + this.statusText = response.statusText; 18 + this.body = response.body; 19 + this.request = request; 20 + } 21 + }
+21
packages/openapi-ts/test/__snapshots__/test/generated/v3_angular_tree_shakeable_transform/core/ApiRequestOptions.ts.snap
··· 1 + export type ApiRequestOptions<T = unknown> = { 2 + readonly body?: any; 3 + readonly cookies?: Record<string, unknown>; 4 + readonly errors?: Record<number | string, string>; 5 + readonly formData?: Record<string, unknown> | any[] | Blob | File; 6 + readonly headers?: Record<string, unknown>; 7 + readonly mediaType?: string; 8 + readonly method: 9 + | 'DELETE' 10 + | 'GET' 11 + | 'HEAD' 12 + | 'OPTIONS' 13 + | 'PATCH' 14 + | 'POST' 15 + | 'PUT'; 16 + readonly path?: Record<string, unknown>; 17 + readonly query?: Record<string, unknown>; 18 + readonly responseHeader?: string; 19 + readonly responseTransformer?: (data: unknown) => Promise<T>; 20 + readonly url: string; 21 + };
+7
packages/openapi-ts/test/__snapshots__/test/generated/v3_angular_tree_shakeable_transform/core/ApiResult.ts.snap
··· 1 + export type ApiResult<TData = any> = { 2 + readonly body: TData; 3 + readonly ok: boolean; 4 + readonly status: number; 5 + readonly statusText: string; 6 + readonly url: string; 7 + };
+55
packages/openapi-ts/test/__snapshots__/test/generated/v3_angular_tree_shakeable_transform/core/OpenAPI.ts.snap
··· 1 + import type { HttpResponse } from '@angular/common/http'; 2 + import type { ApiRequestOptions } from './ApiRequestOptions'; 3 + 4 + type Headers = Record<string, string>; 5 + type Middleware<T> = (value: T) => T | Promise<T>; 6 + type Resolver<T> = (options: ApiRequestOptions<T>) => Promise<T>; 7 + 8 + export class Interceptors<T> { 9 + _fns: Middleware<T>[]; 10 + 11 + constructor() { 12 + this._fns = []; 13 + } 14 + 15 + eject(fn: Middleware<T>): void { 16 + const index = this._fns.indexOf(fn); 17 + if (index !== -1) { 18 + this._fns = [...this._fns.slice(0, index), ...this._fns.slice(index + 1)]; 19 + } 20 + } 21 + 22 + use(fn: Middleware<T>): void { 23 + this._fns = [...this._fns, fn]; 24 + } 25 + } 26 + 27 + export type OpenAPIConfig = { 28 + BASE: string; 29 + CREDENTIALS: 'include' | 'omit' | 'same-origin'; 30 + ENCODE_PATH?: ((path: string) => string) | undefined; 31 + HEADERS?: Headers | Resolver<Headers> | undefined; 32 + PASSWORD?: string | Resolver<string> | undefined; 33 + TOKEN?: string | Resolver<string> | undefined; 34 + USERNAME?: string | Resolver<string> | undefined; 35 + VERSION: string; 36 + WITH_CREDENTIALS: boolean; 37 + interceptors: { 38 + response: Interceptors<HttpResponse<any>>; 39 + }; 40 + }; 41 + 42 + export const OpenAPI: OpenAPIConfig = { 43 + BASE: 'http://localhost:3000/base', 44 + CREDENTIALS: 'include', 45 + ENCODE_PATH: undefined, 46 + HEADERS: undefined, 47 + PASSWORD: undefined, 48 + TOKEN: undefined, 49 + USERNAME: undefined, 50 + VERSION: '1.0', 51 + WITH_CREDENTIALS: false, 52 + interceptors: { 53 + response: new Interceptors(), 54 + }, 55 + };
+337
packages/openapi-ts/test/__snapshots__/test/generated/v3_angular_tree_shakeable_transform/core/request.ts.snap
··· 1 + import { HttpClient, HttpHeaders } from '@angular/common/http'; 2 + import type { HttpResponse, HttpErrorResponse } from '@angular/common/http'; 3 + import { forkJoin, of, throwError } from 'rxjs'; 4 + import { catchError, map, switchMap } from 'rxjs/operators'; 5 + import type { Observable } from 'rxjs'; 6 + 7 + import { ApiError } from './ApiError'; 8 + import type { ApiRequestOptions } from './ApiRequestOptions'; 9 + import type { ApiResult } from './ApiResult'; 10 + import type { OpenAPIConfig } from './OpenAPI'; 11 + 12 + export const isString = (value: unknown): value is string => { 13 + return typeof value === 'string'; 14 + }; 15 + 16 + export const isStringWithValue = (value: unknown): value is string => { 17 + return isString(value) && value !== ''; 18 + }; 19 + 20 + export const isBlob = (value: any): value is Blob => { 21 + return value instanceof Blob; 22 + }; 23 + 24 + export const isFormData = (value: unknown): value is FormData => { 25 + return value instanceof FormData; 26 + }; 27 + 28 + export const base64 = (str: string): string => { 29 + try { 30 + return btoa(str); 31 + } catch (err) { 32 + // @ts-ignore 33 + return Buffer.from(str).toString('base64'); 34 + } 35 + }; 36 + 37 + export const getQueryString = (params: Record<string, unknown>): string => { 38 + const qs: string[] = []; 39 + 40 + const append = (key: string, value: unknown) => { 41 + qs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`); 42 + }; 43 + 44 + const encodePair = (key: string, value: unknown) => { 45 + if (value === undefined || value === null) { 46 + return; 47 + } 48 + 49 + if (value instanceof Date) { 50 + append(key, value.toISOString()); 51 + } else if (Array.isArray(value)) { 52 + value.forEach(v => encodePair(key, v)); 53 + } else if (typeof value === 'object') { 54 + Object.entries(value).forEach(([k, v]) => encodePair(`${key}[${k}]`, v)); 55 + } else { 56 + append(key, value); 57 + } 58 + }; 59 + 60 + Object.entries(params).forEach(([key, value]) => encodePair(key, value)); 61 + 62 + return qs.length ? `?${qs.join('&')}` : ''; 63 + }; 64 + 65 + const getUrl = (config: OpenAPIConfig, options: ApiRequestOptions): string => { 66 + const encoder = config.ENCODE_PATH || encodeURI; 67 + 68 + const path = options.url 69 + .replace('{api-version}', config.VERSION) 70 + .replace(/{(.*?)}/g, (substring: string, group: string) => { 71 + if (options.path?.hasOwnProperty(group)) { 72 + return encoder(String(options.path[group])); 73 + } 74 + return substring; 75 + }); 76 + 77 + const url = config.BASE + path; 78 + return options.query ? url + getQueryString(options.query) : url; 79 + }; 80 + 81 + export const getFormData = (options: ApiRequestOptions): FormData | undefined => { 82 + if (options.formData) { 83 + const formData = new FormData(); 84 + 85 + const process = (key: string, value: unknown) => { 86 + if (isString(value) || isBlob(value)) { 87 + formData.append(key, value); 88 + } else { 89 + formData.append(key, JSON.stringify(value)); 90 + } 91 + }; 92 + 93 + Object.entries(options.formData) 94 + .filter(([, value]) => value !== undefined && value !== null) 95 + .forEach(([key, value]) => { 96 + if (Array.isArray(value)) { 97 + value.forEach(v => process(key, v)); 98 + } else { 99 + process(key, value); 100 + } 101 + }); 102 + 103 + return formData; 104 + } 105 + return undefined; 106 + }; 107 + 108 + type Resolver<T> = (options: ApiRequestOptions<T>) => Promise<T>; 109 + 110 + export const resolve = async <T>(options: ApiRequestOptions<T>, resolver?: T | Resolver<T>): Promise<T | undefined> => { 111 + if (typeof resolver === 'function') { 112 + return (resolver as Resolver<T>)(options); 113 + } 114 + return resolver; 115 + }; 116 + 117 + export const getHeaders = <T>(config: OpenAPIConfig, options: ApiRequestOptions<T>): Observable<HttpHeaders> => { 118 + return forkJoin({ 119 + // @ts-ignore 120 + token: resolve(options, config.TOKEN), 121 + // @ts-ignore 122 + username: resolve(options, config.USERNAME), 123 + // @ts-ignore 124 + password: resolve(options, config.PASSWORD), 125 + // @ts-ignore 126 + additionalHeaders: resolve(options, config.HEADERS), 127 + }).pipe( 128 + map(({ token, username, password, additionalHeaders }) => { 129 + const headers = Object.entries({ 130 + Accept: 'application/json', 131 + ...additionalHeaders, 132 + ...options.headers, 133 + }) 134 + .filter(([, value]) => value !== undefined && value !== null) 135 + .reduce((headers, [key, value]) => ({ 136 + ...headers, 137 + [key]: String(value), 138 + }), {} as Record<string, string>); 139 + 140 + if (isStringWithValue(token)) { 141 + headers['Authorization'] = `Bearer ${token}`; 142 + } 143 + 144 + if (isStringWithValue(username) && isStringWithValue(password)) { 145 + const credentials = base64(`${username}:${password}`); 146 + headers['Authorization'] = `Basic ${credentials}`; 147 + } 148 + 149 + if (options.body !== undefined) { 150 + if (options.mediaType) { 151 + headers['Content-Type'] = options.mediaType; 152 + } else if (isBlob(options.body)) { 153 + headers['Content-Type'] = options.body.type || 'application/octet-stream'; 154 + } else if (isString(options.body)) { 155 + headers['Content-Type'] = 'text/plain'; 156 + } else if (!isFormData(options.body)) { 157 + headers['Content-Type'] = 'application/json'; 158 + } 159 + } 160 + 161 + return new HttpHeaders(headers); 162 + }), 163 + ); 164 + }; 165 + 166 + export const getRequestBody = (options: ApiRequestOptions): unknown => { 167 + if (options.body) { 168 + if (options.mediaType?.includes('application/json') || options.mediaType?.includes('+json')) { 169 + return JSON.stringify(options.body); 170 + } else if (isString(options.body) || isBlob(options.body) || isFormData(options.body)) { 171 + return options.body; 172 + } else { 173 + return JSON.stringify(options.body); 174 + } 175 + } 176 + return undefined; 177 + }; 178 + 179 + export const sendRequest = <T>( 180 + config: OpenAPIConfig, 181 + options: ApiRequestOptions<T>, 182 + http: HttpClient, 183 + url: string, 184 + body: unknown, 185 + formData: FormData | undefined, 186 + headers: HttpHeaders 187 + ): Observable<HttpResponse<T>> => { 188 + return http.request<T>(options.method, url, { 189 + headers, 190 + body: body ?? formData, 191 + withCredentials: config.WITH_CREDENTIALS, 192 + observe: 'response', 193 + }); 194 + }; 195 + 196 + export const getResponseHeader = <T>(response: HttpResponse<T>, responseHeader?: string): string | undefined => { 197 + if (responseHeader) { 198 + const value = response.headers.get(responseHeader); 199 + if (isString(value)) { 200 + return value; 201 + } 202 + } 203 + return undefined; 204 + }; 205 + 206 + export const getResponseBody = <T>(response: HttpResponse<T>): T | undefined => { 207 + if (response.status !== 204 && response.body !== null) { 208 + return response.body; 209 + } 210 + return undefined; 211 + }; 212 + 213 + export const catchErrorCodes = (options: ApiRequestOptions, result: ApiResult): void => { 214 + const errors: Record<number, string> = { 215 + 400: 'Bad Request', 216 + 401: 'Unauthorized', 217 + 402: 'Payment Required', 218 + 403: 'Forbidden', 219 + 404: 'Not Found', 220 + 405: 'Method Not Allowed', 221 + 406: 'Not Acceptable', 222 + 407: 'Proxy Authentication Required', 223 + 408: 'Request Timeout', 224 + 409: 'Conflict', 225 + 410: 'Gone', 226 + 411: 'Length Required', 227 + 412: 'Precondition Failed', 228 + 413: 'Payload Too Large', 229 + 414: 'URI Too Long', 230 + 415: 'Unsupported Media Type', 231 + 416: 'Range Not Satisfiable', 232 + 417: 'Expectation Failed', 233 + 418: 'Im a teapot', 234 + 421: 'Misdirected Request', 235 + 422: 'Unprocessable Content', 236 + 423: 'Locked', 237 + 424: 'Failed Dependency', 238 + 425: 'Too Early', 239 + 426: 'Upgrade Required', 240 + 428: 'Precondition Required', 241 + 429: 'Too Many Requests', 242 + 431: 'Request Header Fields Too Large', 243 + 451: 'Unavailable For Legal Reasons', 244 + 500: 'Internal Server Error', 245 + 501: 'Not Implemented', 246 + 502: 'Bad Gateway', 247 + 503: 'Service Unavailable', 248 + 504: 'Gateway Timeout', 249 + 505: 'HTTP Version Not Supported', 250 + 506: 'Variant Also Negotiates', 251 + 507: 'Insufficient Storage', 252 + 508: 'Loop Detected', 253 + 510: 'Not Extended', 254 + 511: 'Network Authentication Required', 255 + ...options.errors, 256 + } 257 + 258 + const error = errors[result.status]; 259 + if (error) { 260 + throw new ApiError(options, result, error); 261 + } 262 + 263 + if (!result.ok) { 264 + const errorStatus = result.status ?? 'unknown'; 265 + const errorStatusText = result.statusText ?? 'unknown'; 266 + const errorBody = (() => { 267 + try { 268 + return JSON.stringify(result.body, null, 2); 269 + } catch (e) { 270 + return undefined; 271 + } 272 + })(); 273 + 274 + throw new ApiError(options, result, 275 + `Generic Error: status: ${errorStatus}; status text: ${errorStatusText}; body: ${errorBody}` 276 + ); 277 + } 278 + }; 279 + 280 + /** 281 + * Request method 282 + * @param config The OpenAPI configuration object 283 + * @param http The Angular HTTP client 284 + * @param options The request options from the service 285 + * @returns Observable<T> 286 + * @throws ApiError 287 + */ 288 + export const request = <T>(config: OpenAPIConfig, http: HttpClient, options: ApiRequestOptions<T>): Observable<T> => { 289 + const url = getUrl(config, options); 290 + const formData = getFormData(options); 291 + const body = getRequestBody(options); 292 + 293 + return getHeaders(config, options).pipe( 294 + switchMap(headers => { 295 + return sendRequest<T>(config, options, http, url, body, formData, headers); 296 + }), 297 + switchMap(async response => { 298 + for (const fn of config.interceptors.response._fns) { 299 + response = await fn(response); 300 + } 301 + const responseBody = getResponseBody(response); 302 + const responseHeader = getResponseHeader(response, options.responseHeader); 303 + 304 + let transformedBody = responseBody; 305 + if (options.responseTransformer && response.ok) { 306 + transformedBody = await options.responseTransformer(responseBody) 307 + } 308 + 309 + return { 310 + url, 311 + ok: response.ok, 312 + status: response.status, 313 + statusText: response.statusText, 314 + body: responseHeader ?? transformedBody, 315 + } as ApiResult; 316 + }), 317 + catchError((error: HttpErrorResponse) => { 318 + if (!error.status) { 319 + return throwError(() => error); 320 + } 321 + return of({ 322 + url, 323 + ok: error.ok, 324 + status: error.status, 325 + statusText: error.statusText, 326 + body: error.error ?? error.statusText, 327 + } as ApiResult); 328 + }), 329 + map(result => { 330 + catchErrorCodes(options, result); 331 + return result.body as T; 332 + }), 333 + catchError((error: ApiError) => { 334 + return throwError(() => error); 335 + }), 336 + ); 337 + };
+5
packages/openapi-ts/test/__snapshots__/test/generated/v3_angular_tree_shakeable_transform/index.ts.snap
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + export { ApiError } from './core/ApiError'; 3 + export { OpenAPI, type OpenAPIConfig } from './core/OpenAPI'; 4 + export * from './services.gen'; 5 + export * from './types.gen';
+67
packages/openapi-ts/test/__snapshots__/test/generated/v3_angular_tree_shakeable_transform/services.gen.ts.snap
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { Injectable } from '@angular/core'; 4 + import { HttpClient } from '@angular/common/http'; 5 + import type { Observable } from 'rxjs'; 6 + import { OpenAPI } from './core/OpenAPI'; 7 + import { request as __request } from './core/request'; 8 + import { type ParentModelWithDatesResponse, type ModelWithDatesResponse, type ModelWithDatesArrayResponse, type ArrayOfDatesResponse, type DateResponse, type MultipleResponsesResponse, ParentModelWithDatesResponseTransformer, ModelWithDatesResponseTransformer, ModelWithDatesArrayResponseTransformer } from './types.gen'; 9 + 10 + /** 11 + * @returns ParentModelWithDates Success 12 + * @returns unknown Success 13 + * @throws ApiError 14 + */ 15 + export const parentModelWithDates = function (): Observable<ParentModelWithDatesResponse> { return __request(OpenAPI, this.http, { 16 + method: 'POST', 17 + url: '/api/model-with-dates', 18 + responseTransformer: ParentModelWithDatesResponseTransformer 19 + }); }; 20 + 21 + /** 22 + * @returns ModelWithDates Success 23 + * @throws ApiError 24 + */ 25 + export const modelWithDates = function (): Observable<ModelWithDatesResponse> { return __request(OpenAPI, this.http, { 26 + method: 'PUT', 27 + url: '/api/model-with-dates', 28 + responseTransformer: ModelWithDatesResponseTransformer 29 + }); }; 30 + 31 + /** 32 + * @returns ModelWithDates Success 33 + * @throws ApiError 34 + */ 35 + export const modelWithDatesArray = function (): Observable<ModelWithDatesArrayResponse> { return __request(OpenAPI, this.http, { 36 + method: 'PUT', 37 + url: '/api/model-with-dates-array', 38 + responseTransformer: ModelWithDatesArrayResponseTransformer 39 + }); }; 40 + 41 + /** 42 + * @returns string Success 43 + * @throws ApiError 44 + */ 45 + export const arrayOfDates = function (): Observable<ArrayOfDatesResponse> { return __request(OpenAPI, this.http, { 46 + method: 'PUT', 47 + url: '/api/array-of-dates' 48 + }); }; 49 + 50 + /** 51 + * @returns string Success 52 + * @throws ApiError 53 + */ 54 + export const date = function (): Observable<DateResponse> { return __request(OpenAPI, this.http, { 55 + method: 'PUT', 56 + url: '/api/date' 57 + }); }; 58 + 59 + /** 60 + * @returns ModelWithDates Updated 61 + * @returns SimpleModel Created 62 + * @throws ApiError 63 + */ 64 + export const multipleResponses = function (): Observable<MultipleResponsesResponse> { return __request(OpenAPI, this.http, { 65 + method: 'PUT', 66 + url: '/api/multiple-responses' 67 + }); };
+102
packages/openapi-ts/test/__snapshots__/test/generated/v3_angular_tree_shakeable_transform/types.gen.ts.snap
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + /** 4 + * This is a model that contains a some dates 5 + */ 6 + export type SimpleModel = { 7 + id: number; 8 + name: string; 9 + readonly enabled: boolean; 10 + }; 11 + 12 + /** 13 + * This is a model that contains a some dates 14 + */ 15 + export type ModelWithDates = { 16 + id: number; 17 + name: string; 18 + readonly enabled: boolean; 19 + readonly modified: Date; 20 + readonly expires?: Date; 21 + }; 22 + 23 + /** 24 + * This is a model that contains a some dates and arrays 25 + */ 26 + export type ParentModelWithDates = { 27 + id: number; 28 + readonly modified?: Date; 29 + items?: Array<ModelWithDates>; 30 + item?: ModelWithDates; 31 + simpleItems?: Array<SimpleModel>; 32 + simpleItem?: SimpleModel; 33 + dates?: Array<(Date)>; 34 + strings?: Array<(string)>; 35 + }; 36 + 37 + export type ParentModelWithDatesResponse = (ParentModelWithDates | unknown); 38 + 39 + export type ModelWithDatesResponse = (ModelWithDates); 40 + 41 + export type ModelWithDatesArrayResponse = (Array<ModelWithDates>); 42 + 43 + export type ArrayOfDatesResponse = (Array<(Date)>); 44 + 45 + export type DateResponse = (Date); 46 + 47 + export type MultipleResponsesResponse = (Array<ModelWithDates> | Array<SimpleModel>); 48 + 49 + export type ParentModelWithDatesResponseTransformer = (data: any) => Promise<ParentModelWithDatesResponse>; 50 + 51 + export type ParentModelWithDatesModelResponseTransformer = (data: any) => ParentModelWithDates; 52 + 53 + export type ModelWithDatesModelResponseTransformer = (data: any) => ModelWithDates; 54 + 55 + export const ModelWithDatesModelResponseTransformer: ModelWithDatesModelResponseTransformer = data => { 56 + if (data?.modified) { 57 + data.modified = new Date(data.modified); 58 + } 59 + if (data?.expires) { 60 + data.expires = new Date(data.expires); 61 + } 62 + return data; 63 + }; 64 + 65 + export const ParentModelWithDatesModelResponseTransformer: ParentModelWithDatesModelResponseTransformer = data => { 66 + if (data?.modified) { 67 + data.modified = new Date(data.modified); 68 + } 69 + if (Array.isArray(data?.items)) { 70 + data.items.forEach(ModelWithDatesModelResponseTransformer); 71 + } 72 + if (data?.item) { 73 + ModelWithDatesModelResponseTransformer(data.item); 74 + } 75 + if (Array.isArray(data?.dates)) { 76 + data.dates = data.dates.map(item => new Date(item)); 77 + } 78 + return data; 79 + }; 80 + 81 + export const ParentModelWithDatesResponseTransformer: ParentModelWithDatesResponseTransformer = async (data) => { 82 + if (data) { 83 + ParentModelWithDatesModelResponseTransformer(data); 84 + } 85 + return data; 86 + }; 87 + 88 + export type ModelWithDatesResponseTransformer = (data: any) => Promise<ModelWithDatesResponse>; 89 + 90 + export const ModelWithDatesResponseTransformer: ModelWithDatesResponseTransformer = async (data) => { 91 + ModelWithDatesModelResponseTransformer(data); 92 + return data; 93 + }; 94 + 95 + export type ModelWithDatesArrayResponseTransformer = (data: any) => Promise<ModelWithDatesArrayResponse>; 96 + 97 + export const ModelWithDatesArrayResponseTransformer: ModelWithDatesArrayResponseTransformer = async (data) => { 98 + if (Array.isArray(data)) { 99 + data.forEach(ModelWithDatesModelResponseTransformer); 100 + } 101 + return data; 102 + };
+8
packages/openapi-ts/test/index.spec.ts
··· 92 92 }, 93 93 { 94 94 config: createConfig({ 95 + client: 'angular', 96 + types: {}, 97 + }), 98 + description: 'generate tree-shakeable angular client', 99 + name: 'v3_angular_tree_shakeable', 100 + }, 101 + { 102 + config: createConfig({ 95 103 client: 'node', 96 104 services: { 97 105 asClass: true,