diff --git a/.changeset/six-boxes-fry.md b/.changeset/six-boxes-fry.md new file mode 100644 index 000000000..631de5648 --- /dev/null +++ b/.changeset/six-boxes-fry.md @@ -0,0 +1,5 @@ +--- +'@hey-api/openapi-ts': patch +--- + +fix: handle additionalProperties: boolean in experimental parser diff --git a/packages/openapi-ts/src/compiler/types.ts b/packages/openapi-ts/src/compiler/types.ts index efc306f87..71d440142 100644 --- a/packages/openapi-ts/src/compiler/types.ts +++ b/packages/openapi-ts/src/compiler/types.ts @@ -248,13 +248,23 @@ export const toParameterDeclarations = (parameters: FunctionParameter[]) => export const createKeywordTypeNode = ({ keyword, }: { - keyword: 'any' | 'boolean' | 'number' | 'string' | 'undefined' | 'unknown'; + keyword: + | 'any' + | 'boolean' + | 'never' + | 'number' + | 'string' + | 'undefined' + | 'unknown'; }) => { let kind: ts.KeywordTypeSyntaxKind = ts.SyntaxKind.AnyKeyword; switch (keyword) { case 'boolean': kind = ts.SyntaxKind.BooleanKeyword; break; + case 'never': + kind = ts.SyntaxKind.NeverKeyword; + break; case 'number': kind = ts.SyntaxKind.NumberKeyword; break; diff --git a/packages/openapi-ts/src/ir/ir.d.ts b/packages/openapi-ts/src/ir/ir.d.ts index 4f4704508..437375f22 100644 --- a/packages/openapi-ts/src/ir/ir.d.ts +++ b/packages/openapi-ts/src/ir/ir.d.ts @@ -132,6 +132,7 @@ export interface IRSchemaObject | 'array' | 'boolean' | 'enum' + | 'never' | 'null' | 'number' | 'object' diff --git a/packages/openapi-ts/src/openApi/3.0.x/parser/schema.ts b/packages/openapi-ts/src/openApi/3.0.x/parser/schema.ts index bf13faf65..976684220 100644 --- a/packages/openapi-ts/src/openApi/3.0.x/parser/schema.ts +++ b/packages/openapi-ts/src/openApi/3.0.x/parser/schema.ts @@ -160,16 +160,9 @@ const parseObject = ({ if (schema.additionalProperties !== undefined) { if (typeof schema.additionalProperties === 'boolean') { - if (schema.additionalProperties) { - // no need to add "any" additional properties if there are no defined properties - if (irSchema.properties) { - irSchema.additionalProperties = { - type: 'unknown', - }; - } - } else { - // TODO: parser - handle additional properties: false - } + irSchema.additionalProperties = { + type: schema.additionalProperties ? 'unknown' : 'never', + }; } else { const irAdditionalPropertiesSchema = schemaToIrSchema({ context, diff --git a/packages/openapi-ts/src/openApi/3.1.x/parser/schema.ts b/packages/openapi-ts/src/openApi/3.1.x/parser/schema.ts index 96ad11034..d44311f7d 100644 --- a/packages/openapi-ts/src/openApi/3.1.x/parser/schema.ts +++ b/packages/openapi-ts/src/openApi/3.1.x/parser/schema.ts @@ -210,16 +210,9 @@ const parseObject = ({ if (schema.additionalProperties !== undefined) { if (typeof schema.additionalProperties === 'boolean') { - if (schema.additionalProperties) { - // no need to add "any" additional properties if there are no defined properties - if (irSchema.properties) { - irSchema.additionalProperties = { - type: 'unknown', - }; - } - } else { - // TODO: parser - handle additional properties: false - } + irSchema.additionalProperties = { + type: schema.additionalProperties ? 'unknown' : 'never', + }; } else { const irAdditionalPropertiesSchema = schemaToIrSchema({ context, diff --git a/packages/openapi-ts/src/plugins/@hey-api/types/plugin.ts b/packages/openapi-ts/src/plugins/@hey-api/types/plugin.ts index dc66c4c03..efd43c777 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/types/plugin.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/types/plugin.ts @@ -398,7 +398,7 @@ const objectTypeToIdentifier = ({ }) => { let indexProperty: Property | undefined; const schemaProperties: Array = []; - const indexPropertyItems: Array = []; + let indexPropertyItems: Array = []; const required = schema.required ?? []; let hasOptionalProperties = false; @@ -424,8 +424,15 @@ const objectTypeToIdentifier = ({ } } - if (schema.additionalProperties) { - indexPropertyItems.unshift(schema.additionalProperties); + if ( + schema.additionalProperties && + (schema.additionalProperties.type !== 'never' || !indexPropertyItems.length) + ) { + if (schema.additionalProperties.type === 'never') { + indexPropertyItems = [schema.additionalProperties]; + } else { + indexPropertyItems.unshift(schema.additionalProperties); + } if (hasOptionalProperties) { indexPropertyItems.push({ @@ -555,6 +562,10 @@ const schemaTypeToIdentifier = ({ namespace, schema: schema as SchemaWithType<'enum'>, }); + case 'never': + return compiler.keywordTypeNode({ + keyword: 'never', + }); case 'null': return compiler.literalTypeNode({ literal: compiler.null(), diff --git a/packages/openapi-ts/test/3.0.x.spec.ts b/packages/openapi-ts/test/3.0.x.spec.ts new file mode 100644 index 000000000..674600051 --- /dev/null +++ b/packages/openapi-ts/test/3.0.x.spec.ts @@ -0,0 +1,71 @@ +import { readFileSync } from 'node:fs'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; + +import { describe, expect, it } from 'vitest'; + +import { createClient } from '../'; +import type { UserConfig } from '../src/types/config'; +import { getFilePaths } from './utils'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); + +const VERSION = '3.0.x'; + +const outputDir = path.join(__dirname, 'generated', VERSION); + +describe(`OpenAPI ${VERSION}`, () => { + const createConfig = (userConfig: UserConfig): UserConfig => ({ + client: '@hey-api/client-fetch', + experimentalParser: true, + plugins: ['@hey-api/types'], + ...userConfig, + input: path.join( + __dirname, + 'spec', + VERSION, + typeof userConfig.input === 'string' ? userConfig.input : '', + ), + output: path.join( + outputDir, + typeof userConfig.output === 'string' ? userConfig.output : '', + ), + }); + + const scenarios = [ + { + config: createConfig({ + input: 'additional-properties-false.json', + output: 'additional-properties-false', + }), + description: 'forbids arbitrary properties on objects', + }, + { + config: createConfig({ + input: 'additional-properties-true.json', + output: 'additional-properties-true', + }), + description: 'allows arbitrary properties on objects', + }, + ]; + + it.each(scenarios)('$description', async ({ config }) => { + await createClient(config); + + const outputPath = typeof config.output === 'string' ? config.output : ''; + const filePaths = getFilePaths(outputPath); + + filePaths.forEach((filePath) => { + const fileContent = readFileSync(filePath, 'utf-8'); + expect(fileContent).toMatchFileSnapshot( + path.join( + __dirname, + '__snapshots__', + VERSION, + filePath.slice(outputDir.length + 1), + ), + ); + }); + }); +}); diff --git a/packages/openapi-ts/test/3.1.x.spec.ts b/packages/openapi-ts/test/3.1.x.spec.ts index f79eb2e25..b078c0f33 100644 --- a/packages/openapi-ts/test/3.1.x.spec.ts +++ b/packages/openapi-ts/test/3.1.x.spec.ts @@ -34,6 +34,20 @@ describe(`OpenAPI ${VERSION}`, () => { }); const scenarios = [ + { + config: createConfig({ + input: 'additional-properties-false.json', + output: 'additional-properties-false', + }), + description: 'forbids arbitrary properties on objects', + }, + { + config: createConfig({ + input: 'additional-properties-true.json', + output: 'additional-properties-true', + }), + description: 'allows arbitrary properties on objects', + }, { config: createConfig({ input: 'duplicate-null.json', diff --git a/packages/openapi-ts/test/__snapshots__/3.0.x/additional-properties-false/index.ts b/packages/openapi-ts/test/__snapshots__/3.0.x/additional-properties-false/index.ts new file mode 100644 index 000000000..56bade120 --- /dev/null +++ b/packages/openapi-ts/test/__snapshots__/3.0.x/additional-properties-false/index.ts @@ -0,0 +1,2 @@ +// This file is auto-generated by @hey-api/openapi-ts +export * from './types.gen'; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/3.0.x/additional-properties-false/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.0.x/additional-properties-false/types.gen.ts new file mode 100644 index 000000000..7f3c6dab9 --- /dev/null +++ b/packages/openapi-ts/test/__snapshots__/3.0.x/additional-properties-false/types.gen.ts @@ -0,0 +1,13 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type Foo = { + foo: string; +}; + +export type Bar = Foo & { + [key: string]: never; +}; + +export type Baz = Foo & { + bar: string; +}; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/3.0.x/additional-properties-true/index.ts b/packages/openapi-ts/test/__snapshots__/3.0.x/additional-properties-true/index.ts new file mode 100644 index 000000000..56bade120 --- /dev/null +++ b/packages/openapi-ts/test/__snapshots__/3.0.x/additional-properties-true/index.ts @@ -0,0 +1,2 @@ +// This file is auto-generated by @hey-api/openapi-ts +export * from './types.gen'; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/3.0.x/additional-properties-true/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.0.x/additional-properties-true/types.gen.ts new file mode 100644 index 000000000..dbe2aaebf --- /dev/null +++ b/packages/openapi-ts/test/__snapshots__/3.0.x/additional-properties-true/types.gen.ts @@ -0,0 +1,15 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type Foo = { + foo: string; + [key: string]: unknown | string; +}; + +export type Bar = Foo & { + [key: string]: unknown; +}; + +export type Baz = Foo & { + bar: string; + [key: string]: unknown | string; +}; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/types.gen.ts index e2ff1c1e7..0324009bd 100644 --- a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/types.gen.ts @@ -643,7 +643,9 @@ export type FreeFormObjectWithoutAdditionalProperties = {}; /** * This is a free-form object with additionalProperties: true. */ -export type FreeFormObjectWithAdditionalPropertiesEqTrue = {}; +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: {}. @@ -920,7 +922,9 @@ export type Generic_Schema_Duplicate_Issue_1_System_Boolean_ = { item?: boolean; error?: string | null; readonly hasError?: boolean; - data?: {}; + data?: { + [key: string]: never; + }; }; export type Generic_Schema_Duplicate_Issue_1_System_String_ = { diff --git a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/types.gen.ts index e2ff1c1e7..0324009bd 100644 --- a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/types.gen.ts @@ -643,7 +643,9 @@ export type FreeFormObjectWithoutAdditionalProperties = {}; /** * This is a free-form object with additionalProperties: true. */ -export type FreeFormObjectWithAdditionalPropertiesEqTrue = {}; +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: {}. @@ -920,7 +922,9 @@ export type Generic_Schema_Duplicate_Issue_1_System_Boolean_ = { item?: boolean; error?: string | null; readonly hasError?: boolean; - data?: {}; + data?: { + [key: string]: never; + }; }; export type Generic_Schema_Duplicate_Issue_1_System_String_ = { diff --git a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/types.gen.ts index e2ff1c1e7..0324009bd 100644 --- a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/types.gen.ts @@ -643,7 +643,9 @@ export type FreeFormObjectWithoutAdditionalProperties = {}; /** * This is a free-form object with additionalProperties: true. */ -export type FreeFormObjectWithAdditionalPropertiesEqTrue = {}; +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: {}. @@ -920,7 +922,9 @@ export type Generic_Schema_Duplicate_Issue_1_System_Boolean_ = { item?: boolean; error?: string | null; readonly hasError?: boolean; - data?: {}; + data?: { + [key: string]: never; + }; }; export type Generic_Schema_Duplicate_Issue_1_System_String_ = { diff --git a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/types.gen.ts index e2ff1c1e7..0324009bd 100644 --- a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/types.gen.ts @@ -643,7 +643,9 @@ export type FreeFormObjectWithoutAdditionalProperties = {}; /** * This is a free-form object with additionalProperties: true. */ -export type FreeFormObjectWithAdditionalPropertiesEqTrue = {}; +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: {}. @@ -920,7 +922,9 @@ export type Generic_Schema_Duplicate_Issue_1_System_Boolean_ = { item?: boolean; error?: string | null; readonly hasError?: boolean; - data?: {}; + data?: { + [key: string]: never; + }; }; export type Generic_Schema_Duplicate_Issue_1_System_String_ = { diff --git a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/types.gen.ts index e2ff1c1e7..0324009bd 100644 --- a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/types.gen.ts @@ -643,7 +643,9 @@ export type FreeFormObjectWithoutAdditionalProperties = {}; /** * This is a free-form object with additionalProperties: true. */ -export type FreeFormObjectWithAdditionalPropertiesEqTrue = {}; +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: {}. @@ -920,7 +922,9 @@ export type Generic_Schema_Duplicate_Issue_1_System_Boolean_ = { item?: boolean; error?: string | null; readonly hasError?: boolean; - data?: {}; + data?: { + [key: string]: never; + }; }; export type Generic_Schema_Duplicate_Issue_1_System_String_ = { diff --git a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/types.gen.ts index e2ff1c1e7..0324009bd 100644 --- a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/types.gen.ts @@ -643,7 +643,9 @@ export type FreeFormObjectWithoutAdditionalProperties = {}; /** * This is a free-form object with additionalProperties: true. */ -export type FreeFormObjectWithAdditionalPropertiesEqTrue = {}; +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: {}. @@ -920,7 +922,9 @@ export type Generic_Schema_Duplicate_Issue_1_System_Boolean_ = { item?: boolean; error?: string | null; readonly hasError?: boolean; - data?: {}; + data?: { + [key: string]: never; + }; }; export type Generic_Schema_Duplicate_Issue_1_System_String_ = { diff --git a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/types.gen.ts index e2ff1c1e7..0324009bd 100644 --- a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/types.gen.ts @@ -643,7 +643,9 @@ export type FreeFormObjectWithoutAdditionalProperties = {}; /** * This is a free-form object with additionalProperties: true. */ -export type FreeFormObjectWithAdditionalPropertiesEqTrue = {}; +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: {}. @@ -920,7 +922,9 @@ export type Generic_Schema_Duplicate_Issue_1_System_Boolean_ = { item?: boolean; error?: string | null; readonly hasError?: boolean; - data?: {}; + data?: { + [key: string]: never; + }; }; export type Generic_Schema_Duplicate_Issue_1_System_String_ = { diff --git a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/types.gen.ts index e2ff1c1e7..0324009bd 100644 --- a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/types.gen.ts @@ -643,7 +643,9 @@ export type FreeFormObjectWithoutAdditionalProperties = {}; /** * This is a free-form object with additionalProperties: true. */ -export type FreeFormObjectWithAdditionalPropertiesEqTrue = {}; +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: {}. @@ -920,7 +922,9 @@ export type Generic_Schema_Duplicate_Issue_1_System_Boolean_ = { item?: boolean; error?: string | null; readonly hasError?: boolean; - data?: {}; + data?: { + [key: string]: never; + }; }; export type Generic_Schema_Duplicate_Issue_1_System_String_ = { diff --git a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/types.gen.ts index e2ff1c1e7..0324009bd 100644 --- a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/types.gen.ts @@ -643,7 +643,9 @@ export type FreeFormObjectWithoutAdditionalProperties = {}; /** * This is a free-form object with additionalProperties: true. */ -export type FreeFormObjectWithAdditionalPropertiesEqTrue = {}; +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: {}. @@ -920,7 +922,9 @@ export type Generic_Schema_Duplicate_Issue_1_System_Boolean_ = { item?: boolean; error?: string | null; readonly hasError?: boolean; - data?: {}; + data?: { + [key: string]: never; + }; }; export type Generic_Schema_Duplicate_Issue_1_System_String_ = { diff --git a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/types.gen.ts index e2ff1c1e7..0324009bd 100644 --- a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/types.gen.ts @@ -643,7 +643,9 @@ export type FreeFormObjectWithoutAdditionalProperties = {}; /** * This is a free-form object with additionalProperties: true. */ -export type FreeFormObjectWithAdditionalPropertiesEqTrue = {}; +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: {}. @@ -920,7 +922,9 @@ export type Generic_Schema_Duplicate_Issue_1_System_Boolean_ = { item?: boolean; error?: string | null; readonly hasError?: boolean; - data?: {}; + data?: { + [key: string]: never; + }; }; export type Generic_Schema_Duplicate_Issue_1_System_String_ = { diff --git a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/types.gen.ts index e2ff1c1e7..0324009bd 100644 --- a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/types.gen.ts @@ -643,7 +643,9 @@ export type FreeFormObjectWithoutAdditionalProperties = {}; /** * This is a free-form object with additionalProperties: true. */ -export type FreeFormObjectWithAdditionalPropertiesEqTrue = {}; +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: {}. @@ -920,7 +922,9 @@ export type Generic_Schema_Duplicate_Issue_1_System_Boolean_ = { item?: boolean; error?: string | null; readonly hasError?: boolean; - data?: {}; + data?: { + [key: string]: never; + }; }; export type Generic_Schema_Duplicate_Issue_1_System_String_ = { diff --git a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/types.gen.ts index e2ff1c1e7..0324009bd 100644 --- a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/types.gen.ts @@ -643,7 +643,9 @@ export type FreeFormObjectWithoutAdditionalProperties = {}; /** * This is a free-form object with additionalProperties: true. */ -export type FreeFormObjectWithAdditionalPropertiesEqTrue = {}; +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: {}. @@ -920,7 +922,9 @@ export type Generic_Schema_Duplicate_Issue_1_System_Boolean_ = { item?: boolean; error?: string | null; readonly hasError?: boolean; - data?: {}; + data?: { + [key: string]: never; + }; }; export type Generic_Schema_Duplicate_Issue_1_System_String_ = { diff --git a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/types.gen.ts index e2ff1c1e7..0324009bd 100644 --- a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/types.gen.ts @@ -643,7 +643,9 @@ export type FreeFormObjectWithoutAdditionalProperties = {}; /** * This is a free-form object with additionalProperties: true. */ -export type FreeFormObjectWithAdditionalPropertiesEqTrue = {}; +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: {}. @@ -920,7 +922,9 @@ export type Generic_Schema_Duplicate_Issue_1_System_Boolean_ = { item?: boolean; error?: string | null; readonly hasError?: boolean; - data?: {}; + data?: { + [key: string]: never; + }; }; export type Generic_Schema_Duplicate_Issue_1_System_String_ = { diff --git a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/types.gen.ts index e2ff1c1e7..0324009bd 100644 --- a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/types.gen.ts @@ -643,7 +643,9 @@ export type FreeFormObjectWithoutAdditionalProperties = {}; /** * This is a free-form object with additionalProperties: true. */ -export type FreeFormObjectWithAdditionalPropertiesEqTrue = {}; +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: {}. @@ -920,7 +922,9 @@ export type Generic_Schema_Duplicate_Issue_1_System_Boolean_ = { item?: boolean; error?: string | null; readonly hasError?: boolean; - data?: {}; + data?: { + [key: string]: never; + }; }; export type Generic_Schema_Duplicate_Issue_1_System_String_ = { diff --git a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/types.gen.ts index e2ff1c1e7..0324009bd 100644 --- a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/types.gen.ts @@ -643,7 +643,9 @@ export type FreeFormObjectWithoutAdditionalProperties = {}; /** * This is a free-form object with additionalProperties: true. */ -export type FreeFormObjectWithAdditionalPropertiesEqTrue = {}; +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: {}. @@ -920,7 +922,9 @@ export type Generic_Schema_Duplicate_Issue_1_System_Boolean_ = { item?: boolean; error?: string | null; readonly hasError?: boolean; - data?: {}; + data?: { + [key: string]: never; + }; }; export type Generic_Schema_Duplicate_Issue_1_System_String_ = { diff --git a/packages/openapi-ts/test/__snapshots__/3.1.x/additional-properties-false/index.ts b/packages/openapi-ts/test/__snapshots__/3.1.x/additional-properties-false/index.ts new file mode 100644 index 000000000..56bade120 --- /dev/null +++ b/packages/openapi-ts/test/__snapshots__/3.1.x/additional-properties-false/index.ts @@ -0,0 +1,2 @@ +// This file is auto-generated by @hey-api/openapi-ts +export * from './types.gen'; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/3.1.x/additional-properties-false/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.1.x/additional-properties-false/types.gen.ts new file mode 100644 index 000000000..7f3c6dab9 --- /dev/null +++ b/packages/openapi-ts/test/__snapshots__/3.1.x/additional-properties-false/types.gen.ts @@ -0,0 +1,13 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type Foo = { + foo: string; +}; + +export type Bar = Foo & { + [key: string]: never; +}; + +export type Baz = Foo & { + bar: string; +}; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/3.1.x/additional-properties-true/index.ts b/packages/openapi-ts/test/__snapshots__/3.1.x/additional-properties-true/index.ts new file mode 100644 index 000000000..56bade120 --- /dev/null +++ b/packages/openapi-ts/test/__snapshots__/3.1.x/additional-properties-true/index.ts @@ -0,0 +1,2 @@ +// This file is auto-generated by @hey-api/openapi-ts +export * from './types.gen'; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/3.1.x/additional-properties-true/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.1.x/additional-properties-true/types.gen.ts new file mode 100644 index 000000000..dbe2aaebf --- /dev/null +++ b/packages/openapi-ts/test/__snapshots__/3.1.x/additional-properties-true/types.gen.ts @@ -0,0 +1,15 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type Foo = { + foo: string; + [key: string]: unknown | string; +}; + +export type Bar = Foo & { + [key: string]: unknown; +}; + +export type Baz = Foo & { + bar: string; + [key: string]: unknown | string; +}; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/types.gen.ts index e2ff1c1e7..0324009bd 100644 --- a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/types.gen.ts @@ -643,7 +643,9 @@ export type FreeFormObjectWithoutAdditionalProperties = {}; /** * This is a free-form object with additionalProperties: true. */ -export type FreeFormObjectWithAdditionalPropertiesEqTrue = {}; +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: {}. @@ -920,7 +922,9 @@ export type Generic_Schema_Duplicate_Issue_1_System_Boolean_ = { item?: boolean; error?: string | null; readonly hasError?: boolean; - data?: {}; + data?: { + [key: string]: never; + }; }; export type Generic_Schema_Duplicate_Issue_1_System_String_ = { diff --git a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/types.gen.ts index e2ff1c1e7..0324009bd 100644 --- a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/types.gen.ts @@ -643,7 +643,9 @@ export type FreeFormObjectWithoutAdditionalProperties = {}; /** * This is a free-form object with additionalProperties: true. */ -export type FreeFormObjectWithAdditionalPropertiesEqTrue = {}; +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: {}. @@ -920,7 +922,9 @@ export type Generic_Schema_Duplicate_Issue_1_System_Boolean_ = { item?: boolean; error?: string | null; readonly hasError?: boolean; - data?: {}; + data?: { + [key: string]: never; + }; }; export type Generic_Schema_Duplicate_Issue_1_System_String_ = { diff --git a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/types.gen.ts index e2ff1c1e7..0324009bd 100644 --- a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/types.gen.ts @@ -643,7 +643,9 @@ export type FreeFormObjectWithoutAdditionalProperties = {}; /** * This is a free-form object with additionalProperties: true. */ -export type FreeFormObjectWithAdditionalPropertiesEqTrue = {}; +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: {}. @@ -920,7 +922,9 @@ export type Generic_Schema_Duplicate_Issue_1_System_Boolean_ = { item?: boolean; error?: string | null; readonly hasError?: boolean; - data?: {}; + data?: { + [key: string]: never; + }; }; export type Generic_Schema_Duplicate_Issue_1_System_String_ = { diff --git a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/types.gen.ts index e2ff1c1e7..0324009bd 100644 --- a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/types.gen.ts @@ -643,7 +643,9 @@ export type FreeFormObjectWithoutAdditionalProperties = {}; /** * This is a free-form object with additionalProperties: true. */ -export type FreeFormObjectWithAdditionalPropertiesEqTrue = {}; +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: {}. @@ -920,7 +922,9 @@ export type Generic_Schema_Duplicate_Issue_1_System_Boolean_ = { item?: boolean; error?: string | null; readonly hasError?: boolean; - data?: {}; + data?: { + [key: string]: never; + }; }; export type Generic_Schema_Duplicate_Issue_1_System_String_ = { diff --git a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/types.gen.ts index e2ff1c1e7..0324009bd 100644 --- a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/types.gen.ts @@ -643,7 +643,9 @@ export type FreeFormObjectWithoutAdditionalProperties = {}; /** * This is a free-form object with additionalProperties: true. */ -export type FreeFormObjectWithAdditionalPropertiesEqTrue = {}; +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: {}. @@ -920,7 +922,9 @@ export type Generic_Schema_Duplicate_Issue_1_System_Boolean_ = { item?: boolean; error?: string | null; readonly hasError?: boolean; - data?: {}; + data?: { + [key: string]: never; + }; }; export type Generic_Schema_Duplicate_Issue_1_System_String_ = { diff --git a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/types.gen.ts index e2ff1c1e7..0324009bd 100644 --- a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/types.gen.ts @@ -643,7 +643,9 @@ export type FreeFormObjectWithoutAdditionalProperties = {}; /** * This is a free-form object with additionalProperties: true. */ -export type FreeFormObjectWithAdditionalPropertiesEqTrue = {}; +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: {}. @@ -920,7 +922,9 @@ export type Generic_Schema_Duplicate_Issue_1_System_Boolean_ = { item?: boolean; error?: string | null; readonly hasError?: boolean; - data?: {}; + data?: { + [key: string]: never; + }; }; export type Generic_Schema_Duplicate_Issue_1_System_String_ = { diff --git a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/types.gen.ts index e2ff1c1e7..0324009bd 100644 --- a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/types.gen.ts @@ -643,7 +643,9 @@ export type FreeFormObjectWithoutAdditionalProperties = {}; /** * This is a free-form object with additionalProperties: true. */ -export type FreeFormObjectWithAdditionalPropertiesEqTrue = {}; +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: {}. @@ -920,7 +922,9 @@ export type Generic_Schema_Duplicate_Issue_1_System_Boolean_ = { item?: boolean; error?: string | null; readonly hasError?: boolean; - data?: {}; + data?: { + [key: string]: never; + }; }; export type Generic_Schema_Duplicate_Issue_1_System_String_ = { diff --git a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/types.gen.ts index e2ff1c1e7..0324009bd 100644 --- a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/types.gen.ts @@ -643,7 +643,9 @@ export type FreeFormObjectWithoutAdditionalProperties = {}; /** * This is a free-form object with additionalProperties: true. */ -export type FreeFormObjectWithAdditionalPropertiesEqTrue = {}; +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: {}. @@ -920,7 +922,9 @@ export type Generic_Schema_Duplicate_Issue_1_System_Boolean_ = { item?: boolean; error?: string | null; readonly hasError?: boolean; - data?: {}; + data?: { + [key: string]: never; + }; }; export type Generic_Schema_Duplicate_Issue_1_System_String_ = { diff --git a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/types.gen.ts index e2ff1c1e7..0324009bd 100644 --- a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/types.gen.ts @@ -643,7 +643,9 @@ export type FreeFormObjectWithoutAdditionalProperties = {}; /** * This is a free-form object with additionalProperties: true. */ -export type FreeFormObjectWithAdditionalPropertiesEqTrue = {}; +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: {}. @@ -920,7 +922,9 @@ export type Generic_Schema_Duplicate_Issue_1_System_Boolean_ = { item?: boolean; error?: string | null; readonly hasError?: boolean; - data?: {}; + data?: { + [key: string]: never; + }; }; export type Generic_Schema_Duplicate_Issue_1_System_String_ = { diff --git a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/types.gen.ts index e2ff1c1e7..0324009bd 100644 --- a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/types.gen.ts @@ -643,7 +643,9 @@ export type FreeFormObjectWithoutAdditionalProperties = {}; /** * This is a free-form object with additionalProperties: true. */ -export type FreeFormObjectWithAdditionalPropertiesEqTrue = {}; +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: {}. @@ -920,7 +922,9 @@ export type Generic_Schema_Duplicate_Issue_1_System_Boolean_ = { item?: boolean; error?: string | null; readonly hasError?: boolean; - data?: {}; + data?: { + [key: string]: never; + }; }; export type Generic_Schema_Duplicate_Issue_1_System_String_ = { diff --git a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/types.gen.ts index e2ff1c1e7..0324009bd 100644 --- a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/types.gen.ts @@ -643,7 +643,9 @@ export type FreeFormObjectWithoutAdditionalProperties = {}; /** * This is a free-form object with additionalProperties: true. */ -export type FreeFormObjectWithAdditionalPropertiesEqTrue = {}; +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: {}. @@ -920,7 +922,9 @@ export type Generic_Schema_Duplicate_Issue_1_System_Boolean_ = { item?: boolean; error?: string | null; readonly hasError?: boolean; - data?: {}; + data?: { + [key: string]: never; + }; }; export type Generic_Schema_Duplicate_Issue_1_System_String_ = { diff --git a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/types.gen.ts index e2ff1c1e7..0324009bd 100644 --- a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/types.gen.ts @@ -643,7 +643,9 @@ export type FreeFormObjectWithoutAdditionalProperties = {}; /** * This is a free-form object with additionalProperties: true. */ -export type FreeFormObjectWithAdditionalPropertiesEqTrue = {}; +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: {}. @@ -920,7 +922,9 @@ export type Generic_Schema_Duplicate_Issue_1_System_Boolean_ = { item?: boolean; error?: string | null; readonly hasError?: boolean; - data?: {}; + data?: { + [key: string]: never; + }; }; export type Generic_Schema_Duplicate_Issue_1_System_String_ = { diff --git a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/types.gen.ts index e2ff1c1e7..0324009bd 100644 --- a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/types.gen.ts @@ -643,7 +643,9 @@ export type FreeFormObjectWithoutAdditionalProperties = {}; /** * This is a free-form object with additionalProperties: true. */ -export type FreeFormObjectWithAdditionalPropertiesEqTrue = {}; +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: {}. @@ -920,7 +922,9 @@ export type Generic_Schema_Duplicate_Issue_1_System_Boolean_ = { item?: boolean; error?: string | null; readonly hasError?: boolean; - data?: {}; + data?: { + [key: string]: never; + }; }; export type Generic_Schema_Duplicate_Issue_1_System_String_ = { diff --git a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/types.gen.ts index e2ff1c1e7..0324009bd 100644 --- a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/types.gen.ts @@ -643,7 +643,9 @@ export type FreeFormObjectWithoutAdditionalProperties = {}; /** * This is a free-form object with additionalProperties: true. */ -export type FreeFormObjectWithAdditionalPropertiesEqTrue = {}; +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: {}. @@ -920,7 +922,9 @@ export type Generic_Schema_Duplicate_Issue_1_System_Boolean_ = { item?: boolean; error?: string | null; readonly hasError?: boolean; - data?: {}; + data?: { + [key: string]: never; + }; }; export type Generic_Schema_Duplicate_Issue_1_System_String_ = { diff --git a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/types.gen.ts index e2ff1c1e7..0324009bd 100644 --- a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/types.gen.ts @@ -643,7 +643,9 @@ export type FreeFormObjectWithoutAdditionalProperties = {}; /** * This is a free-form object with additionalProperties: true. */ -export type FreeFormObjectWithAdditionalPropertiesEqTrue = {}; +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: {}. @@ -920,7 +922,9 @@ export type Generic_Schema_Duplicate_Issue_1_System_Boolean_ = { item?: boolean; error?: string | null; readonly hasError?: boolean; - data?: {}; + data?: { + [key: string]: never; + }; }; export type Generic_Schema_Duplicate_Issue_1_System_String_ = { diff --git a/packages/openapi-ts/test/sample.cjs b/packages/openapi-ts/test/sample.cjs index 9ec6c8a0b..987dae5ae 100644 --- a/packages/openapi-ts/test/sample.cjs +++ b/packages/openapi-ts/test/sample.cjs @@ -10,8 +10,7 @@ const main = async () => { }, // debug: true, experimentalParser: true, - input: './test/spec/3.0.x/full.json', - // input: './test/spec/3.1.x/full.json', + input: './test/spec/3.0.x/additional-properties-false.json', // input: 'https://mongodb-mms-prod-build-server.s3.amazonaws.com/openapi/2caffd88277a4e27c95dcefc7e3b6a63a3b03297-v2-2023-11-15.json', // name: 'foo', output: { @@ -24,12 +23,12 @@ const main = async () => { // name: '@hey-api/schemas', // type: 'json', // }, - { - // asClass: true, - // filter: '^GET /api/v{api-version}/simple:operation$', - name: '@hey-api/services', - // serviceNameBuilder: '^Parameters', - }, + // { + // // asClass: true, + // // filter: '^GET /api/v{api-version}/simple:operation$', + // name: '@hey-api/services', + // // serviceNameBuilder: '^Parameters', + // }, // { // dates: true, // name: '@hey-api/transformers', diff --git a/packages/openapi-ts/test/spec/3.0.x/additional-properties-false.json b/packages/openapi-ts/test/spec/3.0.x/additional-properties-false.json new file mode 100644 index 000000000..1408e4310 --- /dev/null +++ b/packages/openapi-ts/test/spec/3.0.x/additional-properties-false.json @@ -0,0 +1,49 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "OpenAPI 3.0.1 additional properties false example", + "version": "1" + }, + "components": { + "schemas": { + "Foo": { + "required": ["foo"], + "type": "object", + "properties": { + "foo": { + "type": "string" + } + }, + "additionalProperties": false + }, + "Bar": { + "allOf": [ + { + "$ref": "#/components/schemas/Foo" + }, + { + "type": "object", + "additionalProperties": false + } + ] + }, + "Baz": { + "allOf": [ + { + "$ref": "#/components/schemas/Foo" + }, + { + "required": ["bar"], + "type": "object", + "properties": { + "bar": { + "type": "string" + } + }, + "additionalProperties": false + } + ] + } + } + } +} diff --git a/packages/openapi-ts/test/spec/3.0.x/additional-properties-true.json b/packages/openapi-ts/test/spec/3.0.x/additional-properties-true.json new file mode 100644 index 000000000..4f45870d3 --- /dev/null +++ b/packages/openapi-ts/test/spec/3.0.x/additional-properties-true.json @@ -0,0 +1,49 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "OpenAPI 3.0.1 additional properties true example", + "version": "1" + }, + "components": { + "schemas": { + "Foo": { + "required": ["foo"], + "type": "object", + "properties": { + "foo": { + "type": "string" + } + }, + "additionalProperties": true + }, + "Bar": { + "allOf": [ + { + "$ref": "#/components/schemas/Foo" + }, + { + "type": "object", + "additionalProperties": true + } + ] + }, + "Baz": { + "allOf": [ + { + "$ref": "#/components/schemas/Foo" + }, + { + "required": ["bar"], + "type": "object", + "properties": { + "bar": { + "type": "string" + } + }, + "additionalProperties": true + } + ] + } + } + } +} diff --git a/packages/openapi-ts/test/spec/3.1.x/additional-properties-false.json b/packages/openapi-ts/test/spec/3.1.x/additional-properties-false.json new file mode 100644 index 000000000..57d954db4 --- /dev/null +++ b/packages/openapi-ts/test/spec/3.1.x/additional-properties-false.json @@ -0,0 +1,49 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI 3.1.0 additional properties false example", + "version": "1" + }, + "components": { + "schemas": { + "Foo": { + "required": ["foo"], + "type": "object", + "properties": { + "foo": { + "type": "string" + } + }, + "additionalProperties": false + }, + "Bar": { + "allOf": [ + { + "$ref": "#/components/schemas/Foo" + }, + { + "type": "object", + "additionalProperties": false + } + ] + }, + "Baz": { + "allOf": [ + { + "$ref": "#/components/schemas/Foo" + }, + { + "required": ["bar"], + "type": "object", + "properties": { + "bar": { + "type": "string" + } + }, + "additionalProperties": false + } + ] + } + } + } +} diff --git a/packages/openapi-ts/test/spec/3.1.x/additional-properties-true.json b/packages/openapi-ts/test/spec/3.1.x/additional-properties-true.json new file mode 100644 index 000000000..09143975e --- /dev/null +++ b/packages/openapi-ts/test/spec/3.1.x/additional-properties-true.json @@ -0,0 +1,49 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI 3.1.0 additional properties true example", + "version": "1" + }, + "components": { + "schemas": { + "Foo": { + "required": ["foo"], + "type": "object", + "properties": { + "foo": { + "type": "string" + } + }, + "additionalProperties": true + }, + "Bar": { + "allOf": [ + { + "$ref": "#/components/schemas/Foo" + }, + { + "type": "object", + "additionalProperties": true + } + ] + }, + "Baz": { + "allOf": [ + { + "$ref": "#/components/schemas/Foo" + }, + { + "required": ["bar"], + "type": "object", + "properties": { + "bar": { + "type": "string" + } + }, + "additionalProperties": true + } + ] + } + } + } +}