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.

feat: remove support for client packages

Lubos ​ 96053a5e 16fb3c77

+34 -20
+1 -1
packages/openapi-ts-tests/test/openapi-ts.config.ts
··· 99 99 // bundle: true, 100 100 // bundleSource_EXPERIMENTAL: true, 101 101 // exportFromIndex: true, 102 - name: '@hey-api/client-fetch', 102 + // name: '@hey-api/client-fetch', 103 103 // name: 'legacy/fetch', 104 104 // strictBaseUrl: true, 105 105 },
+14 -1
packages/openapi-ts/src/initConfigs.ts
··· 136 136 config._dependencies = [...config._dependencies, dependency]; 137 137 } 138 138 }, 139 - pluginByTag: (tag, errorMessage) => { 139 + pluginByTag: ({ defaultPlugin, errorMessage, tag }) => { 140 140 for (const userPlugin of userPlugins) { 141 141 const defaultConfig = 142 142 defaultPluginConfigs[userPlugin as PluginNames] || ··· 147 147 userPlugin !== name 148 148 ) { 149 149 return userPlugin; 150 + } 151 + } 152 + 153 + if (defaultPlugin) { 154 + const defaultConfig = 155 + defaultPluginConfigs[defaultPlugin as PluginNames] || 156 + pluginConfigs[defaultPlugin as PluginNames]; 157 + if ( 158 + defaultConfig && 159 + defaultConfig._tags?.includes(tag) && 160 + defaultPlugin !== name 161 + ) { 162 + return defaultPlugin; 150 163 } 151 164 } 152 165
+10 -10
packages/openapi-ts/src/plugins/@hey-api/sdk/config.ts
··· 10 10 _infer: (config, context) => { 11 11 if (config.client) { 12 12 if (typeof config.client === 'boolean') { 13 - config.client = context.pluginByTag( 14 - 'client', 15 - '🚫 client needs to be set to generate SDKs - which HTTP client do you want to use?', 16 - ) as unknown as typeof config.client; 13 + config.client = context.pluginByTag({ 14 + defaultPlugin: '@hey-api/client-fetch', 15 + tag: 'client', 16 + }) as unknown as typeof config.client; 17 17 } 18 18 19 19 context.ensureDependency(config.client); ··· 21 21 22 22 if (config.transformer) { 23 23 if (typeof config.transformer === 'boolean') { 24 - config.transformer = context.pluginByTag( 25 - 'transformer', 26 - ) as unknown as typeof config.transformer; 24 + config.transformer = context.pluginByTag({ 25 + tag: 'transformer', 26 + }) as unknown as typeof config.transformer; 27 27 } 28 28 29 29 context.ensureDependency(config.transformer); ··· 31 31 32 32 if (config.validator) { 33 33 if (typeof config.validator === 'boolean') { 34 - config.validator = context.pluginByTag( 35 - 'validator', 36 - ) as unknown as typeof config.validator; 34 + config.validator = context.pluginByTag({ 35 + tag: 'validator', 36 + }) as unknown as typeof config.validator; 37 37 } 38 38 39 39 context.ensureDependency(config.validator);
+4 -4
packages/openapi-ts/src/plugins/@hey-api/sdk/types.d.ts
··· 46 46 * Use an internal client instance to send HTTP requests? This is useful if 47 47 * you don't want to manually pass the client to each SDK function. 48 48 * 49 - * Ensure you have declared the selected library as a dependency to avoid 50 - * errors. You can customize the selected client output through its plugin. 51 - * You can also set `client` to `true` to automatically choose the client 52 - * from your defined plugins. 49 + * You can customize the selected client output through its plugin. You can 50 + * also set `client` to `true` to automatically choose the client from your 51 + * defined plugins. If we can't detect a client plugin when using `true`, we 52 + * will default to `@hey-api/client-fetch`. 53 53 * 54 54 * @default true 55 55 */
+5 -4
packages/openapi-ts/src/plugins/types.d.ts
··· 41 41 42 42 export interface PluginContext { 43 43 ensureDependency: (name: PluginNames | true) => void; 44 - pluginByTag: ( 45 - tag: PluginTag, 46 - errorMessage?: string, 47 - ) => AnyPluginName | undefined; 44 + pluginByTag: (props: { 45 + defaultPlugin?: AnyPluginName; 46 + errorMessage?: string; 47 + tag: PluginTag; 48 + }) => AnyPluginName | undefined; 48 49 } 49 50 50 51 interface BaseConfig {