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.

chore: export error types

Lubos 10c786df 05f349ad

+234 -1864
+29 -31
examples/openapi-ts-fetch/src/App.tsx
··· 1 1 import './App.css'; 2 2 3 3 import { createClient } from '@hey-api/client-fetch'; 4 - import { useState } from 'react'; 4 + // import { useState } from 'react'; 5 5 6 - import { $Pet } from './client/schemas.gen'; 6 + import { $Email } from './client/schemas.gen'; 7 7 import { 8 - findPetsByStatus, 9 - getInventory, 10 - getPetById, 8 + buyMuseumTickets, 9 + getMuseumHours, 10 + getSpecialEvent, 11 11 } from './client/services.gen'; 12 12 13 13 createClient({ ··· 15 15 }); 16 16 17 17 function App() { 18 - const [pet, setPet] = 19 - useState<Awaited<ReturnType<typeof getPetById>>['data']>(); 18 + // const [pet, setPet] = useState<Awaited<ReturnType<typeof getPetById>>['data']>(); 20 19 21 - const onFetchPet = async () => { 22 - // random id 1-10 23 - const petId = Math.floor(Math.random() * (10 - 1 + 1) + 1); 24 - const { data: pet, error } = await getPetById({ 20 + const onGetSpecialEvent = async () => { 21 + const { data, error } = await getSpecialEvent({ 25 22 path: { 26 - petId, 23 + eventId: 'dad4bce8-f5cb-4078-a211-995864315e39', 27 24 }, 28 25 }); 29 26 if (error) { 30 - // TODO: discriminate by error status 27 + console.log(error.title) 31 28 } 32 - setPet(pet); 29 + console.log(data) 30 + // setPet(data); 33 31 }; 34 32 35 - const onFindPetsByStatus = () => { 36 - // everything in this call is optional 37 - findPetsByStatus({ 38 - query: { 39 - status: 'pending', 40 - }, 33 + const onBuyMuseumTickets = () => { 34 + // @ts-ignore 35 + buyMuseumTickets({ 36 + body: '', 41 37 }); 42 38 }; 43 39 44 - const onGetInventory = () => { 40 + const onGetMuseumHours = () => { 45 41 // this call has no params but could be still customized 46 - getInventory(); 42 + getMuseumHours({ 43 + // query: {} 44 + }); 47 45 }; 48 46 49 47 return ( ··· 59 57 <h1 className="h1">@hey-api/openapi-ts 🤝 Fetch API</h1> 60 58 </div> 61 59 <div className="flex"> 62 - <button className="button" onClick={onFetchPet}> 63 - Fetch random pet 60 + <button className="button" onClick={onGetSpecialEvent}> 61 + Get Special Event 64 62 </button> 65 - <span className="pet-name">Fetched pet's name: {pet?.name}</span> 63 + {/* <span className="pet-name">Fetched pet's name: {pet?.name}</span> */} 66 64 </div> 67 65 <div className="flex"> 68 - <button className="button" onClick={onFindPetsByStatus}> 69 - Find pets by status 66 + <button className="button" onClick={onBuyMuseumTickets}> 67 + Buy Museum Tickets 70 68 </button> 71 - <button className="button" onClick={onGetInventory}> 72 - Get inventory 69 + <button className="button" onClick={onGetMuseumHours}> 70 + Get Museum Hours 73 71 </button> 74 72 </div> 75 73 <div className="openapi-ts"> 76 - <code>{"import { $Pet } from './client/schemas.gen'"}</code> 77 - <pre>{JSON.stringify($Pet, null, 2)}</pre> 74 + <code>{"import { $Email } from './client/schemas.gen'"}</code> 75 + <pre>{JSON.stringify($Email, null, 2)}</pre> 78 76 </div> 79 77 </> 80 78 );
+22 -17
examples/openapi-ts-fetch/src/client/services.gen.ts
··· 4 4 5 5 import type { 6 6 BuyMuseumTicketsData, 7 + BuyMuseumTicketsError, 7 8 BuyMuseumTicketsResponse2, 8 9 CreateSpecialEventData, 10 + CreateSpecialEventError, 9 11 CreateSpecialEventResponse, 10 12 DeleteSpecialEventData, 13 + DeleteSpecialEventError, 11 14 DeleteSpecialEventResponse, 12 15 GetMuseumHoursData, 16 + GetMuseumHoursError, 13 17 GetMuseumHoursResponse2, 14 18 GetSpecialEventData, 19 + GetSpecialEventError, 15 20 GetSpecialEventResponse, 16 21 GetTicketCodeData, 22 + GetTicketCodeError, 17 23 GetTicketCodeResponse2, 18 24 ListSpecialEventsData, 25 + ListSpecialEventsError, 19 26 ListSpecialEventsResponse2, 20 27 UpdateSpecialEventData, 28 + UpdateSpecialEventError, 21 29 UpdateSpecialEventResponse, 22 30 } from './types.gen'; 23 31 ··· 25 33 * Get museum hours 26 34 * Get upcoming museum operating hours. 27 35 */ 28 - export const getMuseumHours = (options?: Options<GetMuseumHoursData>) => 29 - client.get<GetMuseumHoursResponse2>({ 36 + export const getMuseumHours = (options?: Options<GetMuseumHoursData>) => client.get<GetMuseumHoursResponse2, GetMuseumHoursError>({ 30 37 ...options, 31 38 url: '/museum-hours', 32 39 }); ··· 35 42 * Create special events 36 43 * Creates a new special event for the museum. 37 44 */ 38 - export const createSpecialEvent = (options: Options<CreateSpecialEventData>) => 39 - client.post<CreateSpecialEventResponse>({ 45 + export const createSpecialEvent = ( 46 + options: Options<CreateSpecialEventData>, 47 + ) => client.post<CreateSpecialEventResponse, CreateSpecialEventError>({ 40 48 ...options, 41 49 url: '/special-events', 42 50 }); ··· 45 53 * List special events 46 54 * Return a list of upcoming special events at the museum. 47 55 */ 48 - export const listSpecialEvents = (options?: Options<ListSpecialEventsData>) => 49 - client.get<ListSpecialEventsResponse2>({ 56 + export const listSpecialEvents = (options?: Options<ListSpecialEventsData>) => client.get<ListSpecialEventsResponse2, ListSpecialEventsError>({ 50 57 ...options, 51 58 url: '/special-events', 52 59 }); ··· 55 62 * Get special event 56 63 * Get details about a special event. 57 64 */ 58 - export const getSpecialEvent = (options: Options<GetSpecialEventData>) => 59 - client.get<GetSpecialEventResponse>({ 65 + export const getSpecialEvent = (options: Options<GetSpecialEventData>) => client.get<GetSpecialEventResponse, GetSpecialEventError>({ 60 66 ...options, 61 67 url: '/special-events/{eventId}', 62 68 }); 63 69 64 70 /** 65 71 * Update special event 66 - * 67 72 * Update the details of a special event. 68 73 */ 69 - export const updateSpecialEvent = (options: Options<UpdateSpecialEventData>) => 70 - client.patch<UpdateSpecialEventResponse>({ 74 + export const updateSpecialEvent = ( 75 + options: Options<UpdateSpecialEventData>, 76 + ) => client.patch<UpdateSpecialEventResponse, UpdateSpecialEventError>({ 71 77 ...options, 72 78 url: '/special-events/{eventId}', 73 79 }); ··· 76 82 * Delete special event 77 83 * Delete a special event from the collection. Allows museum to cancel planned events. 78 84 */ 79 - export const deleteSpecialEvent = (options: Options<DeleteSpecialEventData>) => 80 - client.delete<DeleteSpecialEventResponse>({ 85 + export const deleteSpecialEvent = ( 86 + options: Options<DeleteSpecialEventData>, 87 + ) => client.delete<DeleteSpecialEventResponse, DeleteSpecialEventError>({ 81 88 ...options, 82 89 url: '/special-events/{eventId}', 83 90 }); ··· 86 93 * Buy museum tickets 87 94 * Purchase museum tickets for general entry or special events. 88 95 */ 89 - export const buyMuseumTickets = (options: Options<BuyMuseumTicketsData>) => 90 - client.post<BuyMuseumTicketsResponse2>({ 96 + export const buyMuseumTickets = (options: Options<BuyMuseumTicketsData>) => client.post<BuyMuseumTicketsResponse2, BuyMuseumTicketsError>({ 91 97 ...options, 92 98 url: '/tickets', 93 99 }); ··· 96 102 * Get ticket QR code 97 103 * Return an image of your ticket with scannable QR code. Used for event entry. 98 104 */ 99 - export const getTicketCode = (options: Options<GetTicketCodeData>) => 100 - client.get<GetTicketCodeResponse2>({ 105 + export const getTicketCode = (options: Options<GetTicketCodeData>) => client.get<GetTicketCodeResponse2, GetTicketCodeError>({ 101 106 ...options, 102 107 url: '/tickets/{ticketId}/qr', 103 108 });
+16
examples/openapi-ts-fetch/src/client/types.gen.ts
··· 215 215 216 216 export type GetMuseumHoursResponse2 = GetMuseumHoursResponse; 217 217 218 + export type GetMuseumHoursError = Error; 219 + 218 220 export type CreateSpecialEventData = { 219 221 body: CreateSpecialEventRequest; 220 222 }; 221 223 222 224 export type CreateSpecialEventResponse = SpecialEventResponse; 225 + 226 + export type CreateSpecialEventError = Error; 223 227 224 228 export type ListSpecialEventsData = { 225 229 query?: { ··· 244 248 245 249 export type ListSpecialEventsResponse2 = ListSpecialEventsResponse; 246 250 251 + export type ListSpecialEventsError = Error; 252 + 247 253 export type GetSpecialEventData = { 248 254 path: { 249 255 /** ··· 254 260 }; 255 261 256 262 export type GetSpecialEventResponse = SpecialEventResponse; 263 + 264 + export type GetSpecialEventError = Error; 257 265 258 266 export type UpdateSpecialEventData = { 259 267 body: UpdateSpecialEventRequest; ··· 267 275 268 276 export type UpdateSpecialEventResponse = SpecialEventResponse; 269 277 278 + export type UpdateSpecialEventError = Error; 279 + 270 280 export type DeleteSpecialEventData = { 271 281 path: { 272 282 /** ··· 277 287 }; 278 288 279 289 export type DeleteSpecialEventResponse = void; 290 + 291 + export type DeleteSpecialEventError = Error; 280 292 281 293 export type BuyMuseumTicketsData = { 282 294 body: BuyMuseumTicketsRequest; ··· 284 296 285 297 export type BuyMuseumTicketsResponse2 = BuyMuseumTicketsResponse; 286 298 299 + export type BuyMuseumTicketsError = Error; 300 + 287 301 export type GetTicketCodeData = { 288 302 path: { 289 303 /** ··· 294 308 }; 295 309 296 310 export type GetTicketCodeResponse2 = GetTicketCodeResponse; 311 + 312 + export type GetTicketCodeError = Error; 297 313 298 314 export type $OpenApiTs = { 299 315 '/museum-hours': {
+38 -2
packages/openapi-ts/src/utils/write/services.ts
··· 48 48 export const operationDataTypeName = (name: string) => 49 49 `${camelcase(name, { pascalCase: true })}Data`; 50 50 51 + export const operationErrorTypeName = (name: string) => 52 + `${camelcase(name, { pascalCase: true })}Error`; 53 + 51 54 export const operationResponseTypeName = (name: string) => 52 55 `${camelcase(name, { pascalCase: true })}Response`; 53 56 ··· 294 297 const options = toRequestOptions(operation); 295 298 296 299 if (config.client.startsWith('@hey-api')) { 297 - const returnType = operation.results.length 300 + const errorType = uniqueTypeName({ 301 + client, 302 + meta: { 303 + // TODO: this should be exact ref to operation for consistency, 304 + // but name should work too as operation ID is unique 305 + $ref: operation.name, 306 + name: operation.name, 307 + }, 308 + nameTransformer: operationErrorTypeName, 309 + }).name; 310 + const responseType = operation.results.length 298 311 ? uniqueTypeName({ 299 312 client, 300 313 meta: { ··· 310 323 compiler.return.functionCall({ 311 324 args: [options], 312 325 name: `client.${operation.method.toLocaleLowerCase()}`, 313 - types: returnType ? [returnType] : [], 326 + types: errorType && responseType 327 + ? [responseType, errorType] 328 + : errorType 329 + ? ['unknown', errorType] 330 + : responseType 331 + ? [responseType] : [], 314 332 }), 315 333 ]; 316 334 } ··· 364 382 }); 365 383 } 366 384 385 + if (config.client.startsWith('@hey-api')) { 386 + // TODO: improve error type detection 387 + if (operation.errors.length) { 388 + generateImport({ 389 + client, 390 + meta: { 391 + // TODO: this should be exact ref to operation for consistency, 392 + // but name should work too as operation ID is unique 393 + $ref: operation.name, 394 + name: operation.name, 395 + }, 396 + nameTransformer: operationErrorTypeName, 397 + onImport, 398 + }); 399 + } 400 + } 401 + 402 + // TODO: improve response type detection 367 403 if (operation.results.length) { 368 404 generateImport({ 369 405 client,
+24 -1
packages/openapi-ts/src/utils/write/types.ts
··· 10 10 import { enumKey, enumUnionType, enumValue } from '../enum'; 11 11 import { escapeComment } from '../escape'; 12 12 import { sortByName, sorterByName } from '../sort'; 13 - import { operationDataTypeName, operationResponseTypeName } from './services'; 13 + import { operationDataTypeName, operationErrorTypeName, operationResponseTypeName } from './services'; 14 14 import { toType, uniqueTypeName } from './type'; 15 15 16 16 type OnNode = (node: Node) => void; ··· 351 351 ...emptyModel, 352 352 export: 'any-of', 353 353 isRequired: true, 354 + // TODO: improve response type detection 354 355 properties: operation.results.filter( 355 356 (result) => 356 357 result.code === 'default' || ··· 358 359 ), 359 360 }), 360 361 }); 362 + 363 + if (config.client.startsWith('@hey-api')) { 364 + // create type export for operation error 365 + generateType({ 366 + client, 367 + meta: { 368 + // TODO: this should be exact ref to operation for consistency, 369 + // but name should work too as operation ID is unique 370 + $ref: operation.name, 371 + name: operation.name, 372 + }, 373 + nameTransformer: operationErrorTypeName, 374 + onNode, 375 + type: toType({ 376 + ...emptyModel, 377 + export: 'all-of', 378 + isRequired: true, 379 + // TODO: improve error type detection 380 + properties: operation.errors.filter((result) => result.code === 'default' || (result.code >= 400 && result.code < 600)), 381 + }), 382 + }); 383 + } 361 384 } 362 385 363 386 if (hasErr) {
+11 -249
packages/openapi-ts/test/__snapshots__/test/generated/v2/types.gen.ts.snap
··· 729 729 export type $OpenApiTs = { 730 730 '/api/v{api-version}/descriptions/': { 731 731 post: { 732 - req: { 733 - /** 734 - * Testing backticks in string: `backticks` and ```multiple backticks``` should work 735 - */ 736 - parameterWithBackticks?: string; 737 - /** 738 - * Testing multiline comments in string: First line 739 - * Second line 740 - * 741 - * Fourth line 742 - */ 743 - parameterWithBreaks?: string; 744 - /** 745 - * Testing expression placeholders in string: ${expression} should work 746 - */ 747 - parameterWithExpressionPlaceholders?: string; 748 - /** 749 - * Testing quotes in string: 'single quote''' and "double quotes""" should work 750 - */ 751 - parameterWithQuotes?: string; 752 - /** 753 - * Testing reserved characters in string: * inline * and ** inline ** should work 754 - */ 755 - parameterWithReservedCharacters?: string; 756 - /** 757 - * Testing slashes in string: \backwards\\\ and /forwards/// should work 758 - */ 759 - parameterWithSlashes?: string; 760 - }; 732 + req: CallWithDescriptionsData; 761 733 }; 762 734 }; 763 735 '/api/v{api-version}/parameters/{parameterPath}': { 764 736 post: { 765 - req: { 766 - /** 767 - * This is the parameter that is sent as request body 768 - */ 769 - parameterBody: string; 770 - /** 771 - * This is the parameter that goes into the form data 772 - */ 773 - parameterForm: string; 774 - /** 775 - * This is the parameter that goes into the header 776 - */ 777 - parameterHeader: string; 778 - /** 779 - * This is the parameter that goes into the path 780 - */ 781 - parameterPath: string; 782 - /** 783 - * This is the parameter that goes into the query params 784 - */ 785 - parameterQuery: string; 786 - }; 737 + req: CallWithParametersData; 787 738 }; 788 739 }; 789 740 '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}': { 790 741 post: { 791 - req: { 792 - /** 793 - * This is the parameter with a reserved keyword 794 - */ 795 - _default?: string; 796 - /** 797 - * This is the parameter that is sent as request body 798 - */ 799 - parameterBody: string; 800 - /** 801 - * This is the parameter that goes into the request form data 802 - */ 803 - parameterForm: string; 804 - /** 805 - * This is the parameter that goes into the request header 806 - */ 807 - parameterHeader: string; 808 - /** 809 - * This is the parameter that goes into the path 810 - */ 811 - parameterPath1?: string; 812 - /** 813 - * This is the parameter that goes into the path 814 - */ 815 - parameterPath2?: string; 816 - /** 817 - * This is the parameter that goes into the path 818 - */ 819 - parameterPath3?: string; 820 - /** 821 - * This is the parameter that goes into the request query params 822 - */ 823 - parameterQuery: string; 824 - }; 742 + req: CallWithWeirdParameterNamesData; 825 743 }; 826 744 }; 827 745 '/api/v{api-version}/defaults': { 828 746 get: { 829 - req: { 830 - /** 831 - * This is a simple boolean with default value 832 - */ 833 - parameterBoolean: boolean; 834 - /** 835 - * This is a simple enum with default value 836 - */ 837 - parameterEnum: 'Success' | 'Warning' | 'Error'; 838 - /** 839 - * This is a simple model with default value 840 - */ 841 - parameterModel: ModelWithString; 842 - /** 843 - * This is a simple number with default value 844 - */ 845 - parameterNumber: number; 846 - /** 847 - * This is a simple string with default value 848 - */ 849 - parameterString: string; 850 - }; 747 + req: CallToTestOrderOfParamsData; 851 748 }; 852 749 post: { 853 - req: { 854 - /** 855 - * This is a simple boolean that is optional with default value 856 - */ 857 - parameterBoolean?: boolean; 858 - /** 859 - * This is a simple enum that is optional with default value 860 - */ 861 - parameterEnum?: 'Success' | 'Warning' | 'Error'; 862 - /** 863 - * This is a simple model that is optional with default value 864 - */ 865 - parameterModel?: ModelWithString; 866 - /** 867 - * This is a simple number that is optional with default value 868 - */ 869 - parameterNumber?: number; 870 - /** 871 - * This is a simple string that is optional with default value 872 - */ 873 - parameterString?: string; 874 - }; 750 + req: CallToTestOrderOfParamsData; 875 751 }; 876 752 put: { 877 - req: { 878 - /** 879 - * This is a optional string with default 880 - */ 881 - parameterOptionalStringWithDefault?: string; 882 - /** 883 - * This is a optional string with empty default 884 - */ 885 - parameterOptionalStringWithEmptyDefault?: string; 886 - /** 887 - * This is a optional string with no default 888 - */ 889 - parameterOptionalStringWithNoDefault?: string; 890 - /** 891 - * This is a string that can be null with default 892 - */ 893 - parameterStringNullableWithDefault?: string | null; 894 - /** 895 - * This is a string that can be null with no default 896 - */ 897 - parameterStringNullableWithNoDefault?: string | null; 898 - /** 899 - * This is a string with default 900 - */ 901 - parameterStringWithDefault: string; 902 - /** 903 - * This is a string with empty default 904 - */ 905 - parameterStringWithEmptyDefault: string; 906 - /** 907 - * This is a string with no default 908 - */ 909 - parameterStringWithNoDefault: string; 910 - }; 753 + req: CallToTestOrderOfParamsData; 911 754 }; 912 755 }; 913 756 '/api/v{api-version}/no-content': { ··· 1022 865 }; 1023 866 '/api/v{api-version}/collectionFormat': { 1024 867 get: { 1025 - req: { 1026 - /** 1027 - * This is an array parameter that is sent as csv format (comma-separated values) 1028 - */ 1029 - parameterArrayCsv: Array<string>; 1030 - /** 1031 - * This is an array parameter that is sent as multi format (multiple parameter instances) 1032 - */ 1033 - parameterArrayMulti: Array<string>; 1034 - /** 1035 - * This is an array parameter that is sent as pipes format (pipe-separated values) 1036 - */ 1037 - parameterArrayPipes: Array<string>; 1038 - /** 1039 - * This is an array parameter that is sent as ssv format (space-separated values) 1040 - */ 1041 - parameterArraySsv: Array<string>; 1042 - /** 1043 - * This is an array parameter that is sent as tsv format (tab-separated values) 1044 - */ 1045 - parameterArrayTsv: Array<string>; 1046 - }; 868 + req: CollectionFormatData; 1047 869 }; 1048 870 }; 1049 871 '/api/v{api-version}/types': { 1050 872 get: { 1051 - req: { 1052 - /** 1053 - * This is a number parameter 1054 - */ 1055 - id?: number; 1056 - /** 1057 - * This is an array parameter 1058 - */ 1059 - parameterArray: Array<string>; 1060 - /** 1061 - * This is a boolean parameter 1062 - */ 1063 - parameterBoolean: boolean; 1064 - /** 1065 - * This is a dictionary parameter 1066 - */ 1067 - parameterDictionary: { 1068 - [key: string]: string; 1069 - }; 1070 - /** 1071 - * This is an enum parameter 1072 - */ 1073 - parameterEnum: 'Success' | 'Warning' | 'Error'; 1074 - /** 1075 - * This is a number parameter 1076 - */ 1077 - parameterNumber: number; 1078 - /** 1079 - * This is an object parameter 1080 - */ 1081 - parameterObject: unknown; 1082 - /** 1083 - * This is a string parameter 1084 - */ 1085 - parameterString: string; 1086 - }; 873 + req: TypesData; 1087 874 res: { 1088 875 /** 1089 876 * Response is a simple number ··· 1106 893 }; 1107 894 '/api/v{api-version}/complex': { 1108 895 get: { 1109 - req: { 1110 - /** 1111 - * Parameter containing object 1112 - */ 1113 - parameterObject: { 1114 - first?: { 1115 - second?: { 1116 - third?: string; 1117 - }; 1118 - }; 1119 - }; 1120 - /** 1121 - * Parameter containing reference 1122 - */ 1123 - parameterReference: ModelWithString; 1124 - }; 896 + req: ComplexTypesData; 1125 897 res: { 1126 898 /** 1127 899 * Successful response ··· 1158 930 }; 1159 931 '/api/v{api-version}/error': { 1160 932 post: { 1161 - req: { 1162 - /** 1163 - * Status code to return 1164 - */ 1165 - status: string; 1166 - }; 933 + req: TestErrorCodeData; 1167 934 res: { 1168 935 /** 1169 936 * Custom message: Successful response ··· 1190 957 }; 1191 958 '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串': { 1192 959 post: { 1193 - req: { 1194 - /** 1195 - * Dummy input param 1196 - */ 1197 - nonAsciiParamæøåÆøÅöôêÊ: number; 1198 - }; 960 + req: NonAsciiæøåÆøÅöôêÊ字符串Data; 1199 961 res: { 1200 962 /** 1201 963 * Successful response
+22 -352
packages/openapi-ts/test/__snapshots__/test/generated/v3/types.gen.ts.snap
··· 1350 1350 export type $OpenApiTs = { 1351 1351 '/api/v{api-version}/no-tag': { 1352 1352 post: { 1353 - req: { 1354 - requestBody: ModelWithReadOnlyAndWriteOnly | ModelWithArrayReadOnlyAndWriteOnly; 1355 - }; 1353 + req: PostServiceWithEmptyTagData; 1356 1354 res: { 1357 1355 default: ModelWithReadOnlyAndWriteOnly; 1358 1356 }; ··· 1370 1368 }; 1371 1369 '/api/v{api-version}/foo/{foo}/bar/{bar}': { 1372 1370 delete: { 1373 - req: { 1374 - /** 1375 - * bar in method 1376 - */ 1377 - bar: string; 1378 - /** 1379 - * foo in method 1380 - */ 1381 - foo: string; 1382 - }; 1371 + req: DeleteFooData3; 1383 1372 }; 1384 1373 }; 1385 1374 '/api/v{api-version}/parameters/{parameterPath}': { 1386 1375 post: { 1387 - req: { 1388 - fooAllOfEnum: ModelWithNestedArrayEnumsDataFoo; 1389 - fooRefEnum?: ModelWithNestedArrayEnumsDataFoo; 1390 - /** 1391 - * This is the parameter that goes into the cookie 1392 - */ 1393 - parameterCookie: string | null; 1394 - /** 1395 - * This is the parameter that goes into the form data 1396 - */ 1397 - parameterForm: string | null; 1398 - /** 1399 - * This is the parameter that goes into the header 1400 - */ 1401 - parameterHeader: string | null; 1402 - /** 1403 - * This is the parameter that goes into the path 1404 - */ 1405 - parameterPath: string | null; 1406 - /** 1407 - * This is the parameter that goes into the query params 1408 - */ 1409 - parameterQuery: string | null; 1410 - /** 1411 - * This is the parameter that goes into the body 1412 - */ 1413 - requestBody: ModelWithString | null; 1414 - }; 1376 + req: CallWithParametersData; 1415 1377 }; 1416 1378 }; 1417 1379 '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}': { 1418 1380 post: { 1419 - req: { 1420 - /** 1421 - * This is the parameter with a reserved keyword 1422 - */ 1423 - _default?: string; 1424 - /** 1425 - * This is the parameter that goes into the cookie 1426 - */ 1427 - parameterCookie: string | null; 1428 - /** 1429 - * This is the parameter that goes into the request form data 1430 - */ 1431 - parameterForm: string | null; 1432 - /** 1433 - * This is the parameter that goes into the request header 1434 - */ 1435 - parameterHeader: string | null; 1436 - /** 1437 - * This is the parameter that goes into the path 1438 - */ 1439 - parameterPath1?: string; 1440 - /** 1441 - * This is the parameter that goes into the path 1442 - */ 1443 - parameterPath2?: string; 1444 - /** 1445 - * This is the parameter that goes into the path 1446 - */ 1447 - parameterPath3?: string; 1448 - /** 1449 - * This is the parameter that goes into the request query params 1450 - */ 1451 - parameterQuery: string | null; 1452 - /** 1453 - * This is the parameter that goes into the body 1454 - */ 1455 - requestBody: ModelWithString | null; 1456 - }; 1381 + req: CallWithWeirdParameterNamesData; 1457 1382 }; 1458 1383 }; 1459 1384 '/api/v{api-version}/parameters/': { 1460 1385 get: { 1461 - req: { 1462 - /** 1463 - * This is an optional parameter 1464 - */ 1465 - parameter?: string; 1466 - /** 1467 - * This is a required parameter 1468 - */ 1469 - requestBody: ModelWithOneOfEnum; 1470 - }; 1386 + req: PostCallWithOptionalParamData; 1471 1387 }; 1472 1388 post: { 1473 - req: { 1474 - /** 1475 - * This is a required parameter 1476 - */ 1477 - parameter: Pageable; 1478 - /** 1479 - * This is an optional parameter 1480 - */ 1481 - requestBody?: ModelWithString; 1482 - }; 1389 + req: PostCallWithOptionalParamData; 1483 1390 }; 1484 1391 }; 1485 1392 '/api/v{api-version}/descriptions/': { 1486 1393 post: { 1487 - req: { 1488 - /** 1489 - * Testing backticks in string: `backticks` and ```multiple backticks``` should work 1490 - */ 1491 - parameterWithBackticks?: unknown; 1492 - /** 1493 - * Testing multiline comments in string: First line 1494 - * Second line 1495 - * 1496 - * Fourth line 1497 - */ 1498 - parameterWithBreaks?: unknown; 1499 - /** 1500 - * Testing expression placeholders in string: ${expression} should work 1501 - */ 1502 - parameterWithExpressionPlaceholders?: unknown; 1503 - /** 1504 - * Testing quotes in string: 'single quote''' and "double quotes""" should work 1505 - */ 1506 - parameterWithQuotes?: unknown; 1507 - /** 1508 - * Testing reserved characters in string: * inline * and ** inline ** should work 1509 - */ 1510 - parameterWithReservedCharacters?: unknown; 1511 - /** 1512 - * Testing slashes in string: \backwards\\\ and /forwards/// should work 1513 - */ 1514 - parameterWithSlashes?: unknown; 1515 - }; 1394 + req: CallWithDescriptionsData; 1516 1395 }; 1517 1396 }; 1518 1397 '/api/v{api-version}/parameters/deprecated': { 1519 1398 post: { 1520 - req: { 1521 - /** 1522 - * This parameter is deprecated 1523 - * @deprecated 1524 - */ 1525 - parameter: DeprecatedModel | null; 1526 - }; 1399 + req: DeprecatedCallData; 1527 1400 }; 1528 1401 }; 1529 1402 '/api/v{api-version}/requestBody/': { 1530 1403 post: { 1531 - req: { 1532 - /** 1533 - * A reusable request body 1534 - */ 1535 - foo?: ModelWithString; 1536 - /** 1537 - * This is a reusable parameter 1538 - */ 1539 - parameter?: string; 1540 - }; 1404 + req: PostApiRequestBodyData; 1541 1405 }; 1542 1406 }; 1543 1407 '/api/v{api-version}/formData/': { 1544 1408 post: { 1545 - req: { 1546 - /** 1547 - * A reusable request body 1548 - */ 1549 - formData?: ModelWithString; 1550 - /** 1551 - * This is a reusable parameter 1552 - */ 1553 - parameter?: string; 1554 - }; 1409 + req: PostApiFormDataData; 1555 1410 }; 1556 1411 }; 1557 1412 '/api/v{api-version}/defaults': { 1558 1413 get: { 1559 - req: { 1560 - /** 1561 - * This is a simple boolean with default value 1562 - */ 1563 - parameterBoolean?: boolean | null; 1564 - /** 1565 - * This is a simple enum with default value 1566 - */ 1567 - parameterEnum?: 'Success' | 'Warning' | 'Error'; 1568 - /** 1569 - * This is a simple model with default value 1570 - */ 1571 - parameterModel?: ModelWithString | null; 1572 - /** 1573 - * This is a simple number with default value 1574 - */ 1575 - parameterNumber?: number | null; 1576 - /** 1577 - * This is a simple string with default value 1578 - */ 1579 - parameterString?: string | null; 1580 - }; 1414 + req: CallToTestOrderOfParamsData; 1581 1415 }; 1582 1416 post: { 1583 - req: { 1584 - /** 1585 - * This is a simple boolean that is optional with default value 1586 - */ 1587 - parameterBoolean?: boolean; 1588 - /** 1589 - * This is a simple enum that is optional with default value 1590 - */ 1591 - parameterEnum?: 'Success' | 'Warning' | 'Error'; 1592 - /** 1593 - * This is a simple model that is optional with default value 1594 - */ 1595 - parameterModel?: ModelWithString; 1596 - /** 1597 - * This is a simple number that is optional with default value 1598 - */ 1599 - parameterNumber?: number; 1600 - /** 1601 - * This is a simple string that is optional with default value 1602 - */ 1603 - parameterString?: string; 1604 - }; 1417 + req: CallToTestOrderOfParamsData; 1605 1418 }; 1606 1419 put: { 1607 - req: { 1608 - /** 1609 - * This is a optional string with default 1610 - */ 1611 - parameterOptionalStringWithDefault?: string; 1612 - /** 1613 - * This is a optional string with empty default 1614 - */ 1615 - parameterOptionalStringWithEmptyDefault?: string; 1616 - /** 1617 - * This is a optional string with no default 1618 - */ 1619 - parameterOptionalStringWithNoDefault?: string; 1620 - /** 1621 - * This is a string that can be null with default 1622 - */ 1623 - parameterStringNullableWithDefault?: string | null; 1624 - /** 1625 - * This is a string that can be null with no default 1626 - */ 1627 - parameterStringNullableWithNoDefault?: string | null; 1628 - /** 1629 - * This is a string with default 1630 - */ 1631 - parameterStringWithDefault: string; 1632 - /** 1633 - * This is a string with empty default 1634 - */ 1635 - parameterStringWithEmptyDefault: string; 1636 - /** 1637 - * This is a string with no default 1638 - */ 1639 - parameterStringWithNoDefault: string; 1640 - }; 1420 + req: CallToTestOrderOfParamsData; 1641 1421 }; 1642 1422 }; 1643 1423 '/api/v{api-version}/no-content': { ··· 1757 1537 }; 1758 1538 '/api/v{api-version}/collectionFormat': { 1759 1539 get: { 1760 - req: { 1761 - /** 1762 - * This is an array parameter that is sent as csv format (comma-separated values) 1763 - */ 1764 - parameterArrayCsv: Array<(string)> | null; 1765 - /** 1766 - * This is an array parameter that is sent as multi format (multiple parameter instances) 1767 - */ 1768 - parameterArrayMulti: Array<(string)> | null; 1769 - /** 1770 - * This is an array parameter that is sent as pipes format (pipe-separated values) 1771 - */ 1772 - parameterArrayPipes: Array<(string)> | null; 1773 - /** 1774 - * This is an array parameter that is sent as ssv format (space-separated values) 1775 - */ 1776 - parameterArraySsv: Array<(string)> | null; 1777 - /** 1778 - * This is an array parameter that is sent as tsv format (tab-separated values) 1779 - */ 1780 - parameterArrayTsv: Array<(string)> | null; 1781 - }; 1540 + req: CollectionFormatData; 1782 1541 }; 1783 1542 }; 1784 1543 '/api/v{api-version}/types': { 1785 1544 get: { 1786 - req: { 1787 - /** 1788 - * This is a number parameter 1789 - */ 1790 - id?: number; 1791 - /** 1792 - * This is an array parameter 1793 - */ 1794 - parameterArray: Array<(string)> | null; 1795 - /** 1796 - * This is a boolean parameter 1797 - */ 1798 - parameterBoolean: boolean | null; 1799 - /** 1800 - * This is a dictionary parameter 1801 - */ 1802 - parameterDictionary: { 1803 - [key: string]: unknown; 1804 - } | null; 1805 - /** 1806 - * This is an enum parameter 1807 - */ 1808 - parameterEnum: 'Success' | 'Warning' | 'Error' | null; 1809 - /** 1810 - * This is a number parameter 1811 - */ 1812 - parameterNumber: number; 1813 - /** 1814 - * This is an object parameter 1815 - */ 1816 - parameterObject: { 1817 - [key: string]: unknown; 1818 - } | null; 1819 - /** 1820 - * This is a string parameter 1821 - */ 1822 - parameterString: string | null; 1823 - }; 1545 + req: TypesData; 1824 1546 res: { 1825 1547 /** 1826 1548 * Response is a simple number ··· 1845 1567 }; 1846 1568 '/api/v{api-version}/upload': { 1847 1569 post: { 1848 - req: { 1849 - /** 1850 - * Supply a file reference for upload 1851 - */ 1852 - file: (Blob | File); 1853 - }; 1570 + req: UploadFileData; 1854 1571 res: { 1855 1572 200: boolean; 1856 1573 }; ··· 1858 1575 }; 1859 1576 '/api/v{api-version}/file/{id}': { 1860 1577 get: { 1861 - req: { 1862 - id: string; 1863 - }; 1578 + req: FileResponseData; 1864 1579 res: { 1865 1580 /** 1866 1581 * Success ··· 1871 1586 }; 1872 1587 '/api/v{api-version}/complex': { 1873 1588 get: { 1874 - req: { 1875 - /** 1876 - * Parameter containing object 1877 - */ 1878 - parameterObject: { 1879 - first?: { 1880 - second?: { 1881 - third?: string; 1882 - }; 1883 - }; 1884 - }; 1885 - /** 1886 - * Parameter containing reference 1887 - */ 1888 - parameterReference: ModelWithString; 1889 - }; 1589 + req: ComplexTypesData; 1890 1590 res: { 1891 1591 /** 1892 1592 * Successful response ··· 1905 1605 }; 1906 1606 '/api/v{api-version}/complex/{id}': { 1907 1607 put: { 1908 - req: { 1909 - id: number; 1910 - requestBody?: { 1911 - readonly key: string | null; 1912 - name: string | null; 1913 - enabled?: boolean; 1914 - readonly type: 'Monkey' | 'Horse' | 'Bird'; 1915 - listOfModels?: Array<ModelWithString> | null; 1916 - listOfStrings?: Array<(string)> | null; 1917 - parameters: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; 1918 - readonly user?: { 1919 - readonly id?: number; 1920 - readonly name?: string | null; 1921 - }; 1922 - }; 1923 - }; 1608 + req: ComplexParamsData; 1924 1609 res: { 1925 1610 /** 1926 1611 * Success ··· 1931 1616 }; 1932 1617 '/api/v{api-version}/multipart': { 1933 1618 post: { 1934 - req: { 1935 - formData?: { 1936 - content?: (Blob | File); 1937 - data?: ModelWithString | null; 1938 - }; 1939 - }; 1619 + req: ; 1940 1620 }; 1941 1621 get: { 1942 1622 res: { ··· 1973 1653 }; 1974 1654 '/api/v{api-version}/error': { 1975 1655 post: { 1976 - req: { 1977 - /** 1978 - * Status code to return 1979 - */ 1980 - status: number; 1981 - }; 1656 + req: TestErrorCodeData; 1982 1657 res: { 1983 1658 /** 1984 1659 * Custom message: Successful response ··· 2005 1680 }; 2006 1681 '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串': { 2007 1682 post: { 2008 - req: { 2009 - /** 2010 - * Dummy input param 2011 - */ 2012 - nonAsciiParamæøåÆøÅöôêÊ: number; 2013 - }; 1683 + req: NonAsciiæøåÆøÅöôêÊ字符串Data; 2014 1684 res: { 2015 1685 /** 2016 1686 * Successful response
+22 -352
packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/types.gen.ts.snap
··· 1270 1270 export type $OpenApiTs = { 1271 1271 '/api/v{api-version}/no-tag': { 1272 1272 post: { 1273 - req: { 1274 - requestBody: ModelWithReadOnlyAndWriteOnly | ModelWithArrayReadOnlyAndWriteOnly; 1275 - }; 1273 + req: PostServiceWithEmptyTagData; 1276 1274 res: { 1277 1275 default: ModelWithReadOnlyAndWriteOnly; 1278 1276 }; ··· 1290 1288 }; 1291 1289 '/api/v{api-version}/foo/{foo}/bar/{bar}': { 1292 1290 delete: { 1293 - req: { 1294 - /** 1295 - * bar in method 1296 - */ 1297 - bar: string; 1298 - /** 1299 - * foo in method 1300 - */ 1301 - foo: string; 1302 - }; 1291 + req: DeleteFooData3; 1303 1292 }; 1304 1293 }; 1305 1294 '/api/v{api-version}/parameters/{parameterPath}': { 1306 1295 post: { 1307 - req: { 1308 - fooAllOfEnum: ModelWithNestedArrayEnumsDataFoo; 1309 - fooRefEnum?: ModelWithNestedArrayEnumsDataFoo; 1310 - /** 1311 - * This is the parameter that goes into the cookie 1312 - */ 1313 - parameterCookie: string | null; 1314 - /** 1315 - * This is the parameter that goes into the form data 1316 - */ 1317 - parameterForm: string | null; 1318 - /** 1319 - * This is the parameter that goes into the header 1320 - */ 1321 - parameterHeader: string | null; 1322 - /** 1323 - * This is the parameter that goes into the path 1324 - */ 1325 - parameterPath: string | null; 1326 - /** 1327 - * This is the parameter that goes into the query params 1328 - */ 1329 - parameterQuery: string | null; 1330 - /** 1331 - * This is the parameter that goes into the body 1332 - */ 1333 - requestBody: ModelWithString | null; 1334 - }; 1296 + req: CallWithParametersData; 1335 1297 }; 1336 1298 }; 1337 1299 '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}': { 1338 1300 post: { 1339 - req: { 1340 - /** 1341 - * This is the parameter with a reserved keyword 1342 - */ 1343 - _default?: string; 1344 - /** 1345 - * This is the parameter that goes into the cookie 1346 - */ 1347 - parameterCookie: string | null; 1348 - /** 1349 - * This is the parameter that goes into the request form data 1350 - */ 1351 - parameterForm: string | null; 1352 - /** 1353 - * This is the parameter that goes into the request header 1354 - */ 1355 - parameterHeader: string | null; 1356 - /** 1357 - * This is the parameter that goes into the path 1358 - */ 1359 - parameterPath1?: string; 1360 - /** 1361 - * This is the parameter that goes into the path 1362 - */ 1363 - parameterPath2?: string; 1364 - /** 1365 - * This is the parameter that goes into the path 1366 - */ 1367 - parameterPath3?: string; 1368 - /** 1369 - * This is the parameter that goes into the request query params 1370 - */ 1371 - parameterQuery: string | null; 1372 - /** 1373 - * This is the parameter that goes into the body 1374 - */ 1375 - requestBody: ModelWithString | null; 1376 - }; 1301 + req: CallWithWeirdParameterNamesData; 1377 1302 }; 1378 1303 }; 1379 1304 '/api/v{api-version}/parameters/': { 1380 1305 get: { 1381 - req: { 1382 - /** 1383 - * This is an optional parameter 1384 - */ 1385 - parameter?: string; 1386 - /** 1387 - * This is a required parameter 1388 - */ 1389 - requestBody: ModelWithOneOfEnum; 1390 - }; 1306 + req: PostCallWithOptionalParamData; 1391 1307 }; 1392 1308 post: { 1393 - req: { 1394 - /** 1395 - * This is a required parameter 1396 - */ 1397 - parameter: Pageable; 1398 - /** 1399 - * This is an optional parameter 1400 - */ 1401 - requestBody?: ModelWithString; 1402 - }; 1309 + req: PostCallWithOptionalParamData; 1403 1310 }; 1404 1311 }; 1405 1312 '/api/v{api-version}/descriptions/': { 1406 1313 post: { 1407 - req: { 1408 - /** 1409 - * Testing backticks in string: `backticks` and ```multiple backticks``` should work 1410 - */ 1411 - parameterWithBackticks?: unknown; 1412 - /** 1413 - * Testing multiline comments in string: First line 1414 - * Second line 1415 - * 1416 - * Fourth line 1417 - */ 1418 - parameterWithBreaks?: unknown; 1419 - /** 1420 - * Testing expression placeholders in string: ${expression} should work 1421 - */ 1422 - parameterWithExpressionPlaceholders?: unknown; 1423 - /** 1424 - * Testing quotes in string: 'single quote''' and "double quotes""" should work 1425 - */ 1426 - parameterWithQuotes?: unknown; 1427 - /** 1428 - * Testing reserved characters in string: * inline * and ** inline ** should work 1429 - */ 1430 - parameterWithReservedCharacters?: unknown; 1431 - /** 1432 - * Testing slashes in string: \backwards\\\ and /forwards/// should work 1433 - */ 1434 - parameterWithSlashes?: unknown; 1435 - }; 1314 + req: CallWithDescriptionsData; 1436 1315 }; 1437 1316 }; 1438 1317 '/api/v{api-version}/parameters/deprecated': { 1439 1318 post: { 1440 - req: { 1441 - /** 1442 - * This parameter is deprecated 1443 - * @deprecated 1444 - */ 1445 - parameter: DeprecatedModel | null; 1446 - }; 1319 + req: DeprecatedCallData; 1447 1320 }; 1448 1321 }; 1449 1322 '/api/v{api-version}/requestBody/': { 1450 1323 post: { 1451 - req: { 1452 - /** 1453 - * A reusable request body 1454 - */ 1455 - foo?: ModelWithString; 1456 - /** 1457 - * This is a reusable parameter 1458 - */ 1459 - parameter?: string; 1460 - }; 1324 + req: PostApiRequestBodyData; 1461 1325 }; 1462 1326 }; 1463 1327 '/api/v{api-version}/formData/': { 1464 1328 post: { 1465 - req: { 1466 - /** 1467 - * A reusable request body 1468 - */ 1469 - formData?: ModelWithString; 1470 - /** 1471 - * This is a reusable parameter 1472 - */ 1473 - parameter?: string; 1474 - }; 1329 + req: PostApiFormDataData; 1475 1330 }; 1476 1331 }; 1477 1332 '/api/v{api-version}/defaults': { 1478 1333 get: { 1479 - req: { 1480 - /** 1481 - * This is a simple boolean with default value 1482 - */ 1483 - parameterBoolean?: boolean | null; 1484 - /** 1485 - * This is a simple enum with default value 1486 - */ 1487 - parameterEnum?: 'Success' | 'Warning' | 'Error'; 1488 - /** 1489 - * This is a simple model with default value 1490 - */ 1491 - parameterModel?: ModelWithString | null; 1492 - /** 1493 - * This is a simple number with default value 1494 - */ 1495 - parameterNumber?: number | null; 1496 - /** 1497 - * This is a simple string with default value 1498 - */ 1499 - parameterString?: string | null; 1500 - }; 1334 + req: CallToTestOrderOfParamsData; 1501 1335 }; 1502 1336 post: { 1503 - req: { 1504 - /** 1505 - * This is a simple boolean that is optional with default value 1506 - */ 1507 - parameterBoolean?: boolean; 1508 - /** 1509 - * This is a simple enum that is optional with default value 1510 - */ 1511 - parameterEnum?: 'Success' | 'Warning' | 'Error'; 1512 - /** 1513 - * This is a simple model that is optional with default value 1514 - */ 1515 - parameterModel?: ModelWithString; 1516 - /** 1517 - * This is a simple number that is optional with default value 1518 - */ 1519 - parameterNumber?: number; 1520 - /** 1521 - * This is a simple string that is optional with default value 1522 - */ 1523 - parameterString?: string; 1524 - }; 1337 + req: CallToTestOrderOfParamsData; 1525 1338 }; 1526 1339 put: { 1527 - req: { 1528 - /** 1529 - * This is a optional string with default 1530 - */ 1531 - parameterOptionalStringWithDefault?: string; 1532 - /** 1533 - * This is a optional string with empty default 1534 - */ 1535 - parameterOptionalStringWithEmptyDefault?: string; 1536 - /** 1537 - * This is a optional string with no default 1538 - */ 1539 - parameterOptionalStringWithNoDefault?: string; 1540 - /** 1541 - * This is a string that can be null with default 1542 - */ 1543 - parameterStringNullableWithDefault?: string | null; 1544 - /** 1545 - * This is a string that can be null with no default 1546 - */ 1547 - parameterStringNullableWithNoDefault?: string | null; 1548 - /** 1549 - * This is a string with default 1550 - */ 1551 - parameterStringWithDefault: string; 1552 - /** 1553 - * This is a string with empty default 1554 - */ 1555 - parameterStringWithEmptyDefault: string; 1556 - /** 1557 - * This is a string with no default 1558 - */ 1559 - parameterStringWithNoDefault: string; 1560 - }; 1340 + req: CallToTestOrderOfParamsData; 1561 1341 }; 1562 1342 }; 1563 1343 '/api/v{api-version}/no-content': { ··· 1677 1457 }; 1678 1458 '/api/v{api-version}/collectionFormat': { 1679 1459 get: { 1680 - req: { 1681 - /** 1682 - * This is an array parameter that is sent as csv format (comma-separated values) 1683 - */ 1684 - parameterArrayCsv: Array<(string)> | null; 1685 - /** 1686 - * This is an array parameter that is sent as multi format (multiple parameter instances) 1687 - */ 1688 - parameterArrayMulti: Array<(string)> | null; 1689 - /** 1690 - * This is an array parameter that is sent as pipes format (pipe-separated values) 1691 - */ 1692 - parameterArrayPipes: Array<(string)> | null; 1693 - /** 1694 - * This is an array parameter that is sent as ssv format (space-separated values) 1695 - */ 1696 - parameterArraySsv: Array<(string)> | null; 1697 - /** 1698 - * This is an array parameter that is sent as tsv format (tab-separated values) 1699 - */ 1700 - parameterArrayTsv: Array<(string)> | null; 1701 - }; 1460 + req: CollectionFormatData; 1702 1461 }; 1703 1462 }; 1704 1463 '/api/v{api-version}/types': { 1705 1464 get: { 1706 - req: { 1707 - /** 1708 - * This is a number parameter 1709 - */ 1710 - id?: number; 1711 - /** 1712 - * This is an array parameter 1713 - */ 1714 - parameterArray: Array<(string)> | null; 1715 - /** 1716 - * This is a boolean parameter 1717 - */ 1718 - parameterBoolean: boolean | null; 1719 - /** 1720 - * This is a dictionary parameter 1721 - */ 1722 - parameterDictionary: { 1723 - [key: string]: unknown; 1724 - } | null; 1725 - /** 1726 - * This is an enum parameter 1727 - */ 1728 - parameterEnum: 'Success' | 'Warning' | 'Error' | null; 1729 - /** 1730 - * This is a number parameter 1731 - */ 1732 - parameterNumber: number; 1733 - /** 1734 - * This is an object parameter 1735 - */ 1736 - parameterObject: { 1737 - [key: string]: unknown; 1738 - } | null; 1739 - /** 1740 - * This is a string parameter 1741 - */ 1742 - parameterString: string | null; 1743 - }; 1465 + req: TypesData; 1744 1466 res: { 1745 1467 /** 1746 1468 * Response is a simple number ··· 1765 1487 }; 1766 1488 '/api/v{api-version}/upload': { 1767 1489 post: { 1768 - req: { 1769 - /** 1770 - * Supply a file reference for upload 1771 - */ 1772 - file: (Blob | File); 1773 - }; 1490 + req: UploadFileData; 1774 1491 res: { 1775 1492 200: boolean; 1776 1493 }; ··· 1778 1495 }; 1779 1496 '/api/v{api-version}/file/{id}': { 1780 1497 get: { 1781 - req: { 1782 - id: string; 1783 - }; 1498 + req: FileResponseData; 1784 1499 res: { 1785 1500 /** 1786 1501 * Success ··· 1791 1506 }; 1792 1507 '/api/v{api-version}/complex': { 1793 1508 get: { 1794 - req: { 1795 - /** 1796 - * Parameter containing object 1797 - */ 1798 - parameterObject: { 1799 - first?: { 1800 - second?: { 1801 - third?: string; 1802 - }; 1803 - }; 1804 - }; 1805 - /** 1806 - * Parameter containing reference 1807 - */ 1808 - parameterReference: ModelWithString; 1809 - }; 1509 + req: ComplexTypesData; 1810 1510 res: { 1811 1511 /** 1812 1512 * Successful response ··· 1825 1525 }; 1826 1526 '/api/v{api-version}/complex/{id}': { 1827 1527 put: { 1828 - req: { 1829 - id: number; 1830 - requestBody?: { 1831 - readonly key: string | null; 1832 - name: string | null; 1833 - enabled?: boolean; 1834 - readonly type: 'Monkey' | 'Horse' | 'Bird'; 1835 - listOfModels?: Array<ModelWithString> | null; 1836 - listOfStrings?: Array<(string)> | null; 1837 - parameters: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; 1838 - readonly user?: { 1839 - readonly id?: number; 1840 - readonly name?: string | null; 1841 - }; 1842 - }; 1843 - }; 1528 + req: ComplexParamsData; 1844 1529 res: { 1845 1530 /** 1846 1531 * Success ··· 1851 1536 }; 1852 1537 '/api/v{api-version}/multipart': { 1853 1538 post: { 1854 - req: { 1855 - formData?: { 1856 - content?: (Blob | File); 1857 - data?: ModelWithString | null; 1858 - }; 1859 - }; 1539 + req: ; 1860 1540 }; 1861 1541 get: { 1862 1542 res: { ··· 1893 1573 }; 1894 1574 '/api/v{api-version}/error': { 1895 1575 post: { 1896 - req: { 1897 - /** 1898 - * Status code to return 1899 - */ 1900 - status: number; 1901 - }; 1576 + req: TestErrorCodeData; 1902 1577 res: { 1903 1578 /** 1904 1579 * Custom message: Successful response ··· 1925 1600 }; 1926 1601 '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串': { 1927 1602 post: { 1928 - req: { 1929 - /** 1930 - * Dummy input param 1931 - */ 1932 - nonAsciiParamæøåÆøÅöôêÊ: number; 1933 - }; 1603 + req: NonAsciiæøåÆøÅöôêÊ字符串Data; 1934 1604 res: { 1935 1605 /** 1936 1606 * Successful response
+22 -352
packages/openapi-ts/test/__snapshots__/test/generated/v3_client/types.gen.ts.snap
··· 1270 1270 export type $OpenApiTs = { 1271 1271 '/api/v{api-version}/no-tag': { 1272 1272 post: { 1273 - req: { 1274 - requestBody: ModelWithReadOnlyAndWriteOnly | ModelWithArrayReadOnlyAndWriteOnly; 1275 - }; 1273 + req: PostServiceWithEmptyTagData; 1276 1274 res: { 1277 1275 default: ModelWithReadOnlyAndWriteOnly; 1278 1276 }; ··· 1290 1288 }; 1291 1289 '/api/v{api-version}/foo/{foo}/bar/{bar}': { 1292 1290 delete: { 1293 - req: { 1294 - /** 1295 - * bar in method 1296 - */ 1297 - bar: string; 1298 - /** 1299 - * foo in method 1300 - */ 1301 - foo: string; 1302 - }; 1291 + req: DeleteFooData3; 1303 1292 }; 1304 1293 }; 1305 1294 '/api/v{api-version}/parameters/{parameterPath}': { 1306 1295 post: { 1307 - req: { 1308 - fooAllOfEnum: ModelWithNestedArrayEnumsDataFoo; 1309 - fooRefEnum?: ModelWithNestedArrayEnumsDataFoo; 1310 - /** 1311 - * This is the parameter that goes into the cookie 1312 - */ 1313 - parameterCookie: string | null; 1314 - /** 1315 - * This is the parameter that goes into the form data 1316 - */ 1317 - parameterForm: string | null; 1318 - /** 1319 - * This is the parameter that goes into the header 1320 - */ 1321 - parameterHeader: string | null; 1322 - /** 1323 - * This is the parameter that goes into the path 1324 - */ 1325 - parameterPath: string | null; 1326 - /** 1327 - * This is the parameter that goes into the query params 1328 - */ 1329 - parameterQuery: string | null; 1330 - /** 1331 - * This is the parameter that goes into the body 1332 - */ 1333 - requestBody: ModelWithString | null; 1334 - }; 1296 + req: CallWithParametersData; 1335 1297 }; 1336 1298 }; 1337 1299 '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}': { 1338 1300 post: { 1339 - req: { 1340 - /** 1341 - * This is the parameter with a reserved keyword 1342 - */ 1343 - _default?: string; 1344 - /** 1345 - * This is the parameter that goes into the cookie 1346 - */ 1347 - parameterCookie: string | null; 1348 - /** 1349 - * This is the parameter that goes into the request form data 1350 - */ 1351 - parameterForm: string | null; 1352 - /** 1353 - * This is the parameter that goes into the request header 1354 - */ 1355 - parameterHeader: string | null; 1356 - /** 1357 - * This is the parameter that goes into the path 1358 - */ 1359 - parameterPath1?: string; 1360 - /** 1361 - * This is the parameter that goes into the path 1362 - */ 1363 - parameterPath2?: string; 1364 - /** 1365 - * This is the parameter that goes into the path 1366 - */ 1367 - parameterPath3?: string; 1368 - /** 1369 - * This is the parameter that goes into the request query params 1370 - */ 1371 - parameterQuery: string | null; 1372 - /** 1373 - * This is the parameter that goes into the body 1374 - */ 1375 - requestBody: ModelWithString | null; 1376 - }; 1301 + req: CallWithWeirdParameterNamesData; 1377 1302 }; 1378 1303 }; 1379 1304 '/api/v{api-version}/parameters/': { 1380 1305 get: { 1381 - req: { 1382 - /** 1383 - * This is an optional parameter 1384 - */ 1385 - parameter?: string; 1386 - /** 1387 - * This is a required parameter 1388 - */ 1389 - requestBody: ModelWithOneOfEnum; 1390 - }; 1306 + req: PostCallWithOptionalParamData; 1391 1307 }; 1392 1308 post: { 1393 - req: { 1394 - /** 1395 - * This is a required parameter 1396 - */ 1397 - parameter: Pageable; 1398 - /** 1399 - * This is an optional parameter 1400 - */ 1401 - requestBody?: ModelWithString; 1402 - }; 1309 + req: PostCallWithOptionalParamData; 1403 1310 }; 1404 1311 }; 1405 1312 '/api/v{api-version}/descriptions/': { 1406 1313 post: { 1407 - req: { 1408 - /** 1409 - * Testing backticks in string: `backticks` and ```multiple backticks``` should work 1410 - */ 1411 - parameterWithBackticks?: unknown; 1412 - /** 1413 - * Testing multiline comments in string: First line 1414 - * Second line 1415 - * 1416 - * Fourth line 1417 - */ 1418 - parameterWithBreaks?: unknown; 1419 - /** 1420 - * Testing expression placeholders in string: ${expression} should work 1421 - */ 1422 - parameterWithExpressionPlaceholders?: unknown; 1423 - /** 1424 - * Testing quotes in string: 'single quote''' and "double quotes""" should work 1425 - */ 1426 - parameterWithQuotes?: unknown; 1427 - /** 1428 - * Testing reserved characters in string: * inline * and ** inline ** should work 1429 - */ 1430 - parameterWithReservedCharacters?: unknown; 1431 - /** 1432 - * Testing slashes in string: \backwards\\\ and /forwards/// should work 1433 - */ 1434 - parameterWithSlashes?: unknown; 1435 - }; 1314 + req: CallWithDescriptionsData; 1436 1315 }; 1437 1316 }; 1438 1317 '/api/v{api-version}/parameters/deprecated': { 1439 1318 post: { 1440 - req: { 1441 - /** 1442 - * This parameter is deprecated 1443 - * @deprecated 1444 - */ 1445 - parameter: DeprecatedModel | null; 1446 - }; 1319 + req: DeprecatedCallData; 1447 1320 }; 1448 1321 }; 1449 1322 '/api/v{api-version}/requestBody/': { 1450 1323 post: { 1451 - req: { 1452 - /** 1453 - * A reusable request body 1454 - */ 1455 - foo?: ModelWithString; 1456 - /** 1457 - * This is a reusable parameter 1458 - */ 1459 - parameter?: string; 1460 - }; 1324 + req: PostApiRequestBodyData; 1461 1325 }; 1462 1326 }; 1463 1327 '/api/v{api-version}/formData/': { 1464 1328 post: { 1465 - req: { 1466 - /** 1467 - * A reusable request body 1468 - */ 1469 - formData?: ModelWithString; 1470 - /** 1471 - * This is a reusable parameter 1472 - */ 1473 - parameter?: string; 1474 - }; 1329 + req: PostApiFormDataData; 1475 1330 }; 1476 1331 }; 1477 1332 '/api/v{api-version}/defaults': { 1478 1333 get: { 1479 - req: { 1480 - /** 1481 - * This is a simple boolean with default value 1482 - */ 1483 - parameterBoolean?: boolean | null; 1484 - /** 1485 - * This is a simple enum with default value 1486 - */ 1487 - parameterEnum?: 'Success' | 'Warning' | 'Error'; 1488 - /** 1489 - * This is a simple model with default value 1490 - */ 1491 - parameterModel?: ModelWithString | null; 1492 - /** 1493 - * This is a simple number with default value 1494 - */ 1495 - parameterNumber?: number | null; 1496 - /** 1497 - * This is a simple string with default value 1498 - */ 1499 - parameterString?: string | null; 1500 - }; 1334 + req: CallToTestOrderOfParamsData; 1501 1335 }; 1502 1336 post: { 1503 - req: { 1504 - /** 1505 - * This is a simple boolean that is optional with default value 1506 - */ 1507 - parameterBoolean?: boolean; 1508 - /** 1509 - * This is a simple enum that is optional with default value 1510 - */ 1511 - parameterEnum?: 'Success' | 'Warning' | 'Error'; 1512 - /** 1513 - * This is a simple model that is optional with default value 1514 - */ 1515 - parameterModel?: ModelWithString; 1516 - /** 1517 - * This is a simple number that is optional with default value 1518 - */ 1519 - parameterNumber?: number; 1520 - /** 1521 - * This is a simple string that is optional with default value 1522 - */ 1523 - parameterString?: string; 1524 - }; 1337 + req: CallToTestOrderOfParamsData; 1525 1338 }; 1526 1339 put: { 1527 - req: { 1528 - /** 1529 - * This is a optional string with default 1530 - */ 1531 - parameterOptionalStringWithDefault?: string; 1532 - /** 1533 - * This is a optional string with empty default 1534 - */ 1535 - parameterOptionalStringWithEmptyDefault?: string; 1536 - /** 1537 - * This is a optional string with no default 1538 - */ 1539 - parameterOptionalStringWithNoDefault?: string; 1540 - /** 1541 - * This is a string that can be null with default 1542 - */ 1543 - parameterStringNullableWithDefault?: string | null; 1544 - /** 1545 - * This is a string that can be null with no default 1546 - */ 1547 - parameterStringNullableWithNoDefault?: string | null; 1548 - /** 1549 - * This is a string with default 1550 - */ 1551 - parameterStringWithDefault: string; 1552 - /** 1553 - * This is a string with empty default 1554 - */ 1555 - parameterStringWithEmptyDefault: string; 1556 - /** 1557 - * This is a string with no default 1558 - */ 1559 - parameterStringWithNoDefault: string; 1560 - }; 1340 + req: CallToTestOrderOfParamsData; 1561 1341 }; 1562 1342 }; 1563 1343 '/api/v{api-version}/no-content': { ··· 1677 1457 }; 1678 1458 '/api/v{api-version}/collectionFormat': { 1679 1459 get: { 1680 - req: { 1681 - /** 1682 - * This is an array parameter that is sent as csv format (comma-separated values) 1683 - */ 1684 - parameterArrayCsv: Array<(string)> | null; 1685 - /** 1686 - * This is an array parameter that is sent as multi format (multiple parameter instances) 1687 - */ 1688 - parameterArrayMulti: Array<(string)> | null; 1689 - /** 1690 - * This is an array parameter that is sent as pipes format (pipe-separated values) 1691 - */ 1692 - parameterArrayPipes: Array<(string)> | null; 1693 - /** 1694 - * This is an array parameter that is sent as ssv format (space-separated values) 1695 - */ 1696 - parameterArraySsv: Array<(string)> | null; 1697 - /** 1698 - * This is an array parameter that is sent as tsv format (tab-separated values) 1699 - */ 1700 - parameterArrayTsv: Array<(string)> | null; 1701 - }; 1460 + req: CollectionFormatData; 1702 1461 }; 1703 1462 }; 1704 1463 '/api/v{api-version}/types': { 1705 1464 get: { 1706 - req: { 1707 - /** 1708 - * This is a number parameter 1709 - */ 1710 - id?: number; 1711 - /** 1712 - * This is an array parameter 1713 - */ 1714 - parameterArray: Array<(string)> | null; 1715 - /** 1716 - * This is a boolean parameter 1717 - */ 1718 - parameterBoolean: boolean | null; 1719 - /** 1720 - * This is a dictionary parameter 1721 - */ 1722 - parameterDictionary: { 1723 - [key: string]: unknown; 1724 - } | null; 1725 - /** 1726 - * This is an enum parameter 1727 - */ 1728 - parameterEnum: 'Success' | 'Warning' | 'Error' | null; 1729 - /** 1730 - * This is a number parameter 1731 - */ 1732 - parameterNumber: number; 1733 - /** 1734 - * This is an object parameter 1735 - */ 1736 - parameterObject: { 1737 - [key: string]: unknown; 1738 - } | null; 1739 - /** 1740 - * This is a string parameter 1741 - */ 1742 - parameterString: string | null; 1743 - }; 1465 + req: TypesData; 1744 1466 res: { 1745 1467 /** 1746 1468 * Response is a simple number ··· 1765 1487 }; 1766 1488 '/api/v{api-version}/upload': { 1767 1489 post: { 1768 - req: { 1769 - /** 1770 - * Supply a file reference for upload 1771 - */ 1772 - file: (Blob | File); 1773 - }; 1490 + req: UploadFileData; 1774 1491 res: { 1775 1492 200: boolean; 1776 1493 }; ··· 1778 1495 }; 1779 1496 '/api/v{api-version}/file/{id}': { 1780 1497 get: { 1781 - req: { 1782 - id: string; 1783 - }; 1498 + req: FileResponseData; 1784 1499 res: { 1785 1500 /** 1786 1501 * Success ··· 1791 1506 }; 1792 1507 '/api/v{api-version}/complex': { 1793 1508 get: { 1794 - req: { 1795 - /** 1796 - * Parameter containing object 1797 - */ 1798 - parameterObject: { 1799 - first?: { 1800 - second?: { 1801 - third?: string; 1802 - }; 1803 - }; 1804 - }; 1805 - /** 1806 - * Parameter containing reference 1807 - */ 1808 - parameterReference: ModelWithString; 1809 - }; 1509 + req: ComplexTypesData; 1810 1510 res: { 1811 1511 /** 1812 1512 * Successful response ··· 1825 1525 }; 1826 1526 '/api/v{api-version}/complex/{id}': { 1827 1527 put: { 1828 - req: { 1829 - id: number; 1830 - requestBody?: { 1831 - readonly key: string | null; 1832 - name: string | null; 1833 - enabled?: boolean; 1834 - readonly type: 'Monkey' | 'Horse' | 'Bird'; 1835 - listOfModels?: Array<ModelWithString> | null; 1836 - listOfStrings?: Array<(string)> | null; 1837 - parameters: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; 1838 - readonly user?: { 1839 - readonly id?: number; 1840 - readonly name?: string | null; 1841 - }; 1842 - }; 1843 - }; 1528 + req: ComplexParamsData; 1844 1529 res: { 1845 1530 /** 1846 1531 * Success ··· 1851 1536 }; 1852 1537 '/api/v{api-version}/multipart': { 1853 1538 post: { 1854 - req: { 1855 - formData?: { 1856 - content?: (Blob | File); 1857 - data?: ModelWithString | null; 1858 - }; 1859 - }; 1539 + req: ; 1860 1540 }; 1861 1541 get: { 1862 1542 res: { ··· 1893 1573 }; 1894 1574 '/api/v{api-version}/error': { 1895 1575 post: { 1896 - req: { 1897 - /** 1898 - * Status code to return 1899 - */ 1900 - status: number; 1901 - }; 1576 + req: TestErrorCodeData; 1902 1577 res: { 1903 1578 /** 1904 1579 * Custom message: Successful response ··· 1925 1600 }; 1926 1601 '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串': { 1927 1602 post: { 1928 - req: { 1929 - /** 1930 - * Dummy input param 1931 - */ 1932 - nonAsciiParamæøåÆøÅöôêÊ: number; 1933 - }; 1603 + req: NonAsciiæøåÆøÅöôêÊ字符串Data; 1934 1604 res: { 1935 1605 /** 1936 1606 * Successful response
+22 -352
packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/types.gen.ts.snap
··· 1325 1325 export type $OpenApiTs = { 1326 1326 '/api/v{api-version}/no-tag': { 1327 1327 post: { 1328 - req: { 1329 - requestBody: ModelWithReadOnlyAndWriteOnly | ModelWithArrayReadOnlyAndWriteOnly; 1330 - }; 1328 + req: PostServiceWithEmptyTagData; 1331 1329 res: { 1332 1330 default: ModelWithReadOnlyAndWriteOnly; 1333 1331 }; ··· 1345 1343 }; 1346 1344 '/api/v{api-version}/foo/{foo}/bar/{bar}': { 1347 1345 delete: { 1348 - req: { 1349 - /** 1350 - * bar in method 1351 - */ 1352 - bar: string; 1353 - /** 1354 - * foo in method 1355 - */ 1356 - foo: string; 1357 - }; 1346 + req: DeleteFooData3; 1358 1347 }; 1359 1348 }; 1360 1349 '/api/v{api-version}/parameters/{parameterPath}': { 1361 1350 post: { 1362 - req: { 1363 - fooAllOfEnum: ModelWithNestedArrayEnumsDataFoo; 1364 - fooRefEnum?: ModelWithNestedArrayEnumsDataFoo; 1365 - /** 1366 - * This is the parameter that goes into the cookie 1367 - */ 1368 - parameterCookie: string | null; 1369 - /** 1370 - * This is the parameter that goes into the form data 1371 - */ 1372 - parameterForm: string | null; 1373 - /** 1374 - * This is the parameter that goes into the header 1375 - */ 1376 - parameterHeader: string | null; 1377 - /** 1378 - * This is the parameter that goes into the path 1379 - */ 1380 - parameterPath: string | null; 1381 - /** 1382 - * This is the parameter that goes into the query params 1383 - */ 1384 - parameterQuery: string | null; 1385 - /** 1386 - * This is the parameter that goes into the body 1387 - */ 1388 - requestBody: ModelWithString | null; 1389 - }; 1351 + req: CallWithParametersData; 1390 1352 }; 1391 1353 }; 1392 1354 '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}': { 1393 1355 post: { 1394 - req: { 1395 - /** 1396 - * This is the parameter with a reserved keyword 1397 - */ 1398 - _default?: string; 1399 - /** 1400 - * This is the parameter that goes into the cookie 1401 - */ 1402 - parameterCookie: string | null; 1403 - /** 1404 - * This is the parameter that goes into the request form data 1405 - */ 1406 - parameterForm: string | null; 1407 - /** 1408 - * This is the parameter that goes into the request header 1409 - */ 1410 - parameterHeader: string | null; 1411 - /** 1412 - * This is the parameter that goes into the path 1413 - */ 1414 - parameterPath1?: string; 1415 - /** 1416 - * This is the parameter that goes into the path 1417 - */ 1418 - parameterPath2?: string; 1419 - /** 1420 - * This is the parameter that goes into the path 1421 - */ 1422 - parameterPath3?: string; 1423 - /** 1424 - * This is the parameter that goes into the request query params 1425 - */ 1426 - parameterQuery: string | null; 1427 - /** 1428 - * This is the parameter that goes into the body 1429 - */ 1430 - requestBody: ModelWithString | null; 1431 - }; 1356 + req: CallWithWeirdParameterNamesData; 1432 1357 }; 1433 1358 }; 1434 1359 '/api/v{api-version}/parameters/': { 1435 1360 get: { 1436 - req: { 1437 - /** 1438 - * This is an optional parameter 1439 - */ 1440 - parameter?: string; 1441 - /** 1442 - * This is a required parameter 1443 - */ 1444 - requestBody: ModelWithOneOfEnum; 1445 - }; 1361 + req: PostCallWithOptionalParamData; 1446 1362 }; 1447 1363 post: { 1448 - req: { 1449 - /** 1450 - * This is a required parameter 1451 - */ 1452 - parameter: Pageable; 1453 - /** 1454 - * This is an optional parameter 1455 - */ 1456 - requestBody?: ModelWithString; 1457 - }; 1364 + req: PostCallWithOptionalParamData; 1458 1365 }; 1459 1366 }; 1460 1367 '/api/v{api-version}/descriptions/': { 1461 1368 post: { 1462 - req: { 1463 - /** 1464 - * Testing backticks in string: `backticks` and ```multiple backticks``` should work 1465 - */ 1466 - parameterWithBackticks?: unknown; 1467 - /** 1468 - * Testing multiline comments in string: First line 1469 - * Second line 1470 - * 1471 - * Fourth line 1472 - */ 1473 - parameterWithBreaks?: unknown; 1474 - /** 1475 - * Testing expression placeholders in string: ${expression} should work 1476 - */ 1477 - parameterWithExpressionPlaceholders?: unknown; 1478 - /** 1479 - * Testing quotes in string: 'single quote''' and "double quotes""" should work 1480 - */ 1481 - parameterWithQuotes?: unknown; 1482 - /** 1483 - * Testing reserved characters in string: * inline * and ** inline ** should work 1484 - */ 1485 - parameterWithReservedCharacters?: unknown; 1486 - /** 1487 - * Testing slashes in string: \backwards\\\ and /forwards/// should work 1488 - */ 1489 - parameterWithSlashes?: unknown; 1490 - }; 1369 + req: CallWithDescriptionsData; 1491 1370 }; 1492 1371 }; 1493 1372 '/api/v{api-version}/parameters/deprecated': { 1494 1373 post: { 1495 - req: { 1496 - /** 1497 - * This parameter is deprecated 1498 - * @deprecated 1499 - */ 1500 - parameter: DeprecatedModel | null; 1501 - }; 1374 + req: DeprecatedCallData; 1502 1375 }; 1503 1376 }; 1504 1377 '/api/v{api-version}/requestBody/': { 1505 1378 post: { 1506 - req: { 1507 - /** 1508 - * A reusable request body 1509 - */ 1510 - foo?: ModelWithString; 1511 - /** 1512 - * This is a reusable parameter 1513 - */ 1514 - parameter?: string; 1515 - }; 1379 + req: PostApiRequestBodyData; 1516 1380 }; 1517 1381 }; 1518 1382 '/api/v{api-version}/formData/': { 1519 1383 post: { 1520 - req: { 1521 - /** 1522 - * A reusable request body 1523 - */ 1524 - formData?: ModelWithString; 1525 - /** 1526 - * This is a reusable parameter 1527 - */ 1528 - parameter?: string; 1529 - }; 1384 + req: PostApiFormDataData; 1530 1385 }; 1531 1386 }; 1532 1387 '/api/v{api-version}/defaults': { 1533 1388 get: { 1534 - req: { 1535 - /** 1536 - * This is a simple boolean with default value 1537 - */ 1538 - parameterBoolean?: boolean | null; 1539 - /** 1540 - * This is a simple enum with default value 1541 - */ 1542 - parameterEnum?: 'Success' | 'Warning' | 'Error'; 1543 - /** 1544 - * This is a simple model with default value 1545 - */ 1546 - parameterModel?: ModelWithString | null; 1547 - /** 1548 - * This is a simple number with default value 1549 - */ 1550 - parameterNumber?: number | null; 1551 - /** 1552 - * This is a simple string with default value 1553 - */ 1554 - parameterString?: string | null; 1555 - }; 1389 + req: CallToTestOrderOfParamsData; 1556 1390 }; 1557 1391 post: { 1558 - req: { 1559 - /** 1560 - * This is a simple boolean that is optional with default value 1561 - */ 1562 - parameterBoolean?: boolean; 1563 - /** 1564 - * This is a simple enum that is optional with default value 1565 - */ 1566 - parameterEnum?: 'Success' | 'Warning' | 'Error'; 1567 - /** 1568 - * This is a simple model that is optional with default value 1569 - */ 1570 - parameterModel?: ModelWithString; 1571 - /** 1572 - * This is a simple number that is optional with default value 1573 - */ 1574 - parameterNumber?: number; 1575 - /** 1576 - * This is a simple string that is optional with default value 1577 - */ 1578 - parameterString?: string; 1579 - }; 1392 + req: CallToTestOrderOfParamsData; 1580 1393 }; 1581 1394 put: { 1582 - req: { 1583 - /** 1584 - * This is a optional string with default 1585 - */ 1586 - parameterOptionalStringWithDefault?: string; 1587 - /** 1588 - * This is a optional string with empty default 1589 - */ 1590 - parameterOptionalStringWithEmptyDefault?: string; 1591 - /** 1592 - * This is a optional string with no default 1593 - */ 1594 - parameterOptionalStringWithNoDefault?: string; 1595 - /** 1596 - * This is a string that can be null with default 1597 - */ 1598 - parameterStringNullableWithDefault?: string | null; 1599 - /** 1600 - * This is a string that can be null with no default 1601 - */ 1602 - parameterStringNullableWithNoDefault?: string | null; 1603 - /** 1604 - * This is a string with default 1605 - */ 1606 - parameterStringWithDefault: string; 1607 - /** 1608 - * This is a string with empty default 1609 - */ 1610 - parameterStringWithEmptyDefault: string; 1611 - /** 1612 - * This is a string with no default 1613 - */ 1614 - parameterStringWithNoDefault: string; 1615 - }; 1395 + req: CallToTestOrderOfParamsData; 1616 1396 }; 1617 1397 }; 1618 1398 '/api/v{api-version}/no-content': { ··· 1732 1512 }; 1733 1513 '/api/v{api-version}/collectionFormat': { 1734 1514 get: { 1735 - req: { 1736 - /** 1737 - * This is an array parameter that is sent as csv format (comma-separated values) 1738 - */ 1739 - parameterArrayCsv: Array<(string)> | null; 1740 - /** 1741 - * This is an array parameter that is sent as multi format (multiple parameter instances) 1742 - */ 1743 - parameterArrayMulti: Array<(string)> | null; 1744 - /** 1745 - * This is an array parameter that is sent as pipes format (pipe-separated values) 1746 - */ 1747 - parameterArrayPipes: Array<(string)> | null; 1748 - /** 1749 - * This is an array parameter that is sent as ssv format (space-separated values) 1750 - */ 1751 - parameterArraySsv: Array<(string)> | null; 1752 - /** 1753 - * This is an array parameter that is sent as tsv format (tab-separated values) 1754 - */ 1755 - parameterArrayTsv: Array<(string)> | null; 1756 - }; 1515 + req: CollectionFormatData; 1757 1516 }; 1758 1517 }; 1759 1518 '/api/v{api-version}/types': { 1760 1519 get: { 1761 - req: { 1762 - /** 1763 - * This is a number parameter 1764 - */ 1765 - id?: number; 1766 - /** 1767 - * This is an array parameter 1768 - */ 1769 - parameterArray: Array<(string)> | null; 1770 - /** 1771 - * This is a boolean parameter 1772 - */ 1773 - parameterBoolean: boolean | null; 1774 - /** 1775 - * This is a dictionary parameter 1776 - */ 1777 - parameterDictionary: { 1778 - [key: string]: unknown; 1779 - } | null; 1780 - /** 1781 - * This is an enum parameter 1782 - */ 1783 - parameterEnum: 'Success' | 'Warning' | 'Error' | null; 1784 - /** 1785 - * This is a number parameter 1786 - */ 1787 - parameterNumber: number; 1788 - /** 1789 - * This is an object parameter 1790 - */ 1791 - parameterObject: { 1792 - [key: string]: unknown; 1793 - } | null; 1794 - /** 1795 - * This is a string parameter 1796 - */ 1797 - parameterString: string | null; 1798 - }; 1520 + req: TypesData; 1799 1521 res: { 1800 1522 /** 1801 1523 * Response is a simple number ··· 1820 1542 }; 1821 1543 '/api/v{api-version}/upload': { 1822 1544 post: { 1823 - req: { 1824 - /** 1825 - * Supply a file reference for upload 1826 - */ 1827 - file: (Blob | File); 1828 - }; 1545 + req: UploadFileData; 1829 1546 res: { 1830 1547 200: boolean; 1831 1548 }; ··· 1833 1550 }; 1834 1551 '/api/v{api-version}/file/{id}': { 1835 1552 get: { 1836 - req: { 1837 - id: string; 1838 - }; 1553 + req: FileResponseData; 1839 1554 res: { 1840 1555 /** 1841 1556 * Success ··· 1846 1561 }; 1847 1562 '/api/v{api-version}/complex': { 1848 1563 get: { 1849 - req: { 1850 - /** 1851 - * Parameter containing object 1852 - */ 1853 - parameterObject: { 1854 - first?: { 1855 - second?: { 1856 - third?: string; 1857 - }; 1858 - }; 1859 - }; 1860 - /** 1861 - * Parameter containing reference 1862 - */ 1863 - parameterReference: ModelWithString; 1864 - }; 1564 + req: ComplexTypesData; 1865 1565 res: { 1866 1566 /** 1867 1567 * Successful response ··· 1880 1580 }; 1881 1581 '/api/v{api-version}/complex/{id}': { 1882 1582 put: { 1883 - req: { 1884 - id: number; 1885 - requestBody?: { 1886 - readonly key: string | null; 1887 - name: string | null; 1888 - enabled?: boolean; 1889 - readonly type: 'Monkey' | 'Horse' | 'Bird'; 1890 - listOfModels?: Array<ModelWithString> | null; 1891 - listOfStrings?: Array<(string)> | null; 1892 - parameters: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; 1893 - readonly user?: { 1894 - readonly id?: number; 1895 - readonly name?: string | null; 1896 - }; 1897 - }; 1898 - }; 1583 + req: ComplexParamsData; 1899 1584 res: { 1900 1585 /** 1901 1586 * Success ··· 1906 1591 }; 1907 1592 '/api/v{api-version}/multipart': { 1908 1593 post: { 1909 - req: { 1910 - formData?: { 1911 - content?: (Blob | File); 1912 - data?: ModelWithString | null; 1913 - }; 1914 - }; 1594 + req: ; 1915 1595 }; 1916 1596 get: { 1917 1597 res: { ··· 1948 1628 }; 1949 1629 '/api/v{api-version}/error': { 1950 1630 post: { 1951 - req: { 1952 - /** 1953 - * Status code to return 1954 - */ 1955 - status: number; 1956 - }; 1631 + req: TestErrorCodeData; 1957 1632 res: { 1958 1633 /** 1959 1634 * Custom message: Successful response ··· 1980 1655 }; 1981 1656 '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串': { 1982 1657 post: { 1983 - req: { 1984 - /** 1985 - * Dummy input param 1986 - */ 1987 - nonAsciiParamæøåÆøÅöôêÊ: number; 1988 - }; 1658 + req: NonAsciiæøåÆøÅöôêÊ字符串Data; 1989 1659 res: { 1990 1660 /** 1991 1661 * Successful response
+3 -78
packages/openapi-ts/test/__snapshots__/test/generated/v3_legacy_positional_args/types.gen.ts.snap
··· 104 104 export type $OpenApiTs = { 105 105 '/api/v{api-version}/defaults': { 106 106 get: { 107 - req: { 108 - /** 109 - * This is a simple boolean with default value 110 - */ 111 - parameterBoolean: boolean | null; 112 - /** 113 - * This is a simple enum with default value 114 - */ 115 - parameterEnum: 'Success' | 'Warning' | 'Error'; 116 - /** 117 - * This is a simple model with default value 118 - */ 119 - parameterModel: ModelWithString | null; 120 - /** 121 - * This is a simple number with default value 122 - */ 123 - parameterNumber: number | null; 124 - /** 125 - * This is a simple string with default value 126 - */ 127 - parameterString: string | null; 128 - }; 107 + req: CallToTestOrderOfParamsData; 129 108 }; 130 109 post: { 131 - req: { 132 - /** 133 - * This is a simple boolean that is optional with default value 134 - */ 135 - parameterBoolean: boolean; 136 - /** 137 - * This is a simple enum that is optional with default value 138 - */ 139 - parameterEnum: 'Success' | 'Warning' | 'Error'; 140 - /** 141 - * This is a simple model that is optional with default value 142 - */ 143 - parameterModel: ModelWithString; 144 - /** 145 - * This is a simple number that is optional with default value 146 - */ 147 - parameterNumber: number; 148 - /** 149 - * This is a simple string that is optional with default value 150 - */ 151 - parameterString: string; 152 - }; 110 + req: CallToTestOrderOfParamsData; 153 111 }; 154 112 put: { 155 - req: { 156 - /** 157 - * This is a optional string with default 158 - */ 159 - parameterOptionalStringWithDefault: string; 160 - /** 161 - * This is a optional string with empty default 162 - */ 163 - parameterOptionalStringWithEmptyDefault: string; 164 - /** 165 - * This is a optional string with no default 166 - */ 167 - parameterOptionalStringWithNoDefault?: string; 168 - /** 169 - * This is a string that can be null with default 170 - */ 171 - parameterStringNullableWithDefault: string | null; 172 - /** 173 - * This is a string that can be null with no default 174 - */ 175 - parameterStringNullableWithNoDefault?: string | null; 176 - /** 177 - * This is a string with default 178 - */ 179 - parameterStringWithDefault: string; 180 - /** 181 - * This is a string with empty default 182 - */ 183 - parameterStringWithEmptyDefault: string; 184 - /** 185 - * This is a string with no default 186 - */ 187 - parameterStringWithNoDefault: string; 188 - }; 113 + req: CallToTestOrderOfParamsData; 189 114 }; 190 115 }; 191 116 };
+3 -78
packages/openapi-ts/test/__snapshots__/test/generated/v3_options/types.gen.ts.snap
··· 104 104 export type $OpenApiTs = { 105 105 '/api/v{api-version}/defaults': { 106 106 get: { 107 - req: { 108 - /** 109 - * This is a simple boolean with default value 110 - */ 111 - parameterBoolean?: boolean | null; 112 - /** 113 - * This is a simple enum with default value 114 - */ 115 - parameterEnum?: 'Success' | 'Warning' | 'Error'; 116 - /** 117 - * This is a simple model with default value 118 - */ 119 - parameterModel?: ModelWithString | null; 120 - /** 121 - * This is a simple number with default value 122 - */ 123 - parameterNumber?: number | null; 124 - /** 125 - * This is a simple string with default value 126 - */ 127 - parameterString?: string | null; 128 - }; 107 + req: CallToTestOrderOfParamsData; 129 108 }; 130 109 post: { 131 - req: { 132 - /** 133 - * This is a simple boolean that is optional with default value 134 - */ 135 - parameterBoolean?: boolean; 136 - /** 137 - * This is a simple enum that is optional with default value 138 - */ 139 - parameterEnum?: 'Success' | 'Warning' | 'Error'; 140 - /** 141 - * This is a simple model that is optional with default value 142 - */ 143 - parameterModel?: ModelWithString; 144 - /** 145 - * This is a simple number that is optional with default value 146 - */ 147 - parameterNumber?: number; 148 - /** 149 - * This is a simple string that is optional with default value 150 - */ 151 - parameterString?: string; 152 - }; 110 + req: CallToTestOrderOfParamsData; 153 111 }; 154 112 put: { 155 - req: { 156 - /** 157 - * This is a optional string with default 158 - */ 159 - parameterOptionalStringWithDefault?: string; 160 - /** 161 - * This is a optional string with empty default 162 - */ 163 - parameterOptionalStringWithEmptyDefault?: string; 164 - /** 165 - * This is a optional string with no default 166 - */ 167 - parameterOptionalStringWithNoDefault?: string; 168 - /** 169 - * This is a string that can be null with default 170 - */ 171 - parameterStringNullableWithDefault?: string | null; 172 - /** 173 - * This is a string that can be null with no default 174 - */ 175 - parameterStringNullableWithNoDefault?: string | null; 176 - /** 177 - * This is a string with default 178 - */ 179 - parameterStringWithDefault: string; 180 - /** 181 - * This is a string with empty default 182 - */ 183 - parameterStringWithEmptyDefault: string; 184 - /** 185 - * This is a string with no default 186 - */ 187 - parameterStringWithNoDefault: string; 188 - }; 113 + req: CallToTestOrderOfParamsData; 189 114 }; 190 115 }; 191 116 };