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

Merge pull request #2923 from hey-api/fix/types-context

fix: bundled context types

authored by

Lubos and committed by
GitHub
2e237c35 a7697da5

+194 -212
+5
.changeset/whole-parts-tan.md
··· 1 + --- 2 + '@hey-api/openapi-ts': patch 3 + --- 4 + 5 + fix: bundled context types
+13 -55
dev/playground.ts
··· 1 - import { Sdk } from './.gen/sdk.gen'; 1 + import type { DefinePlugin, IR } from '@hey-api/openapi-ts'; 2 2 3 - const opencode = new Sdk(); 4 - opencode.session.create( 5 - { 6 - parentID: '', 7 - title: '', 8 - }, 9 - { 10 - headers: { 11 - 'X-Custom-Header': 'value', 12 - }, 13 - }, 14 - ); 15 - opencode.session.init({ 16 - id: '', 17 - messageID: '', 18 - modelID: '', 19 - providerID: '', 20 - }); 21 - opencode.session.chat({ 22 - agent: '', 23 - id: '', 24 - messageID: '', 25 - modelID: '', 26 - parts: [ 27 - { 28 - name: '', 29 - type: 'agent', 30 - }, 31 - ], 32 - providerID: '', 33 - system: '', 34 - tools: {}, 35 - }); 36 - opencode.auth.set({ 37 - auth: { 38 - // access: '', 39 - // expires: 1, 40 - key: '', 41 - // refresh: '', 42 - // token: '', 43 - type: 'api', 44 - }, 45 - id: '123', 46 - }); 47 - opencode.postSessionByIdPermissionsByPermissionId({ 48 - id: 'session-id', 49 - permissionID: 'permission-id', 50 - response: 'always', 51 - }); 52 - opencode.tui.showToast({ 53 - message: '', 54 - title: '', 55 - variant: 'error', 56 - }); 3 + type MyPluginConfig = { readonly name: 'myplugin' }; 4 + type MyPlugin = DefinePlugin<MyPluginConfig>; 5 + 6 + export function f(schema: IR.SchemaObject, plugin: MyPlugin['Instance']) { 7 + plugin.context.resolveIrRef(schema.$ref); 8 + } 9 + 10 + export const handler: MyPlugin['Handler'] = ({ plugin }) => { 11 + plugin.forEach('schema', 'operation', (event) => { 12 + console.log(event); 13 + }); 14 + };
+3 -3
packages/openapi-ts/src/createClient.ts
··· 6 6 import { generateLegacyOutput } from '~/generate/legacy/output'; 7 7 import { generateOutput } from '~/generate/output'; 8 8 import { getSpec } from '~/getSpec'; 9 - import type { IR } from '~/ir/types'; 9 + import type { Context } from '~/ir/context'; 10 10 import { parseLegacy, parseOpenApiSpec } from '~/openApi'; 11 11 import { buildGraph } from '~/openApi/shared/utils/graph'; 12 12 import { patchOpenApiSpec } from '~/openApi/shared/utils/patch'; ··· 254 254 * Always undefined on the first run, defined on subsequent runs. 255 255 */ 256 256 watches?: ReadonlyArray<WatchValues>; 257 - }): Promise<Client | undefined | IR.Context> => { 257 + }): Promise<Client | undefined | Context> => { 258 258 const watches: ReadonlyArray<WatchValues> = 259 259 _watches || 260 260 Array.from({ length: config.input.length }, () => ({ ··· 296 296 ).filter((data) => data.arrayBuffer || data.resolvedInput); 297 297 298 298 let client: Client | undefined; 299 - let context: IR.Context | undefined; 299 + let context: Context | undefined; 300 300 301 301 if (specData.length) { 302 302 const refParser = new $RefParser();
+3 -3
packages/openapi-ts/src/generate.ts
··· 11 11 printCrashReport, 12 12 shouldReportCrash, 13 13 } from '~/error'; 14 - import type { IR } from '~/ir/types'; 14 + import type { Context } from '~/ir/context'; 15 15 import type { Client } from '~/types/client'; 16 16 import type { UserConfig } from '~/types/config'; 17 17 import type { LazyOrAsync, MaybeArray } from '~/types/utils'; ··· 27 27 export const createClient = async ( 28 28 userConfig?: LazyOrAsync<MaybeArray<UserConfig>>, 29 29 logger = new Logger(), 30 - ): Promise<ReadonlyArray<Client | IR.Context>> => { 30 + ): Promise<ReadonlyArray<Client | Context>> => { 31 31 const resolvedConfig = 32 32 typeof userConfig === 'function' ? await userConfig() : userConfig; 33 33 const userConfigs = resolvedConfig ··· 90 90 }), 91 91 ); 92 92 const result = clients.filter((client) => Boolean(client)) as ReadonlyArray< 93 - Client | IR.Context 93 + Client | Context 94 94 >; 95 95 96 96 eventCreateClient.timeEnd();
+2 -2
packages/openapi-ts/src/generate/output.ts
··· 3 3 4 4 import type { ProjectRenderMeta } from '@hey-api/codegen-core'; 5 5 6 - import type { IR } from '~/ir/types'; 6 + import type { Context } from '~/ir/context'; 7 7 import { getClientPlugin } from '~/plugins/@hey-api/client-core/utils'; 8 8 9 9 import { generateClientBundle } from './client'; 10 10 import { removeDirSync } from './utils'; 11 11 12 - export const generateOutput = async ({ context }: { context: IR.Context }) => { 12 + export const generateOutput = async ({ context }: { context: Context }) => { 13 13 const outputPath = path.resolve(context.config.output.path); 14 14 15 15 if (context.config.output.clean) {
+4 -3
packages/openapi-ts/src/ir/__tests__/pagination.test.ts
··· 3 3 import { defaultPaginationKeywords } from '~/config/parser'; 4 4 import type { Config } from '~/types/config'; 5 5 6 + import type { Context } from '../context'; 6 7 import { operationPagination } from '../operation'; 7 8 import { getPaginationKeywordsRegExp } from '../pagination'; 8 9 import type { IR } from '../types'; ··· 92 93 ...(pagination ? { pagination: true } : {}), 93 94 }); 94 95 95 - const emptyContext = {} as IR.Context; 96 + const emptyContext = {} as Context; 96 97 97 98 const baseOperationMeta = { 98 99 method: 'post' as const, ··· 216 217 }); 217 218 218 219 it('resolves $ref and uses the resolved pagination property', () => { 219 - const context: IR.Context = { 220 + const context: Context = { 220 221 resolveIrRef: vi.fn().mockReturnValue({ 221 222 properties: { 222 223 pagination: { ··· 228 229 }, 229 230 type: 'object', 230 231 }), 231 - } as unknown as IR.Context; 232 + } as unknown as Context; 232 233 233 234 const operation: IR.OperationObject = { 234 235 ...baseOperationMeta,
+2 -1
packages/openapi-ts/src/ir/operation.ts
··· 1 + import type { Context } from './context'; 1 2 import type { Pagination } from './pagination'; 2 3 import { 3 4 hasParametersObjectRequired, ··· 33 34 context, 34 35 operation, 35 36 }: { 36 - context: IR.Context; 37 + context: Context; 37 38 operation: IR.OperationObject; 38 39 }): Pagination | undefined => { 39 40 const body = operation.body;
+3 -2
packages/openapi-ts/src/ir/parameter.ts
··· 1 + import type { Context } from './context'; 1 2 import type { Pagination } from './pagination'; 2 3 import type { IR } from './types'; 3 4 ··· 5 6 context, 6 7 parameter, 7 8 }: { 8 - context: IR.Context; 9 + context: Context; 9 10 parameter: IR.ParameterObject; 10 11 }): IR.SchemaObject | undefined => { 11 12 if (!parameter.pagination) { ··· 66 67 context, 67 68 parameters, 68 69 }: { 69 - context: IR.Context; 70 + context: Context; 70 71 parameters: IR.ParametersObject | undefined; 71 72 }): Pagination | undefined => { 72 73 if (!parameters) {
-2
packages/openapi-ts/src/ir/types.d.ts
··· 4 4 ServerObject, 5 5 } from '~/openApi/3.1.x/types/spec'; 6 6 7 - import type { Context as IRContext } from './context'; 8 7 import type { IRMediaType } from './mediaType'; 9 8 10 9 interface IRBodyObject { ··· 221 220 export namespace IR { 222 221 export type BodyObject = IRBodyObject; 223 222 export type ComponentsObject = IRComponentsObject; 224 - export type Context<Spec extends Record<string, any> = any> = IRContext<Spec>; 225 223 export type Model = IRModel; 226 224 export type OperationObject = IROperationObject; 227 225 export type ParameterObject = IRParameterObject;
+3 -2
packages/openapi-ts/src/openApi/2.0.x/parser/__tests__/operation.test.ts
··· 1 1 import { describe, expect, it } from 'vitest'; 2 2 3 - import type { IR } from '../../../../ir/types'; 3 + import type { Context } from '~/ir/context'; 4 + 4 5 import type { ParameterObject, SecuritySchemeObject } from '../../types/spec'; 5 6 import { parsePathOperation } from '../operation'; 6 7 ··· 27 28 resolveRef: () => 28 29 // Mock implementation 29 30 undefined, 30 - }) as unknown as IR.Context; 31 + }) as unknown as Context; 31 32 32 33 describe('operation', () => { 33 34 const context = createContext();
+11 -11
packages/openapi-ts/src/openApi/2.0.x/parser/__tests__/server.test.ts
··· 1 1 import { describe, expect, it } from 'vitest'; 2 2 3 + import type { Context } from '~/ir/context'; 3 4 import type { OpenApi } from '~/openApi/types'; 4 5 5 - import type { IR } from '../../../../ir/types'; 6 6 import { parseServers } from '../server'; 7 7 8 8 describe('parseServers', () => { 9 9 it('host + basePath + schemes', () => { 10 - const context: Partial<IR.Context<Partial<OpenApi.V2_0_X>>> = { 10 + const context: Partial<Context<Partial<OpenApi.V2_0_X>>> = { 11 11 config: { 12 12 input: [ 13 13 // @ts-expect-error ··· 23 23 schemes: ['http', 'https'], 24 24 }, 25 25 }; 26 - parseServers({ context: context as IR.Context }); 26 + parseServers({ context: context as Context }); 27 27 expect(context.ir!.servers).toEqual([ 28 28 { 29 29 url: 'http://foo.com/v1', ··· 35 35 }); 36 36 37 37 it('schemes + host', () => { 38 - const context: Partial<IR.Context<Partial<OpenApi.V2_0_X>>> = { 38 + const context: Partial<Context<Partial<OpenApi.V2_0_X>>> = { 39 39 config: { 40 40 input: [ 41 41 // @ts-expect-error ··· 50 50 schemes: ['ws'], 51 51 }, 52 52 }; 53 - parseServers({ context: context as IR.Context }); 53 + parseServers({ context: context as Context }); 54 54 expect(context.ir!.servers).toEqual([ 55 55 { 56 56 url: 'ws://foo.com', ··· 59 59 }); 60 60 61 61 it('host + basePath', () => { 62 - const context: Partial<IR.Context<Partial<OpenApi.V2_0_X>>> = { 62 + const context: Partial<Context<Partial<OpenApi.V2_0_X>>> = { 63 63 config: { 64 64 input: [ 65 65 // @ts-expect-error ··· 74 74 host: 'foo.com', 75 75 }, 76 76 }; 77 - parseServers({ context: context as IR.Context }); 77 + parseServers({ context: context as Context }); 78 78 expect(context.ir!.servers).toEqual([ 79 79 { 80 80 url: 'foo.com/v1', ··· 83 83 }); 84 84 85 85 it('host', () => { 86 - const context: Partial<IR.Context<Partial<OpenApi.V2_0_X>>> = { 86 + const context: Partial<Context<Partial<OpenApi.V2_0_X>>> = { 87 87 config: { 88 88 input: [ 89 89 // @ts-expect-error ··· 97 97 host: 'foo.com', 98 98 }, 99 99 }; 100 - parseServers({ context: context as IR.Context }); 100 + parseServers({ context: context as Context }); 101 101 expect(context.ir!.servers).toEqual([ 102 102 { 103 103 url: 'foo.com', ··· 106 106 }); 107 107 108 108 it('basePath', () => { 109 - const context: Partial<IR.Context<Partial<OpenApi.V2_0_X>>> = { 109 + const context: Partial<Context<Partial<OpenApi.V2_0_X>>> = { 110 110 config: { 111 111 input: [ 112 112 // @ts-expect-error ··· 120 120 basePath: '/v1', 121 121 }, 122 122 }; 123 - parseServers({ context: context as IR.Context }); 123 + parseServers({ context: context as Context }); 124 124 expect(context.ir!.servers).toEqual([ 125 125 { 126 126 url: '/v1',
+2 -2
packages/openapi-ts/src/openApi/2.0.x/parser/index.ts
··· 1 - import type { IR } from '~/ir/types'; 1 + import type { Context } from '~/ir/context'; 2 2 import { buildResourceMetadata } from '~/openApi/shared/graph/meta'; 3 3 import { transformOpenApiSpec } from '~/openApi/shared/transforms'; 4 4 import type { State } from '~/openApi/shared/types/state'; ··· 28 28 type PathKeys<T extends keyof PathsObject = keyof PathsObject> = 29 29 keyof T extends infer K ? (K extends `/${string}` ? K : never) : never; 30 30 31 - export const parseV2_0_X = (context: IR.Context<OpenApiV2_0_X>) => { 31 + export const parseV2_0_X = (context: Context<OpenApiV2_0_X>) => { 32 32 if (context.config.parser.validate_EXPERIMENTAL) { 33 33 const result = validateOpenApiSpec(context.spec, context.logger); 34 34 handleValidatorResult({ context, result });
+4 -3
packages/openapi-ts/src/openApi/2.0.x/parser/operation.ts
··· 1 + import type { Context } from '~/ir/context'; 1 2 import type { IR, IRBodyObject } from '~/ir/types'; 2 3 import type { State } from '~/openApi/shared/types/state'; 3 4 import { operationToId } from '~/openApi/shared/utils/operation'; ··· 51 52 path, 52 53 state, 53 54 }: Pick<IR.OperationObject, 'method' | 'path'> & { 54 - context: IR.Context; 55 + context: Context; 55 56 operation: Operation; 56 57 state: State; 57 58 }): IR.OperationObject => { ··· 87 88 securitySchemesMap, 88 89 state, 89 90 }: Pick<IR.OperationObject, 'method' | 'path'> & { 90 - context: IR.Context; 91 + context: Context; 91 92 operation: Operation; 92 93 securitySchemesMap: Map<string, SecuritySchemeObject>; 93 94 state: State; ··· 364 365 securitySchemesMap, 365 366 state, 366 367 }: { 367 - context: IR.Context; 368 + context: Context; 368 369 method: Extract< 369 370 keyof PathItemObject, 370 371 'delete' | 'get' | 'head' | 'options' | 'patch' | 'post' | 'put' | 'trace'
+2 -2
packages/openapi-ts/src/openApi/2.0.x/parser/pagination.ts
··· 1 + import type { Context } from '~/ir/context'; 1 2 import { getPaginationKeywordsRegExp } from '~/ir/pagination'; 2 - import type { IR } from '~/ir/types'; 3 3 import type { SchemaType } from '~/openApi/shared/types/schema'; 4 4 5 5 import type { ParameterObject, ReferenceObject } from '../types/spec'; ··· 20 20 name, 21 21 schema, 22 22 }: { 23 - context: IR.Context; 23 + context: Context; 24 24 name: string; 25 25 schema: 26 26 | ParameterObject
+3 -2
packages/openapi-ts/src/openApi/2.0.x/parser/parameter.ts
··· 1 + import type { Context } from '~/ir/context'; 1 2 import type { IR } from '~/ir/types'; 2 3 3 4 import type { ··· 50 51 operation, 51 52 parameters, 52 53 }: { 53 - context: IR.Context; 54 + context: Context; 54 55 operation: OperationObject; 55 56 parameters?: ReadonlyArray<ParameterObject | ReferenceObject>; 56 57 }): IR.ParametersObject | undefined => { ··· 101 102 parameter, 102 103 }: { 103 104 $ref: string; 104 - context: IR.Context; 105 + context: Context; 105 106 parameter: Parameter; 106 107 }): IR.ParameterObject => { 107 108 const schema = parameter;
+15 -14
packages/openapi-ts/src/openApi/2.0.x/parser/schema.ts
··· 1 + import type { Context } from '~/ir/context'; 1 2 import type { IR } from '~/ir/types'; 2 3 import { addItemsToSchema } from '~/ir/utils'; 3 4 import type { ··· 109 110 schema, 110 111 state, 111 112 }: { 112 - context: IR.Context; 113 + context: Context; 113 114 irSchema?: IR.SchemaObject; 114 115 schema: SchemaObject; 115 116 state: SchemaState; ··· 164 165 const parseBoolean = ({ 165 166 irSchema = {}, 166 167 }: { 167 - context: IR.Context; 168 + context: Context; 168 169 irSchema?: IR.SchemaObject; 169 170 schema: SchemaObject; 170 171 state: SchemaState; ··· 178 179 irSchema = {}, 179 180 schema, 180 181 }: { 181 - context: IR.Context; 182 + context: Context; 182 183 irSchema?: IR.SchemaObject; 183 184 schema: SchemaWithRequired<SchemaObject, 'type'>; 184 185 state: SchemaState; ··· 194 195 schema, 195 196 state, 196 197 }: { 197 - context: IR.Context; 198 + context: Context; 198 199 irSchema?: IR.SchemaObject; 199 200 schema: SchemaObject; 200 201 state: SchemaState; ··· 259 260 const parseString = ({ 260 261 irSchema = {}, 261 262 }: { 262 - context: IR.Context; 263 + context: Context; 263 264 irSchema?: IR.SchemaObject; 264 265 schema: SchemaObject; 265 266 state: SchemaState; ··· 289 290 schema, 290 291 state, 291 292 }: { 292 - context: IR.Context; 293 + context: Context; 293 294 schema: SchemaWithRequired<SchemaObject, 'allOf'>; 294 295 state: SchemaState; 295 296 }): IR.SchemaObject => { ··· 449 450 schema, 450 451 state, 451 452 }: { 452 - context: IR.Context; 453 + context: Context; 453 454 schema: SchemaWithRequired<SchemaObject, 'enum'>; 454 455 state: SchemaState; 455 456 }): IR.SchemaObject => { ··· 527 528 schema, 528 529 state, 529 530 }: { 530 - context: IR.Context; 531 + context: Context; 531 532 schema: SchemaWithRequired<SchemaObject, '$ref'>; 532 533 state: SchemaState; 533 534 }): IR.SchemaObject => { ··· 582 583 schema, 583 584 state, 584 585 }: { 585 - context: IR.Context; 586 + context: Context; 586 587 irSchema?: IR.SchemaObject; 587 588 schema: SchemaWithRequired<SchemaObject, 'type'>; 588 589 state: SchemaState; ··· 626 627 schema, 627 628 state, 628 629 }: { 629 - context: IR.Context; 630 + context: Context; 630 631 schema: SchemaWithRequired<SchemaObject, 'type'>; 631 632 state: SchemaState; 632 633 }): IR.SchemaObject => { ··· 669 670 schema, 670 671 state, 671 672 }: { 672 - context: IR.Context; 673 + context: Context; 673 674 irSchema?: IR.SchemaObject; 674 675 schema: SchemaWithRequired<SchemaObject, 'type'>; 675 676 state: SchemaState; ··· 731 732 irSchema, 732 733 schema, 733 734 }: { 734 - context: IR.Context; 735 + context: Context; 735 736 irSchema?: IR.SchemaObject; 736 737 schema: SchemaObject; 737 738 }): IR.SchemaObject => { ··· 751 752 schema, 752 753 state, 753 754 }: { 754 - context: IR.Context; 755 + context: Context; 755 756 schema: SchemaObject; 756 757 state: SchemaState | undefined; 757 758 }): IR.SchemaObject => { ··· 807 808 schema, 808 809 }: { 809 810 $ref: string; 810 - context: IR.Context; 811 + context: Context; 811 812 schema: SchemaObject; 812 813 }) => { 813 814 if (!context.ir.components) {
+2 -2
packages/openapi-ts/src/openApi/2.0.x/parser/server.ts
··· 1 - import type { IR } from '~/ir/types'; 1 + import type { Context } from '~/ir/context'; 2 2 import { parseUrl } from '~/utils/url'; 3 3 4 - export const parseServers = ({ context }: { context: IR.Context }) => { 4 + export const parseServers = ({ context }: { context: Context }) => { 5 5 let schemes: ReadonlyArray<string> = context.spec.schemes ?? []; 6 6 let host = context.spec.host ?? ''; 7 7 const path = context.spec.basePath ?? '';
+3 -2
packages/openapi-ts/src/openApi/3.0.x/parser/__tests__/operation.test.ts
··· 1 1 import { describe, expect, it } from 'vitest'; 2 2 3 - import type { IR } from '../../../../ir/types'; 3 + import type { Context } from '~/ir/context'; 4 + 4 5 import type { SecuritySchemeObject } from '../../types/spec'; 5 6 import { parsePathOperation } from '../operation'; 6 7 ··· 15 16 paths: {}, 16 17 servers: [], 17 18 }, 18 - } as unknown as IR.Context; 19 + } as unknown as Context; 19 20 20 21 it('should parse operation correctly', () => { 21 22 const method = 'get';
+2 -2
packages/openapi-ts/src/openApi/3.0.x/parser/index.ts
··· 1 - import type { IR } from '~/ir/types'; 1 + import type { Context } from '~/ir/context'; 2 2 import { buildResourceMetadata } from '~/openApi/shared/graph/meta'; 3 3 import { transformOpenApiSpec } from '~/openApi/shared/transforms'; 4 4 import type { State } from '~/openApi/shared/types/state'; ··· 27 27 import { parseServers } from './server'; 28 28 import { validateOpenApiSpec } from './validate'; 29 29 30 - export const parseV3_0_X = (context: IR.Context<OpenApiV3_0_X>) => { 30 + export const parseV3_0_X = (context: Context<OpenApiV3_0_X>) => { 31 31 if (context.config.parser.validate_EXPERIMENTAL) { 32 32 const result = validateOpenApiSpec(context.spec, context.logger); 33 33 handleValidatorResult({ context, result });
+4 -3
packages/openapi-ts/src/openApi/3.0.x/parser/operation.ts
··· 1 + import type { Context } from '~/ir/context'; 1 2 import type { IR } from '~/ir/types'; 2 3 import type { State } from '~/openApi/shared/types/state'; 3 4 import { operationToId } from '~/openApi/shared/utils/operation'; ··· 48 49 path, 49 50 state, 50 51 }: Pick<IR.OperationObject, 'method' | 'path'> & { 51 - context: IR.Context; 52 + context: Context; 52 53 operation: Operation; 53 54 state: State; 54 55 }): IR.OperationObject => { ··· 84 85 securitySchemesMap, 85 86 state, 86 87 }: Pick<IR.OperationObject, 'method' | 'path'> & { 87 - context: IR.Context; 88 + context: Context; 88 89 operation: Operation; 89 90 securitySchemesMap: Map<string, SecuritySchemeObject>; 90 91 state: State; ··· 237 238 securitySchemesMap, 238 239 state, 239 240 }: { 240 - context: IR.Context; 241 + context: Context; 241 242 method: Extract< 242 243 keyof PathItemObject, 243 244 'delete' | 'get' | 'head' | 'options' | 'patch' | 'post' | 'put' | 'trace'
+2 -2
packages/openapi-ts/src/openApi/3.0.x/parser/pagination.ts
··· 1 + import type { Context } from '~/ir/context'; 1 2 import { getPaginationKeywordsRegExp } from '~/ir/pagination'; 2 - import type { IR } from '~/ir/types'; 3 3 import type { SchemaType } from '~/openApi/shared/types/schema'; 4 4 5 5 import type { ··· 25 25 name, 26 26 schema, 27 27 }: { 28 - context: IR.Context; 28 + context: Context; 29 29 name: string; 30 30 schema: SchemaObject | ReferenceObject; 31 31 }): boolean | string => {
+4 -3
packages/openapi-ts/src/openApi/3.0.x/parser/parameter.ts
··· 1 + import type { Context } from '~/ir/context'; 1 2 import type { IR } from '~/ir/types'; 2 3 import { refToName } from '~/utils/ref'; 3 4 ··· 60 61 context, 61 62 parameters, 62 63 }: { 63 - context: IR.Context; 64 + context: Context; 64 65 parameters?: ReadonlyArray<ParameterObject | ReferenceObject>; 65 66 }): IR.ParametersObject | undefined => { 66 67 if (!parameters || !Object.keys(parameters).length) { ··· 97 98 parameter, 98 99 }: { 99 100 $ref: string; 100 - context: IR.Context; 101 + context: Context; 101 102 parameter: ParameterObject; 102 103 }): IR.ParameterObject => { 103 104 // TODO: parser - fix ··· 181 182 parameter, 182 183 }: { 183 184 $ref: string; 184 - context: IR.Context; 185 + context: Context; 185 186 parameter: ParameterObject; 186 187 }) => { 187 188 if (!context.ir.components) {
+3 -2
packages/openapi-ts/src/openApi/3.0.x/parser/requestBody.ts
··· 1 + import type { Context } from '~/ir/context'; 1 2 import type { IR } from '~/ir/types'; 2 3 import { refToName } from '~/utils/ref'; 3 4 ··· 11 12 requestBody, 12 13 }: { 13 14 $ref: string; 14 - context: IR.Context; 15 + context: Context; 15 16 requestBody: RequestBodyObject; 16 17 }): IR.RequestBodyObject => { 17 18 // TODO: parser - fix ··· 54 55 requestBody, 55 56 }: { 56 57 $ref: string; 57 - context: IR.Context; 58 + context: Context; 58 59 requestBody: RequestBodyObject; 59 60 }) => { 60 61 if (!context.ir.components) {
+17 -16
packages/openapi-ts/src/openApi/3.0.x/parser/schema.ts
··· 1 + import type { Context } from '~/ir/context'; 1 2 import type { IR } from '~/ir/types'; 2 3 import { addItemsToSchema } from '~/ir/utils'; 3 4 import type { ··· 115 116 schema, 116 117 state, 117 118 }: { 118 - context: IR.Context; 119 + context: Context; 119 120 irSchema?: IR.SchemaObject; 120 121 schema: SchemaObject; 121 122 state: SchemaState; ··· 171 172 const parseBoolean = ({ 172 173 irSchema = {}, 173 174 }: { 174 - context: IR.Context; 175 + context: Context; 175 176 irSchema?: IR.SchemaObject; 176 177 schema: SchemaObject; 177 178 state: SchemaState; ··· 185 186 irSchema = {}, 186 187 schema, 187 188 }: { 188 - context: IR.Context; 189 + context: Context; 189 190 irSchema?: IR.SchemaObject; 190 191 schema: SchemaWithRequired<SchemaObject, 'type'>; 191 192 state: SchemaState; ··· 201 202 schema, 202 203 state, 203 204 }: { 204 - context: IR.Context; 205 + context: Context; 205 206 irSchema?: IR.SchemaObject; 206 207 schema: SchemaObject; 207 208 state: SchemaState; ··· 265 266 const parseString = ({ 266 267 irSchema = {}, 267 268 }: { 268 - context: IR.Context; 269 + context: Context; 269 270 irSchema?: IR.SchemaObject; 270 271 schema: SchemaObject; 271 272 state: SchemaState; ··· 295 296 schema, 296 297 state, 297 298 }: { 298 - context: IR.Context; 299 + context: Context; 299 300 schema: SchemaWithRequired<SchemaObject, 'allOf'>; 300 301 state: SchemaState; 301 302 }): IR.SchemaObject => { ··· 468 469 schema, 469 470 state, 470 471 }: { 471 - context: IR.Context; 472 + context: Context; 472 473 schema: SchemaWithRequired<SchemaObject, 'anyOf'>; 473 474 state: SchemaState; 474 475 }): IR.SchemaObject => { ··· 556 557 schema, 557 558 state, 558 559 }: { 559 - context: IR.Context; 560 + context: Context; 560 561 schema: SchemaWithRequired<SchemaObject, 'enum'>; 561 562 state: SchemaState; 562 563 }): IR.SchemaObject => { ··· 634 635 schema, 635 636 state, 636 637 }: { 637 - context: IR.Context; 638 + context: Context; 638 639 schema: SchemaWithRequired<SchemaObject, 'oneOf'>; 639 640 state: SchemaState; 640 641 }): IR.SchemaObject => { ··· 734 735 schema, 735 736 state, 736 737 }: { 737 - context: IR.Context; 738 + context: Context; 738 739 schema: ReferenceObject; 739 740 state: SchemaState; 740 741 }): IR.SchemaObject => { ··· 783 784 schema, 784 785 state, 785 786 }: { 786 - context: IR.Context; 787 + context: Context; 787 788 irSchema?: IR.SchemaObject; 788 789 schema: SchemaWithRequired<SchemaObject, 'type'>; 789 790 state: SchemaState; ··· 827 828 schema, 828 829 state, 829 830 }: { 830 - context: IR.Context; 831 + context: Context; 831 832 schema: SchemaWithRequired<SchemaObject, 'type'>; 832 833 state: SchemaState; 833 834 }): IR.SchemaObject => { ··· 870 871 schema, 871 872 state, 872 873 }: { 873 - context: IR.Context; 874 + context: Context; 874 875 irSchema?: IR.SchemaObject; 875 876 schema: SchemaWithRequired<SchemaObject, 'type'>; 876 877 state: SchemaState; ··· 932 933 irSchema, 933 934 schema, 934 935 }: { 935 - context: IR.Context; 936 + context: Context; 936 937 irSchema?: IR.SchemaObject; 937 938 schema: SchemaObject; 938 939 }): IR.SchemaObject => { ··· 952 953 schema, 953 954 state, 954 955 }: { 955 - context: IR.Context; 956 + context: Context; 956 957 schema: SchemaObject | ReferenceObject; 957 958 state: SchemaState | undefined; 958 959 }): IR.SchemaObject => { ··· 1024 1025 schema, 1025 1026 }: { 1026 1027 $ref: string; 1027 - context: IR.Context; 1028 + context: Context; 1028 1029 schema: SchemaObject | ReferenceObject; 1029 1030 }) => { 1030 1031 if (!context.ir.components) {
+2 -2
packages/openapi-ts/src/openApi/3.0.x/parser/server.ts
··· 1 - import type { IR } from '~/ir/types'; 1 + import type { Context } from '~/ir/context'; 2 2 import { parseUrl } from '~/utils/url'; 3 3 4 - export const parseServers = ({ context }: { context: IR.Context }) => { 4 + export const parseServers = ({ context }: { context: Context }) => { 5 5 if (context.spec.servers) { 6 6 context.ir.servers = context.spec.servers; 7 7 return;
+3 -2
packages/openapi-ts/src/openApi/3.1.x/parser/__tests__/operation.test.ts
··· 1 1 import { describe, expect, it } from 'vitest'; 2 2 3 - import type { IR } from '../../../../ir/types'; 3 + import type { Context } from '~/ir/context'; 4 + 4 5 import type { SecuritySchemeObject } from '../../types/spec'; 5 6 import { parsePathOperation } from '../operation'; 6 7 ··· 15 16 paths: {}, 16 17 servers: [], 17 18 }, 18 - } as unknown as IR.Context; 19 + } as unknown as Context; 19 20 20 21 it('should parse operation correctly', () => { 21 22 const method = 'get';
+2 -2
packages/openapi-ts/src/openApi/3.1.x/parser/index.ts
··· 1 - import type { IR } from '~/ir/types'; 1 + import type { Context } from '~/ir/context'; 2 2 import { buildResourceMetadata } from '~/openApi/shared/graph/meta'; 3 3 import { transformOpenApiSpec } from '~/openApi/shared/transforms'; 4 4 import type { State } from '~/openApi/shared/types/state'; ··· 28 28 import { validateOpenApiSpec } from './validate'; 29 29 import { parseWebhooks } from './webhook'; 30 30 31 - export const parseV3_1_X = (context: IR.Context<OpenApiV3_1_X>) => { 31 + export const parseV3_1_X = (context: Context<OpenApiV3_1_X>) => { 32 32 if (context.config.parser.validate_EXPERIMENTAL) { 33 33 const result = validateOpenApiSpec(context.spec, context.logger); 34 34 handleValidatorResult({ context, result });
+6 -5
packages/openapi-ts/src/openApi/3.1.x/parser/operation.ts
··· 1 + import type { Context } from '~/ir/context'; 1 2 import type { IR } from '~/ir/types'; 2 3 import type { State } from '~/openApi/shared/types/state'; 3 4 import type { httpMethods } from '~/openApi/shared/utils/operation'; ··· 48 49 path, 49 50 state, 50 51 }: Pick<IR.OperationObject, 'method' | 'path'> & { 51 - context: IR.Context; 52 + context: Context; 52 53 operation: Operation; 53 54 state: State; 54 55 }): IR.OperationObject => { ··· 84 85 securitySchemesMap, 85 86 state, 86 87 }: Pick<IR.OperationObject, 'method' | 'path'> & { 87 - context: IR.Context; 88 + context: Context; 88 89 operation: Operation; 89 90 securitySchemesMap: Map<string, SecuritySchemeObject>; 90 91 state: State; ··· 222 223 securitySchemesMap, 223 224 state, 224 225 }: { 225 - context: IR.Context; 226 + context: Context; 226 227 method: (typeof httpMethods)[number]; 227 228 operation: Operation; 228 229 path: keyof IR.PathsObject; ··· 251 252 path, 252 253 ...options 253 254 }: { 254 - context: IR.Context; 255 + context: Context; 255 256 method: (typeof httpMethods)[number]; 256 257 operation: Operation; 257 258 path: keyof IR.PathsObject; ··· 282 283 method, 283 284 ...options 284 285 }: { 285 - context: IR.Context; 286 + context: Context; 286 287 key: string; 287 288 method: (typeof httpMethods)[number]; 288 289 operation: Operation;
+2 -2
packages/openapi-ts/src/openApi/3.1.x/parser/pagination.ts
··· 1 + import type { Context } from '~/ir/context'; 1 2 import { getPaginationKeywordsRegExp } from '~/ir/pagination'; 2 - import type { IR } from '~/ir/types'; 3 3 import type { SchemaType } from '~/openApi/shared/types/schema'; 4 4 5 5 import type { ParameterObject, RequestBodyObject } from '../types/spec'; ··· 21 21 name, 22 22 schema, 23 23 }: { 24 - context: IR.Context; 24 + context: Context; 25 25 name: string; 26 26 schema: SchemaObject; 27 27 }): boolean | string => {
+4 -3
packages/openapi-ts/src/openApi/3.1.x/parser/parameter.ts
··· 1 + import type { Context } from '~/ir/context'; 1 2 import type { IR } from '~/ir/types'; 2 3 import { refToName } from '~/utils/ref'; 3 4 ··· 60 61 context, 61 62 parameters, 62 63 }: { 63 - context: IR.Context; 64 + context: Context; 64 65 parameters?: ReadonlyArray<ParameterObject | ReferenceObject>; 65 66 }): IR.ParametersObject | undefined => { 66 67 if (!parameters || !Object.keys(parameters).length) { ··· 97 98 parameter, 98 99 }: { 99 100 $ref: string; 100 - context: IR.Context; 101 + context: Context; 101 102 parameter: ParameterObject; 102 103 }): IR.ParameterObject => { 103 104 // TODO: parser - fix ··· 174 175 parameter, 175 176 }: { 176 177 $ref: string; 177 - context: IR.Context; 178 + context: Context; 178 179 parameter: ParameterObject; 179 180 }) => { 180 181 if (!context.ir.components) {
+3 -2
packages/openapi-ts/src/openApi/3.1.x/parser/requestBody.ts
··· 1 + import type { Context } from '~/ir/context'; 1 2 import type { IR } from '~/ir/types'; 2 3 import { refToName } from '~/utils/ref'; 3 4 ··· 11 12 requestBody, 12 13 }: { 13 14 $ref: string; 14 - context: IR.Context; 15 + context: Context; 15 16 requestBody: RequestBodyObject; 16 17 }): IR.RequestBodyObject => { 17 18 // TODO: parser - fix ··· 54 55 requestBody, 55 56 }: { 56 57 $ref: string; 57 - context: IR.Context; 58 + context: Context; 58 59 requestBody: RequestBodyObject; 59 60 }) => { 60 61 if (!context.ir.components) {
+18 -17
packages/openapi-ts/src/openApi/3.1.x/parser/schema.ts
··· 1 + import type { Context } from '~/ir/context'; 1 2 import type { IR } from '~/ir/types'; 2 3 import { addItemsToSchema } from '~/ir/utils'; 3 4 import type { ··· 143 144 schema, 144 145 state, 145 146 }: { 146 - context: IR.Context; 147 + context: Context; 147 148 irSchema?: IR.SchemaObject; 148 149 schema: SchemaObject; 149 150 state: SchemaState; ··· 212 213 const parseBoolean = ({ 213 214 irSchema = {}, 214 215 }: { 215 - context: IR.Context; 216 + context: Context; 216 217 irSchema?: IR.SchemaObject; 217 218 schema: SchemaObject; 218 219 }): IR.SchemaObject => { ··· 224 225 const parseNull = ({ 225 226 irSchema = {}, 226 227 }: { 227 - context: IR.Context; 228 + context: Context; 228 229 irSchema?: IR.SchemaObject; 229 230 schema: SchemaObject; 230 231 }) => { ··· 237 238 irSchema = {}, 238 239 schema, 239 240 }: { 240 - context: IR.Context; 241 + context: Context; 241 242 irSchema?: IR.SchemaObject; 242 243 schema: Omit<SchemaObject, 'type'> & { 243 244 type: SchemaType<SchemaObject>; ··· 254 255 schema, 255 256 state, 256 257 }: { 257 - context: IR.Context; 258 + context: Context; 258 259 irSchema?: IR.SchemaObject; 259 260 schema: SchemaObject; 260 261 state: SchemaState; ··· 347 348 const parseString = ({ 348 349 irSchema = {}, 349 350 }: { 350 - context: IR.Context; 351 + context: Context; 351 352 irSchema?: IR.SchemaObject; 352 353 schema: SchemaObject; 353 354 }): IR.SchemaObject => { ··· 376 377 schema, 377 378 state, 378 379 }: { 379 - context: IR.Context; 380 + context: Context; 380 381 schema: SchemaWithRequired<SchemaObject, 'allOf'>; 381 382 state: SchemaState; 382 383 }): IR.SchemaObject => { ··· 537 538 schema, 538 539 state, 539 540 }: { 540 - context: IR.Context; 541 + context: Context; 541 542 schema: SchemaWithRequired<SchemaObject, 'anyOf'>; 542 543 state: SchemaState; 543 544 }): IR.SchemaObject => { ··· 625 626 schema, 626 627 state, 627 628 }: { 628 - context: IR.Context; 629 + context: Context; 629 630 schema: SchemaWithRequired<SchemaObject, 'enum'>; 630 631 state: SchemaState; 631 632 }): IR.SchemaObject => { ··· 693 694 schema, 694 695 state, 695 696 }: { 696 - context: IR.Context; 697 + context: Context; 697 698 schema: SchemaWithRequired<SchemaObject, 'oneOf'>; 698 699 state: SchemaState; 699 700 }): IR.SchemaObject => { ··· 793 794 schema, 794 795 state, 795 796 }: { 796 - context: IR.Context; 797 + context: Context; 797 798 schema: SchemaWithRequired<SchemaObject, '$ref'>; 798 799 state: SchemaState; 799 800 }): IR.SchemaObject => { ··· 859 860 schema, 860 861 state, 861 862 }: { 862 - context: IR.Context; 863 + context: Context; 863 864 irSchema?: IR.SchemaObject; 864 865 schema: Omit<SchemaObject, 'type'> & { 865 866 type: SchemaType<SchemaObject>; ··· 923 924 schema, 924 925 state, 925 926 }: { 926 - context: IR.Context; 927 + context: Context; 927 928 irSchema?: IR.SchemaObject; 928 929 schema: Omit<SchemaObject, 'type'> & { 929 930 type: ReadonlyArray<SchemaType<SchemaObject>>; ··· 977 978 schema, 978 979 state, 979 980 }: { 980 - context: IR.Context; 981 + context: Context; 981 982 schema: SchemaWithRequired<SchemaObject, 'type'>; 982 983 state: SchemaState; 983 984 }): IR.SchemaObject => { ··· 1014 1015 irSchema, 1015 1016 schema, 1016 1017 }: { 1017 - context: IR.Context; 1018 + context: Context; 1018 1019 irSchema?: IR.SchemaObject; 1019 1020 schema: SchemaObject; 1020 1021 }): IR.SchemaObject => { ··· 1034 1035 schema, 1035 1036 state, 1036 1037 }: { 1037 - context: IR.Context; 1038 + context: Context; 1038 1039 schema: SchemaObject; 1039 1040 state: SchemaState | undefined; 1040 1041 }): IR.SchemaObject => { ··· 1106 1107 schema, 1107 1108 }: { 1108 1109 $ref: string; 1109 - context: IR.Context; 1110 + context: Context; 1110 1111 schema: SchemaObject; 1111 1112 }) => { 1112 1113 if (!context.ir.components) {
+2 -2
packages/openapi-ts/src/openApi/3.1.x/parser/server.ts
··· 1 - import type { IR } from '~/ir/types'; 1 + import type { Context } from '~/ir/context'; 2 2 import { parseUrl } from '~/utils/url'; 3 3 4 - export const parseServers = ({ context }: { context: IR.Context }) => { 4 + export const parseServers = ({ context }: { context: Context }) => { 5 5 if (context.spec.servers) { 6 6 context.ir.servers = context.spec.servers; 7 7 return;
+2 -2
packages/openapi-ts/src/openApi/3.1.x/parser/webhook.ts
··· 1 - import type { IR } from '~/ir/types'; 1 + import type { Context } from '~/ir/context'; 2 2 import { mergeParametersObjects } from '~/openApi/shared/utils/parameter'; 3 3 4 4 import type { OpenApiV3_1_X, PathItemObject } from '../types/spec'; ··· 9 9 context, 10 10 securitySchemesMap, 11 11 }: Pick<Parameters<typeof parseWebhookOperation>[0], 'securitySchemesMap'> & { 12 - context: IR.Context<OpenApiV3_1_X>; 12 + context: Context<OpenApiV3_1_X>; 13 13 }) => { 14 14 const state: Parameters<typeof parseWebhookOperation>[0]['state'] = { 15 15 ids: new Map(),
+4 -5
packages/openapi-ts/src/openApi/index.ts
··· 1 1 import { satisfies } from '~/config/utils/package'; 2 2 import { Context } from '~/ir/context'; 3 - import type { IR } from '~/ir/types'; 4 3 import { parseV2_0_X } from '~/openApi/2.0.x'; 5 4 import { parseV3_0_X } from '~/openApi/3.0.x'; 6 5 import { parseV3_1_X } from '~/openApi/3.1.x'; ··· 73 72 dependencies: Record<string, string>; 74 73 logger: Logger; 75 74 spec: unknown; 76 - }): IR.Context | undefined => { 75 + }): Context | undefined => { 77 76 const context = new Context({ 78 77 config, 79 78 dependencies, ··· 82 81 }); 83 82 84 83 if ('swagger' in context.spec) { 85 - parseV2_0_X(context as IR.Context<OpenApi.V2_0_X>); 84 + parseV2_0_X(context as Context<OpenApi.V2_0_X>); 86 85 return context; 87 86 } 88 87 89 88 if (satisfies(context.spec.openapi, '>=3.0.0 <3.1.0')) { 90 - parseV3_0_X(context as IR.Context<OpenApi.V3_0_X>); 89 + parseV3_0_X(context as Context<OpenApi.V3_0_X>); 91 90 return context; 92 91 } 93 92 94 93 if (satisfies(context.spec.openapi, '>=3.1.0')) { 95 - parseV3_1_X(context as IR.Context<OpenApi.V3_1_X>); 94 + parseV3_1_X(context as Context<OpenApi.V3_1_X>); 96 95 return context; 97 96 } 98 97
+2 -2
packages/openapi-ts/src/openApi/shared/transforms/index.ts
··· 1 - import type { IR } from '~/ir/types'; 1 + import type { Context } from '~/ir/context'; 2 2 3 3 import { enumsTransform } from './enums'; 4 4 import { propertiesRequiredByDefaultTransform } from './propertiesRequiredByDefault'; 5 5 import { readWriteTransform } from './readWrite'; 6 6 7 - export const transformOpenApiSpec = ({ context }: { context: IR.Context }) => { 7 + export const transformOpenApiSpec = ({ context }: { context: Context }) => { 8 8 const { logger } = context; 9 9 const eventTransformOpenApiSpec = logger.timeEvent('transform-openapi-spec'); 10 10 if (context.config.parser.transforms.enums.enabled) {
+4 -3
packages/openapi-ts/src/openApi/shared/utils/__tests__/operation.test.ts
··· 1 1 import { describe, expect, it } from 'vitest'; 2 2 3 - import type { IR } from '../../../../ir/types'; 3 + import type { Context } from '~/ir/context'; 4 + 4 5 import { operationToId } from '../operation'; 5 6 6 7 describe('operationToId', () => { ··· 36 37 it.each(scenarios)( 37 38 'transforms $method $path ($id) -> $output', 38 39 async ({ id, method, output, path }) => { 39 - const context: Partial<IR.Context> = { 40 + const context: Partial<Context> = { 40 41 config: { 41 42 plugins: { 42 43 // @ts-expect-error ··· 51 52 }; 52 53 expect( 53 54 operationToId({ 54 - context: context as IR.Context, 55 + context: context as Context, 55 56 id, 56 57 method, 57 58 path,
+2 -2
packages/openapi-ts/src/openApi/shared/utils/operation.ts
··· 1 + import type { Context } from '~/ir/context'; 1 2 import { createOperationKey } from '~/ir/operation'; 2 - import type { IR } from '~/ir/types'; 3 3 import { sanitizeNamespaceIdentifier } from '~/openApi/common/parser/sanitize'; 4 4 import { stringCase } from '~/utils/stringCase'; 5 5 ··· 29 29 path, 30 30 state, 31 31 }: { 32 - context: IR.Context; 32 + context: Context; 33 33 count?: number; 34 34 id: string | undefined; 35 35 method: string;
+3 -3
packages/openapi-ts/src/openApi/shared/utils/validator.ts
··· 1 1 import colors from 'ansi-colors'; 2 2 3 - import type { IR } from '~/ir/types'; 3 + import type { Context } from '~/ir/context'; 4 4 5 5 export interface ValidatorIssue { 6 6 /** ··· 72 72 context, 73 73 issue, 74 74 }: { 75 - context: IR.Context; 75 + context: Context; 76 76 issue: ValidatorIssue; 77 77 }) => { 78 78 if (context.config.logs.level === 'silent') { ··· 90 90 context, 91 91 result, 92 92 }: { 93 - context: IR.Context; 93 + context: Context; 94 94 result: ValidatorResult; 95 95 }) => { 96 96 for (const issue of result.issues) {
+10 -10
packages/openapi-ts/src/plugins/@hey-api/schemas/plugin.ts
··· 1 1 import { satisfies } from '~/config/utils/package'; 2 - import type { IR } from '~/ir/types'; 2 + import type { Context } from '~/ir/context'; 3 3 import type { OpenApiV2_0_XTypes } from '~/openApi/2.0.x'; 4 4 import type { OpenApiV3_0_XTypes } from '~/openApi/3.0.x'; 5 5 import type { OpenApiV3_1_XTypes } from '~/openApi/3.1.x'; ··· 47 47 plugin, 48 48 schema: _schema, 49 49 }: { 50 - context: IR.Context; 50 + context: Context; 51 51 plugin: HeyApiSchemasPlugin['Instance']; 52 52 schema: OpenApiV2_0_XTypes['SchemaObject']; 53 53 }): OpenApiV2_0_XTypes['SchemaObject'] => { ··· 123 123 plugin, 124 124 schema: _schema, 125 125 }: { 126 - context: IR.Context; 126 + context: Context; 127 127 plugin: HeyApiSchemasPlugin['Instance']; 128 128 schema: 129 129 | OpenApiV3_0_XTypes['SchemaObject'] ··· 225 225 plugin, 226 226 schema: _schema, 227 227 }: { 228 - context: IR.Context; 228 + context: Context; 229 229 plugin: HeyApiSchemasPlugin['Instance']; 230 230 schema: OpenApiV3_1_XTypes['SchemaObject']; 231 231 }): OpenApiV3_1_XTypes['SchemaObject'] => { ··· 359 359 context, 360 360 plugin, 361 361 }: { 362 - context: IR.Context<OpenApi.V2_0_X>; 362 + context: Context<OpenApi.V2_0_X>; 363 363 plugin: HeyApiSchemasPlugin['Instance']; 364 364 }) => { 365 365 if (!context.spec.definitions) { ··· 397 397 context, 398 398 plugin, 399 399 }: { 400 - context: IR.Context<OpenApi.V3_0_X>; 400 + context: Context<OpenApi.V3_0_X>; 401 401 plugin: HeyApiSchemasPlugin['Instance']; 402 402 }) => { 403 403 if (!context.spec.components) { ··· 435 435 context, 436 436 plugin, 437 437 }: { 438 - context: IR.Context<OpenApi.V3_1_X>; 438 + context: Context<OpenApi.V3_1_X>; 439 439 plugin: HeyApiSchemasPlugin['Instance']; 440 440 }) => { 441 441 if (!context.spec.components) { ··· 472 472 export const handler: HeyApiSchemasPlugin['Handler'] = ({ plugin }) => { 473 473 if ('swagger' in plugin.context.spec) { 474 474 schemasV2_0_X({ 475 - context: plugin.context as IR.Context<OpenApi.V2_0_X>, 475 + context: plugin.context as Context<OpenApi.V2_0_X>, 476 476 plugin, 477 477 }); 478 478 return; ··· 480 480 481 481 if (satisfies(plugin.context.spec.openapi, '>=3.0.0 <3.1.0')) { 482 482 schemasV3_0_X({ 483 - context: plugin.context as IR.Context<OpenApi.V3_0_X>, 483 + context: plugin.context as Context<OpenApi.V3_0_X>, 484 484 plugin, 485 485 }); 486 486 return; ··· 488 488 489 489 if (satisfies(plugin.context.spec.openapi, '>=3.1.0')) { 490 490 schemasV3_1_X({ 491 - context: plugin.context as IR.Context<OpenApi.V3_1_X>, 491 + context: plugin.context as Context<OpenApi.V3_1_X>, 492 492 plugin, 493 493 }); 494 494 return;
+2 -1
packages/openapi-ts/src/plugins/@hey-api/sdk/shared/auth.ts
··· 1 + import type { Context } from '~/ir/context'; 1 2 import type { IR } from '~/ir/types'; 2 3 3 4 import type { Auth } from '../../client-core/bundle/auth'; ··· 73 74 operation, 74 75 plugin, 75 76 }: { 76 - context: IR.Context; 77 + context: Context; 77 78 operation: IR.OperationObject; 78 79 plugin: HeyApiSdkPlugin['Instance']; 79 80 }): Array<Auth> => {
+3 -2
packages/openapi-ts/src/plugins/@hey-api/sdk/shared/operation.ts
··· 1 1 import type { SymbolMeta } from '@hey-api/codegen-core'; 2 2 import type ts from 'typescript'; 3 3 4 + import type { Context } from '~/ir/context'; 4 5 import { statusCodeToGroup } from '~/ir/operation'; 5 6 import type { IR } from '~/ir/types'; 6 7 import { sanitizeNamespaceIdentifier } from '~/openApi'; ··· 39 40 context, 40 41 value, 41 42 }: { 42 - context: IR.Context; 43 + context: Context; 43 44 value: string; 44 45 }) => { 45 46 const name = stringCase({ ··· 84 85 operation, 85 86 plugin, 86 87 }: { 87 - context: IR.Context; 88 + context: Context; 88 89 operation: IR.OperationObject; 89 90 plugin: { 90 91 config: Pick<
+2 -2
packages/openapi-ts/src/plugins/shared/utils/case.ts
··· 1 1 import ts from 'typescript'; 2 2 3 - import type { IR } from '~/ir/types'; 3 + import type { Context } from '~/ir/context'; 4 4 import { numberRegExp } from '~/utils/regexp'; 5 5 import { stringCase } from '~/utils/stringCase'; 6 6 ··· 12 12 context, 13 13 name, 14 14 }: { 15 - context: IR.Context; 15 + context: Context; 16 16 name: string; 17 17 }) => { 18 18 numberRegExp.lastIndex = 0;
+4 -3
packages/openapi-ts/src/plugins/shared/utils/instance.ts
··· 11 11 import { HeyApiError } from '~/error'; 12 12 import type { MatchPointerToGroupFn, WalkOptions } from '~/graph'; 13 13 import { walk } from '~/graph'; 14 + import type { Context } from '~/ir/context'; 14 15 import type { IrTopLevelKind } from '~/ir/graph'; 15 16 import { 16 17 getIrPointerPriority, ··· 68 69 export class PluginInstance<T extends Plugin.Types = Plugin.Types> { 69 70 api: T['api']; 70 71 config: Omit<T['resolvedConfig'], 'name' | 'output'>; 71 - context: IR.Context; 72 + context: Context; 72 73 dependencies: Required<Plugin.Config<T>>['dependencies'] = []; 73 74 private eventHooks: EventHooks; 74 75 gen: IProject; ··· 81 82 * information such as name, version, and dependency resolution during 82 83 * code generation. 83 84 */ 84 - package: IR.Context['package']; 85 + package: Context['package']; 85 86 86 87 constructor( 87 88 props: Pick< ··· 89 90 'config' | 'dependencies' | 'handler' 90 91 > & { 91 92 api?: T['api']; 92 - context: IR.Context<OpenApi.V2_0_X | OpenApi.V3_0_X | OpenApi.V3_1_X>; 93 + context: Context<OpenApi.V2_0_X | OpenApi.V3_0_X | OpenApi.V3_1_X>; 93 94 gen: IProject; 94 95 name: string; 95 96 output: string;
+2 -1
packages/openapi-ts/src/plugins/shared/utils/operation.ts
··· 1 + import type { Context } from '~/ir/context'; 1 2 import { hasOperationDataRequired } from '~/ir/operation'; 2 3 import type { IR } from '~/ir/types'; 3 4 import { getClientPlugin } from '~/plugins/@hey-api/client-core/utils'; ··· 42 43 context, 43 44 operation, 44 45 }: { 45 - context: IR.Context; 46 + context: Context; 46 47 operation: IR.OperationObject; 47 48 }): boolean => { 48 49 const client = getClientPlugin(context.config);