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

Configure Feed

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

Merge pull request #120 from hey-api/fix/use-options-api

fix(api): make useOptions true default

authored by

Lubos and committed by
GitHub
60f4d4b8 088060e9

+31 -7
+20 -1
README.md
··· 13 13 - [Linting](#linting) 14 14 - [Enums](#enums) 15 15 - [Config API](#config-api) 16 + - [Migrating](#migrating) 16 17 - [Contributing](#contributing) 17 18 18 19 ## About ··· 160 161 -o, --output <value> Output directory (required) 161 162 -c, --client <value> HTTP client to generate [fetch, xhr, node, axios, angular] (default: "fetch") 162 163 --name <value> Custom client class name 163 - --useOptions <value> Use options instead of arguments (default: false) 164 + --useOptions <value> Use options instead of arguments (default: true) 164 165 --base <value> Manually set base in OpenAPI config instead of inferring from server value 165 166 --enums Generate JavaScript objects from enum definitions (default: false) 166 167 --exportCore <value> Write core files to disk (default: true) ··· 178 179 --useDateType <value> Output Date instead of string for the format "date-time" in the models (default: false) 179 180 -h, --help display help for command 180 181 ``` 182 + 183 + ## Migrating 184 + 185 + While we try to avoid breaking changes, sometimes it's unavoidable in order to offer you the latest features. 186 + 187 + ### v0.27.38 188 + 189 + ### `useOptions: true` 190 + 191 + By default, generated clients will use a single object argument to pass values to API calls. This is a significant change from the previous default of unspecified array of arguments. If migrating your application in one go isn't feasible, we recommend deprecating your old client and generating a new client. 192 + 193 + ```ts 194 + import { DefaultService } from 'client' // <-- old client with array arguments 195 + 196 + import { DefaultService } from 'client_v2' // <-- new client with options argument 197 + ``` 198 + 199 + This way, you can gradually switch over to the new syntax as you update parts of your code. Once you've removed all instances of `client` imports, you can safely delete the old `client` folder and find and replace all `client_v2` calls to `client`. 181 200 182 201 ## Contributing 183 202
+2 -2
package-lock.json
··· 1 1 { 2 2 "name": "@hey-api/openapi-ts", 3 - "version": "0.27.37", 3 + "version": "0.27.38", 4 4 "lockfileVersion": 3, 5 5 "requires": true, 6 6 "packages": { 7 7 "": { 8 8 "name": "@hey-api/openapi-ts", 9 - "version": "0.27.37", 9 + "version": "0.27.38", 10 10 "license": "MIT", 11 11 "dependencies": { 12 12 "@apidevtools/json-schema-ref-parser": "11.5.4",
+1 -1
package.json
··· 1 1 { 2 2 "name": "@hey-api/openapi-ts", 3 - "version": "0.27.37", 3 + "version": "0.27.38", 4 4 "type": "module", 5 5 "description": "Turn your OpenAPI specification into a beautiful TypeScript client", 6 6 "homepage": "https://github.com/hey-api/openapi-ts/",
+7 -1
src/index.ts
··· 94 94 request, 95 95 serviceResponse = 'body', 96 96 useDateType = false, 97 - useOptions = false, 97 + useOptions = true, 98 98 write = true, 99 99 } = userConfig; 100 100 ··· 108 108 109 109 if (!isSubDirectory(process.cwd(), userConfig.output)) { 110 110 throw new Error('🚫 output must be within the current working directory'); 111 + } 112 + 113 + if (!useOptions) { 114 + console.warn( 115 + '⚠️ Deprecation warning: useOptions set to false. This setting will be removed in future versions. Please migrate useOptions to true https://github.com/hey-api/openapi-ts#v0.27.38' 116 + ); 111 117 } 112 118 113 119 const client = userConfig.client || inferClient(dependencies);
+1 -1
src/types/config.ts
··· 86 86 useDateType?: boolean; 87 87 /** 88 88 * Use options or arguments functions 89 - * @default false 89 + * @default true 90 90 */ 91 91 useOptions?: boolean; 92 92 /**
-1
test/sample.cjs
··· 7 7 enums: true, 8 8 input: './test/spec/v3.json', 9 9 output: './test/generated/v3/', 10 - useOptions: true, 11 10 }; 12 11 13 12 const { createClient } = await import(path.resolve(process.cwd(), 'dist/index.js'));