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

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #744 from hey-api/fix/default-response-types

fix: improve default response type detection

authored by

Lubos and committed by
GitHub
88f79bf3 c8f39842

+419 -229
+5
.changeset/polite-baboons-rescue.md
··· 1 + --- 2 + '@hey-api/openapi-ts': patch 3 + --- 4 + 5 + fix: improve default response type detection
+2 -2
packages/openapi-ts/src/openApi/common/interfaces/client.ts
··· 31 31 export interface OperationResponse extends Model { 32 32 in: 'header' | 'response'; 33 33 code: number | 'default' | '1XX' | '2XX' | '3XX' | '4XX' | '5XX'; 34 + responseTypes: Array<'error' | 'success'>; 34 35 } 35 36 36 37 export type Method = ··· 47 48 export interface Operation extends OperationParameters { 48 49 deprecated: boolean; 49 50 description: string | null; 50 - errors: OperationResponse[]; 51 51 /** 52 52 * The operationId from OpenAPI specification. 53 53 */ ··· 63 63 * All operation responses defined in OpenAPI specification. 64 64 * Sorted by status code. 65 65 */ 66 - results: OperationResponse[]; 66 + responses: OperationResponse[]; 67 67 /** 68 68 * Service name, might be without postfix. This will be used to name the 69 69 * exported class.
+70 -65
packages/openapi-ts/src/openApi/common/parser/operation.ts
··· 1 1 import camelCase from 'camelcase'; 2 2 3 3 import { getConfig } from '../../../utils/config'; 4 - import type { Model, OperationResponse } from '../interfaces/client'; 4 + import type { OperationResponse } from '../interfaces/client'; 5 5 import { sanitizeNamespaceIdentifier } from './sanitize'; 6 - 7 - const areEqual = (a: Model, b: Model): boolean => { 8 - const equal = 9 - a.type === b.type && a.base === b.base && a.template === b.template; 10 - if (equal && a.link && b.link) { 11 - if (!Array.isArray(a.link) && !Array.isArray(b.link)) { 12 - return areEqual(a.link, b.link); 13 - } 14 - 15 - if ( 16 - Array.isArray(a.link) && 17 - Array.isArray(b.link) && 18 - a.link.length === b.link.length 19 - ) { 20 - const bLinks = b.link; 21 - return a.link.every((model, index) => areEqual(model, bLinks[index]!)); 22 - } 23 - 24 - return false; 25 - } 26 - return equal; 27 - }; 28 6 29 7 /** 30 8 * Convert the input value to a correct operation (method) class name. ··· 104 82 return null; 105 83 }; 106 84 85 + export const sorterByResponseStatusCode = ( 86 + a: OperationResponse, 87 + b: OperationResponse, 88 + ) => { 89 + if (a.code > b.code) { 90 + return 1; 91 + } 92 + 93 + if (a.code < b.code) { 94 + return -1; 95 + } 96 + 97 + return 0; 98 + }; 99 + 107 100 const isErrorStatusCode = (code: OperationResponse['code']) => 108 101 code === '3XX' || 109 102 code === '4XX' || ··· 114 107 code === '2XX' || (typeof code === 'number' && code >= 200 && code < 300); 115 108 116 109 /** 117 - * Returns only error status code responses. 110 + * Detects whether default response is meant to be used 111 + * for error or success response. 118 112 */ 119 - export const getErrorResponses = ( 113 + const inferDefaultResponseTypes = ( 114 + response: OperationResponse, 120 115 responses: OperationResponse[], 121 - ): OperationResponse[] => { 122 - const results = responses.filter( 123 - ({ code }) => 124 - (code === 'default' && inferDefaultResponse(responses) === 'error') || 125 - isErrorStatusCode(code), 116 + ) => { 117 + let types: Array<'error' | 'success'> = []; 118 + 119 + const addResponseType = (type: (typeof types)[number]) => { 120 + if (!types.includes(type)) { 121 + types = [...types, type]; 122 + } 123 + }; 124 + 125 + const hasSuccessResponse = responses.some(({ code }) => 126 + isSuccessStatusCode(code), 126 127 ); 127 - return results; 128 - }; 128 + if (!hasSuccessResponse) { 129 + addResponseType('success'); 130 + } 131 + 132 + const description = (response.description ?? '').toLocaleLowerCase(); 133 + const $refs = response.$refs.join('|').toLocaleLowerCase(); 134 + 135 + // must be in lowercase 136 + const errorKeywords = ['error', 'problem']; 137 + const successKeywords = ['success']; 129 138 130 - /** 131 - * Returns only successful status code responses. 132 - */ 133 - export const getSuccessResponses = ( 134 - responses: OperationResponse[], 135 - ): OperationResponse[] => { 136 - const results = responses.filter( 137 - ({ code }) => 138 - (code === 'default' && inferDefaultResponse(responses) === 'success') || 139 - isSuccessStatusCode(code), 140 - ); 141 - return results.filter( 142 - (result, index, arr) => 143 - arr.findIndex((item) => areEqual(item, result)) === index, 144 - ); 145 - }; 139 + if ( 140 + successKeywords.some( 141 + (keyword) => description.includes(keyword) || $refs.includes(keyword), 142 + ) 143 + ) { 144 + addResponseType('success'); 145 + } 146 146 147 - /** 148 - * Detects whether default response is meant to be used for errors or 149 - * successful responses. Returns an empty string if there's no default 150 - * response. 151 - */ 152 - export const inferDefaultResponse = ( 153 - responses: OperationResponse[], 154 - ): 'error' | 'success' | '' => { 155 - const defaultResponse = responses.find(({ code }) => code === 'default'); 156 - if (!defaultResponse) { 157 - return ''; 147 + if ( 148 + errorKeywords.some( 149 + (keyword) => description.includes(keyword) || $refs.includes(keyword), 150 + ) 151 + ) { 152 + addResponseType('error'); 158 153 } 159 154 160 - const successResponses = responses.filter(({ code }) => 161 - isSuccessStatusCode(code), 162 - ); 163 - if (!successResponses.length) { 164 - return 'success'; 155 + if (!types.length) { 156 + addResponseType('error'); 165 157 } 166 158 167 - return 'error'; 159 + return types; 168 160 }; 161 + 162 + export const tagResponseTypes = (responses: OperationResponse[]) => 163 + responses.map((response) => { 164 + const { code } = response; 165 + if (code === 'default') { 166 + response.responseTypes = inferDefaultResponseTypes(response, responses); 167 + } else if (isSuccessStatusCode(code)) { 168 + response.responseTypes = ['success']; 169 + } else if (isErrorStatusCode(code)) { 170 + response.responseTypes = ['error']; 171 + } 172 + return response; 173 + });
+8 -10
packages/openapi-ts/src/openApi/v2/parser/getOperation.ts
··· 4 4 OperationParameters, 5 5 } from '../../common/interfaces/client'; 6 6 import { 7 - getErrorResponses, 8 7 getOperationName, 9 8 getOperationResponseHeader, 10 - getSuccessResponses, 11 9 } from '../../common/parser/operation'; 12 10 import { getServiceName } from '../../common/parser/service'; 13 11 import { toSortedByRequired } from '../../common/parser/sort'; ··· 41 39 $refs: [], 42 40 deprecated: op.deprecated === true, 43 41 description: op.description || null, 44 - errors: [], 45 42 id: op.operationId || null, 46 43 imports: [], 47 44 method: method.toUpperCase() as Operation['method'], ··· 55 52 parametersQuery: [...pathParams.parametersQuery], 56 53 path: url, 57 54 responseHeader: null, 58 - results: [], 55 + responses: [], 59 56 service: serviceName, 60 57 summary: op.summary || null, 61 58 }; ··· 94 91 95 92 // Parse the operation responses. 96 93 if (op.responses) { 97 - const operationResponses = getOperationResponses({ 94 + operation.responses = getOperationResponses({ 98 95 openApi, 99 96 responses: op.responses, 100 97 types, 101 98 }); 102 - operation.errors = getErrorResponses(operationResponses); 99 + const successResponses = operation.responses.filter((response) => 100 + response.responseTypes.includes('success'), 101 + ); 103 102 104 - const successResponses = getSuccessResponses(operationResponses); 105 103 operation.responseHeader = getOperationResponseHeader(successResponses); 106 104 107 - successResponses.forEach((operationResult) => { 108 - operation.results = [...operation.results, operationResult]; 109 - operation.imports = [...operation.imports, ...operationResult.imports]; 105 + successResponses.forEach((response) => { 106 + operation.$refs = [...operation.$refs, ...response.$refs]; 107 + operation.imports = [...operation.imports, ...response.imports]; 110 108 }); 111 109 } 112 110
+1
packages/openapi-ts/src/openApi/v2/parser/getOperationResponse.ts
··· 36 36 link: null, 37 37 name: '', 38 38 properties: [], 39 + responseTypes: [], 39 40 template: null, 40 41 type: code !== 204 ? 'unknown' : 'void', 41 42 };
+8 -5
packages/openapi-ts/src/openApi/v2/parser/getOperationResponses.ts
··· 1 1 import type { Client } from '../../../types/client'; 2 2 import type { OperationResponse } from '../../common/interfaces/client'; 3 3 import { getRef } from '../../common/parser/getRef'; 4 - import { parseResponseStatusCode } from '../../common/parser/operation'; 4 + import { 5 + parseResponseStatusCode, 6 + sorterByResponseStatusCode, 7 + tagResponseTypes, 8 + } from '../../common/parser/operation'; 5 9 import type { OpenApi } from '../interfaces/OpenApi'; 6 10 import type { OpenApiResponse } from '../interfaces/OpenApiResponse'; 7 11 import type { OpenApiResponses } from '../interfaces/OpenApiResponses'; ··· 34 38 operationResponses = [...operationResponses, operationResponse]; 35 39 }); 36 40 37 - // Sort the responses to 2xx success codes come before 4xx and 5xx error codes. 38 - return operationResponses.sort((a, b): number => 39 - a.code < b.code ? -1 : a.code > b.code ? 1 : 0, 40 - ); 41 + operationResponses = tagResponseTypes(operationResponses); 42 + 43 + return operationResponses.sort(sorterByResponseStatusCode); 41 44 };
+1
packages/openapi-ts/src/openApi/v3/parser/getOperationResponse.ts
··· 37 37 link: null, 38 38 name: '', 39 39 properties: [], 40 + responseTypes: [], 40 41 template: null, 41 42 type: code !== 204 ? 'unknown' : 'void', 42 43 };
+8 -5
packages/openapi-ts/src/openApi/v3/parser/getOperationResponses.ts
··· 1 1 import type { Client } from '../../../types/client'; 2 2 import type { OperationResponse } from '../../common/interfaces/client'; 3 3 import { getRef } from '../../common/parser/getRef'; 4 - import { parseResponseStatusCode } from '../../common/parser/operation'; 4 + import { 5 + parseResponseStatusCode, 6 + sorterByResponseStatusCode, 7 + tagResponseTypes, 8 + } from '../../common/parser/operation'; 5 9 import type { OpenApi } from '../interfaces/OpenApi'; 6 10 import type { OpenApiResponse } from '../interfaces/OpenApiResponse'; 7 11 import type { OpenApiResponses } from '../interfaces/OpenApiResponses'; ··· 34 38 operationResponses = [...operationResponses, operationResponse]; 35 39 }); 36 40 37 - // Sort the responses to 2xx success codes come before 4xx and 5xx error codes. 38 - return operationResponses.sort((a, b): number => 39 - a.code < b.code ? -1 : a.code > b.code ? 1 : 0, 40 - ); 41 + operationResponses = tagResponseTypes(operationResponses); 42 + 43 + return operationResponses.sort(sorterByResponseStatusCode); 41 44 };
+8 -11
packages/openapi-ts/src/openApi/v3/parser/operation.ts
··· 6 6 } from '../../common/interfaces/client'; 7 7 import { getRef } from '../../common/parser/getRef'; 8 8 import { 9 - getErrorResponses, 10 9 getOperationName, 11 10 getOperationResponseHeader, 12 - getSuccessResponses, 13 11 } from '../../common/parser/operation'; 14 12 import { getServiceName } from '../../common/parser/service'; 15 13 import { toSortedByRequired } from '../../common/parser/sort'; ··· 65 63 $refs: [], 66 64 deprecated: Boolean(op.deprecated), 67 65 description: op.description || null, 68 - errors: [], 69 66 id: op.operationId || null, 70 67 imports: [], 71 68 method: method.toUpperCase() as Operation['method'], ··· 79 76 parametersQuery: [], 80 77 path: url, 81 78 responseHeader: null, 82 - results: [], 79 + responses: [], 83 80 service, 84 81 summary: op.summary || null, 85 82 }; ··· 130 127 } 131 128 132 129 if (op.responses) { 133 - const operationResponses = getOperationResponses({ 130 + operation.responses = getOperationResponses({ 134 131 openApi, 135 132 responses: op.responses, 136 133 types, 137 134 }); 138 - operation.errors = getErrorResponses(operationResponses); 135 + const successResponses = operation.responses.filter((response) => 136 + response.responseTypes.includes('success'), 137 + ); 139 138 140 - const successResponses = getSuccessResponses(operationResponses); 141 139 operation.responseHeader = getOperationResponseHeader(successResponses); 142 140 143 - successResponses.forEach((operationResult) => { 144 - operation.$refs = [...operation.$refs, ...operationResult.$refs]; 145 - operation.imports = [...operation.imports, ...operationResult.imports]; 146 - operation.results = [...operation.results, operationResult]; 141 + successResponses.forEach((response) => { 142 + operation.$refs = [...operation.$refs, ...response.$refs]; 143 + operation.imports = [...operation.imports, ...response.imports]; 147 144 }); 148 145 } 149 146
+5 -2
packages/openapi-ts/src/utils/postprocess.ts
··· 50 50 return service.operations.map((operation) => { 51 51 const clone = { ...operation }; 52 52 53 - // Parse the service parameters and results, very similar to how we parse 53 + // Parse the service parameters and successes, very similar to how we parse 54 54 // properties of models. These methods will extend the type if needed. 55 55 clone.imports.push( 56 56 ...clone.parameters.flatMap((parameter) => parameter.imports), 57 57 ); 58 - clone.imports.push(...clone.results.flatMap((result) => result.imports)); 58 + const successResponses = clone.responses.filter((response) => 59 + response.responseTypes.includes('success'), 60 + ); 61 + clone.imports.push(...successResponses.flatMap((result) => result.imports)); 59 62 60 63 // Check if the operation name is unique, if not then prefix this with a number 61 64 const name = clone.name;
+1 -2
packages/openapi-ts/src/utils/write/__tests__/services.spec.ts
··· 71 71 $refs: [], 72 72 deprecated: false, 73 73 description: null, 74 - errors: [], 75 74 id: 'User_get', 76 75 imports: [], 77 76 method: 'GET', ··· 85 84 parametersQuery: [], 86 85 path: '/users', 87 86 responseHeader: null, 88 - results: [], 87 + responses: [], 89 88 service: 'User', 90 89 summary: null, 91 90 };
+28 -12
packages/openapi-ts/src/utils/write/services.ts
··· 132 132 133 133 let returnType = compiler.typedef.basic('void'); 134 134 135 - // TODO: we should return nothing when results don't exist 135 + const successResponses = operation.responses.filter((response) => 136 + response.responseTypes.includes('success'), 137 + ); 138 + 139 + // TODO: we should return nothing when successes don't exist 136 140 // can't remove this logic without removing request/name config 137 141 // as it complicates things 138 - if (operation.results.length) { 142 + if (successResponses.length) { 139 143 const { name: importedType } = setUniqueTypeName({ 140 144 client, 141 145 meta: { ··· 193 197 } 194 198 } 195 199 200 + const successResponses = operation.responses.filter((response) => 201 + response.responseTypes.includes('success'), 202 + ); 203 + 196 204 const comment = [ 197 205 operation.deprecated && '@deprecated', 198 206 operation.summary && escapeComment(operation.summary), 199 207 operation.description && escapeComment(operation.description), 200 208 ...params, 201 - ...operation.results.map( 202 - (r) => 203 - `@returns ${r.type} ${r.description ? escapeComment(r.description) : ''}`, 209 + ...successResponses.map( 210 + (response) => 211 + `@returns ${response.type} ${response.description ? escapeComment(response.description) : ''}`, 204 212 ), 205 213 '@throws ApiError', 206 214 ]; ··· 254 262 } 255 263 256 264 // TODO: set parseAs to skip inference if every result has the same 257 - // content type. currently impossible because results do not contain 265 + // content type. currently impossible because successes do not contain 258 266 // header information 259 267 260 268 obj = [ ··· 352 360 obj.responseTransformer = responseTransformerName; 353 361 } 354 362 355 - if (operation.errors.length) { 363 + const errorResponses = operation.responses.filter((response) => 364 + response.responseTypes.includes('error'), 365 + ); 366 + if (errorResponses.length > 0) { 356 367 const errors: Record<number | string, string> = {}; 357 - operation.errors.forEach((err) => { 358 - errors[err.code] = err.description ?? ''; 368 + errorResponses.forEach((response) => { 369 + errors[response.code] = response.description ?? ''; 359 370 }); 360 371 obj.errors = errors; 361 372 } ··· 396 407 }, 397 408 nameTransformer: operationErrorTypeName, 398 409 }).name; 399 - const responseType = operation.results.length 410 + const successResponses = operation.responses.filter((response) => 411 + response.responseTypes.includes('success'), 412 + ); 413 + const responseType = successResponses.length 400 414 ? setUniqueTypeName({ 401 415 client, 402 416 meta: { ··· 490 504 }); 491 505 } 492 506 493 - // TODO: improve response type detection 494 - if (operation.results.length) { 507 + const successResponses = operation.responses.filter((response) => 508 + response.responseTypes.includes('success'), 509 + ); 510 + if (successResponses.length) { 495 511 generateImport({ 496 512 client, 497 513 meta: {
+9 -10
packages/openapi-ts/src/utils/write/transformers.ts
··· 5 5 ModelMeta, 6 6 OperationResponse, 7 7 } from '../../openApi/common/interfaces/client'; 8 - import { getSuccessResponses } from '../../openApi/common/parser/operation'; 9 8 import { getConfig } from '../config'; 10 9 import { 11 10 modelResponseTransformerTypeName, ··· 244 243 245 244 for (const service of client.services) { 246 245 for (const operation of service.operations) { 247 - const hasRes = operation.results.length; 246 + const successResponses = operation.responses.filter((response) => 247 + response.responseTypes.includes('success'), 248 + ); 248 249 249 - if (!hasRes) { 250 + if (!successResponses.length) { 250 251 continue; 251 252 } 252 253 253 - const responses = getSuccessResponses(operation.results); 254 - 255 - const nonVoidResponses = responses.filter( 254 + const nonVoidResponses = successResponses.filter( 256 255 (response) => !isVoidResponse(response), 257 256 ); 258 257 ··· 263 262 if (nonVoidResponses.length > 1) { 264 263 if (config.debug) { 265 264 console.warn( 266 - `⚠️ Transformers warning: route ${operation.method} ${operation.path} has ${responses.length} success responses. This is currently not handled and we will not generate a response transformer. Please open an issue if you'd like this feature https://github.com/hey-api/openapi-ts/issues`, 265 + `⚠️ Transformers warning: route ${operation.method} ${operation.path} has ${nonVoidResponses.length} non-void success responses. This is currently not handled and we will not generate a response transformer. Please open an issue if you'd like this feature https://github.com/hey-api/openapi-ts/issues`, 267 266 ); 268 267 } 269 268 continue; ··· 279 278 nameTransformer: operationResponseTransformerTypeName, 280 279 onCreated: (nameCreated) => { 281 280 const statements = 282 - responses.length > 1 283 - ? responses.flatMap((response) => { 281 + successResponses.length > 1 282 + ? successResponses.flatMap((response) => { 284 283 const statements = processModel({ 285 284 client, 286 285 meta: { ··· 311 310 $ref: `transformers/${name}`, 312 311 name, 313 312 }, 314 - model: operation.results[0], 313 + model: successResponses[0], 315 314 onNode, 316 315 onRemoveNode, 317 316 path: [dataVariableName],
+27 -42
packages/openapi-ts/src/utils/write/types.ts
··· 6 6 } from '../../compiler'; 7 7 import type { Model, OperationParameter } from '../../openApi'; 8 8 import type { Method } from '../../openApi/common/interfaces/client'; 9 - import { 10 - getErrorResponses, 11 - getSuccessResponses, 12 - } from '../../openApi/common/parser/operation'; 13 9 import type { Client } from '../../types/client'; 14 10 import { getConfig, isStandaloneClient } from '../config'; 15 11 import { enumEntry, enumUnionType } from '../enum'; ··· 239 235 240 236 for (const service of client.services) { 241 237 for (const operation of service.operations) { 242 - const hasReq = operation.parameters.length; 243 - const hasRes = operation.results.length; 244 - const hasErr = operation.errors.length; 245 - 246 - if (!hasReq && !hasRes && !hasErr) { 238 + if (!operation.parameters.length && !operation.responses.length) { 247 239 continue; 248 240 } 249 241 ··· 258 250 const methodMap = pathMap[operation.method]!; 259 251 methodMap.$ref = operation.name; 260 252 261 - if (hasReq) { 253 + if (operation.responses.length > 0) { 254 + if (!methodMap.res) { 255 + methodMap.res = {}; 256 + } 257 + 258 + if (Array.isArray(methodMap.res)) { 259 + continue; 260 + } 261 + 262 + operation.responses.forEach((response) => { 263 + methodMap.res![response.code] = response; 264 + }); 265 + } 266 + 267 + if (operation.parameters.length > 0) { 262 268 const bodyParameter = operation.parameters 263 269 .filter((parameter) => parameter.in === 'body') 264 270 .sort(sorterByName)[0]; ··· 345 351 }); 346 352 } 347 353 348 - if (hasRes) { 349 - if (!methodMap.res) { 350 - methodMap.res = {}; 351 - } 354 + const successResponses = operation.responses.filter((response) => 355 + response.responseTypes.includes('success'), 356 + ); 352 357 353 - if (Array.isArray(methodMap.res)) { 354 - continue; 355 - } 356 - 357 - operation.results.forEach((result) => { 358 - methodMap.res![result.code] = result; 359 - }); 360 - 361 - const responses = getSuccessResponses(operation.results); 362 - 358 + if (successResponses.length > 0) { 363 359 // create type export for operation response 364 360 generateType({ 365 361 client, ··· 375 371 ...emptyModel, 376 372 export: 'any-of', 377 373 isRequired: true, 378 - properties: responses, 374 + properties: successResponses, 379 375 }), 380 376 }); 381 377 378 + const errorResponses = operation.responses.filter((response) => 379 + response.responseTypes.includes('error'), 380 + ); 381 + 382 382 if (isStandaloneClient(config)) { 383 - const errorResults = getErrorResponses(operation.errors); 384 383 // create type export for operation error 385 384 generateType({ 386 385 client, ··· 393 392 nameTransformer: operationErrorTypeName, 394 393 onNode, 395 394 type: toType( 396 - errorResults.length 395 + errorResponses.length 397 396 ? { 398 397 ...emptyModel, 399 398 export: 'all-of', 400 399 isRequired: true, 401 - properties: errorResults, 400 + properties: errorResponses, 402 401 } 403 402 : { 404 403 ...emptyModel, ··· 409 408 ), 410 409 }); 411 410 } 412 - } 413 - 414 - if (hasErr) { 415 - if (!methodMap.res) { 416 - methodMap.res = {}; 417 - } 418 - 419 - if (Array.isArray(methodMap.res)) { 420 - continue; 421 - } 422 - 423 - operation.errors.forEach((error) => { 424 - methodMap.res![error.code] = error; 425 - }); 426 411 } 427 412 } 428 413 }
+1
packages/openapi-ts/test/__snapshots__/test/generated/v2/services.gen.ts.snap
··· 362 362 363 363 /** 364 364 * @returns ModelWithString Message for 201 response 365 + * @returns ModelWithString Message for 202 response 365 366 * @throws ApiError 366 367 */ 367 368 public static callWithDuplicateResponses(): CancelablePromise<CallWithDuplicateResponsesResponse> {
+4
packages/openapi-ts/test/__snapshots__/test/generated/v2/types.gen.ts.snap
··· 793 793 */ 794 794 201: ModelWithString; 795 795 /** 796 + * Message for 202 response 797 + */ 798 + 202: ModelWithString; 799 + /** 796 800 * Message for 500 error 797 801 */ 798 802 500: ModelWithStringError;
+4 -2
packages/openapi-ts/test/__snapshots__/test/generated/v3/services.gen.ts.snap
··· 19 19 /** 20 20 * @param data The data for the request. 21 21 * @param data.requestBody 22 - * @returns ModelWithReadOnlyAndWriteOnly 22 + * @returns Model_From_Zendesk Success 23 + * @returns ModelWithReadOnlyAndWriteOnly Default success response 23 24 * @throws ApiError 24 25 */ 25 26 public static postServiceWithEmptyTag(data: PostServiceWithEmptyTagData): CancelablePromise<PostServiceWithEmptyTagResponse3> { ··· 521 522 /** 522 523 * @returns unknown Message for 200 response 523 524 * @returns ModelWithString Message for 201 response 525 + * @returns ModelWithString Message for 202 response 524 526 * @throws ApiError 525 527 */ 526 528 public static callWithDuplicateResponses(): CancelablePromise<CallWithDuplicateResponsesResponse> { ··· 532 534 501: 'Message for 501 error', 533 535 502: 'Message for 502 error', 534 536 '4XX': 'Message for 4XX errors', 535 - default: 'Message for default response' 537 + default: 'Default error response' 536 538 } 537 539 }); 538 540 }
+14 -3
packages/openapi-ts/test/__snapshots__/test/generated/v3/types.gen.ts.snap
··· 997 997 requestBody: ModelWithReadOnlyAndWriteOnly | ModelWithArrayReadOnlyAndWriteOnly; 998 998 }; 999 999 1000 - export type PostServiceWithEmptyTagResponse3 = ModelWithReadOnlyAndWriteOnly; 1000 + export type PostServiceWithEmptyTagResponse3 = Model_From_Zendesk | ModelWithReadOnlyAndWriteOnly; 1001 1001 1002 1002 export type ApiVversionOdataControllerCountResponse = Model_From_Zendesk; 1003 1003 ··· 1424 1424 post: { 1425 1425 req: PostServiceWithEmptyTagData; 1426 1426 res: { 1427 + /** 1428 + * Success 1429 + */ 1430 + 200: Model_From_Zendesk; 1431 + /** 1432 + * Default success response 1433 + */ 1427 1434 default: ModelWithReadOnlyAndWriteOnly; 1428 1435 }; 1429 1436 }; ··· 1533 1540 */ 1534 1541 201: ModelWithString; 1535 1542 /** 1543 + * Message for 202 response 1544 + */ 1545 + 202: ModelWithString; 1546 + /** 1536 1547 * Message for 500 error 1537 1548 */ 1538 1549 500: ModelWithStringError; ··· 1549 1560 */ 1550 1561 '4XX': DictionaryWithArray; 1551 1562 /** 1552 - * Message for default response 1563 + * Default error response 1553 1564 */ 1554 1565 default: ModelWithBoolean; 1555 1566 }; ··· 1587 1598 /** 1588 1599 * Message for default response 1589 1600 */ 1590 - default: ModelWithString; 1601 + default: ModelWithStringError; 1591 1602 }; 1592 1603 }; 1593 1604 };
+4 -2
packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/services.gen.ts.snap
··· 26 26 /** 27 27 * @param data The data for the request. 28 28 * @param data.requestBody 29 - * @returns ModelWithReadOnlyAndWriteOnly 29 + * @returns Model_From_Zendesk Success 30 + * @returns ModelWithReadOnlyAndWriteOnly Default success response 30 31 * @throws ApiError 31 32 */ 32 33 public postServiceWithEmptyTag(data: PostServiceWithEmptyTagData): Observable<PostServiceWithEmptyTagResponse3> { ··· 578 579 /** 579 580 * @returns unknown Message for 200 response 580 581 * @returns ModelWithString Message for 201 response 582 + * @returns ModelWithString Message for 202 response 581 583 * @throws ApiError 582 584 */ 583 585 public callWithDuplicateResponses(): Observable<CallWithDuplicateResponsesResponse> { ··· 589 591 501: 'Message for 501 error', 590 592 502: 'Message for 502 error', 591 593 '4XX': 'Message for 4XX errors', 592 - default: 'Message for default response' 594 + default: 'Default error response' 593 595 } 594 596 }); 595 597 }
+14 -3
packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/types.gen.ts.snap
··· 874 874 requestBody: ModelWithReadOnlyAndWriteOnly | ModelWithArrayReadOnlyAndWriteOnly; 875 875 }; 876 876 877 - export type PostServiceWithEmptyTagResponse3 = ModelWithReadOnlyAndWriteOnly; 877 + export type PostServiceWithEmptyTagResponse3 = Model_From_Zendesk | ModelWithReadOnlyAndWriteOnly; 878 878 879 879 export type ApiVversionOdataControllerCountResponse = Model_From_Zendesk; 880 880 ··· 1301 1301 post: { 1302 1302 req: PostServiceWithEmptyTagData; 1303 1303 res: { 1304 + /** 1305 + * Success 1306 + */ 1307 + 200: Model_From_Zendesk; 1308 + /** 1309 + * Default success response 1310 + */ 1304 1311 default: ModelWithReadOnlyAndWriteOnly; 1305 1312 }; 1306 1313 }; ··· 1410 1417 */ 1411 1418 201: ModelWithString; 1412 1419 /** 1420 + * Message for 202 response 1421 + */ 1422 + 202: ModelWithString; 1423 + /** 1413 1424 * Message for 500 error 1414 1425 */ 1415 1426 500: ModelWithStringError; ··· 1426 1437 */ 1427 1438 '4XX': DictionaryWithArray; 1428 1439 /** 1429 - * Message for default response 1440 + * Default error response 1430 1441 */ 1431 1442 default: ModelWithBoolean; 1432 1443 }; ··· 1464 1475 /** 1465 1476 * Message for default response 1466 1477 */ 1467 - default: ModelWithString; 1478 + default: ModelWithStringError; 1468 1479 }; 1469 1480 }; 1470 1481 };
+4 -2
packages/openapi-ts/test/__snapshots__/test/generated/v3_axios/services.gen.ts.snap
··· 19 19 /** 20 20 * @param data The data for the request. 21 21 * @param data.requestBody 22 - * @returns ModelWithReadOnlyAndWriteOnly 22 + * @returns Model_From_Zendesk Success 23 + * @returns ModelWithReadOnlyAndWriteOnly Default success response 23 24 * @throws ApiError 24 25 */ 25 26 public static postServiceWithEmptyTag(data: PostServiceWithEmptyTagData): CancelablePromise<PostServiceWithEmptyTagResponse3> { ··· 521 522 /** 522 523 * @returns unknown Message for 200 response 523 524 * @returns ModelWithString Message for 201 response 525 + * @returns ModelWithString Message for 202 response 524 526 * @throws ApiError 525 527 */ 526 528 public static callWithDuplicateResponses(): CancelablePromise<CallWithDuplicateResponsesResponse> { ··· 532 534 501: 'Message for 501 error', 533 535 502: 'Message for 502 error', 534 536 '4XX': 'Message for 4XX errors', 535 - default: 'Message for default response' 537 + default: 'Default error response' 536 538 } 537 539 }); 538 540 }
+14 -3
packages/openapi-ts/test/__snapshots__/test/generated/v3_axios/types.gen.ts.snap
··· 997 997 requestBody: ModelWithReadOnlyAndWriteOnly | ModelWithArrayReadOnlyAndWriteOnly; 998 998 }; 999 999 1000 - export type PostServiceWithEmptyTagResponse3 = ModelWithReadOnlyAndWriteOnly; 1000 + export type PostServiceWithEmptyTagResponse3 = Model_From_Zendesk | ModelWithReadOnlyAndWriteOnly; 1001 1001 1002 1002 export type ApiVversionOdataControllerCountResponse = Model_From_Zendesk; 1003 1003 ··· 1424 1424 post: { 1425 1425 req: PostServiceWithEmptyTagData; 1426 1426 res: { 1427 + /** 1428 + * Success 1429 + */ 1430 + 200: Model_From_Zendesk; 1431 + /** 1432 + * Default success response 1433 + */ 1427 1434 default: ModelWithReadOnlyAndWriteOnly; 1428 1435 }; 1429 1436 }; ··· 1533 1540 */ 1534 1541 201: ModelWithString; 1535 1542 /** 1543 + * Message for 202 response 1544 + */ 1545 + 202: ModelWithString; 1546 + /** 1536 1547 * Message for 500 error 1537 1548 */ 1538 1549 500: ModelWithStringError; ··· 1549 1560 */ 1550 1561 '4XX': DictionaryWithArray; 1551 1562 /** 1552 - * Message for default response 1563 + * Default error response 1553 1564 */ 1554 1565 default: ModelWithBoolean; 1555 1566 }; ··· 1587 1598 /** 1588 1599 * Message for default response 1589 1600 */ 1590 - default: ModelWithString; 1601 + default: ModelWithStringError; 1591 1602 }; 1592 1603 }; 1593 1604 };
+4 -2
packages/openapi-ts/test/__snapshots__/test/generated/v3_client/services.gen.ts.snap
··· 20 20 /** 21 21 * @param data The data for the request. 22 22 * @param data.requestBody 23 - * @returns ModelWithReadOnlyAndWriteOnly 23 + * @returns Model_From_Zendesk Success 24 + * @returns ModelWithReadOnlyAndWriteOnly Default success response 24 25 * @throws ApiError 25 26 */ 26 27 public postServiceWithEmptyTag(data: PostServiceWithEmptyTagData): CancelablePromise<PostServiceWithEmptyTagResponse3> { ··· 542 543 /** 543 544 * @returns unknown Message for 200 response 544 545 * @returns ModelWithString Message for 201 response 546 + * @returns ModelWithString Message for 202 response 545 547 * @throws ApiError 546 548 */ 547 549 public callWithDuplicateResponses(): CancelablePromise<CallWithDuplicateResponsesResponse> { ··· 553 555 501: 'Message for 501 error', 554 556 502: 'Message for 502 error', 555 557 '4XX': 'Message for 4XX errors', 556 - default: 'Message for default response' 558 + default: 'Default error response' 557 559 } 558 560 }); 559 561 }
+14 -3
packages/openapi-ts/test/__snapshots__/test/generated/v3_client/types.gen.ts.snap
··· 874 874 requestBody: ModelWithReadOnlyAndWriteOnly | ModelWithArrayReadOnlyAndWriteOnly; 875 875 }; 876 876 877 - export type PostServiceWithEmptyTagResponse3 = ModelWithReadOnlyAndWriteOnly; 877 + export type PostServiceWithEmptyTagResponse3 = Model_From_Zendesk | ModelWithReadOnlyAndWriteOnly; 878 878 879 879 export type ApiVversionOdataControllerCountResponse = Model_From_Zendesk; 880 880 ··· 1301 1301 post: { 1302 1302 req: PostServiceWithEmptyTagData; 1303 1303 res: { 1304 + /** 1305 + * Success 1306 + */ 1307 + 200: Model_From_Zendesk; 1308 + /** 1309 + * Default success response 1310 + */ 1304 1311 default: ModelWithReadOnlyAndWriteOnly; 1305 1312 }; 1306 1313 }; ··· 1410 1417 */ 1411 1418 201: ModelWithString; 1412 1419 /** 1420 + * Message for 202 response 1421 + */ 1422 + 202: ModelWithString; 1423 + /** 1413 1424 * Message for 500 error 1414 1425 */ 1415 1426 500: ModelWithStringError; ··· 1426 1437 */ 1427 1438 '4XX': DictionaryWithArray; 1428 1439 /** 1429 - * Message for default response 1440 + * Default error response 1430 1441 */ 1431 1442 default: ModelWithBoolean; 1432 1443 }; ··· 1464 1475 /** 1465 1476 * Message for default response 1466 1477 */ 1467 - default: ModelWithString; 1478 + default: ModelWithStringError; 1468 1479 }; 1469 1480 }; 1470 1481 };
+14 -3
packages/openapi-ts/test/__snapshots__/test/generated/v3_date/types.gen.ts.snap
··· 19 19 requestBody: ModelWithReadOnlyAndWriteOnly | ModelWithArrayReadOnlyAndWriteOnly; 20 20 }; 21 21 22 - export type PostServiceWithEmptyTagResponse = ModelWithReadOnlyAndWriteOnly; 22 + export type PostServiceWithEmptyTagResponse = Model_From_Zendesk | ModelWithReadOnlyAndWriteOnly; 23 23 24 24 export type ApiVversionOdataControllerCountResponse = Model_From_Zendesk; 25 25 ··· 446 446 post: { 447 447 req: PostServiceWithEmptyTagData; 448 448 res: { 449 + /** 450 + * Success 451 + */ 452 + 200: Model_From_Zendesk; 453 + /** 454 + * Default success response 455 + */ 449 456 default: ModelWithReadOnlyAndWriteOnly; 450 457 }; 451 458 }; ··· 575 582 */ 576 583 201: ModelWithString; 577 584 /** 585 + * Message for 202 response 586 + */ 587 + 202: ModelWithString; 588 + /** 578 589 * Message for 500 error 579 590 */ 580 591 500: ModelWithStringError; ··· 591 602 */ 592 603 '4XX': DictionaryWithArray; 593 604 /** 594 - * Message for default response 605 + * Default error response 595 606 */ 596 607 default: ModelWithBoolean; 597 608 }; ··· 629 640 /** 630 641 * Message for default response 631 642 */ 632 - default: ModelWithString; 643 + default: ModelWithStringError; 633 644 }; 634 645 }; 635 646 };
+4 -2
packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/services.gen.ts.snap
··· 19 19 /** 20 20 * @param data The data for the request. 21 21 * @param data.requestBody 22 - * @returns ModelWithReadOnlyAndWriteOnly 22 + * @returns Model_From_Zendesk Success 23 + * @returns ModelWithReadOnlyAndWriteOnly Default success response 23 24 * @throws ApiError 24 25 */ 25 26 public static postServiceWithEmptyTag(data: PostServiceWithEmptyTagData): CancelablePromise<PostServiceWithEmptyTagResponse3> { ··· 521 522 /** 522 523 * @returns unknown Message for 200 response 523 524 * @returns ModelWithString Message for 201 response 525 + * @returns ModelWithString Message for 202 response 524 526 * @throws ApiError 525 527 */ 526 528 public static callWithDuplicateResponses(): CancelablePromise<CallWithDuplicateResponsesResponse> { ··· 532 534 501: 'Message for 501 error', 533 535 502: 'Message for 502 error', 534 536 '4XX': 'Message for 4XX errors', 535 - default: 'Message for default response' 537 + default: 'Default error response' 536 538 } 537 539 }); 538 540 }
+14 -3
packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/types.gen.ts.snap
··· 953 953 requestBody: ModelWithReadOnlyAndWriteOnly | ModelWithArrayReadOnlyAndWriteOnly; 954 954 }; 955 955 956 - export type PostServiceWithEmptyTagResponse3 = ModelWithReadOnlyAndWriteOnly; 956 + export type PostServiceWithEmptyTagResponse3 = Model_From_Zendesk | ModelWithReadOnlyAndWriteOnly; 957 957 958 958 export type ApiVversionOdataControllerCountResponse = Model_From_Zendesk; 959 959 ··· 1380 1380 post: { 1381 1381 req: PostServiceWithEmptyTagData; 1382 1382 res: { 1383 + /** 1384 + * Success 1385 + */ 1386 + 200: Model_From_Zendesk; 1387 + /** 1388 + * Default success response 1389 + */ 1383 1390 default: ModelWithReadOnlyAndWriteOnly; 1384 1391 }; 1385 1392 }; ··· 1489 1496 */ 1490 1497 201: ModelWithString; 1491 1498 /** 1499 + * Message for 202 response 1500 + */ 1501 + 202: ModelWithString; 1502 + /** 1492 1503 * Message for 500 error 1493 1504 */ 1494 1505 500: ModelWithStringError; ··· 1505 1516 */ 1506 1517 '4XX': DictionaryWithArray; 1507 1518 /** 1508 - * Message for default response 1519 + * Default error response 1509 1520 */ 1510 1521 default: ModelWithBoolean; 1511 1522 }; ··· 1543 1554 /** 1544 1555 * Message for default response 1545 1556 */ 1546 - default: ModelWithString; 1557 + default: ModelWithStringError; 1547 1558 }; 1548 1559 }; 1549 1560 };
+15 -4
packages/openapi-ts/test/__snapshots__/test/generated/v3_hey-api_client-axios/types.gen.ts.snap
··· 997 997 body: ModelWithReadOnlyAndWriteOnly | ModelWithArrayReadOnlyAndWriteOnly; 998 998 }; 999 999 1000 - export type PostServiceWithEmptyTagResponse3 = ModelWithReadOnlyAndWriteOnly; 1000 + export type PostServiceWithEmptyTagResponse3 = Model_From_Zendesk | ModelWithReadOnlyAndWriteOnly; 1001 1001 1002 1002 export type PostServiceWithEmptyTagError = unknown; 1003 1003 ··· 1287 1287 1288 1288 export type CallWithDuplicateResponsesResponse = ModelWithBoolean & ModelWithInteger | ModelWithString; 1289 1289 1290 - export type CallWithDuplicateResponsesError = ModelWithStringError & DictionaryWithArray; 1290 + export type CallWithDuplicateResponsesError = ModelWithStringError & DictionaryWithArray & ModelWithBoolean; 1291 1291 1292 1292 export type CallWithResponsesResponse = { 1293 1293 readonly '@namespace.string'?: string; ··· 1480 1480 post: { 1481 1481 req: PostServiceWithEmptyTagData; 1482 1482 res: { 1483 + /** 1484 + * Success 1485 + */ 1486 + '200': Model_From_Zendesk; 1487 + /** 1488 + * Default success response 1489 + */ 1483 1490 default: ModelWithReadOnlyAndWriteOnly; 1484 1491 }; 1485 1492 }; ··· 1609 1616 */ 1610 1617 '201': ModelWithString; 1611 1618 /** 1619 + * Message for 202 response 1620 + */ 1621 + '202': ModelWithString; 1622 + /** 1612 1623 * Message for 500 error 1613 1624 */ 1614 1625 '500': ModelWithStringError; ··· 1625 1636 */ 1626 1637 '4XX': DictionaryWithArray; 1627 1638 /** 1628 - * Message for default response 1639 + * Default error response 1629 1640 */ 1630 1641 default: ModelWithBoolean; 1631 1642 }; ··· 1663 1674 /** 1664 1675 * Message for default response 1665 1676 */ 1666 - default: ModelWithString; 1677 + default: ModelWithStringError; 1667 1678 }; 1668 1679 }; 1669 1680 };
+15 -4
packages/openapi-ts/test/__snapshots__/test/generated/v3_hey-api_client-fetch/types.gen.ts.snap
··· 997 997 body: ModelWithReadOnlyAndWriteOnly | ModelWithArrayReadOnlyAndWriteOnly; 998 998 }; 999 999 1000 - export type PostServiceWithEmptyTagResponse3 = ModelWithReadOnlyAndWriteOnly; 1000 + export type PostServiceWithEmptyTagResponse3 = Model_From_Zendesk | ModelWithReadOnlyAndWriteOnly; 1001 1001 1002 1002 export type PostServiceWithEmptyTagError = unknown; 1003 1003 ··· 1287 1287 1288 1288 export type CallWithDuplicateResponsesResponse = ModelWithBoolean & ModelWithInteger | ModelWithString; 1289 1289 1290 - export type CallWithDuplicateResponsesError = ModelWithStringError & DictionaryWithArray; 1290 + export type CallWithDuplicateResponsesError = ModelWithStringError & DictionaryWithArray & ModelWithBoolean; 1291 1291 1292 1292 export type CallWithResponsesResponse = { 1293 1293 readonly '@namespace.string'?: string; ··· 1480 1480 post: { 1481 1481 req: PostServiceWithEmptyTagData; 1482 1482 res: { 1483 + /** 1484 + * Success 1485 + */ 1486 + '200': Model_From_Zendesk; 1487 + /** 1488 + * Default success response 1489 + */ 1483 1490 default: ModelWithReadOnlyAndWriteOnly; 1484 1491 }; 1485 1492 }; ··· 1609 1616 */ 1610 1617 '201': ModelWithString; 1611 1618 /** 1619 + * Message for 202 response 1620 + */ 1621 + '202': ModelWithString; 1622 + /** 1612 1623 * Message for 500 error 1613 1624 */ 1614 1625 '500': ModelWithStringError; ··· 1625 1636 */ 1626 1637 '4XX': DictionaryWithArray; 1627 1638 /** 1628 - * Message for default response 1639 + * Default error response 1629 1640 */ 1630 1641 default: ModelWithBoolean; 1631 1642 }; ··· 1663 1674 /** 1664 1675 * Message for default response 1665 1676 */ 1666 - default: ModelWithString; 1677 + default: ModelWithStringError; 1667 1678 }; 1668 1679 }; 1669 1680 };
+4 -2
packages/openapi-ts/test/__snapshots__/test/generated/v3_node/services.gen.ts.snap
··· 19 19 /** 20 20 * @param data The data for the request. 21 21 * @param data.requestBody 22 - * @returns ModelWithReadOnlyAndWriteOnly 22 + * @returns Model_From_Zendesk Success 23 + * @returns ModelWithReadOnlyAndWriteOnly Default success response 23 24 * @throws ApiError 24 25 */ 25 26 public static postServiceWithEmptyTag(data: PostServiceWithEmptyTagData): CancelablePromise<PostServiceWithEmptyTagResponse3> { ··· 521 522 /** 522 523 * @returns unknown Message for 200 response 523 524 * @returns ModelWithString Message for 201 response 525 + * @returns ModelWithString Message for 202 response 524 526 * @throws ApiError 525 527 */ 526 528 public static callWithDuplicateResponses(): CancelablePromise<CallWithDuplicateResponsesResponse> { ··· 532 534 501: 'Message for 501 error', 533 535 502: 'Message for 502 error', 534 536 '4XX': 'Message for 4XX errors', 535 - default: 'Message for default response' 537 + default: 'Default error response' 536 538 } 537 539 }); 538 540 }
+14 -3
packages/openapi-ts/test/__snapshots__/test/generated/v3_node/types.gen.ts.snap
··· 997 997 requestBody: ModelWithReadOnlyAndWriteOnly | ModelWithArrayReadOnlyAndWriteOnly; 998 998 }; 999 999 1000 - export type PostServiceWithEmptyTagResponse3 = ModelWithReadOnlyAndWriteOnly; 1000 + export type PostServiceWithEmptyTagResponse3 = Model_From_Zendesk | ModelWithReadOnlyAndWriteOnly; 1001 1001 1002 1002 export type ApiVversionOdataControllerCountResponse = Model_From_Zendesk; 1003 1003 ··· 1424 1424 post: { 1425 1425 req: PostServiceWithEmptyTagData; 1426 1426 res: { 1427 + /** 1428 + * Success 1429 + */ 1430 + 200: Model_From_Zendesk; 1431 + /** 1432 + * Default success response 1433 + */ 1427 1434 default: ModelWithReadOnlyAndWriteOnly; 1428 1435 }; 1429 1436 }; ··· 1533 1540 */ 1534 1541 201: ModelWithString; 1535 1542 /** 1543 + * Message for 202 response 1544 + */ 1545 + 202: ModelWithString; 1546 + /** 1536 1547 * Message for 500 error 1537 1548 */ 1538 1549 500: ModelWithStringError; ··· 1549 1560 */ 1550 1561 '4XX': DictionaryWithArray; 1551 1562 /** 1552 - * Message for default response 1563 + * Default error response 1553 1564 */ 1554 1565 default: ModelWithBoolean; 1555 1566 }; ··· 1587 1598 /** 1588 1599 * Message for default response 1589 1600 */ 1590 - default: ModelWithString; 1601 + default: ModelWithStringError; 1591 1602 }; 1592 1603 }; 1593 1604 };
+14 -3
packages/openapi-ts/test/__snapshots__/test/generated/v3_pascalcase/types.gen.ts.snap
··· 20 20 requestBody: ModelWithReadOnlyAndWriteOnly | ModelWithArrayReadOnlyAndWriteOnly; 21 21 }; 22 22 23 - export type PostServiceWithEmptyTagResponse = ModelWithReadOnlyAndWriteOnly; 23 + export type PostServiceWithEmptyTagResponse = ModelFromZendesk | ModelWithReadOnlyAndWriteOnly; 24 24 25 25 export type ApiVversionOdataControllerCountResponse = ModelFromZendesk; 26 26 ··· 447 447 post: { 448 448 req: PostServiceWithEmptyTagData; 449 449 res: { 450 + /** 451 + * Success 452 + */ 453 + 200: ModelFromZendesk; 454 + /** 455 + * Default success response 456 + */ 450 457 default: ModelWithReadOnlyAndWriteOnly; 451 458 }; 452 459 }; ··· 576 583 */ 577 584 201: ModelWithString; 578 585 /** 586 + * Message for 202 response 587 + */ 588 + 202: ModelWithString; 589 + /** 579 590 * Message for 500 error 580 591 */ 581 592 500: ModelWithStringError; ··· 592 603 */ 593 604 '4XX': DictionaryWithArray; 594 605 /** 595 - * Message for default response 606 + * Default error response 596 607 */ 597 608 default: ModelWithBoolean; 598 609 }; ··· 630 641 /** 631 642 * Message for default response 632 643 */ 633 - default: ModelWithString; 644 + default: ModelWithStringError; 634 645 }; 635 646 }; 636 647 };
+4 -2
packages/openapi-ts/test/__snapshots__/test/generated/v3_tree_shakeable/services.gen.ts.snap
··· 16 16 /** 17 17 * @param data The data for the request. 18 18 * @param data.requestBody 19 - * @returns ModelWithReadOnlyAndWriteOnly 19 + * @returns Model_From_Zendesk Success 20 + * @returns ModelWithReadOnlyAndWriteOnly Default success response 20 21 * @throws ApiError 21 22 */ 22 23 export const postServiceWithEmptyTag = (data: PostServiceWithEmptyTagData): CancelablePromise<PostServiceWithEmptyTagResponse3> => { return __request(OpenAPI, { ··· 438 439 /** 439 440 * @returns unknown Message for 200 response 440 441 * @returns ModelWithString Message for 201 response 442 + * @returns ModelWithString Message for 202 response 441 443 * @throws ApiError 442 444 */ 443 445 export const callWithDuplicateResponses = (): CancelablePromise<CallWithDuplicateResponsesResponse> => { return __request(OpenAPI, { ··· 448 450 501: 'Message for 501 error', 449 451 502: 'Message for 502 error', 450 452 '4XX': 'Message for 4XX errors', 451 - default: 'Message for default response' 453 + default: 'Default error response' 452 454 } 453 455 }); }; 454 456
+14 -3
packages/openapi-ts/test/__snapshots__/test/generated/v3_tree_shakeable/types.gen.ts.snap
··· 997 997 requestBody: ModelWithReadOnlyAndWriteOnly | ModelWithArrayReadOnlyAndWriteOnly; 998 998 }; 999 999 1000 - export type PostServiceWithEmptyTagResponse3 = ModelWithReadOnlyAndWriteOnly; 1000 + export type PostServiceWithEmptyTagResponse3 = Model_From_Zendesk | ModelWithReadOnlyAndWriteOnly; 1001 1001 1002 1002 export type ApiVversionOdataControllerCountResponse = Model_From_Zendesk; 1003 1003 ··· 1424 1424 post: { 1425 1425 req: PostServiceWithEmptyTagData; 1426 1426 res: { 1427 + /** 1428 + * Success 1429 + */ 1430 + 200: Model_From_Zendesk; 1431 + /** 1432 + * Default success response 1433 + */ 1427 1434 default: ModelWithReadOnlyAndWriteOnly; 1428 1435 }; 1429 1436 }; ··· 1553 1560 */ 1554 1561 201: ModelWithString; 1555 1562 /** 1563 + * Message for 202 response 1564 + */ 1565 + 202: ModelWithString; 1566 + /** 1556 1567 * Message for 500 error 1557 1568 */ 1558 1569 500: ModelWithStringError; ··· 1569 1580 */ 1570 1581 '4XX': DictionaryWithArray; 1571 1582 /** 1572 - * Message for default response 1583 + * Default error response 1573 1584 */ 1574 1585 default: ModelWithBoolean; 1575 1586 }; ··· 1607 1618 /** 1608 1619 * Message for default response 1609 1620 */ 1610 - default: ModelWithString; 1621 + default: ModelWithStringError; 1611 1622 }; 1612 1623 }; 1613 1624 };
+14 -3
packages/openapi-ts/test/__snapshots__/test/generated/v3_types/types.gen.ts.snap
··· 874 874 requestBody: ModelWithReadOnlyAndWriteOnly | ModelWithArrayReadOnlyAndWriteOnly; 875 875 }; 876 876 877 - export type PostServiceWithEmptyTagResponse3 = ModelWithReadOnlyAndWriteOnly; 877 + export type PostServiceWithEmptyTagResponse3 = Model_From_Zendesk | ModelWithReadOnlyAndWriteOnly; 878 878 879 879 export type ApiVversionOdataControllerCountResponse = Model_From_Zendesk; 880 880 ··· 1301 1301 post: { 1302 1302 req: PostServiceWithEmptyTagData; 1303 1303 res: { 1304 + /** 1305 + * Success 1306 + */ 1307 + 200: Model_From_Zendesk; 1308 + /** 1309 + * Default success response 1310 + */ 1304 1311 default: ModelWithReadOnlyAndWriteOnly; 1305 1312 }; 1306 1313 }; ··· 1430 1437 */ 1431 1438 201: ModelWithString; 1432 1439 /** 1440 + * Message for 202 response 1441 + */ 1442 + 202: ModelWithString; 1443 + /** 1433 1444 * Message for 500 error 1434 1445 */ 1435 1446 500: ModelWithStringError; ··· 1446 1457 */ 1447 1458 '4XX': DictionaryWithArray; 1448 1459 /** 1449 - * Message for default response 1460 + * Default error response 1450 1461 */ 1451 1462 default: ModelWithBoolean; 1452 1463 }; ··· 1484 1495 /** 1485 1496 * Message for default response 1486 1497 */ 1487 - default: ModelWithString; 1498 + default: ModelWithStringError; 1488 1499 }; 1489 1500 }; 1490 1501 };
+4 -2
packages/openapi-ts/test/__snapshots__/test/generated/v3_xhr/services.gen.ts.snap
··· 19 19 /** 20 20 * @param data The data for the request. 21 21 * @param data.requestBody 22 - * @returns ModelWithReadOnlyAndWriteOnly 22 + * @returns Model_From_Zendesk Success 23 + * @returns ModelWithReadOnlyAndWriteOnly Default success response 23 24 * @throws ApiError 24 25 */ 25 26 public static postServiceWithEmptyTag(data: PostServiceWithEmptyTagData): CancelablePromise<PostServiceWithEmptyTagResponse3> { ··· 521 522 /** 522 523 * @returns unknown Message for 200 response 523 524 * @returns ModelWithString Message for 201 response 525 + * @returns ModelWithString Message for 202 response 524 526 * @throws ApiError 525 527 */ 526 528 public static callWithDuplicateResponses(): CancelablePromise<CallWithDuplicateResponsesResponse> { ··· 532 534 501: 'Message for 501 error', 533 535 502: 'Message for 502 error', 534 536 '4XX': 'Message for 4XX errors', 535 - default: 'Message for default response' 537 + default: 'Default error response' 536 538 } 537 539 }); 538 540 }
+14 -3
packages/openapi-ts/test/__snapshots__/test/generated/v3_xhr/types.gen.ts.snap
··· 997 997 requestBody: ModelWithReadOnlyAndWriteOnly | ModelWithArrayReadOnlyAndWriteOnly; 998 998 }; 999 999 1000 - export type PostServiceWithEmptyTagResponse3 = ModelWithReadOnlyAndWriteOnly; 1000 + export type PostServiceWithEmptyTagResponse3 = Model_From_Zendesk | ModelWithReadOnlyAndWriteOnly; 1001 1001 1002 1002 export type ApiVversionOdataControllerCountResponse = Model_From_Zendesk; 1003 1003 ··· 1424 1424 post: { 1425 1425 req: PostServiceWithEmptyTagData; 1426 1426 res: { 1427 + /** 1428 + * Success 1429 + */ 1430 + 200: Model_From_Zendesk; 1431 + /** 1432 + * Default success response 1433 + */ 1427 1434 default: ModelWithReadOnlyAndWriteOnly; 1428 1435 }; 1429 1436 }; ··· 1533 1540 */ 1534 1541 201: ModelWithString; 1535 1542 /** 1543 + * Message for 202 response 1544 + */ 1545 + 202: ModelWithString; 1546 + /** 1536 1547 * Message for 500 error 1537 1548 */ 1538 1549 500: ModelWithStringError; ··· 1549 1560 */ 1550 1561 '4XX': DictionaryWithArray; 1551 1562 /** 1552 - * Message for default response 1563 + * Default error response 1553 1564 */ 1554 1565 default: ModelWithBoolean; 1555 1566 }; ··· 1587 1598 /** 1588 1599 * Message for default response 1589 1600 */ 1590 - default: ModelWithString; 1601 + default: ModelWithStringError; 1591 1602 }; 1592 1603 }; 1593 1604 };
+4 -4
packages/openapi-ts/test/sample.cjs
··· 4 4 /** @type {import('../src/node/index').UserConfig} */ 5 5 const config = { 6 6 client: '@hey-api/client-fetch', 7 - // input: './test/spec/v3.json', 8 7 debug: true, 9 - input: './test/spec/v3-transforms.json', 8 + // input: './test/spec/v3-transforms.json', 9 + input: './test/spec/v3.json', 10 10 // input: 'https://mongodb-mms-prod-build-server.s3.amazonaws.com/openapi/2caffd88277a4e27c95dcefc7e3b6a63a3b03297-v2-2023-11-15.json', 11 - name: 'foo', 11 + // name: 'foo', 12 12 output: { 13 13 path: './test/generated/sample/', 14 14 }, ··· 21 21 // name: '^Parameters', 22 22 }, 23 23 types: { 24 - dates: 'types+transform', 24 + // dates: 'types+transform', 25 25 enums: 'typescript', 26 26 // include: 27 27 // '^ModelWithPrefixItemsConstantSizeArray|ModelWithAnyOfConstantSizeArray',
+13 -2
packages/openapi-ts/test/spec/v3.json
··· 37 37 }, 38 38 "responses": { 39 39 "default": { 40 + "description": "Default success response", 40 41 "content": { 41 42 "application/json": { 42 43 "schema": { 43 44 "$ref": "#/components/schemas/ModelWithReadOnlyAndWriteOnly" 45 + } 46 + } 47 + } 48 + }, 49 + "200": { 50 + "description": "Success", 51 + "content": { 52 + "application/json; type=collection": { 53 + "schema": { 54 + "$ref": "#/components/schemas/Model-From.Zendesk" 44 55 } 45 56 } 46 57 } ··· 802 813 "operationId": "CallWithDuplicateResponses", 803 814 "responses": { 804 815 "default": { 805 - "description": "Message for default response", 816 + "description": "Default error response", 806 817 "content": { 807 818 "application/json": { 808 819 "schema": { ··· 899 910 "content": { 900 911 "application/json": { 901 912 "schema": { 902 - "$ref": "#/components/schemas/ModelWithString" 913 + "$ref": "#/components/schemas/ModelWithStringError" 903 914 } 904 915 } 905 916 }