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 #2838 from hey-api/feat/symbol-meta-path

refactor: pass path to symbol meta instead of resource type

authored by

Lubos and committed by
GitHub
972b93e4 757fb1f7

+111 -187
+12 -4
packages/openapi-ts-tests/main/test/openapi-ts.config.ts
··· 134 134 // 'symbol:register:after': ({ plugin, symbol }) => { 135 135 // console.log(`(global, ${plugin.name}) registered:`, symbol.id); 136 136 // }, 137 - // 'symbol:register:before': ({ plugin, symbol }) => { 138 - // console.log(`(global, ${plugin.name}):`, symbol.name); 139 - // }, 137 + 'symbol:register:before': ({ plugin, symbol }) => { 138 + // if (!symbol.external && !symbol.meta?.resourceType) { 139 + // console.log(`[${plugin.name}]:`, symbol.name); 140 + // } 141 + if (!symbol.external && !symbol.meta?.path) { 142 + console.log(`[${plugin.name}]:`, symbol.name, symbol.meta); 143 + } 144 + // if (symbol.meta?.path) { 145 + // console.log(`[${plugin.name}]:`, symbol.name, symbol.meta.path); 146 + // } 147 + }, 140 148 // 'symbol:setValue:after': ({ plugin, symbol }) => { 141 149 // console.log(`(${plugin.name}) set value:`, symbol.id); 142 150 // }, ··· 295 303 // mutationOptions: { 296 304 // name: '{{name}}MO', 297 305 // }, 298 - name: '@tanstack/react-query', 306 + // name: '@tanstack/react-query', 299 307 // queryKeys: { 300 308 // name: '{{name}}QK', 301 309 // },
+28 -2
packages/openapi-ts/src/index.ts
··· 1 - // eslint-disable-next-line @typescript-eslint/triple-slash-reference 2 - /// <reference path="./overrides.d.ts" /> 1 + // OVERRIDES 2 + // hard-coded here because build process doesn't pick up overrides from separate files 3 + import '@hey-api/codegen-core'; 4 + 5 + declare module '@hey-api/codegen-core' { 6 + interface ProjectRenderMeta { 7 + /** 8 + * If specified, this will be the file extension used when importing 9 + * other modules. By default, we don't add a file extension and let the 10 + * runtime resolve it. 11 + * 12 + * @default null 13 + */ 14 + importFileExtension?: (string & {}) | null; 15 + } 16 + 17 + interface SymbolMeta { 18 + /** 19 + * Path to the resource this symbol represents. 20 + */ 21 + path?: ReadonlyArray<string | number>; 22 + /** 23 + * Name of the plugin that registered this symbol. 24 + */ 25 + pluginName?: string; 26 + } 27 + } 28 + // END OVERRIDES 3 29 4 30 import colors from 'ansi-colors'; 5 31 // @ts-expect-error
-31
packages/openapi-ts/src/overrides.d.ts
··· 1 - import '@hey-api/codegen-core'; 2 - 3 - declare module '@hey-api/codegen-core' { 4 - interface ProjectRenderMeta { 5 - /** 6 - * If specified, this will be the file extension used when importing 7 - * other modules. By default, we don't add a file extension and let the 8 - * runtime resolve it. 9 - * 10 - * @default null 11 - */ 12 - importFileExtension?: (string & {}) | null; 13 - } 14 - 15 - interface SymbolMeta { 16 - /** 17 - * Name of the plugin that registered this symbol. 18 - */ 19 - pluginName?: string; 20 - /** 21 - * Type of resource this symbol represents. 22 - */ 23 - resourceType?: 24 - | 'operation' 25 - | 'parameter' 26 - | 'requestBody' 27 - | 'schema' 28 - | 'server' 29 - | 'webhook'; 30 - } 31 - }
+2 -4
packages/openapi-ts/src/plugins/arktype/v2/plugin.ts
··· 2 2 import type { IR } from '~/ir/types'; 3 3 import { buildName } from '~/openApi/shared/utils/name'; 4 4 import type { SchemaWithType } from '~/plugins/shared/types/schema'; 5 - import { pathToSymbolResourceType } from '~/plugins/shared/utils/meta'; 6 5 import { toRefs } from '~/plugins/shared/utils/refs'; 7 6 import { tsc } from '~/tsc'; 8 7 import { refToName } from '~/utils/ref'; ··· 247 246 }): void => { 248 247 const ast = irSchemaToAst({ plugin, schema, state }); 249 248 const baseName = refToName($ref); 250 - const resourceType = pathToSymbolResourceType(state._path.value); 251 249 const symbol = plugin.registerSymbol({ 252 250 exported: true, 253 251 meta: { 254 - resourceType, 252 + path: state._path.value, 255 253 }, 256 254 name: buildName({ 257 255 config: plugin.config.definitions, ··· 264 262 exported: true, 265 263 meta: { 266 264 kind: 'type', 267 - resourceType, 265 + path: state._path.value, 268 266 }, 269 267 name: buildName({ 270 268 config: plugin.config.definitions.types.infer,
-46
packages/openapi-ts/src/plugins/shared/utils/__tests__/meta.test.ts
··· 1 - import { describe, expect, it } from 'vitest'; 2 - 3 - import { pathToSymbolResourceType } from '../meta'; 4 - 5 - describe('pathToSymbolResourceType', () => { 6 - it('returns schema for components/schemas', () => { 7 - expect(pathToSymbolResourceType(['components', 'schemas', 'Pet'])).toBe( 8 - 'schema', 9 - ); 10 - }); 11 - 12 - it('returns parameter for components/parameters', () => { 13 - expect( 14 - pathToSymbolResourceType(['components', 'parameters', 'limit']), 15 - ).toBe('parameter'); 16 - }); 17 - 18 - it('returns requestBody for components/requestBodies', () => { 19 - expect( 20 - pathToSymbolResourceType(['components', 'requestBodies', 'Body']), 21 - ).toBe('requestBody'); 22 - }); 23 - 24 - it('returns operation for paths', () => { 25 - expect(pathToSymbolResourceType(['paths', '/pets', 'get'])).toBe( 26 - 'operation', 27 - ); 28 - }); 29 - 30 - it('returns server for servers', () => { 31 - expect(pathToSymbolResourceType(['servers', 0])).toBe('server'); 32 - }); 33 - 34 - it('returns webhook for webhooks', () => { 35 - expect(pathToSymbolResourceType(['webhooks', 'onEvent'])).toBe('webhook'); 36 - }); 37 - 38 - it('returns undefined for unknown paths', () => { 39 - expect( 40 - pathToSymbolResourceType(['components', 'unknown', 'foo']), 41 - ).toBeUndefined(); 42 - expect(pathToSymbolResourceType(['random', 'value'])).toBeUndefined(); 43 - expect(pathToSymbolResourceType(['components'])).toBeUndefined(); 44 - expect(pathToSymbolResourceType([])).toBeUndefined(); 45 - }); 46 - });
-17
packages/openapi-ts/src/plugins/shared/utils/meta.ts
··· 1 - import type { SymbolMeta } from '@hey-api/codegen-core'; 2 - 3 - export const pathToSymbolResourceType = ( 4 - path: ReadonlyArray<string | number>, 5 - ): SymbolMeta['resourceType'] => { 6 - if (path.length >= 2) { 7 - if (path[0] === 'components') { 8 - if (path[1] === 'schemas') return 'schema'; 9 - if (path[1] === 'parameters') return 'parameter'; 10 - if (path[1] === 'requestBodies') return 'requestBody'; 11 - } 12 - if (path[0] === 'paths') return 'operation'; 13 - if (path[0] === 'servers') return 'server'; 14 - if (path[0] === 'webhooks') return 'webhook'; 15 - } 16 - return; 17 - };
+4 -4
packages/openapi-ts/src/plugins/valibot/shared/types.d.ts
··· 10 10 }; 11 11 12 12 export type PluginState = { 13 - /** 14 - * Path to the schema in the intermediary representation. 15 - */ 16 - _path: ReadonlyArray<string | number>; 17 13 hasLazyExpression: boolean; 18 14 nameCase: StringCase; 19 15 nameTransformer: StringName; 16 + /** 17 + * Path to the schema in the intermediary representation. 18 + */ 19 + path: ReadonlyArray<string | number>; 20 20 }; 21 21 22 22 export type ValidatorArgs = {
+4 -5
packages/openapi-ts/src/plugins/valibot/v1/operation.ts
··· 1 1 import { operationResponsesMap } from '~/ir/operation'; 2 2 import type { IR } from '~/ir/types'; 3 3 import { buildName } from '~/openApi/shared/utils/name'; 4 - import { pathToSymbolResourceType } from '~/plugins/shared/utils/meta'; 5 4 import { toRef } from '~/plugins/shared/utils/refs'; 6 5 7 6 import type { IrSchemaToAstOptions } from '../shared/types'; ··· 115 114 const symbol = plugin.registerSymbol({ 116 115 exported: true, 117 116 meta: { 118 - resourceType: pathToSymbolResourceType(state._path.value), 117 + path: state.path.value, 119 118 }, 120 119 name: buildName({ 121 120 config: plugin.config.requests, ··· 136 135 const { response } = operationResponsesMap(operation); 137 136 138 137 if (response) { 139 - const path = [...state._path.value, 'responses']; 138 + const path = [...state.path.value, 'responses']; 140 139 const symbol = plugin.registerSymbol({ 141 140 exported: true, 142 141 meta: { 143 - resourceType: pathToSymbolResourceType(path), 142 + path, 144 143 }, 145 144 name: buildName({ 146 145 config: plugin.config.responses, ··· 153 152 schema: response, 154 153 state: { 155 154 ...state, 156 - _path: toRef(path), 155 + path: toRef(path), 157 156 }, 158 157 symbol, 159 158 });
+3 -4
packages/openapi-ts/src/plugins/valibot/v1/plugin.ts
··· 5 5 import type { IR } from '~/ir/types'; 6 6 import { buildName } from '~/openApi/shared/utils/name'; 7 7 import type { SchemaWithType } from '~/plugins/shared/types/schema'; 8 - import { pathToSymbolResourceType } from '~/plugins/shared/utils/meta'; 9 8 import { toRef, toRefs } from '~/plugins/shared/utils/refs'; 10 9 import { createSchemaComment } from '~/plugins/shared/utils/schema'; 11 10 import { tsc } from '~/tsc'; ··· 118 117 schema: item, 119 118 state: { 120 119 ...state, 121 - _path: toRef([...state._path.value, 'items', index]), 120 + path: toRef([...state.path.value, 'items', index]), 122 121 }, 123 122 }); 124 123 return pipesToAst({ pipes: itemAst, plugin }); ··· 215 214 symbol = plugin.registerSymbol({ 216 215 exported: true, 217 216 meta: { 218 - resourceType: pathToSymbolResourceType(state._path.value), 217 + path: state.path.value, 219 218 }, 220 219 name: buildName({ 221 220 config: { ··· 264 263 'webhook', 265 264 (event) => { 266 265 const state = toRefs<PluginState>({ 267 - _path: event._path, 268 266 hasLazyExpression: false, 269 267 nameCase: plugin.config.definitions.case, 270 268 nameTransformer: plugin.config.definitions.name, 269 + path: event._path, 271 270 }); 272 271 273 272 switch (event.type) {
+1 -1
packages/openapi-ts/src/plugins/valibot/v1/toAst/array.ts
··· 52 52 schema: item, 53 53 state: { 54 54 ...state, 55 - _path: toRef([...state._path.value, 'items', index]), 55 + path: toRef([...state.path.value, 'items', index]), 56 56 }, 57 57 }); 58 58 return pipesToAst({ pipes: schemaPipes, plugin });
+2 -2
packages/openapi-ts/src/plugins/valibot/v1/toAst/object.ts
··· 35 35 schema: property, 36 36 state: { 37 37 ...state, 38 - _path: toRef([...state._path.value, 'properties', name]), 38 + path: toRef([...state.path.value, 'properties', name]), 39 39 }, 40 40 }); 41 41 ··· 80 80 schema: schema.additionalProperties, 81 81 state: { 82 82 ...state, 83 - _path: toRef([...state._path.value, 'additionalProperties']), 83 + path: toRef([...state.path.value, 'additionalProperties']), 84 84 }, 85 85 }); 86 86 const expression = tsc.callExpression({
+1 -1
packages/openapi-ts/src/plugins/valibot/v1/toAst/tuple.ts
··· 50 50 schema: item, 51 51 state: { 52 52 ...state, 53 - _path: toRef([...state._path.value, 'items', index]), 53 + path: toRef([...state.path.value, 'items', index]), 54 54 }, 55 55 }); 56 56 return pipesToAst({ pipes: schemaPipes, plugin });
+1 -2
packages/openapi-ts/src/plugins/valibot/v1/webhook.ts
··· 1 1 import type { IR } from '~/ir/types'; 2 2 import { buildName } from '~/openApi/shared/utils/name'; 3 - import { pathToSymbolResourceType } from '~/plugins/shared/utils/meta'; 4 3 5 4 import type { IrSchemaToAstOptions } from '../shared/types'; 6 5 import { irSchemaToAst } from './plugin'; ··· 113 112 const symbol = plugin.registerSymbol({ 114 113 exported: true, 115 114 meta: { 116 - resourceType: pathToSymbolResourceType(state._path.value), 115 + path: state.path.value, 117 116 }, 118 117 name: buildName({ 119 118 config: plugin.config.webhooks,
+10 -12
packages/openapi-ts/src/plugins/zod/mini/plugin.ts
··· 2 2 import type { IR } from '~/ir/types'; 3 3 import { buildName } from '~/openApi/shared/utils/name'; 4 4 import type { SchemaWithType } from '~/plugins/shared/types/schema'; 5 - import { pathToSymbolResourceType } from '~/plugins/shared/utils/meta'; 6 5 import { toRef, toRefs } from '~/plugins/shared/utils/refs'; 7 6 import { tsc } from '~/tsc'; 8 7 import { refToName } from '~/utils/ref'; ··· 103 102 schema: item, 104 103 state: { 105 104 ...state, 106 - _path: toRef([...state._path.value, 'items', index]), 105 + path: toRef([...state.path.value, 'items', index]), 107 106 }, 108 107 }), 109 108 ); ··· 237 236 }): void => { 238 237 const ast = irSchemaToAst({ plugin, schema, state }); 239 238 const baseName = refToName($ref); 240 - const resourceType = pathToSymbolResourceType(state._path.value); 241 239 const symbol = plugin.registerSymbol({ 242 240 exported: true, 243 241 meta: { 244 - resourceType, 242 + path: state.path.value, 245 243 }, 246 244 name: buildName({ 247 245 config: plugin.config.definitions, ··· 254 252 exported: true, 255 253 meta: { 256 254 kind: 'type', 257 - resourceType, 255 + path: state.path.value, 258 256 }, 259 257 name: buildName({ 260 258 config: plugin.config.definitions.types.infer, ··· 292 290 irOperationToAst({ 293 291 getAst: (schema, path) => { 294 292 const state = toRefs<PluginState>({ 295 - _path: path, 296 293 hasLazyExpression: false, 294 + path, 297 295 }); 298 296 return irSchemaToAst({ plugin, schema, state }); 299 297 }, 300 298 operation: event.operation, 301 299 plugin, 302 300 state: toRefs({ 303 - _path: event._path, 301 + path: event._path, 304 302 }), 305 303 }); 306 304 break; ··· 310 308 plugin, 311 309 schema: event.parameter.schema, 312 310 state: toRefs({ 313 - _path: event._path, 314 311 hasLazyExpression: false, 312 + path: event._path, 315 313 }), 316 314 }); 317 315 break; ··· 321 319 plugin, 322 320 schema: event.requestBody.schema, 323 321 state: toRefs({ 324 - _path: event._path, 325 322 hasLazyExpression: false, 323 + path: event._path, 326 324 }), 327 325 }); 328 326 break; ··· 332 330 plugin, 333 331 schema: event.schema, 334 332 state: toRefs({ 335 - _path: event._path, 336 333 hasLazyExpression: false, 334 + path: event._path, 337 335 }), 338 336 }); 339 337 break; ··· 341 339 irWebhookToAst({ 342 340 getAst: (schema, path) => { 343 341 const state = toRefs<PluginState>({ 344 - _path: path, 345 342 hasLazyExpression: false, 343 + path, 346 344 }); 347 345 return irSchemaToAst({ plugin, schema, state }); 348 346 }, 349 347 operation: event.operation, 350 348 plugin, 351 349 state: toRefs({ 352 - _path: event._path, 350 + path: event._path, 353 351 }), 354 352 }); 355 353 break;
+1 -1
packages/openapi-ts/src/plugins/zod/mini/toAst/array.ts
··· 49 49 schema: item, 50 50 state: { 51 51 ...state, 52 - _path: toRef([...state._path.value, 'items', index]), 52 + path: toRef([...state.path.value, 'items', index]), 53 53 }, 54 54 }); 55 55 if (itemAst.hasLazyExpression) {
+2 -2
packages/openapi-ts/src/plugins/zod/mini/toAst/object.ts
··· 36 36 schema: property, 37 37 state: { 38 38 ...state, 39 - _path: toRef([...state._path.value, 'properties', name]), 39 + path: toRef([...state.path.value, 'properties', name]), 40 40 }, 41 41 }); 42 42 if (propertyAst.hasLazyExpression) { ··· 93 93 schema: schema.additionalProperties, 94 94 state: { 95 95 ...state, 96 - _path: toRef([...state._path.value, 'additionalProperties']), 96 + path: toRef([...state.path.value, 'additionalProperties']), 97 97 }, 98 98 }); 99 99 result.expression = tsc.callExpression({
+1 -1
packages/openapi-ts/src/plugins/zod/mini/toAst/tuple.ts
··· 52 52 schema: item, 53 53 state: { 54 54 ...state, 55 - _path: toRef([...state._path.value, 'items', index]), 55 + path: toRef([...state.path.value, 'items', index]), 56 56 }, 57 57 }); 58 58 tupleElements.push(itemSchema.expression);
+6 -9
packages/openapi-ts/src/plugins/zod/shared/operation.ts
··· 1 1 import { operationResponsesMap } from '~/ir/operation'; 2 2 import type { IR } from '~/ir/types'; 3 3 import { buildName } from '~/openApi/shared/utils/name'; 4 - import { pathToSymbolResourceType } from '~/plugins/shared/utils/meta'; 5 4 6 5 import { exportAst } from './export'; 7 6 import type { Ast, IrSchemaToAstOptions } from './types'; ··· 117 116 118 117 schemaData.required = [...requiredProperties]; 119 118 120 - const path = state._path?.value || []; 119 + const path = state.path?.value || []; 121 120 const ast = getAst(schemaData, path); 122 - const resourceType = pathToSymbolResourceType(path); 123 121 const symbol = plugin.registerSymbol({ 124 122 exported: true, 125 123 meta: { 126 - resourceType, 124 + path, 127 125 }, 128 126 name: buildName({ 129 127 config: plugin.config.requests, ··· 136 134 exported: true, 137 135 meta: { 138 136 kind: 'type', 139 - resourceType, 137 + path, 140 138 }, 141 139 name: buildName({ 142 140 config: plugin.config.requests.types.infer, ··· 159 157 const { response } = operationResponsesMap(operation); 160 158 161 159 if (response) { 162 - const path = [...(state._path?.value || []), 'responses']; 160 + const path = [...(state.path?.value || []), 'responses']; 163 161 const ast = getAst(response, path); 164 - const resourceType = pathToSymbolResourceType(path); 165 162 const symbol = plugin.registerSymbol({ 166 163 exported: true, 167 164 meta: { 168 - resourceType, 165 + path, 169 166 }, 170 167 name: buildName({ 171 168 config: plugin.config.responses, ··· 178 175 exported: true, 179 176 meta: { 180 177 kind: 'type', 181 - resourceType, 178 + path, 182 179 }, 183 180 name: buildName({ 184 181 config: plugin.config.responses.types.infer,
+2 -2
packages/openapi-ts/src/plugins/zod/shared/types.d.ts
··· 17 17 }; 18 18 19 19 export type PluginState = { 20 + hasLazyExpression: boolean; 20 21 /** 21 22 * Path to the schema in the intermediary representation. 22 23 */ 23 - _path: ReadonlyArray<string | number>; 24 - hasLazyExpression: boolean; 24 + path: ReadonlyArray<string | number>; 25 25 }; 26 26 27 27 export type ValidatorArgs = {
+3 -5
packages/openapi-ts/src/plugins/zod/shared/webhook.ts
··· 1 1 import type { IR } from '~/ir/types'; 2 2 import { buildName } from '~/openApi/shared/utils/name'; 3 - import { pathToSymbolResourceType } from '~/plugins/shared/utils/meta'; 4 3 5 4 import { exportAst } from './export'; 6 5 import type { Ast, IrSchemaToAstOptions } from './types'; ··· 116 115 117 116 schemaData.required = [...requiredProperties]; 118 117 119 - const path = state._path?.value || []; 118 + const path = state.path?.value || []; 120 119 const ast = getAst(schemaData, path); 121 - const resourceType = pathToSymbolResourceType(path); 122 120 const symbol = plugin.registerSymbol({ 123 121 exported: true, 124 122 meta: { 125 - resourceType, 123 + path, 126 124 }, 127 125 name: buildName({ 128 126 config: plugin.config.webhooks, ··· 135 133 exported: true, 136 134 meta: { 137 135 kind: 'type', 138 - resourceType, 136 + path, 139 137 }, 140 138 name: buildName({ 141 139 config: plugin.config.webhooks.types.infer,
+10 -12
packages/openapi-ts/src/plugins/zod/v3/plugin.ts
··· 2 2 import type { IR } from '~/ir/types'; 3 3 import { buildName } from '~/openApi/shared/utils/name'; 4 4 import type { SchemaWithType } from '~/plugins/shared/types/schema'; 5 - import { pathToSymbolResourceType } from '~/plugins/shared/utils/meta'; 6 5 import { toRef, toRefs } from '~/plugins/shared/utils/refs'; 7 6 import { tsc } from '~/tsc'; 8 7 import { refToName } from '~/utils/ref'; ··· 89 88 schema: item, 90 89 state: { 91 90 ...state, 92 - _path: toRef([...state._path.value, 'items', index]), 91 + path: toRef([...state.path.value, 'items', index]), 93 92 }, 94 93 }); 95 94 return typeAst.expression; ··· 211 210 }): void => { 212 211 const ast = irSchemaToAst({ plugin, schema, state }); 213 212 const baseName = refToName($ref); 214 - const resourceType = pathToSymbolResourceType(state._path.value); 215 213 const symbol = plugin.registerSymbol({ 216 214 exported: true, 217 215 meta: { 218 - resourceType, 216 + path: state.path.value, 219 217 }, 220 218 name: buildName({ 221 219 config: plugin.config.definitions, ··· 228 226 exported: true, 229 227 meta: { 230 228 kind: 'type', 231 - resourceType, 229 + path: state.path.value, 232 230 }, 233 231 name: buildName({ 234 232 config: plugin.config.definitions.types.infer, ··· 265 263 irOperationToAst({ 266 264 getAst: (schema, path) => { 267 265 const state = toRefs<PluginState>({ 268 - _path: path, 269 266 hasLazyExpression: false, 267 + path, 270 268 }); 271 269 return irSchemaToAst({ plugin, schema, state }); 272 270 }, 273 271 operation: event.operation, 274 272 plugin, 275 273 state: toRefs({ 276 - _path: event._path, 274 + path: event._path, 277 275 }), 278 276 }); 279 277 break; ··· 283 281 plugin, 284 282 schema: event.parameter.schema, 285 283 state: toRefs({ 286 - _path: event._path, 287 284 hasLazyExpression: false, 285 + path: event._path, 288 286 }), 289 287 }); 290 288 break; ··· 294 292 plugin, 295 293 schema: event.requestBody.schema, 296 294 state: toRefs({ 297 - _path: event._path, 298 295 hasLazyExpression: false, 296 + path: event._path, 299 297 }), 300 298 }); 301 299 break; ··· 305 303 plugin, 306 304 schema: event.schema, 307 305 state: toRefs({ 308 - _path: event._path, 309 306 hasLazyExpression: false, 307 + path: event._path, 310 308 }), 311 309 }); 312 310 break; ··· 314 312 irWebhookToAst({ 315 313 getAst: (schema, path) => { 316 314 const state = toRefs<PluginState>({ 317 - _path: path, 318 315 hasLazyExpression: false, 316 + path, 319 317 }); 320 318 return irSchemaToAst({ plugin, schema, state }); 321 319 }, 322 320 operation: event.operation, 323 321 plugin, 324 322 state: toRefs({ 325 - _path: event._path, 323 + path: event._path, 326 324 }), 327 325 }); 328 326 break;
+1 -1
packages/openapi-ts/src/plugins/zod/v3/toAst/array.ts
··· 52 52 schema: item, 53 53 state: { 54 54 ...state, 55 - _path: toRef([...state._path.value, 'items', index]), 55 + path: toRef([...state.path.value, 'items', index]), 56 56 }, 57 57 }); 58 58 if (itemAst.hasLazyExpression) {
+2 -2
packages/openapi-ts/src/plugins/zod/v3/toAst/object.ts
··· 37 37 schema: property, 38 38 state: { 39 39 ...state, 40 - _path: toRef([...state._path.value, 'properties', name]), 40 + path: toRef([...state.path.value, 'properties', name]), 41 41 }, 42 42 }); 43 43 ··· 81 81 schema: schema.additionalProperties, 82 82 state: { 83 83 ...state, 84 - _path: toRef([...state._path.value, 'additionalProperties']), 84 + path: toRef([...state.path.value, 'additionalProperties']), 85 85 }, 86 86 }); 87 87 const expression = tsc.callExpression({
+1 -1
packages/openapi-ts/src/plugins/zod/v3/toAst/tuple.ts
··· 57 57 schema: item, 58 58 state: { 59 59 ...state, 60 - _path: toRef([...state._path.value, 'items', index]), 60 + path: toRef([...state.path.value, 'items', index]), 61 61 }, 62 62 }); 63 63 tupleElements.push(itemSchema.expression);
+10 -12
packages/openapi-ts/src/plugins/zod/v4/plugin.ts
··· 2 2 import type { IR } from '~/ir/types'; 3 3 import { buildName } from '~/openApi/shared/utils/name'; 4 4 import type { SchemaWithType } from '~/plugins/shared/types/schema'; 5 - import { pathToSymbolResourceType } from '~/plugins/shared/utils/meta'; 6 5 import { toRef, toRefs } from '~/plugins/shared/utils/refs'; 7 6 import { tsc } from '~/tsc'; 8 7 import { refToName } from '~/utils/ref'; ··· 103 102 schema: item, 104 103 state: { 105 104 ...state, 106 - _path: toRef([...state._path.value, 'items', index]), 105 + path: toRef([...state.path.value, 'items', index]), 107 106 }, 108 107 }), 109 108 ); ··· 239 238 }): void => { 240 239 const ast = irSchemaToAst({ plugin, schema, state }); 241 240 const baseName = refToName($ref); 242 - const resourceType = pathToSymbolResourceType(state._path.value); 243 241 const symbol = plugin.registerSymbol({ 244 242 exported: true, 245 243 meta: { 246 - resourceType, 244 + path: state.path.value, 247 245 }, 248 246 name: buildName({ 249 247 config: plugin.config.definitions, ··· 256 254 exported: true, 257 255 meta: { 258 256 kind: 'type', 259 - resourceType, 257 + path: state.path.value, 260 258 }, 261 259 name: buildName({ 262 260 config: plugin.config.definitions.types.infer, ··· 293 291 irOperationToAst({ 294 292 getAst: (schema, path) => { 295 293 const state = toRefs<PluginState>({ 296 - _path: path, 297 294 hasLazyExpression: false, 295 + path, 298 296 }); 299 297 return irSchemaToAst({ plugin, schema, state }); 300 298 }, 301 299 operation: event.operation, 302 300 plugin, 303 301 state: toRefs({ 304 - _path: event._path, 302 + path: event._path, 305 303 }), 306 304 }); 307 305 break; ··· 311 309 plugin, 312 310 schema: event.parameter.schema, 313 311 state: toRefs({ 314 - _path: event._path, 315 312 hasLazyExpression: false, 313 + path: event._path, 316 314 }), 317 315 }); 318 316 break; ··· 322 320 plugin, 323 321 schema: event.requestBody.schema, 324 322 state: toRefs({ 325 - _path: event._path, 326 323 hasLazyExpression: false, 324 + path: event._path, 327 325 }), 328 326 }); 329 327 break; ··· 333 331 plugin, 334 332 schema: event.schema, 335 333 state: toRefs({ 336 - _path: event._path, 337 334 hasLazyExpression: false, 335 + path: event._path, 338 336 }), 339 337 }); 340 338 break; ··· 342 340 irWebhookToAst({ 343 341 getAst: (schema, path) => { 344 342 const state = toRefs<PluginState>({ 345 - _path: path, 346 343 hasLazyExpression: false, 344 + path, 347 345 }); 348 346 return irSchemaToAst({ plugin, schema, state }); 349 347 }, 350 348 operation: event.operation, 351 349 plugin, 352 350 state: toRefs({ 353 - _path: event._path, 351 + path: event._path, 354 352 }), 355 353 }); 356 354 break;
+1 -1
packages/openapi-ts/src/plugins/zod/v4/toAst/array.ts
··· 49 49 schema: item, 50 50 state: { 51 51 ...state, 52 - _path: toRef([...state._path.value, 'items', index]), 52 + path: toRef([...state.path.value, 'items', index]), 53 53 }, 54 54 }); 55 55 if (itemAst.hasLazyExpression) {
+2 -2
packages/openapi-ts/src/plugins/zod/v4/toAst/object.ts
··· 36 36 schema: property, 37 37 state: { 38 38 ...state, 39 - _path: toRef([...state._path.value, 'properties', name]), 39 + path: toRef([...state.path.value, 'properties', name]), 40 40 }, 41 41 }); 42 42 if (propertyAst.hasLazyExpression) { ··· 93 93 schema: schema.additionalProperties, 94 94 state: { 95 95 ...state, 96 - _path: toRef([...state._path.value, 'additionalProperties']), 96 + path: toRef([...state.path.value, 'additionalProperties']), 97 97 }, 98 98 }); 99 99 result.expression = tsc.callExpression({
+1 -1
packages/openapi-ts/src/plugins/zod/v4/toAst/tuple.ts
··· 52 52 schema: item, 53 53 state: { 54 54 ...state, 55 - _path: toRef([...state._path.value, 'items', index]), 55 + path: toRef([...state.path.value, 'items', index]), 56 56 }, 57 57 }); 58 58 tupleElements.push(itemSchema.expression);