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 branch 'main' into copilot/fix-type-discriminator-values

authored by

Lubos and committed by
GitHub
300d2311 8126ad1b

+174 -27
+5
.changeset/tired-rats-watch.md
··· 1 + --- 2 + "@hey-api/openapi-ts": patch 3 + --- 4 + 5 + **fix**: improve dev mode detection causing builds to fail
+6
.vscode/settings.json
··· 16 16 "**/*.map": true, 17 17 "**/*.mjs": true, 18 18 "**/*.mts": true, 19 + "**/.vitepress/dist": true, 20 + "**/.mypy_cache": true, 21 + "**/__snapshots__": true, 22 + "**/coverage": true, 23 + "**/openapi-ts-tests/**/generated": true, 24 + "**/openapi-ts-tests/**/.gen": true, 19 25 "**/*.tsbuildinfo": true 20 26 }, 21 27 "typescript.preferences.autoImportFileExcludePatterns": ["dist/**"],
+1 -1
docs/openapi-ts/clients/angular.md
··· 251 251 252 252 ## API 253 253 254 - You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/@hey-api/client-angular/types.d.ts) interface. 254 + You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/@hey-api/client-angular/types.ts) interface. 255 255 256 256 <!--@include: ../../partials/examples.md--> 257 257 <!--@include: ../../partials/sponsors.md-->
+1 -1
docs/openapi-ts/clients/angular/v19.md
··· 251 251 252 252 ## API 253 253 254 - You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/@hey-api/client-angular/types.d.ts) interface. 254 + You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/@hey-api/client-angular/types.ts) interface. 255 255 256 256 <!--@include: ../../../partials/examples.md--> 257 257 <!--@include: ../../../partials/sponsors.md-->
+1 -1
docs/openapi-ts/clients/axios.md
··· 246 246 247 247 ## API 248 248 249 - You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/@hey-api/client-axios/types.d.ts) interface. 249 + You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/@hey-api/client-axios/types.ts) interface. 250 250 251 251 <!--@include: ../../partials/examples.md--> 252 252 <!--@include: ../../partials/sponsors.md-->
+1 -1
docs/openapi-ts/clients/fetch.md
··· 307 307 308 308 ## API 309 309 310 - You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/@hey-api/client-fetch/types.d.ts) interface. 310 + You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/@hey-api/client-fetch/types.ts) interface. 311 311 312 312 <!--@include: ../../partials/examples.md--> 313 313 <!--@include: ../../partials/sponsors.md-->
+1 -1
docs/openapi-ts/clients/ky.md
··· 305 305 306 306 ## API 307 307 308 - You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/@hey-api/client-ky/types.d.ts) interface. 308 + You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/@hey-api/client-ky/types.ts) interface. 309 309 310 310 <!--@include: ../../partials/examples.md--> 311 311 <!--@include: ../../partials/sponsors.md-->
+1 -1
docs/openapi-ts/clients/next-js.md
··· 290 290 291 291 ## API 292 292 293 - You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/@hey-api/client-next/types.d.ts) interface. 293 + You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/@hey-api/client-next/types.ts) interface. 294 294 295 295 <!--@include: ../../partials/examples.md--> 296 296 <!--@include: ../../partials/sponsors.md-->
+1 -1
docs/openapi-ts/clients/nuxt.md
··· 261 261 262 262 ## API 263 263 264 - You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/@hey-api/client-nuxt/types.d.ts) interface. 264 + You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/@hey-api/client-nuxt/types.ts) interface. 265 265 266 266 <!--@include: ../../partials/examples.md--> 267 267 <!--@include: ../../partials/sponsors.md-->
+1 -1
docs/openapi-ts/clients/ofetch.md
··· 344 344 345 345 ## API 346 346 347 - You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/@hey-api/client-ofetch/types.d.ts) interface. 347 + You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/@hey-api/client-ofetch/types.ts) interface. 348 348 349 349 <!--@include: ../../partials/examples.md--> 350 350 <!--@include: ../../partials/sponsors.md-->
+1 -1
docs/openapi-ts/configuration.md
··· 242 242 243 243 ## API 244 244 245 - You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/config/types.d.ts) interface. 245 + You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/config/types.ts) interface. 246 246 247 247 <!--@include: ../partials/examples.md--> 248 248 <!--@include: ../partials/sponsors.md-->
+1 -1
docs/openapi-ts/plugins/angular.md
··· 116 116 117 117 ## API 118 118 119 - You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/@angular/common/types.d.ts) interface. 119 + You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/@angular/common/types.ts) interface. 120 120 121 121 <!--@include: ../../partials/examples.md--> 122 122 <!--@include: ../../partials/sponsors.md-->
+1 -1
docs/openapi-ts/plugins/angular/v19.md
··· 116 116 117 117 ## API 118 118 119 - You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/@angular/common/types.d.ts) interface. 119 + You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/@angular/common/types.ts) interface. 120 120 121 121 <!--@include: ../../partials/examples.md--> 122 122 <!--@include: ../../partials/sponsors.md-->
+2 -2
docs/openapi-ts/plugins/custom.md
··· 30 30 31 31 ## TypeScript 32 32 33 - `index.ts` references two files, so we need to create them. `types.d.ts` contains the TypeScript interface for your plugin options. It must have the reserved `name` and `output` fields, everything else will become user-configurable options. 33 + `index.ts` references two files, so we need to create them. `types.ts` contains the TypeScript interface for your plugin options. It must have the reserved `name` and `output` fields, everything else will become user-configurable options. 34 34 35 35 ::: code-group 36 36 37 - ```ts [types.d.ts] 37 + ```ts [types.ts] 38 38 import type { DefinePlugin } from '@hey-api/openapi-ts'; 39 39 40 40 export type UserConfig = {
+1 -1
docs/openapi-ts/plugins/fastify.md
··· 97 97 98 98 ## API 99 99 100 - You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/fastify/types.d.ts) interface. 100 + You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/fastify/types.ts) interface. 101 101 102 102 <!--@include: ../../partials/examples.md--> 103 103 <!--@include: ../../partials/sponsors.md-->
+1 -1
docs/openapi-ts/plugins/pinia-colada.md
··· 262 262 263 263 ## API 264 264 265 - You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/@pinia/colada/types.d.ts) interface. 265 + You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/@pinia/colada/types.ts) interface. 266 266 267 267 <!--@include: ../../partials/examples.md--> 268 268 <!--@include: ../../partials/sponsors.md-->
+1 -1
docs/openapi-ts/plugins/schemas.md
··· 92 92 93 93 ## API 94 94 95 - You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/@hey-api/schemas/types.d.ts) interface. 95 + You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/@hey-api/schemas/types.ts) interface. 96 96 97 97 <!--@include: ../../partials/examples.md--> 98 98 <!--@include: ../../partials/sponsors.md-->
+1 -1
docs/openapi-ts/plugins/sdk.md
··· 544 544 545 545 ## API 546 546 547 - You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/@hey-api/sdk/types.d.ts) interface. 547 + You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/@hey-api/sdk/types.ts) interface. 548 548 549 549 <!--@include: ../../partials/examples.md--> 550 550 <!--@include: ../../partials/sponsors.md-->
+1 -1
docs/openapi-ts/plugins/tanstack-query.md
··· 608 608 609 609 ## API 610 610 611 - You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/@tanstack/react-query/types.d.ts) interface. 611 + You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/@tanstack/react-query/types.ts) interface. 612 612 613 613 <!--@include: ../../partials/examples.md--> 614 614 <!--@include: ../../partials/sponsors.md-->
+1 -1
docs/openapi-ts/plugins/transformers.md
··· 151 151 152 152 ## API 153 153 154 - You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/@hey-api/transformers/types.d.ts) interface. 154 + You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/@hey-api/transformers/types.ts) interface. 155 155 156 156 <!--@include: ../partials/sponsors.md-->
+1 -1
docs/openapi-ts/plugins/typescript.md
··· 132 132 133 133 ## API 134 134 135 - You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/@hey-api/typescript/types.d.ts) interface. 135 + You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/@hey-api/typescript/types.ts) interface. 136 136 137 137 <!--@include: ../../partials/examples.md--> 138 138 <!--@include: ../../partials/sponsors.md-->
+1 -1
docs/openapi-ts/plugins/valibot.md
··· 213 213 214 214 ## API 215 215 216 - You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/valibot/types.d.ts) interface. 216 + You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/valibot/types.ts) interface. 217 217 218 218 <!--@include: ../../partials/examples.md--> 219 219 <!--@include: ../../partials/sponsors.md-->
+1 -1
docs/openapi-ts/plugins/zod.md
··· 305 305 306 306 ## API 307 307 308 - You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/zod/types.d.ts) interface. 308 + You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/zod/types.ts) interface. 309 309 310 310 <!--@include: ../../partials/examples.md--> 311 311 <!--@include: ../../partials/sponsors.md-->
+1 -1
docs/openapi-ts/plugins/zod/mini.md
··· 318 318 319 319 ## API 320 320 321 - You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/zod/types.d.ts) interface. 321 + You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/zod/types.ts) interface. 322 322 323 323 <!--@include: ../../../partials/examples.md--> 324 324 <!--@include: ../../../partials/sponsors.md-->
+1 -1
docs/openapi-ts/plugins/zod/v3.md
··· 316 316 317 317 ## API 318 318 319 - You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/zod/types.d.ts) interface. 319 + You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/zod/types.ts) interface. 320 320 321 321 <!--@include: ../../../partials/examples.md--> 322 322 <!--@include: ../../../partials/sponsors.md-->
+127
packages/openapi-ts/src/generate/__tests__/client.test.ts
··· 1 + import path from 'node:path'; 2 + 3 + import { describe, expect, it } from 'vitest'; 4 + 5 + describe('isDevMode logic', () => { 6 + const scenarios: ReadonlyArray<{ 7 + description: string; 8 + expected: boolean; 9 + mockPath: string; 10 + }> = [ 11 + { 12 + description: 'returns true in dev mode (src/generate)', 13 + expected: true, 14 + mockPath: ['', 'home', 'user', 'packages', 'openapi-ts', 'src', 'generate'].join(path.sep), 15 + }, 16 + { 17 + description: 'returns false in prod mode (dist/generate)', 18 + expected: false, 19 + mockPath: ['', 'home', 'user', 'packages', 'openapi-ts', 'dist', 'generate'].join(path.sep), 20 + }, 21 + { 22 + description: 'returns false when path contains /src/ but not in correct position', 23 + expected: false, 24 + mockPath: [ 25 + '', 26 + 'home', 27 + 'user', 28 + 'src', 29 + 'project', 30 + 'node_modules', 31 + '@hey-api', 32 + 'openapi-ts', 33 + 'dist', 34 + 'generate', 35 + ].join(path.sep), 36 + }, 37 + { 38 + description: 'returns false when src is in project path (pnpm case from issue)', 39 + expected: false, 40 + mockPath: [ 41 + '', 42 + 'home', 43 + 'user', 44 + 'src', 45 + 'thcdb', 46 + 'worktree', 47 + 'schema-gen', 48 + 'web', 49 + 'node_modules', 50 + '.pnpm', 51 + '@hey-api+openapi-ts@0.91.1', 52 + 'node_modules', 53 + '@hey-api', 54 + 'openapi-ts', 55 + 'dist', 56 + 'generate', 57 + ].join(path.sep), 58 + }, 59 + { 60 + description: 61 + 'returns false when src is in project path with plugins path (exact error from issue)', 62 + expected: false, 63 + mockPath: [ 64 + '', 65 + 'home', 66 + 'user', 67 + 'src', 68 + 'thcdb', 69 + 'worktree', 70 + 'schema-gen', 71 + 'web', 72 + 'node_modules', 73 + '.pnpm', 74 + '@hey-api+openapi-ts@0.91.1_magicast@0.5.1_typescript@5.9.3', 75 + 'node_modules', 76 + '@hey-api', 77 + 'openapi-ts', 78 + 'plugins', 79 + '@hey-api', 80 + 'client-core', 81 + 'bundle', 82 + ].join(path.sep), 83 + }, 84 + { 85 + description: 'returns true only when ending with src/generate', 86 + expected: true, 87 + mockPath: [ 88 + '', 89 + 'home', 90 + 'user', 91 + 'src', 92 + 'backup', 93 + 'packages', 94 + 'openapi-ts', 95 + 'src', 96 + 'generate', 97 + ].join(path.sep), 98 + }, 99 + { 100 + description: 'returns false when not ending with generate', 101 + expected: false, 102 + mockPath: ['', 'home', 'user', 'packages', 'openapi-ts', 'src', 'plugins'].join(path.sep), 103 + }, 104 + { 105 + description: 'returns false when src exists but dist is later', 106 + expected: false, 107 + mockPath: ['', 'home', 'user', 'src', 'project', 'openapi-ts', 'dist', 'generate'].join( 108 + path.sep, 109 + ), 110 + }, 111 + ]; 112 + 113 + it.each(scenarios)('$description', ({ expected, mockPath }) => { 114 + // Test the isDevMode logic 115 + const normalized = mockPath.split(path.sep); 116 + const srcIndex = normalized.lastIndexOf('src'); 117 + const distIndex = normalized.lastIndexOf('dist'); 118 + 119 + const result = 120 + srcIndex !== -1 && 121 + srcIndex > distIndex && 122 + srcIndex === normalized.length - 2 && 123 + normalized[srcIndex + 1] === 'generate'; 124 + 125 + expect(result).toBe(expected); 126 + }); 127 + });
+12 -3
packages/openapi-ts/src/generate/client.ts
··· 13 13 const __filename = fileURLToPath(import.meta.url); 14 14 const __dirname = path.dirname(__filename); 15 15 16 + /** 17 + * Dev mode: 'src' appears after 'dist' (or dist doesn't exist), and 'generate' follows 'src' 18 + */ 16 19 function isDevMode(): boolean { 17 - // In dev: __dirname = .../packages/openapi-ts/src/generate 18 - // In prod: __dirname = .../packages/openapi-ts/dist/generate 19 - return __dirname.includes(`${path.sep}src${path.sep}`); 20 + const normalized = __dirname.split(path.sep); 21 + const srcIndex = normalized.lastIndexOf('src'); 22 + const distIndex = normalized.lastIndexOf('dist'); 23 + return ( 24 + srcIndex !== -1 && 25 + srcIndex > distIndex && 26 + srcIndex === normalized.length - 2 && 27 + normalized[srcIndex + 1] === 'generate' 28 + ); 20 29 } 21 30 22 31 /**