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

Merge pull request #1241 from hey-api/feat/input-filter

feat: add `input.include` option

authored by

Lubos and committed by
GitHub
3e204195 3562159b

+567 -291
+5
.changeset/tidy-eyes-flash.md
··· 1 + --- 2 + '@hey-api/openapi-ts': minor 3 + --- 4 + 5 + feat: add input.include option
+2 -2
docs/.vitepress/config/en.ts
··· 69 69 }, 70 70 { 71 71 items: [ 72 - { link: '/about', text: 'Philosophy' }, 72 + { link: '/openapi-ts/migrating', text: 'Migrating' }, 73 73 { link: '/license', text: 'License' }, 74 + { link: '/about', text: 'Philosophy' }, 74 75 { link: '/contributing', text: 'Contributing' }, 75 - { link: '/openapi-ts/migrating', text: 'Migrating' }, 76 76 ], 77 77 text: '@hey-api', 78 78 },
+47
docs/openapi-ts/configuration.md
··· 49 49 We use [`@apidevtools/json-schema-ref-parser`](https://github.com/APIDevTools/json-schema-ref-parser) to resolve file locations. Please note that accessing a HTTPS URL on localhost has a known [workaround](https://github.com/hey-api/openapi-ts/issues/276). 50 50 ::: 51 51 52 + ## Filters 53 + 54 + ::: warning 55 + Filters work only with the [experimental parser](#parser) which is currently an opt-in feature. 56 + ::: 57 + 58 + If you work with large specifications and want to generate output from their subset, set `input.include` to a valid regular expression string. 59 + 60 + ```js 61 + export default { 62 + client: '@hey-api/client-fetch', 63 + experimentalParser: true, // [!code ++] 64 + input: { 65 + include: '^(#/components/schemas/foo|#/paths/api/v1/foo/get)$', // [!code ++] 66 + path: 'path/to/openapi.json', 67 + }, 68 + output: 'src/client', 69 + }; 70 + ``` 71 + 72 + The configuration above will process only the schema named `foo` and `GET` operation for the `/api/v1/foo` path. 73 + 52 74 ## Output 53 75 54 76 Output is the next thing to define. It can be either a string pointing to the destination folder or a configuration object containing the destination folder path and optional settings (these are described below). ··· 179 201 Plugins are responsible for generating artifacts from your input. By default, Hey API will generate TypeScript interfaces, JSON Schemas, and services from your OpenAPI specification. You can add, remove, or customize any of the plugins. In fact, we highly encourage you to do so! 180 202 181 203 You can learn more on the [Output](/openapi-ts/output) page. 204 + 205 + ## Parser 206 + 207 + If you're using OpenAPI 3.0 or newer, we encourage you to try out the experimental parser. In the future it will become the default parser, but until it's been tested it's an opt-in feature. To try it out, set the `experimentalParser` flag in your configuration to `true`. 208 + 209 + ::: code-group 210 + 211 + ```js [config] 212 + export default { 213 + client: '@hey-api/client-fetch', 214 + experimentalParser: true, // [!code ++] 215 + input: 'path/to/openapi.json', 216 + output: 'src/client', 217 + }; 218 + ``` 219 + 220 + ```sh [cli] 221 + npx @hey-api/openapi-ts -i path/to/openapi.json -o src/client -c @hey-api/client-fetch -e 222 + ``` 223 + 224 + ::: 225 + 226 + The experimental parser produces a cleaner output while being faster than the legacy parser. It also supports features such as [Filters](#filters) and more will be added in the future. 227 + 228 + The legacy parser will remain enabled for the [legacy clients](/openapi-ts/clients/legacy) regardless of the `experimentalParser` flag value. However, it's unlikely to receive any further updates. 182 229 183 230 ## Config API 184 231
+32
docs/openapi-ts/migrating.md
··· 50 50 51 51 This config option is deprecated and will be removed. 52 52 53 + ## v0.55.0 54 + 55 + This release adds the ability to filter your OpenAPI specification before it's processed. This feature will be useful if you are working with a large specification and are interested in generating output only from a small subset. 56 + 57 + This feature is available only in the experimental parser. In the future, this will become the default parser. To opt-in to the experimental parser, set the `experimentalParser` flag in your configuration to `true`. 58 + 59 + ### Deprecated `include` in `@hey-api/types` 60 + 61 + This config option is deprecated and will be removed when the experimental parser becomes the default. 62 + 63 + ### Deprecated `filter` in `@hey-api/services` 64 + 65 + This config option is deprecated and will be removed when the experimental parser becomes the default. 66 + 67 + ### Added `input.include` option 68 + 69 + This config option can be used to replace the deprecated options. It accepts a regular expression string matching against references within the bundled specification. 70 + 71 + ```js 72 + export default { 73 + client: '@hey-api/client-fetch', 74 + experimentalParser: true, 75 + input: { 76 + include: '^(#/components/schemas/foo|#/paths/api/v1/foo/get)$', // [!code ++] 77 + path: 'path/to/openapi.json', 78 + }, 79 + output: 'src/client', 80 + }; 81 + ``` 82 + 83 + The configuration above will process only the schema named `foo` and `GET` operation for the `/api/v1/foo` path. 84 + 53 85 ## v0.54.0 54 86 55 87 This release makes plugins first-class citizens. In order to achieve that, the following breaking changes were introduced.
-2
docs/openapi-ts/output.md
··· 8 8 Learn about files generated with `@hey-api/openapi-ts`. 9 9 10 10 ::: tip 11 - 12 11 Your actual output depends on your Hey API configuration. It may contain a different number of files and their contents might differ. 13 - 14 12 ::: 15 13 16 14 ## Overview
+3 -1
packages/openapi-ts/src/generate/__tests__/class.spec.ts
··· 19 19 dryRun: false, 20 20 experimentalParser: false, 21 21 exportCore: true, 22 - input: '', 22 + input: { 23 + path: '', 24 + }, 23 25 name: 'AppClient', 24 26 output: { 25 27 path: '',
+9 -3
packages/openapi-ts/src/generate/__tests__/core.spec.ts
··· 33 33 dryRun: false, 34 34 experimentalParser: false, 35 35 exportCore: true, 36 - input: '', 36 + input: { 37 + path: '', 38 + }, 37 39 name: 'AppClient', 38 40 output: { 39 41 path: '', ··· 106 108 dryRun: false, 107 109 experimentalParser: false, 108 110 exportCore: true, 109 - input: '', 111 + input: { 112 + path: '', 113 + }, 110 114 name: 'AppClient', 111 115 output: { 112 116 path: '', ··· 162 166 dryRun: false, 163 167 experimentalParser: false, 164 168 exportCore: true, 165 - input: '', 169 + input: { 170 + path: '', 171 + }, 166 172 name: 'AppClient', 167 173 output: { 168 174 path: '',
+3 -1
packages/openapi-ts/src/generate/__tests__/index.spec.ts
··· 20 20 dryRun: false, 21 21 experimentalParser: false, 22 22 exportCore: true, 23 - input: '', 23 + input: { 24 + path: '', 25 + }, 24 26 output: { 25 27 path: '', 26 28 },
+3 -1
packages/openapi-ts/src/generate/__tests__/output.spec.ts
··· 20 20 dryRun: false, 21 21 experimentalParser: false, 22 22 exportCore: true, 23 - input: '', 23 + input: { 24 + path: '', 25 + }, 24 26 output: { 25 27 format: 'prettier', 26 28 path: './dist',
+5 -3
packages/openapi-ts/src/generate/output.ts
··· 25 25 templates, 26 26 }: { 27 27 client: Client; 28 - openApi: OpenApi; 28 + openApi: unknown; 29 29 templates: Templates; 30 30 }): Promise<void> => { 31 31 const config = getConfig(); 32 + 33 + const spec = openApi as OpenApi; 32 34 33 35 // TODO: parser - move to config.input 34 36 if (client) { ··· 55 57 } 56 58 57 59 // deprecated files 58 - await generateLegacyClientClass(openApi, outputPath, client, templates); 60 + await generateLegacyClientClass(spec, outputPath, client, templates); 59 61 await generateLegacyCore( 60 62 path.resolve(config.output.path, 'core'), 61 63 client, ··· 78 80 plugin._handlerLegacy({ 79 81 client, 80 82 files, 81 - openApi, 83 + openApi: spec, 82 84 plugin: plugin as never, 83 85 }); 84 86 }
+43 -14
packages/openapi-ts/src/index.ts
··· 1 + import { existsSync } from 'node:fs'; 1 2 import path from 'node:path'; 2 3 4 + import $RefParser from '@apidevtools/json-schema-ref-parser'; 3 5 import { loadConfig } from 'c12'; 4 6 import { sync } from 'cross-spawn'; 5 7 ··· 23 25 legacyNameFromConfig, 24 26 setConfig, 25 27 } from './utils/config'; 26 - import { getOpenApiSpec } from './utils/getOpenApiSpec'; 27 28 import { registerHandlebarTemplates } from './utils/handlebars'; 28 29 import { Performance, PerformanceReport } from './utils/performance'; 29 30 import { postProcessClient } from './utils/postprocess'; ··· 125 126 return client; 126 127 }; 127 128 129 + const getInput = (userConfig: ClientConfig): Config['input'] => { 130 + let input: Config['input'] = { 131 + path: '', 132 + }; 133 + if (typeof userConfig.input === 'string') { 134 + input.path = userConfig.input; 135 + } else if (userConfig.input && userConfig.input.path) { 136 + input = { 137 + ...input, 138 + ...userConfig.input, 139 + }; 140 + } else { 141 + input = { 142 + ...input, 143 + path: userConfig.input, 144 + }; 145 + } 146 + return input; 147 + }; 148 + 128 149 const getOutput = (userConfig: ClientConfig): Config['output'] => { 129 150 let output: Config['output'] = { 130 151 format: false, ··· 221 242 }; 222 243 }; 223 244 245 + const getSpec = async ({ config }: { config: Config }) => { 246 + let spec: unknown = config.input.path; 247 + 248 + if (typeof config.input.path === 'string') { 249 + const absolutePathOrUrl = existsSync(config.input.path) 250 + ? path.resolve(config.input.path) 251 + : config.input.path; 252 + spec = await $RefParser.bundle(absolutePathOrUrl, absolutePathOrUrl, {}); 253 + } 254 + 255 + return spec; 256 + }; 257 + 224 258 const initConfigs = async (userConfig: UserConfig): Promise<Config[]> => { 225 259 let configurationFile: string | undefined = undefined; 226 260 if (userConfig.configFile) { ··· 250 284 dryRun = false, 251 285 exportCore = true, 252 286 experimentalParser = false, 253 - input, 254 287 name, 255 288 request, 256 289 useOptions = true, ··· 260 293 console.warn('userConfig:', userConfig); 261 294 } 262 295 296 + const input = getInput(userConfig); 263 297 const output = getOutput(userConfig); 264 298 265 - if (!input) { 299 + if (!input.path) { 266 300 throw new Error( 267 301 '🚫 missing input - which OpenAPI specification should we use to generate your client?', 268 302 ); ··· 332 366 Performance.end('handlebars'); 333 367 334 368 const pCreateClient = (config: Config) => async () => { 335 - Performance.start('openapi'); 336 - const openApi = 337 - typeof config.input === 'string' 338 - ? await getOpenApiSpec(config.input) 339 - : (config.input as unknown as Awaited< 340 - ReturnType<typeof getOpenApiSpec> 341 - >); 342 - Performance.end('openapi'); 369 + Performance.start('spec'); 370 + const spec = await getSpec({ config }); 371 + Performance.end('spec'); 343 372 344 373 let client: Client | undefined; 345 374 let context: IRContext | undefined; ··· 363 392 context = parseExperimental({ 364 393 config, 365 394 parserConfig, 366 - spec: openApi, 395 + spec, 367 396 }); 368 397 } 369 398 370 399 // fallback to legacy parser 371 400 if (!context) { 372 401 const parsed = parseLegacy({ 373 - openApi, 402 + openApi: spec, 374 403 parserConfig, 375 404 }); 376 405 client = postProcessClient(parsed); ··· 383 412 if (context) { 384 413 await generateOutput({ context }); 385 414 } else if (client) { 386 - await generateLegacyOutput({ client, openApi, templates }); 415 + await generateLegacyOutput({ client, openApi: spec, templates }); 387 416 } 388 417 Performance.end('generator'); 389 418
+31 -8
packages/openapi-ts/src/openApi/3.0.x/parser/index.ts
··· 1 1 import type { IRContext } from '../../../ir/context'; 2 + import { canProcessRef } from '../../shared/utils/filter'; 2 3 import type { 3 4 OpenApiV3_0_X, 4 5 ParameterObject, ··· 15 16 16 17 export const parseV3_0_X = (context: IRContext<OpenApiV3_0_X>) => { 17 18 const operationIds = new Map<string, string>(); 19 + 20 + const regexp = context.config.input.include 21 + ? new RegExp(context.config.input.include) 22 + : undefined; 18 23 19 24 for (const path in context.spec.paths) { 20 25 const pathItem = context.spec.paths[path as keyof PathsObject]; ··· 50 55 path: path as keyof PathsObject, 51 56 }; 52 57 53 - if (finalPathItem.delete) { 58 + const $refDelete = `#/paths${path}/delete`; 59 + if (finalPathItem.delete && canProcessRef($refDelete, regexp)) { 54 60 parseOperation({ 55 61 ...operationArgs, 56 62 method: 'delete', ··· 68 74 }); 69 75 } 70 76 71 - if (finalPathItem.get) { 77 + const $refGet = `#/paths${path}/get`; 78 + if (finalPathItem.get && canProcessRef($refGet, regexp)) { 72 79 parseOperation({ 73 80 ...operationArgs, 74 81 method: 'get', ··· 86 93 }); 87 94 } 88 95 89 - if (finalPathItem.head) { 96 + const $refHead = `#/paths${path}/head`; 97 + if (finalPathItem.head && canProcessRef($refHead, regexp)) { 90 98 parseOperation({ 91 99 ...operationArgs, 92 100 method: 'head', ··· 104 112 }); 105 113 } 106 114 107 - if (finalPathItem.options) { 115 + const $refOptions = `#/paths${path}/options`; 116 + if (finalPathItem.options && canProcessRef($refOptions, regexp)) { 108 117 parseOperation({ 109 118 ...operationArgs, 110 119 method: 'options', ··· 122 131 }); 123 132 } 124 133 125 - if (finalPathItem.patch) { 134 + const $refPatch = `#/paths${path}/patch`; 135 + if (finalPathItem.patch && canProcessRef($refPatch, regexp)) { 126 136 parseOperation({ 127 137 ...operationArgs, 128 138 method: 'patch', ··· 140 150 }); 141 151 } 142 152 143 - if (finalPathItem.post) { 153 + const $refPost = `#/paths${path}/post`; 154 + if (finalPathItem.post && canProcessRef($refPost, regexp)) { 144 155 parseOperation({ 145 156 ...operationArgs, 146 157 method: 'post', ··· 158 169 }); 159 170 } 160 171 161 - if (finalPathItem.put) { 172 + const $refPut = `#/paths${path}/put`; 173 + if (finalPathItem.put && canProcessRef($refPut, regexp)) { 162 174 parseOperation({ 163 175 ...operationArgs, 164 176 method: 'put', ··· 176 188 }); 177 189 } 178 190 179 - if (finalPathItem.trace) { 191 + const $refTrace = `#/paths${path}/trace`; 192 + if (finalPathItem.trace && canProcessRef($refTrace, regexp)) { 180 193 parseOperation({ 181 194 ...operationArgs, 182 195 method: 'trace', ··· 198 211 // TODO: parser - handle more component types, old parser handles only parameters and schemas 199 212 if (context.spec.components) { 200 213 for (const name in context.spec.components.parameters) { 214 + const $ref = `#/components/parameters/${name}`; 215 + if (!canProcessRef($ref, regexp)) { 216 + continue; 217 + } 218 + 201 219 const parameterOrReference = context.spec.components.parameters[name]; 202 220 const parameter = 203 221 '$ref' in parameterOrReference ··· 212 230 } 213 231 214 232 for (const name in context.spec.components.schemas) { 233 + const $ref = `#/components/schemas/${name}`; 234 + if (!canProcessRef($ref, regexp)) { 235 + continue; 236 + } 237 + 215 238 const schema = context.spec.components.schemas[name]; 216 239 217 240 parseSchema({
+2 -12
packages/openapi-ts/src/openApi/3.0.x/parser/operation.ts
··· 184 184 operationIds: Map<string, string>; 185 185 path: keyof IRPathsObject; 186 186 }) => { 187 - const operationKey = `${method.toUpperCase()} ${path}`; 188 - 189 - // TODO: parser - move services to plugin, cleaner syntax 190 - if ( 191 - !context.parserConfig.filterFn.operation({ 192 - config: context.config, 193 - operationKey, 194 - }) 195 - ) { 196 - return; 197 - } 198 - 199 187 // TODO: parser - support throw on duplicate 200 188 if (operation.operationId) { 189 + const operationKey = `${method.toUpperCase()} ${path}`; 190 + 201 191 if (operationIds.has(operation.operationId)) { 202 192 console.warn( 203 193 `❗️ Duplicate operationId: ${operation.operationId} in ${operationKey}. Please ensure your operation IDs are unique. This behavior is not supported and will likely lead to unexpected results.`,
+31 -8
packages/openapi-ts/src/openApi/3.1.x/parser/index.ts
··· 1 1 import type { IRContext } from '../../../ir/context'; 2 + import { canProcessRef } from '../../shared/utils/filter'; 2 3 import type { 3 4 OpenApiV3_1_X, 4 5 ParameterObject, ··· 15 16 16 17 export const parseV3_1_X = (context: IRContext<OpenApiV3_1_X>) => { 17 18 const operationIds = new Map<string, string>(); 19 + 20 + const regexp = context.config.input.include 21 + ? new RegExp(context.config.input.include) 22 + : undefined; 18 23 19 24 for (const path in context.spec.paths) { 20 25 const pathItem = context.spec.paths[path as keyof PathsObject]; ··· 43 48 path: path as keyof PathsObject, 44 49 }; 45 50 46 - if (finalPathItem.delete) { 51 + const $refDelete = `#/paths${path}/delete`; 52 + if (finalPathItem.delete && canProcessRef($refDelete, regexp)) { 47 53 parseOperation({ 48 54 ...operationArgs, 49 55 method: 'delete', ··· 61 67 }); 62 68 } 63 69 64 - if (finalPathItem.get) { 70 + const $refGet = `#/paths${path}/get`; 71 + if (finalPathItem.get && canProcessRef($refGet, regexp)) { 65 72 parseOperation({ 66 73 ...operationArgs, 67 74 method: 'get', ··· 79 86 }); 80 87 } 81 88 82 - if (finalPathItem.head) { 89 + const $refHead = `#/paths${path}/head`; 90 + if (finalPathItem.head && canProcessRef($refHead, regexp)) { 83 91 parseOperation({ 84 92 ...operationArgs, 85 93 method: 'head', ··· 97 105 }); 98 106 } 99 107 100 - if (finalPathItem.options) { 108 + const $refOptions = `#/paths${path}/options`; 109 + if (finalPathItem.options && canProcessRef($refOptions, regexp)) { 101 110 parseOperation({ 102 111 ...operationArgs, 103 112 method: 'options', ··· 115 124 }); 116 125 } 117 126 118 - if (finalPathItem.patch) { 127 + const $refPatch = `#/paths${path}/patch`; 128 + if (finalPathItem.patch && canProcessRef($refPatch, regexp)) { 119 129 parseOperation({ 120 130 ...operationArgs, 121 131 method: 'patch', ··· 133 143 }); 134 144 } 135 145 136 - if (finalPathItem.post) { 146 + const $refPost = `#/paths${path}/post`; 147 + if (finalPathItem.post && canProcessRef($refPost, regexp)) { 137 148 parseOperation({ 138 149 ...operationArgs, 139 150 method: 'post', ··· 151 162 }); 152 163 } 153 164 154 - if (finalPathItem.put) { 165 + const $refPut = `#/paths${path}/put`; 166 + if (finalPathItem.put && canProcessRef($refPut, regexp)) { 155 167 parseOperation({ 156 168 ...operationArgs, 157 169 method: 'put', ··· 169 181 }); 170 182 } 171 183 172 - if (finalPathItem.trace) { 184 + const $refTrace = `#/paths${path}/trace`; 185 + if (finalPathItem.trace && canProcessRef($refTrace, regexp)) { 173 186 parseOperation({ 174 187 ...operationArgs, 175 188 method: 'trace', ··· 191 204 // TODO: parser - handle more component types, old parser handles only parameters and schemas 192 205 if (context.spec.components) { 193 206 for (const name in context.spec.components.parameters) { 207 + const $ref = `#/components/parameters/${name}`; 208 + if (!canProcessRef($ref, regexp)) { 209 + continue; 210 + } 211 + 194 212 const parameterOrReference = context.spec.components.parameters[name]; 195 213 const parameter = 196 214 '$ref' in parameterOrReference ··· 205 223 } 206 224 207 225 for (const name in context.spec.components.schemas) { 226 + const $ref = `#/components/schemas/${name}`; 227 + if (!canProcessRef($ref, regexp)) { 228 + continue; 229 + } 230 + 208 231 const schema = context.spec.components.schemas[name]; 209 232 210 233 parseSchema({
+2 -12
packages/openapi-ts/src/openApi/3.1.x/parser/operation.ts
··· 172 172 operationIds: Map<string, string>; 173 173 path: keyof IRPathsObject; 174 174 }) => { 175 - const operationKey = `${method.toUpperCase()} ${path}`; 176 - 177 - // TODO: parser - move services to plugin, cleaner syntax 178 - if ( 179 - !context.parserConfig.filterFn.operation({ 180 - config: context.config, 181 - operationKey, 182 - }) 183 - ) { 184 - return; 185 - } 186 - 187 175 // TODO: parser - support throw on duplicate 188 176 if (operation.operationId) { 177 + const operationKey = `${method.toUpperCase()} ${path}`; 178 + 189 179 if (operationIds.has(operation.operationId)) { 190 180 console.warn( 191 181 `❗️ Duplicate operationId: ${operation.operationId} in ${operationKey}. Please ensure your operation IDs are unique. This behavior is not supported and will likely lead to unexpected results.`,
-1
packages/openapi-ts/src/openApi/__tests__/index.spec.ts
··· 97 97 98 98 it('throws on unknown version', () => { 99 99 expect(() => 100 - // @ts-expect-error 101 100 parseLegacy({ openApi: { foo: 'bar' }, parserConfig }), 102 101 ).toThrow( 103 102 `Unsupported OpenAPI specification: ${JSON.stringify({ foo: 'bar' }, null, 2)}`,
+8 -6
packages/openapi-ts/src/openApi/index.ts
··· 39 39 openApi, 40 40 parserConfig, 41 41 }: { 42 - openApi: OpenApi; 42 + openApi: unknown; 43 43 parserConfig: ParserConfig; 44 44 }): Client { 45 + const spec = openApi as OpenApi; 46 + 45 47 setParserConfig(parserConfig); 46 48 47 - if ('openapi' in openApi) { 48 - return parseV3(openApi); 49 + if ('openapi' in spec) { 50 + return parseV3(spec); 49 51 } 50 52 51 - if ('swagger' in openApi) { 52 - return parseV2(openApi); 53 + if ('swagger' in spec) { 54 + return parseV2(spec); 53 55 } 54 56 55 57 throw new Error( 56 - `Unsupported OpenAPI specification: ${JSON.stringify(openApi, null, 2)}`, 58 + `Unsupported OpenAPI specification: ${JSON.stringify(spec, null, 2)}`, 57 59 ); 58 60 } 59 61
+8
packages/openapi-ts/src/openApi/shared/utils/filter.ts
··· 1 + export const canProcessRef = ($ref: string, regexp?: RegExp): boolean => { 2 + if (!regexp) { 3 + return true; 4 + } 5 + 6 + regexp.lastIndex = 0; 7 + return regexp.test($ref); 8 + };
+6 -2
packages/openapi-ts/src/plugins/@hey-api/schemas/__tests__/schemas.spec.ts
··· 21 21 dryRun: false, 22 22 experimentalParser: false, 23 23 exportCore: true, 24 - input: '', 24 + input: { 25 + path: '', 26 + }, 25 27 name: 'AppClient', 26 28 output: { 27 29 path: '', ··· 90 92 dryRun: false, 91 93 experimentalParser: false, 92 94 exportCore: true, 93 - input: '', 95 + input: { 96 + path: '', 97 + }, 94 98 name: 'AppClient', 95 99 output: { 96 100 path: '',
+12 -4
packages/openapi-ts/src/plugins/@hey-api/services/__tests__/services.spec.ts
··· 23 23 dryRun: false, 24 24 experimentalParser: false, 25 25 exportCore: true, 26 - input: '', 26 + input: { 27 + path: '', 28 + }, 27 29 output: { 28 30 path: '', 29 31 }, ··· 161 163 dryRun: false, 162 164 experimentalParser: false, 163 165 exportCore: true, 164 - input: '', 166 + input: { 167 + path: '', 168 + }, 165 169 output: { 166 170 path: '', 167 171 }, ··· 223 227 dryRun: false, 224 228 experimentalParser: false, 225 229 exportCore: true, 226 - input: '', 230 + input: { 231 + path: '', 232 + }, 227 233 output: { 228 234 path: '', 229 235 }, ··· 288 294 dryRun: false, 289 295 experimentalParser: false, 290 296 exportCore: true, 291 - input: '', 297 + input: { 298 + path: '', 299 + }, 292 300 output: { 293 301 path: '', 294 302 },
+4
packages/openapi-ts/src/plugins/@hey-api/services/types.d.ts
··· 20 20 * results will be included in the output. The input pattern this 21 21 * string will be tested against is `{method} {path}`. For example, 22 22 * you can match `POST /api/v1/foo` with `^POST /api/v1/foo$`. 23 + * 24 + * This option does not work with the experimental parser. 25 + * 26 + * @deprecated 23 27 */ 24 28 filter?: string; 25 29 /**
+3 -1
packages/openapi-ts/src/plugins/@hey-api/types/__tests__/types.spec.ts
··· 20 20 dryRun: false, 21 21 experimentalParser: false, 22 22 exportCore: true, 23 - input: '', 23 + input: { 24 + path: '', 25 + }, 24 26 name: 'AppClient', 25 27 output: { 26 28 path: '',
+5 -1
packages/openapi-ts/src/plugins/@hey-api/types/types.d.ts
··· 7 7 */ 8 8 enums?: 'javascript' | 'typescript' | 'typescript+namespace' | false; 9 9 /** 10 - * Include only types matching regular expression 10 + * Include only types matching regular expression. 11 + * 12 + * This option does not work with the experimental parser. 13 + * 14 + * @deprecated 11 15 */ 12 16 include?: string; 13 17 /**
+33 -5
packages/openapi-ts/src/types/config.ts
··· 1 1 import type { ClientPlugins, UserPlugins } from '../plugins/'; 2 - import type { ArrayOfObjectsToObjectMap, ExtractArrayOfObjects } from './utils'; 2 + import type { 3 + ArrayOfObjectsToObjectMap, 4 + ExtractArrayOfObjects, 5 + ExtractWithDiscriminator, 6 + } from './utils'; 3 7 4 8 export const CLIENTS = [ 5 9 '@hey-api/client-axios', ··· 67 71 */ 68 72 exportCore?: boolean; 69 73 /** 70 - * The relative location of the OpenAPI spec 74 + * Path to the OpenAPI specification. This can be either local or remote path. 75 + * Both JSON and YAML file formats are supported. You can also pass the parsed 76 + * object directly if you're fetching the file yourself. 77 + * 78 + * Alternatively, you can define a configuration object with more options. 71 79 */ 72 - input: string | Record<string, unknown>; 80 + input: 81 + | string 82 + | Record<string, unknown> 83 + | { 84 + /** 85 + * Process only parts matching the regular expression. You can select both 86 + * operations and components by reference within the bundled input. 87 + * 88 + * @example 89 + * operation: '^#/paths/api/v1/foo/get$' 90 + * schema: '^#/components/schemas/Foo$' 91 + */ 92 + include?: string; 93 + /** 94 + * Path to the OpenAPI specification. This can be either local or remote path. 95 + * Both JSON and YAML file formats are supported. You can also pass the parsed 96 + * object directly if you're fetching the file yourself. 97 + */ 98 + path: string | Record<string, unknown>; 99 + }; 73 100 /** 74 101 * Custom client class name. Please note this option is deprecated and 75 102 * will be removed in favor of clients. ··· 123 150 124 151 export type Config = Omit< 125 152 Required<ClientConfig>, 126 - 'base' | 'client' | 'name' | 'output' | 'plugins' | 'request' 153 + 'base' | 'client' | 'input' | 'name' | 'output' | 'plugins' | 'request' 127 154 > & 128 155 Pick<ClientConfig, 'base' | 'name' | 'request'> & { 129 156 client: Extract<Required<ClientConfig>['client'], object>; 130 - output: Extract<Required<ClientConfig>['output'], object>; 157 + input: ExtractWithDiscriminator<ClientConfig['input'], { path: unknown }>; 158 + output: Extract<ClientConfig['output'], object>; 131 159 pluginOrder: ReadonlyArray<ClientPlugins['name']>; 132 160 plugins: ArrayOfObjectsToObjectMap< 133 161 ExtractArrayOfObjects<ReadonlyArray<ClientPlugins>, { name: string }>,
+5 -3
packages/openapi-ts/src/types/utils.ts
··· 1 1 import type { TypeScriptFile } from '../generate/files'; 2 2 3 - type ExtractFromArray<T, Discriminator> = T extends Discriminator ? T : never; 3 + export type ExtractWithDiscriminator<T, Discriminator> = T extends Discriminator 4 + ? T 5 + : never; 4 6 5 7 /** 6 8 * Accepts an array of elements union and attempts to extract only objects. ··· 9 11 */ 10 12 export type ExtractArrayOfObjects<T, Discriminator> = 11 13 T extends Array<infer U> 12 - ? Array<ExtractFromArray<U, Discriminator>> 14 + ? Array<ExtractWithDiscriminator<U, Discriminator>> 13 15 : T extends ReadonlyArray<infer U> 14 - ? ReadonlyArray<ExtractFromArray<U, Discriminator>> 16 + ? ReadonlyArray<ExtractWithDiscriminator<U, Discriminator>> 15 17 : never; 16 18 17 19 export type Files = Record<string, TypeScriptFile>;
+6 -2
packages/openapi-ts/src/utils/__tests__/handlebars.spec.ts
··· 18 18 dryRun: false, 19 19 experimentalParser: false, 20 20 exportCore: true, 21 - input: '', 21 + input: { 22 + path: '', 23 + }, 22 24 output: { 23 25 format: 'prettier', 24 26 path: '', ··· 66 68 dryRun: false, 67 69 experimentalParser: false, 68 70 exportCore: true, 69 - input: '', 71 + input: { 72 + path: '', 73 + }, 70 74 output: { 71 75 format: 'prettier', 72 76 path: '',
+3 -1
packages/openapi-ts/src/utils/__tests__/parse.spec.ts
··· 13 13 dryRun: true, 14 14 experimentalParser: false, 15 15 exportCore: false, 16 - input: '', 16 + input: { 17 + path: '', 18 + }, 17 19 output: { 18 20 path: '', 19 21 },
-24
packages/openapi-ts/src/utils/getOpenApiSpec.ts
··· 1 - import { existsSync } from 'node:fs'; 2 - import path from 'node:path'; 3 - 4 - import $RefParser from '@apidevtools/json-schema-ref-parser'; 5 - 6 - import type { OpenApi } from '../openApi'; 7 - 8 - /** 9 - * Load and parse te open api spec. If the file extension is ".yml" or ".yaml" 10 - * we will try to parse the file as a YAML spec, otherwise we will fall back 11 - * on parsing the file as JSON. 12 - * @param location: Path or url 13 - */ 14 - export const getOpenApiSpec = async (location: string) => { 15 - const absolutePathOrUrl = existsSync(location) 16 - ? path.resolve(location) 17 - : location; 18 - const schema = (await $RefParser.bundle( 19 - absolutePathOrUrl, 20 - absolutePathOrUrl, 21 - {}, 22 - )) as OpenApi; 23 - return schema; 24 - };
+7
packages/openapi-ts/test/3.0.x.spec.ts
··· 48 48 }), 49 49 description: 'allows arbitrary properties on objects', 50 50 }, 51 + { 52 + config: createConfig({ 53 + input: 'enum-escape.json', 54 + output: 'enum-escape', 55 + }), 56 + description: 'escapes enum values', 57 + }, 51 58 ]; 52 59 53 60 it.each(scenarios)('$description', async ({ config }) => {
+7
packages/openapi-ts/test/3.1.x.spec.ts
··· 57 57 }, 58 58 { 59 59 config: createConfig({ 60 + input: 'enum-escape.json', 61 + output: 'enum-escape', 62 + }), 63 + description: 'escapes enum values', 64 + }, 65 + { 66 + config: createConfig({ 60 67 input: 'object-properties-all-of.json', 61 68 output: 'object-properties-all-of', 62 69 }),
+2
packages/openapi-ts/test/__snapshots__/3.0.x/enum-escape/index.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + export * from './types.gen';
+7
packages/openapi-ts/test/__snapshots__/3.0.x/enum-escape/types.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + export type Foo = { 4 + foo?: "foo'bar" | 'foo"bar'; 5 + }; 6 + 7 + export type Bar = "foo'bar" | 'foo"bar';
+5 -5
packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@hey-api/services/default/services.gen.ts
··· 96 96 export const callWithDescriptions = <ThrowOnError extends boolean = false>(options?: Options<CallWithDescriptionsData, ThrowOnError>) => { 97 97 return (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ 98 98 ...options, 99 - url: '/api/v{api-version}/descriptions/' 99 + url: '/api/v{api-version}/descriptions' 100 100 }); 101 101 }; 102 102 ··· 139 139 'Content-Type': 'application/json', 140 140 ...options?.headers 141 141 }, 142 - url: '/api/v{api-version}/parameters/' 142 + url: '/api/v{api-version}/parameters' 143 143 }); 144 144 }; 145 145 ··· 150 150 'Content-Type': 'application/json', 151 151 ...options?.headers 152 152 }, 153 - url: '/api/v{api-version}/parameters/' 153 + url: '/api/v{api-version}/parameters' 154 154 }); 155 155 }; 156 156 ··· 161 161 'Content-Type': 'application/json', 162 162 ...options?.headers 163 163 }, 164 - url: '/api/v{api-version}/requestBody/' 164 + url: '/api/v{api-version}/requestBody' 165 165 }); 166 166 }; 167 167 ··· 173 173 'Content-Type': null, 174 174 ...options?.headers 175 175 }, 176 - url: '/api/v{api-version}/formData/' 176 + url: '/api/v{api-version}/formData' 177 177 }); 178 178 }; 179 179
+5 -5
packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/services.gen.ts
··· 129 129 'Content-Type': 'application/json', 130 130 ...options?.headers 131 131 }, 132 - url: '/api/v{api-version}/parameters/' 132 + url: '/api/v{api-version}/parameters' 133 133 }); 134 134 } 135 135 ··· 140 140 'Content-Type': 'application/json', 141 141 ...options?.headers 142 142 }, 143 - url: '/api/v{api-version}/parameters/' 143 + url: '/api/v{api-version}/parameters' 144 144 }); 145 145 } 146 146 ··· 150 150 public static callWithDescriptions<ThrowOnError extends boolean = false>(options?: Options<CallWithDescriptionsData, ThrowOnError>) { 151 151 return (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ 152 152 ...options, 153 - url: '/api/v{api-version}/descriptions/' 153 + url: '/api/v{api-version}/descriptions' 154 154 }); 155 155 } 156 156 ··· 177 177 'Content-Type': 'application/json', 178 178 ...options?.headers 179 179 }, 180 - url: '/api/v{api-version}/requestBody/' 180 + url: '/api/v{api-version}/requestBody' 181 181 }); 182 182 } 183 183 ··· 192 192 'Content-Type': null, 193 193 ...options?.headers 194 194 }, 195 - url: '/api/v{api-version}/formData/' 195 + url: '/api/v{api-version}/formData' 196 196 }); 197 197 } 198 198
+5 -5
packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/services.gen.ts
··· 96 96 export const callWithDescriptions = <ThrowOnError extends boolean = false>(options?: Options<CallWithDescriptionsData, ThrowOnError>) => { 97 97 return (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ 98 98 ...options, 99 - url: '/api/v{api-version}/descriptions/' 99 + url: '/api/v{api-version}/descriptions' 100 100 }); 101 101 }; 102 102 ··· 139 139 'Content-Type': 'application/json', 140 140 ...options?.headers 141 141 }, 142 - url: '/api/v{api-version}/parameters/' 142 + url: '/api/v{api-version}/parameters' 143 143 }); 144 144 }; 145 145 ··· 150 150 'Content-Type': 'application/json', 151 151 ...options?.headers 152 152 }, 153 - url: '/api/v{api-version}/parameters/' 153 + url: '/api/v{api-version}/parameters' 154 154 }); 155 155 }; 156 156 ··· 161 161 'Content-Type': 'application/json', 162 162 ...options?.headers 163 163 }, 164 - url: '/api/v{api-version}/requestBody/' 164 + url: '/api/v{api-version}/requestBody' 165 165 }); 166 166 }; 167 167 ··· 173 173 'Content-Type': null, 174 174 ...options?.headers 175 175 }, 176 - url: '/api/v{api-version}/formData/' 176 + url: '/api/v{api-version}/formData' 177 177 }); 178 178 }; 179 179
+5 -5
packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/services.gen.ts
··· 96 96 export const callWithDescriptions = <ThrowOnError extends boolean = false>(options?: Options<CallWithDescriptionsData, ThrowOnError>) => { 97 97 return (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ 98 98 ...options, 99 - url: '/api/v{api-version}/descriptions/' 99 + url: '/api/v{api-version}/descriptions' 100 100 }); 101 101 }; 102 102 ··· 139 139 'Content-Type': 'application/json', 140 140 ...options?.headers 141 141 }, 142 - url: '/api/v{api-version}/parameters/' 142 + url: '/api/v{api-version}/parameters' 143 143 }); 144 144 }; 145 145 ··· 150 150 'Content-Type': 'application/json', 151 151 ...options?.headers 152 152 }, 153 - url: '/api/v{api-version}/parameters/' 153 + url: '/api/v{api-version}/parameters' 154 154 }); 155 155 }; 156 156 ··· 161 161 'Content-Type': 'application/json', 162 162 ...options?.headers 163 163 }, 164 - url: '/api/v{api-version}/requestBody/' 164 + url: '/api/v{api-version}/requestBody' 165 165 }); 166 166 }; 167 167 ··· 173 173 'Content-Type': null, 174 174 ...options?.headers 175 175 }, 176 - url: '/api/v{api-version}/formData/' 176 + url: '/api/v{api-version}/formData' 177 177 }); 178 178 }; 179 179
+5 -5
packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/services.gen.ts
··· 129 129 'Content-Type': 'application/json', 130 130 ...options?.headers 131 131 }, 132 - url: '/api/v{api-version}/parameters/' 132 + url: '/api/v{api-version}/parameters' 133 133 }); 134 134 } 135 135 ··· 140 140 'Content-Type': 'application/json', 141 141 ...options?.headers 142 142 }, 143 - url: '/api/v{api-version}/parameters/' 143 + url: '/api/v{api-version}/parameters' 144 144 }); 145 145 } 146 146 ··· 150 150 public static callWithDescriptions<ThrowOnError extends boolean = false>(options?: Options<CallWithDescriptionsData, ThrowOnError>) { 151 151 return (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ 152 152 ...options, 153 - url: '/api/v{api-version}/descriptions/' 153 + url: '/api/v{api-version}/descriptions' 154 154 }); 155 155 } 156 156 ··· 177 177 'Content-Type': 'application/json', 178 178 ...options?.headers 179 179 }, 180 - url: '/api/v{api-version}/requestBody/' 180 + url: '/api/v{api-version}/requestBody' 181 181 }); 182 182 } 183 183 ··· 192 192 'Content-Type': null, 193 193 ...options?.headers 194 194 }, 195 - url: '/api/v{api-version}/formData/' 195 + url: '/api/v{api-version}/formData' 196 196 }); 197 197 } 198 198
+5 -5
packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/services.gen.ts
··· 96 96 export const callWithDescriptions = <ThrowOnError extends boolean = false>(options?: Options<CallWithDescriptionsData, ThrowOnError>) => { 97 97 return (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ 98 98 ...options, 99 - url: '/api/v{api-version}/descriptions/' 99 + url: '/api/v{api-version}/descriptions' 100 100 }); 101 101 }; 102 102 ··· 139 139 'Content-Type': 'application/json', 140 140 ...options?.headers 141 141 }, 142 - url: '/api/v{api-version}/parameters/' 142 + url: '/api/v{api-version}/parameters' 143 143 }); 144 144 }; 145 145 ··· 150 150 'Content-Type': 'application/json', 151 151 ...options?.headers 152 152 }, 153 - url: '/api/v{api-version}/parameters/' 153 + url: '/api/v{api-version}/parameters' 154 154 }); 155 155 }; 156 156 ··· 161 161 'Content-Type': 'application/json', 162 162 ...options?.headers 163 163 }, 164 - url: '/api/v{api-version}/requestBody/' 164 + url: '/api/v{api-version}/requestBody' 165 165 }); 166 166 }; 167 167 ··· 173 173 'Content-Type': null, 174 174 ...options?.headers 175 175 }, 176 - url: '/api/v{api-version}/formData/' 176 + url: '/api/v{api-version}/formData' 177 177 }); 178 178 }; 179 179
+5 -5
packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/services.gen.ts
··· 96 96 export const callWithDescriptions = <ThrowOnError extends boolean = false>(options?: Options<CallWithDescriptionsData, ThrowOnError>) => { 97 97 return (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ 98 98 ...options, 99 - url: '/api/v{api-version}/descriptions/' 99 + url: '/api/v{api-version}/descriptions' 100 100 }); 101 101 }; 102 102 ··· 139 139 'Content-Type': 'application/json', 140 140 ...options?.headers 141 141 }, 142 - url: '/api/v{api-version}/parameters/' 142 + url: '/api/v{api-version}/parameters' 143 143 }); 144 144 }; 145 145 ··· 150 150 'Content-Type': 'application/json', 151 151 ...options?.headers 152 152 }, 153 - url: '/api/v{api-version}/parameters/' 153 + url: '/api/v{api-version}/parameters' 154 154 }); 155 155 }; 156 156 ··· 161 161 'Content-Type': 'application/json', 162 162 ...options?.headers 163 163 }, 164 - url: '/api/v{api-version}/requestBody/' 164 + url: '/api/v{api-version}/requestBody' 165 165 }); 166 166 }; 167 167 ··· 173 173 'Content-Type': null, 174 174 ...options?.headers 175 175 }, 176 - url: '/api/v{api-version}/formData/' 176 + url: '/api/v{api-version}/formData' 177 177 }); 178 178 }; 179 179
+5 -5
packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/services.gen.ts
··· 129 129 'Content-Type': 'application/json', 130 130 ...options?.headers 131 131 }, 132 - url: '/api/v{api-version}/parameters/' 132 + url: '/api/v{api-version}/parameters' 133 133 }); 134 134 } 135 135 ··· 140 140 'Content-Type': 'application/json', 141 141 ...options?.headers 142 142 }, 143 - url: '/api/v{api-version}/parameters/' 143 + url: '/api/v{api-version}/parameters' 144 144 }); 145 145 } 146 146 ··· 150 150 public static callWithDescriptions<ThrowOnError extends boolean = false>(options?: Options<CallWithDescriptionsData, ThrowOnError>) { 151 151 return (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ 152 152 ...options, 153 - url: '/api/v{api-version}/descriptions/' 153 + url: '/api/v{api-version}/descriptions' 154 154 }); 155 155 } 156 156 ··· 177 177 'Content-Type': 'application/json', 178 178 ...options?.headers 179 179 }, 180 - url: '/api/v{api-version}/requestBody/' 180 + url: '/api/v{api-version}/requestBody' 181 181 }); 182 182 } 183 183 ··· 192 192 'Content-Type': null, 193 193 ...options?.headers 194 194 }, 195 - url: '/api/v{api-version}/formData/' 195 + url: '/api/v{api-version}/formData' 196 196 }); 197 197 } 198 198
+5 -5
packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/services.gen.ts
··· 96 96 export const callWithDescriptions = <ThrowOnError extends boolean = false>(options?: Options<CallWithDescriptionsData, ThrowOnError>) => { 97 97 return (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ 98 98 ...options, 99 - url: '/api/v{api-version}/descriptions/' 99 + url: '/api/v{api-version}/descriptions' 100 100 }); 101 101 }; 102 102 ··· 139 139 'Content-Type': 'application/json', 140 140 ...options?.headers 141 141 }, 142 - url: '/api/v{api-version}/parameters/' 142 + url: '/api/v{api-version}/parameters' 143 143 }); 144 144 }; 145 145 ··· 150 150 'Content-Type': 'application/json', 151 151 ...options?.headers 152 152 }, 153 - url: '/api/v{api-version}/parameters/' 153 + url: '/api/v{api-version}/parameters' 154 154 }); 155 155 }; 156 156 ··· 161 161 'Content-Type': 'application/json', 162 162 ...options?.headers 163 163 }, 164 - url: '/api/v{api-version}/requestBody/' 164 + url: '/api/v{api-version}/requestBody' 165 165 }); 166 166 }; 167 167 ··· 173 173 'Content-Type': null, 174 174 ...options?.headers 175 175 }, 176 - url: '/api/v{api-version}/formData/' 176 + url: '/api/v{api-version}/formData' 177 177 }); 178 178 }; 179 179
+5 -5
packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/services.gen.ts
··· 96 96 export const callWithDescriptions = <ThrowOnError extends boolean = false>(options?: Options<CallWithDescriptionsData, ThrowOnError>) => { 97 97 return (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ 98 98 ...options, 99 - url: '/api/v{api-version}/descriptions/' 99 + url: '/api/v{api-version}/descriptions' 100 100 }); 101 101 }; 102 102 ··· 139 139 'Content-Type': 'application/json', 140 140 ...options?.headers 141 141 }, 142 - url: '/api/v{api-version}/parameters/' 142 + url: '/api/v{api-version}/parameters' 143 143 }); 144 144 }; 145 145 ··· 150 150 'Content-Type': 'application/json', 151 151 ...options?.headers 152 152 }, 153 - url: '/api/v{api-version}/parameters/' 153 + url: '/api/v{api-version}/parameters' 154 154 }); 155 155 }; 156 156 ··· 161 161 'Content-Type': 'application/json', 162 162 ...options?.headers 163 163 }, 164 - url: '/api/v{api-version}/requestBody/' 164 + url: '/api/v{api-version}/requestBody' 165 165 }); 166 166 }; 167 167 ··· 173 173 'Content-Type': null, 174 174 ...options?.headers 175 175 }, 176 - url: '/api/v{api-version}/formData/' 176 + url: '/api/v{api-version}/formData' 177 177 }); 178 178 }; 179 179
+5 -5
packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/services.gen.ts
··· 129 129 'Content-Type': 'application/json', 130 130 ...options?.headers 131 131 }, 132 - url: '/api/v{api-version}/parameters/' 132 + url: '/api/v{api-version}/parameters' 133 133 }); 134 134 } 135 135 ··· 140 140 'Content-Type': 'application/json', 141 141 ...options?.headers 142 142 }, 143 - url: '/api/v{api-version}/parameters/' 143 + url: '/api/v{api-version}/parameters' 144 144 }); 145 145 } 146 146 ··· 150 150 public static callWithDescriptions<ThrowOnError extends boolean = false>(options?: Options<CallWithDescriptionsData, ThrowOnError>) { 151 151 return (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ 152 152 ...options, 153 - url: '/api/v{api-version}/descriptions/' 153 + url: '/api/v{api-version}/descriptions' 154 154 }); 155 155 } 156 156 ··· 177 177 'Content-Type': 'application/json', 178 178 ...options?.headers 179 179 }, 180 - url: '/api/v{api-version}/requestBody/' 180 + url: '/api/v{api-version}/requestBody' 181 181 }); 182 182 } 183 183 ··· 192 192 'Content-Type': null, 193 193 ...options?.headers 194 194 }, 195 - url: '/api/v{api-version}/formData/' 195 + url: '/api/v{api-version}/formData' 196 196 }); 197 197 } 198 198
+5 -5
packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/services.gen.ts
··· 96 96 export const callWithDescriptions = <ThrowOnError extends boolean = false>(options?: Options<CallWithDescriptionsData, ThrowOnError>) => { 97 97 return (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ 98 98 ...options, 99 - url: '/api/v{api-version}/descriptions/' 99 + url: '/api/v{api-version}/descriptions' 100 100 }); 101 101 }; 102 102 ··· 139 139 'Content-Type': 'application/json', 140 140 ...options?.headers 141 141 }, 142 - url: '/api/v{api-version}/parameters/' 142 + url: '/api/v{api-version}/parameters' 143 143 }); 144 144 }; 145 145 ··· 150 150 'Content-Type': 'application/json', 151 151 ...options?.headers 152 152 }, 153 - url: '/api/v{api-version}/parameters/' 153 + url: '/api/v{api-version}/parameters' 154 154 }); 155 155 }; 156 156 ··· 161 161 'Content-Type': 'application/json', 162 162 ...options?.headers 163 163 }, 164 - url: '/api/v{api-version}/requestBody/' 164 + url: '/api/v{api-version}/requestBody' 165 165 }); 166 166 }; 167 167 ··· 173 173 'Content-Type': null, 174 174 ...options?.headers 175 175 }, 176 - url: '/api/v{api-version}/formData/' 176 + url: '/api/v{api-version}/formData' 177 177 }); 178 178 }; 179 179
+5 -5
packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/services.gen.ts
··· 96 96 export const callWithDescriptions = <ThrowOnError extends boolean = false>(options?: Options<CallWithDescriptionsData, ThrowOnError>) => { 97 97 return (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ 98 98 ...options, 99 - url: '/api/v{api-version}/descriptions/' 99 + url: '/api/v{api-version}/descriptions' 100 100 }); 101 101 }; 102 102 ··· 139 139 'Content-Type': 'application/json', 140 140 ...options?.headers 141 141 }, 142 - url: '/api/v{api-version}/parameters/' 142 + url: '/api/v{api-version}/parameters' 143 143 }); 144 144 }; 145 145 ··· 150 150 'Content-Type': 'application/json', 151 151 ...options?.headers 152 152 }, 153 - url: '/api/v{api-version}/parameters/' 153 + url: '/api/v{api-version}/parameters' 154 154 }); 155 155 }; 156 156 ··· 161 161 'Content-Type': 'application/json', 162 162 ...options?.headers 163 163 }, 164 - url: '/api/v{api-version}/requestBody/' 164 + url: '/api/v{api-version}/requestBody' 165 165 }); 166 166 }; 167 167 ··· 173 173 'Content-Type': null, 174 174 ...options?.headers 175 175 }, 176 - url: '/api/v{api-version}/formData/' 176 + url: '/api/v{api-version}/formData' 177 177 }); 178 178 }; 179 179
+5 -5
packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/services.gen.ts
··· 129 129 'Content-Type': 'application/json', 130 130 ...options?.headers 131 131 }, 132 - url: '/api/v{api-version}/parameters/' 132 + url: '/api/v{api-version}/parameters' 133 133 }); 134 134 } 135 135 ··· 140 140 'Content-Type': 'application/json', 141 141 ...options?.headers 142 142 }, 143 - url: '/api/v{api-version}/parameters/' 143 + url: '/api/v{api-version}/parameters' 144 144 }); 145 145 } 146 146 ··· 150 150 public static callWithDescriptions<ThrowOnError extends boolean = false>(options?: Options<CallWithDescriptionsData, ThrowOnError>) { 151 151 return (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ 152 152 ...options, 153 - url: '/api/v{api-version}/descriptions/' 153 + url: '/api/v{api-version}/descriptions' 154 154 }); 155 155 } 156 156 ··· 177 177 'Content-Type': 'application/json', 178 178 ...options?.headers 179 179 }, 180 - url: '/api/v{api-version}/requestBody/' 180 + url: '/api/v{api-version}/requestBody' 181 181 }); 182 182 } 183 183 ··· 192 192 'Content-Type': null, 193 193 ...options?.headers 194 194 }, 195 - url: '/api/v{api-version}/formData/' 195 + url: '/api/v{api-version}/formData' 196 196 }); 197 197 } 198 198
+5 -5
packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/services.gen.ts
··· 96 96 export const callWithDescriptions = <ThrowOnError extends boolean = false>(options?: Options<CallWithDescriptionsData, ThrowOnError>) => { 97 97 return (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ 98 98 ...options, 99 - url: '/api/v{api-version}/descriptions/' 99 + url: '/api/v{api-version}/descriptions' 100 100 }); 101 101 }; 102 102 ··· 139 139 'Content-Type': 'application/json', 140 140 ...options?.headers 141 141 }, 142 - url: '/api/v{api-version}/parameters/' 142 + url: '/api/v{api-version}/parameters' 143 143 }); 144 144 }; 145 145 ··· 150 150 'Content-Type': 'application/json', 151 151 ...options?.headers 152 152 }, 153 - url: '/api/v{api-version}/parameters/' 153 + url: '/api/v{api-version}/parameters' 154 154 }); 155 155 }; 156 156 ··· 161 161 'Content-Type': 'application/json', 162 162 ...options?.headers 163 163 }, 164 - url: '/api/v{api-version}/requestBody/' 164 + url: '/api/v{api-version}/requestBody' 165 165 }); 166 166 }; 167 167 ··· 173 173 'Content-Type': null, 174 174 ...options?.headers 175 175 }, 176 - url: '/api/v{api-version}/formData/' 176 + url: '/api/v{api-version}/formData' 177 177 }); 178 178 }; 179 179
+5 -5
packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/services.gen.ts
··· 96 96 export const callWithDescriptions = <ThrowOnError extends boolean = false>(options?: Options<CallWithDescriptionsData, ThrowOnError>) => { 97 97 return (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ 98 98 ...options, 99 - url: '/api/v{api-version}/descriptions/' 99 + url: '/api/v{api-version}/descriptions' 100 100 }); 101 101 }; 102 102 ··· 139 139 'Content-Type': 'application/json', 140 140 ...options?.headers 141 141 }, 142 - url: '/api/v{api-version}/parameters/' 142 + url: '/api/v{api-version}/parameters' 143 143 }); 144 144 }; 145 145 ··· 150 150 'Content-Type': 'application/json', 151 151 ...options?.headers 152 152 }, 153 - url: '/api/v{api-version}/parameters/' 153 + url: '/api/v{api-version}/parameters' 154 154 }); 155 155 }; 156 156 ··· 161 161 'Content-Type': 'application/json', 162 162 ...options?.headers 163 163 }, 164 - url: '/api/v{api-version}/requestBody/' 164 + url: '/api/v{api-version}/requestBody' 165 165 }); 166 166 }; 167 167 ··· 173 173 'Content-Type': null, 174 174 ...options?.headers 175 175 }, 176 - url: '/api/v{api-version}/formData/' 176 + url: '/api/v{api-version}/formData' 177 177 }); 178 178 }; 179 179
+2
packages/openapi-ts/test/__snapshots__/3.1.x/enum-escape/index.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + export * from './types.gen';
+7
packages/openapi-ts/test/__snapshots__/3.1.x/enum-escape/types.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + export type Foo = { 4 + foo?: "foo'bar" | 'foo"bar'; 5 + }; 6 + 7 + export type Bar = "foo'bar" | 'foo"bar';
+5 -5
packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@hey-api/services/default/services.gen.ts
··· 96 96 export const callWithDescriptions = <ThrowOnError extends boolean = false>(options?: Options<CallWithDescriptionsData, ThrowOnError>) => { 97 97 return (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ 98 98 ...options, 99 - url: '/api/v{api-version}/descriptions/' 99 + url: '/api/v{api-version}/descriptions' 100 100 }); 101 101 }; 102 102 ··· 139 139 'Content-Type': 'application/json', 140 140 ...options?.headers 141 141 }, 142 - url: '/api/v{api-version}/parameters/' 142 + url: '/api/v{api-version}/parameters' 143 143 }); 144 144 }; 145 145 ··· 150 150 'Content-Type': 'application/json', 151 151 ...options?.headers 152 152 }, 153 - url: '/api/v{api-version}/parameters/' 153 + url: '/api/v{api-version}/parameters' 154 154 }); 155 155 }; 156 156 ··· 161 161 'Content-Type': 'application/json', 162 162 ...options?.headers 163 163 }, 164 - url: '/api/v{api-version}/requestBody/' 164 + url: '/api/v{api-version}/requestBody' 165 165 }); 166 166 }; 167 167 ··· 173 173 'Content-Type': null, 174 174 ...options?.headers 175 175 }, 176 - url: '/api/v{api-version}/formData/' 176 + url: '/api/v{api-version}/formData' 177 177 }); 178 178 }; 179 179
+5 -5
packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/services.gen.ts
··· 129 129 'Content-Type': 'application/json', 130 130 ...options?.headers 131 131 }, 132 - url: '/api/v{api-version}/parameters/' 132 + url: '/api/v{api-version}/parameters' 133 133 }); 134 134 } 135 135 ··· 140 140 'Content-Type': 'application/json', 141 141 ...options?.headers 142 142 }, 143 - url: '/api/v{api-version}/parameters/' 143 + url: '/api/v{api-version}/parameters' 144 144 }); 145 145 } 146 146 ··· 150 150 public static callWithDescriptions<ThrowOnError extends boolean = false>(options?: Options<CallWithDescriptionsData, ThrowOnError>) { 151 151 return (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ 152 152 ...options, 153 - url: '/api/v{api-version}/descriptions/' 153 + url: '/api/v{api-version}/descriptions' 154 154 }); 155 155 } 156 156 ··· 177 177 'Content-Type': 'application/json', 178 178 ...options?.headers 179 179 }, 180 - url: '/api/v{api-version}/requestBody/' 180 + url: '/api/v{api-version}/requestBody' 181 181 }); 182 182 } 183 183 ··· 192 192 'Content-Type': null, 193 193 ...options?.headers 194 194 }, 195 - url: '/api/v{api-version}/formData/' 195 + url: '/api/v{api-version}/formData' 196 196 }); 197 197 } 198 198
+5 -5
packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/services.gen.ts
··· 96 96 export const callWithDescriptions = <ThrowOnError extends boolean = false>(options?: Options<CallWithDescriptionsData, ThrowOnError>) => { 97 97 return (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ 98 98 ...options, 99 - url: '/api/v{api-version}/descriptions/' 99 + url: '/api/v{api-version}/descriptions' 100 100 }); 101 101 }; 102 102 ··· 139 139 'Content-Type': 'application/json', 140 140 ...options?.headers 141 141 }, 142 - url: '/api/v{api-version}/parameters/' 142 + url: '/api/v{api-version}/parameters' 143 143 }); 144 144 }; 145 145 ··· 150 150 'Content-Type': 'application/json', 151 151 ...options?.headers 152 152 }, 153 - url: '/api/v{api-version}/parameters/' 153 + url: '/api/v{api-version}/parameters' 154 154 }); 155 155 }; 156 156 ··· 161 161 'Content-Type': 'application/json', 162 162 ...options?.headers 163 163 }, 164 - url: '/api/v{api-version}/requestBody/' 164 + url: '/api/v{api-version}/requestBody' 165 165 }); 166 166 }; 167 167 ··· 173 173 'Content-Type': null, 174 174 ...options?.headers 175 175 }, 176 - url: '/api/v{api-version}/formData/' 176 + url: '/api/v{api-version}/formData' 177 177 }); 178 178 }; 179 179
+5 -5
packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/services.gen.ts
··· 96 96 export const callWithDescriptions = <ThrowOnError extends boolean = false>(options?: Options<CallWithDescriptionsData, ThrowOnError>) => { 97 97 return (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ 98 98 ...options, 99 - url: '/api/v{api-version}/descriptions/' 99 + url: '/api/v{api-version}/descriptions' 100 100 }); 101 101 }; 102 102 ··· 139 139 'Content-Type': 'application/json', 140 140 ...options?.headers 141 141 }, 142 - url: '/api/v{api-version}/parameters/' 142 + url: '/api/v{api-version}/parameters' 143 143 }); 144 144 }; 145 145 ··· 150 150 'Content-Type': 'application/json', 151 151 ...options?.headers 152 152 }, 153 - url: '/api/v{api-version}/parameters/' 153 + url: '/api/v{api-version}/parameters' 154 154 }); 155 155 }; 156 156 ··· 161 161 'Content-Type': 'application/json', 162 162 ...options?.headers 163 163 }, 164 - url: '/api/v{api-version}/requestBody/' 164 + url: '/api/v{api-version}/requestBody' 165 165 }); 166 166 }; 167 167 ··· 173 173 'Content-Type': null, 174 174 ...options?.headers 175 175 }, 176 - url: '/api/v{api-version}/formData/' 176 + url: '/api/v{api-version}/formData' 177 177 }); 178 178 }; 179 179
+5 -5
packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/services.gen.ts
··· 129 129 'Content-Type': 'application/json', 130 130 ...options?.headers 131 131 }, 132 - url: '/api/v{api-version}/parameters/' 132 + url: '/api/v{api-version}/parameters' 133 133 }); 134 134 } 135 135 ··· 140 140 'Content-Type': 'application/json', 141 141 ...options?.headers 142 142 }, 143 - url: '/api/v{api-version}/parameters/' 143 + url: '/api/v{api-version}/parameters' 144 144 }); 145 145 } 146 146 ··· 150 150 public static callWithDescriptions<ThrowOnError extends boolean = false>(options?: Options<CallWithDescriptionsData, ThrowOnError>) { 151 151 return (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ 152 152 ...options, 153 - url: '/api/v{api-version}/descriptions/' 153 + url: '/api/v{api-version}/descriptions' 154 154 }); 155 155 } 156 156 ··· 177 177 'Content-Type': 'application/json', 178 178 ...options?.headers 179 179 }, 180 - url: '/api/v{api-version}/requestBody/' 180 + url: '/api/v{api-version}/requestBody' 181 181 }); 182 182 } 183 183 ··· 192 192 'Content-Type': null, 193 193 ...options?.headers 194 194 }, 195 - url: '/api/v{api-version}/formData/' 195 + url: '/api/v{api-version}/formData' 196 196 }); 197 197 } 198 198
+5 -5
packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/services.gen.ts
··· 96 96 export const callWithDescriptions = <ThrowOnError extends boolean = false>(options?: Options<CallWithDescriptionsData, ThrowOnError>) => { 97 97 return (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ 98 98 ...options, 99 - url: '/api/v{api-version}/descriptions/' 99 + url: '/api/v{api-version}/descriptions' 100 100 }); 101 101 }; 102 102 ··· 139 139 'Content-Type': 'application/json', 140 140 ...options?.headers 141 141 }, 142 - url: '/api/v{api-version}/parameters/' 142 + url: '/api/v{api-version}/parameters' 143 143 }); 144 144 }; 145 145 ··· 150 150 'Content-Type': 'application/json', 151 151 ...options?.headers 152 152 }, 153 - url: '/api/v{api-version}/parameters/' 153 + url: '/api/v{api-version}/parameters' 154 154 }); 155 155 }; 156 156 ··· 161 161 'Content-Type': 'application/json', 162 162 ...options?.headers 163 163 }, 164 - url: '/api/v{api-version}/requestBody/' 164 + url: '/api/v{api-version}/requestBody' 165 165 }); 166 166 }; 167 167 ··· 173 173 'Content-Type': null, 174 174 ...options?.headers 175 175 }, 176 - url: '/api/v{api-version}/formData/' 176 + url: '/api/v{api-version}/formData' 177 177 }); 178 178 }; 179 179
+5 -5
packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/services.gen.ts
··· 96 96 export const callWithDescriptions = <ThrowOnError extends boolean = false>(options?: Options<CallWithDescriptionsData, ThrowOnError>) => { 97 97 return (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ 98 98 ...options, 99 - url: '/api/v{api-version}/descriptions/' 99 + url: '/api/v{api-version}/descriptions' 100 100 }); 101 101 }; 102 102 ··· 139 139 'Content-Type': 'application/json', 140 140 ...options?.headers 141 141 }, 142 - url: '/api/v{api-version}/parameters/' 142 + url: '/api/v{api-version}/parameters' 143 143 }); 144 144 }; 145 145 ··· 150 150 'Content-Type': 'application/json', 151 151 ...options?.headers 152 152 }, 153 - url: '/api/v{api-version}/parameters/' 153 + url: '/api/v{api-version}/parameters' 154 154 }); 155 155 }; 156 156 ··· 161 161 'Content-Type': 'application/json', 162 162 ...options?.headers 163 163 }, 164 - url: '/api/v{api-version}/requestBody/' 164 + url: '/api/v{api-version}/requestBody' 165 165 }); 166 166 }; 167 167 ··· 173 173 'Content-Type': null, 174 174 ...options?.headers 175 175 }, 176 - url: '/api/v{api-version}/formData/' 176 + url: '/api/v{api-version}/formData' 177 177 }); 178 178 }; 179 179
+5 -5
packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/services.gen.ts
··· 129 129 'Content-Type': 'application/json', 130 130 ...options?.headers 131 131 }, 132 - url: '/api/v{api-version}/parameters/' 132 + url: '/api/v{api-version}/parameters' 133 133 }); 134 134 } 135 135 ··· 140 140 'Content-Type': 'application/json', 141 141 ...options?.headers 142 142 }, 143 - url: '/api/v{api-version}/parameters/' 143 + url: '/api/v{api-version}/parameters' 144 144 }); 145 145 } 146 146 ··· 150 150 public static callWithDescriptions<ThrowOnError extends boolean = false>(options?: Options<CallWithDescriptionsData, ThrowOnError>) { 151 151 return (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ 152 152 ...options, 153 - url: '/api/v{api-version}/descriptions/' 153 + url: '/api/v{api-version}/descriptions' 154 154 }); 155 155 } 156 156 ··· 177 177 'Content-Type': 'application/json', 178 178 ...options?.headers 179 179 }, 180 - url: '/api/v{api-version}/requestBody/' 180 + url: '/api/v{api-version}/requestBody' 181 181 }); 182 182 } 183 183 ··· 192 192 'Content-Type': null, 193 193 ...options?.headers 194 194 }, 195 - url: '/api/v{api-version}/formData/' 195 + url: '/api/v{api-version}/formData' 196 196 }); 197 197 } 198 198
+5 -5
packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/services.gen.ts
··· 96 96 export const callWithDescriptions = <ThrowOnError extends boolean = false>(options?: Options<CallWithDescriptionsData, ThrowOnError>) => { 97 97 return (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ 98 98 ...options, 99 - url: '/api/v{api-version}/descriptions/' 99 + url: '/api/v{api-version}/descriptions' 100 100 }); 101 101 }; 102 102 ··· 139 139 'Content-Type': 'application/json', 140 140 ...options?.headers 141 141 }, 142 - url: '/api/v{api-version}/parameters/' 142 + url: '/api/v{api-version}/parameters' 143 143 }); 144 144 }; 145 145 ··· 150 150 'Content-Type': 'application/json', 151 151 ...options?.headers 152 152 }, 153 - url: '/api/v{api-version}/parameters/' 153 + url: '/api/v{api-version}/parameters' 154 154 }); 155 155 }; 156 156 ··· 161 161 'Content-Type': 'application/json', 162 162 ...options?.headers 163 163 }, 164 - url: '/api/v{api-version}/requestBody/' 164 + url: '/api/v{api-version}/requestBody' 165 165 }); 166 166 }; 167 167 ··· 173 173 'Content-Type': null, 174 174 ...options?.headers 175 175 }, 176 - url: '/api/v{api-version}/formData/' 176 + url: '/api/v{api-version}/formData' 177 177 }); 178 178 }; 179 179
+5 -5
packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/services.gen.ts
··· 96 96 export const callWithDescriptions = <ThrowOnError extends boolean = false>(options?: Options<CallWithDescriptionsData, ThrowOnError>) => { 97 97 return (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ 98 98 ...options, 99 - url: '/api/v{api-version}/descriptions/' 99 + url: '/api/v{api-version}/descriptions' 100 100 }); 101 101 }; 102 102 ··· 139 139 'Content-Type': 'application/json', 140 140 ...options?.headers 141 141 }, 142 - url: '/api/v{api-version}/parameters/' 142 + url: '/api/v{api-version}/parameters' 143 143 }); 144 144 }; 145 145 ··· 150 150 'Content-Type': 'application/json', 151 151 ...options?.headers 152 152 }, 153 - url: '/api/v{api-version}/parameters/' 153 + url: '/api/v{api-version}/parameters' 154 154 }); 155 155 }; 156 156 ··· 161 161 'Content-Type': 'application/json', 162 162 ...options?.headers 163 163 }, 164 - url: '/api/v{api-version}/requestBody/' 164 + url: '/api/v{api-version}/requestBody' 165 165 }); 166 166 }; 167 167 ··· 173 173 'Content-Type': null, 174 174 ...options?.headers 175 175 }, 176 - url: '/api/v{api-version}/formData/' 176 + url: '/api/v{api-version}/formData' 177 177 }); 178 178 }; 179 179
+5 -5
packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/services.gen.ts
··· 129 129 'Content-Type': 'application/json', 130 130 ...options?.headers 131 131 }, 132 - url: '/api/v{api-version}/parameters/' 132 + url: '/api/v{api-version}/parameters' 133 133 }); 134 134 } 135 135 ··· 140 140 'Content-Type': 'application/json', 141 141 ...options?.headers 142 142 }, 143 - url: '/api/v{api-version}/parameters/' 143 + url: '/api/v{api-version}/parameters' 144 144 }); 145 145 } 146 146 ··· 150 150 public static callWithDescriptions<ThrowOnError extends boolean = false>(options?: Options<CallWithDescriptionsData, ThrowOnError>) { 151 151 return (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ 152 152 ...options, 153 - url: '/api/v{api-version}/descriptions/' 153 + url: '/api/v{api-version}/descriptions' 154 154 }); 155 155 } 156 156 ··· 177 177 'Content-Type': 'application/json', 178 178 ...options?.headers 179 179 }, 180 - url: '/api/v{api-version}/requestBody/' 180 + url: '/api/v{api-version}/requestBody' 181 181 }); 182 182 } 183 183 ··· 192 192 'Content-Type': null, 193 193 ...options?.headers 194 194 }, 195 - url: '/api/v{api-version}/formData/' 195 + url: '/api/v{api-version}/formData' 196 196 }); 197 197 } 198 198
+5 -5
packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/services.gen.ts
··· 96 96 export const callWithDescriptions = <ThrowOnError extends boolean = false>(options?: Options<CallWithDescriptionsData, ThrowOnError>) => { 97 97 return (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ 98 98 ...options, 99 - url: '/api/v{api-version}/descriptions/' 99 + url: '/api/v{api-version}/descriptions' 100 100 }); 101 101 }; 102 102 ··· 139 139 'Content-Type': 'application/json', 140 140 ...options?.headers 141 141 }, 142 - url: '/api/v{api-version}/parameters/' 142 + url: '/api/v{api-version}/parameters' 143 143 }); 144 144 }; 145 145 ··· 150 150 'Content-Type': 'application/json', 151 151 ...options?.headers 152 152 }, 153 - url: '/api/v{api-version}/parameters/' 153 + url: '/api/v{api-version}/parameters' 154 154 }); 155 155 }; 156 156 ··· 161 161 'Content-Type': 'application/json', 162 162 ...options?.headers 163 163 }, 164 - url: '/api/v{api-version}/requestBody/' 164 + url: '/api/v{api-version}/requestBody' 165 165 }); 166 166 }; 167 167 ··· 173 173 'Content-Type': null, 174 174 ...options?.headers 175 175 }, 176 - url: '/api/v{api-version}/formData/' 176 + url: '/api/v{api-version}/formData' 177 177 }); 178 178 }; 179 179
+5 -5
packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/services.gen.ts
··· 96 96 export const callWithDescriptions = <ThrowOnError extends boolean = false>(options?: Options<CallWithDescriptionsData, ThrowOnError>) => { 97 97 return (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ 98 98 ...options, 99 - url: '/api/v{api-version}/descriptions/' 99 + url: '/api/v{api-version}/descriptions' 100 100 }); 101 101 }; 102 102 ··· 139 139 'Content-Type': 'application/json', 140 140 ...options?.headers 141 141 }, 142 - url: '/api/v{api-version}/parameters/' 142 + url: '/api/v{api-version}/parameters' 143 143 }); 144 144 }; 145 145 ··· 150 150 'Content-Type': 'application/json', 151 151 ...options?.headers 152 152 }, 153 - url: '/api/v{api-version}/parameters/' 153 + url: '/api/v{api-version}/parameters' 154 154 }); 155 155 }; 156 156 ··· 161 161 'Content-Type': 'application/json', 162 162 ...options?.headers 163 163 }, 164 - url: '/api/v{api-version}/requestBody/' 164 + url: '/api/v{api-version}/requestBody' 165 165 }); 166 166 }; 167 167 ··· 173 173 'Content-Type': null, 174 174 ...options?.headers 175 175 }, 176 - url: '/api/v{api-version}/formData/' 176 + url: '/api/v{api-version}/formData' 177 177 }); 178 178 }; 179 179
+5 -5
packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/services.gen.ts
··· 129 129 'Content-Type': 'application/json', 130 130 ...options?.headers 131 131 }, 132 - url: '/api/v{api-version}/parameters/' 132 + url: '/api/v{api-version}/parameters' 133 133 }); 134 134 } 135 135 ··· 140 140 'Content-Type': 'application/json', 141 141 ...options?.headers 142 142 }, 143 - url: '/api/v{api-version}/parameters/' 143 + url: '/api/v{api-version}/parameters' 144 144 }); 145 145 } 146 146 ··· 150 150 public static callWithDescriptions<ThrowOnError extends boolean = false>(options?: Options<CallWithDescriptionsData, ThrowOnError>) { 151 151 return (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ 152 152 ...options, 153 - url: '/api/v{api-version}/descriptions/' 153 + url: '/api/v{api-version}/descriptions' 154 154 }); 155 155 } 156 156 ··· 177 177 'Content-Type': 'application/json', 178 178 ...options?.headers 179 179 }, 180 - url: '/api/v{api-version}/requestBody/' 180 + url: '/api/v{api-version}/requestBody' 181 181 }); 182 182 } 183 183 ··· 192 192 'Content-Type': null, 193 193 ...options?.headers 194 194 }, 195 - url: '/api/v{api-version}/formData/' 195 + url: '/api/v{api-version}/formData' 196 196 }); 197 197 } 198 198
+5 -5
packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/services.gen.ts
··· 96 96 export const callWithDescriptions = <ThrowOnError extends boolean = false>(options?: Options<CallWithDescriptionsData, ThrowOnError>) => { 97 97 return (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ 98 98 ...options, 99 - url: '/api/v{api-version}/descriptions/' 99 + url: '/api/v{api-version}/descriptions' 100 100 }); 101 101 }; 102 102 ··· 139 139 'Content-Type': 'application/json', 140 140 ...options?.headers 141 141 }, 142 - url: '/api/v{api-version}/parameters/' 142 + url: '/api/v{api-version}/parameters' 143 143 }); 144 144 }; 145 145 ··· 150 150 'Content-Type': 'application/json', 151 151 ...options?.headers 152 152 }, 153 - url: '/api/v{api-version}/parameters/' 153 + url: '/api/v{api-version}/parameters' 154 154 }); 155 155 }; 156 156 ··· 161 161 'Content-Type': 'application/json', 162 162 ...options?.headers 163 163 }, 164 - url: '/api/v{api-version}/requestBody/' 164 + url: '/api/v{api-version}/requestBody' 165 165 }); 166 166 }; 167 167 ··· 173 173 'Content-Type': null, 174 174 ...options?.headers 175 175 }, 176 - url: '/api/v{api-version}/formData/' 176 + url: '/api/v{api-version}/formData' 177 177 }); 178 178 }; 179 179
+5 -5
packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/services.gen.ts
··· 96 96 export const callWithDescriptions = <ThrowOnError extends boolean = false>(options?: Options<CallWithDescriptionsData, ThrowOnError>) => { 97 97 return (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ 98 98 ...options, 99 - url: '/api/v{api-version}/descriptions/' 99 + url: '/api/v{api-version}/descriptions' 100 100 }); 101 101 }; 102 102 ··· 139 139 'Content-Type': 'application/json', 140 140 ...options?.headers 141 141 }, 142 - url: '/api/v{api-version}/parameters/' 142 + url: '/api/v{api-version}/parameters' 143 143 }); 144 144 }; 145 145 ··· 150 150 'Content-Type': 'application/json', 151 151 ...options?.headers 152 152 }, 153 - url: '/api/v{api-version}/parameters/' 153 + url: '/api/v{api-version}/parameters' 154 154 }); 155 155 }; 156 156 ··· 161 161 'Content-Type': 'application/json', 162 162 ...options?.headers 163 163 }, 164 - url: '/api/v{api-version}/requestBody/' 164 + url: '/api/v{api-version}/requestBody' 165 165 }); 166 166 }; 167 167 ··· 173 173 'Content-Type': null, 174 174 ...options?.headers 175 175 }, 176 - url: '/api/v{api-version}/formData/' 176 + url: '/api/v{api-version}/formData' 177 177 }); 178 178 }; 179 179
+8 -6
packages/openapi-ts/test/sample.cjs
··· 10 10 }, 11 11 // debug: true, 12 12 experimentalParser: true, 13 - input: './test/spec/3.0.x/full.json', 14 - // input: 'https://mongodb-mms-prod-build-server.s3.amazonaws.com/openapi/2caffd88277a4e27c95dcefc7e3b6a63a3b03297-v2-2023-11-15.json', 13 + input: { 14 + include: 15 + '^(#/components/schemas/import|#/paths/api/v{api-version}/simple/options)$', 16 + path: './test/spec/3.1.x/full.json', 17 + // path: 'https://mongodb-mms-prod-build-server.s3.amazonaws.com/openapi/2caffd88277a4e27c95dcefc7e3b6a63a3b03297-v2-2023-11-15.json', 18 + }, 15 19 // name: 'foo', 16 20 output: { 17 21 // format: 'prettier', ··· 25 29 // }, 26 30 { 27 31 // asClass: true, 28 - // filter: '^GET /api/v{api-version}/simple:operation$', 32 + // include... 29 33 name: '@hey-api/services', 30 34 // serviceNameBuilder: '^Parameters', 31 35 }, ··· 37 41 // enums: 'typescript', 38 42 // enums: 'typescript+namespace', 39 43 // enums: 'javascript', 40 - // include: 41 - // '^(_400|CompositionWithOneOfAndProperties)', 42 44 name: '@hey-api/types', 43 45 // style: 'PascalCase', 44 46 // tree: false, 45 47 }, 46 - '@tanstack/react-query', 48 + // '@tanstack/react-query', 47 49 // 'zod', 48 50 ], 49 51 // useOptions: false,
+24
packages/openapi-ts/test/spec/3.0.x/enum-escape.json
··· 1 + { 2 + "openapi": "3.0.2", 3 + "info": { 4 + "title": "OpenAPI 3.0.2 enum escape example", 5 + "version": "1" 6 + }, 7 + "components": { 8 + "schemas": { 9 + "Foo": { 10 + "type": "object", 11 + "properties": { 12 + "foo": { 13 + "enum": ["foo'bar", "foo\"bar"], 14 + "type": "string" 15 + } 16 + } 17 + }, 18 + "Bar": { 19 + "enum": ["foo'bar", "foo\"bar"], 20 + "type": "string" 21 + } 22 + } 23 + } 24 + }
+4 -4
packages/openapi-ts/test/spec/3.0.x/full.json
··· 203 203 } 204 204 ] 205 205 }, 206 - "/api/v{api-version}/descriptions/": { 206 + "/api/v{api-version}/descriptions": { 207 207 "post": { 208 208 "tags": ["Descriptions"], 209 209 "operationId": "CallWithDescriptions", ··· 478 478 } 479 479 } 480 480 }, 481 - "/api/v{api-version}/parameters/": { 481 + "/api/v{api-version}/parameters": { 482 482 "get": { 483 483 "tags": ["Parameters"], 484 484 "operationId": "GetCallWithOptionalParam", ··· 554 554 } 555 555 } 556 556 }, 557 - "/api/v{api-version}/requestBody/": { 557 + "/api/v{api-version}/requestBody": { 558 558 "post": { 559 559 "tags": ["RequestBody"], 560 560 "parameters": [ ··· 567 567 } 568 568 } 569 569 }, 570 - "/api/v{api-version}/formData/": { 570 + "/api/v{api-version}/formData": { 571 571 "post": { 572 572 "tags": ["FormData"], 573 573 "parameters": [
+24
packages/openapi-ts/test/spec/3.1.x/enum-escape.json
··· 1 + { 2 + "openapi": "3.1.1", 3 + "info": { 4 + "title": "OpenAPI 3.1.1 enum escape example", 5 + "version": "1" 6 + }, 7 + "components": { 8 + "schemas": { 9 + "Foo": { 10 + "type": "object", 11 + "properties": { 12 + "foo": { 13 + "enum": ["foo'bar", "foo\"bar"], 14 + "type": "string" 15 + } 16 + } 17 + }, 18 + "Bar": { 19 + "enum": ["foo'bar", "foo\"bar"], 20 + "type": "string" 21 + } 22 + } 23 + } 24 + }
+4 -4
packages/openapi-ts/test/spec/3.1.x/full.json
··· 211 211 } 212 212 ] 213 213 }, 214 - "/api/v{api-version}/descriptions/": { 214 + "/api/v{api-version}/descriptions": { 215 215 "post": { 216 216 "tags": ["Descriptions"], 217 217 "operationId": "CallWithDescriptions", ··· 476 476 } 477 477 } 478 478 }, 479 - "/api/v{api-version}/parameters/": { 479 + "/api/v{api-version}/parameters": { 480 480 "get": { 481 481 "tags": ["Parameters"], 482 482 "operationId": "GetCallWithOptionalParam", ··· 551 551 } 552 552 } 553 553 }, 554 - "/api/v{api-version}/requestBody/": { 554 + "/api/v{api-version}/requestBody": { 555 555 "post": { 556 556 "tags": ["RequestBody"], 557 557 "parameters": [ ··· 564 564 } 565 565 } 566 566 }, 567 - "/api/v{api-version}/formData/": { 567 + "/api/v{api-version}/formData": { 568 568 "post": { 569 569 "tags": ["FormData"], 570 570 "parameters": [