diff --git a/.changeset/clean-worms-sing.md b/.changeset/clean-worms-sing.md index 95c800d3c..cc070cbbd 100644 --- a/.changeset/clean-worms-sing.md +++ b/.changeset/clean-worms-sing.md @@ -2,7 +2,7 @@ '@hey-api/openapi-ts': minor --- -feat: add logs.level option +feat: add `logs.level` option ### Added `logs.level` option diff --git a/.changeset/hungry-dolphins-clap.md b/.changeset/hungry-dolphins-clap.md index ad5f02299..94e3a903d 100644 --- a/.changeset/hungry-dolphins-clap.md +++ b/.changeset/hungry-dolphins-clap.md @@ -2,4 +2,4 @@ '@hey-api/openapi-ts': patch --- -fix: add --silent or -s CLI option for silent log level +fix: add `--silent` or `-s` CLI option for silent log level diff --git a/.changeset/moody-falcons-pay.md b/.changeset/moody-falcons-pay.md index bfc38ecbb..6dd841b3e 100644 --- a/.changeset/moody-falcons-pay.md +++ b/.changeset/moody-falcons-pay.md @@ -2,4 +2,4 @@ '@hey-api/openapi-ts': patch --- -feat: add logs configuration option to customize log directory +feat: add `logs` configuration option to customize log directory diff --git a/.changeset/proud-socks-dance.md b/.changeset/proud-socks-dance.md new file mode 100644 index 000000000..6c1523cc2 --- /dev/null +++ b/.changeset/proud-socks-dance.md @@ -0,0 +1,5 @@ +--- +'@hey-api/openapi-ts': patch +--- + +fix: allow arbitrary object properties when additionalProperties is undefined diff --git a/.changeset/twelve-doors-look.md b/.changeset/twelve-doors-look.md index 78bfd33f8..a3daee739 100644 --- a/.changeset/twelve-doors-look.md +++ b/.changeset/twelve-doors-look.md @@ -2,4 +2,4 @@ '@hey-api/openapi-ts': patch --- -fix: support DEBUG environment variable +fix: support `DEBUG` environment variable 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 f37e99539..1170858c4 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 @@ -216,23 +216,27 @@ const parseObject = ({ irSchema.properties = schemaProperties; } - if (schema.additionalProperties !== undefined) { - if (typeof schema.additionalProperties === 'boolean') { + if (schema.additionalProperties === undefined) { + if (!irSchema.properties) { irSchema.additionalProperties = { - type: schema.additionalProperties ? 'unknown' : 'never', + type: 'unknown', }; - } else { - const irAdditionalPropertiesSchema = schemaToIrSchema({ - context, - schema: schema.additionalProperties, - }); - // no need to add "any" additional properties if there are no defined properties - if ( - irSchema.properties || - irAdditionalPropertiesSchema.type !== 'unknown' - ) { - irSchema.additionalProperties = irAdditionalPropertiesSchema; - } + } + } else if (typeof schema.additionalProperties === 'boolean') { + irSchema.additionalProperties = { + type: schema.additionalProperties ? 'unknown' : 'never', + }; + } else { + const irAdditionalPropertiesSchema = schemaToIrSchema({ + context, + schema: schema.additionalProperties, + }); + // no need to add "any" additional properties if there are no defined properties + if ( + irSchema.properties || + irAdditionalPropertiesSchema.type !== 'unknown' + ) { + irSchema.additionalProperties = irAdditionalPropertiesSchema; } } 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 a9746da51..f202ff36d 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 @@ -269,23 +269,27 @@ const parseObject = ({ irSchema.properties = schemaProperties; } - if (schema.additionalProperties !== undefined) { - if (typeof schema.additionalProperties === 'boolean') { + if (schema.additionalProperties === undefined) { + if (!irSchema.properties) { irSchema.additionalProperties = { - type: schema.additionalProperties ? 'unknown' : 'never', + type: 'unknown', }; - } else { - const irAdditionalPropertiesSchema = schemaToIrSchema({ - context, - schema: schema.additionalProperties, - }); - // no need to add "any" additional properties if there are no defined properties - if ( - irSchema.properties || - irAdditionalPropertiesSchema.type !== 'unknown' - ) { - irSchema.additionalProperties = irAdditionalPropertiesSchema; - } + } + } else if (typeof schema.additionalProperties === 'boolean') { + irSchema.additionalProperties = { + type: schema.additionalProperties ? 'unknown' : 'never', + }; + } else { + const irAdditionalPropertiesSchema = schemaToIrSchema({ + context, + schema: schema.additionalProperties, + }); + // no need to add "any" additional properties if there are no defined properties + if ( + irSchema.properties || + irAdditionalPropertiesSchema.type !== 'unknown' + ) { + irSchema.additionalProperties = irAdditionalPropertiesSchema; } } diff --git a/packages/openapi-ts/test/3.0.x.test.ts b/packages/openapi-ts/test/3.0.x.test.ts index ce09c85ca..23674654d 100644 --- a/packages/openapi-ts/test/3.0.x.test.ts +++ b/packages/openapi-ts/test/3.0.x.test.ts @@ -48,6 +48,13 @@ describe(`OpenAPI ${VERSION}`, () => { }), description: 'allows arbitrary properties on objects', }, + { + config: createConfig({ + input: 'additional-properties-undefined.json', + output: 'additional-properties-undefined', + }), + description: 'allows arbitrary properties on objects', + }, { config: createConfig({ input: 'array-items-one-of-length-1.json', diff --git a/packages/openapi-ts/test/3.1.x.test.ts b/packages/openapi-ts/test/3.1.x.test.ts index a0c1f91bb..4eca6bf3e 100644 --- a/packages/openapi-ts/test/3.1.x.test.ts +++ b/packages/openapi-ts/test/3.1.x.test.ts @@ -48,6 +48,13 @@ describe(`OpenAPI ${VERSION}`, () => { }), description: 'allows arbitrary properties on objects', }, + { + config: createConfig({ + input: 'additional-properties-undefined.json', + output: 'additional-properties-undefined', + }), + description: 'allows arbitrary properties on objects', + }, { config: createConfig({ input: 'array-items-one-of-length-1.json', diff --git a/packages/openapi-ts/test/__snapshots__/3.0.x/additional-properties-undefined/index.ts b/packages/openapi-ts/test/__snapshots__/3.0.x/additional-properties-undefined/index.ts new file mode 100644 index 000000000..56bade120 --- /dev/null +++ b/packages/openapi-ts/test/__snapshots__/3.0.x/additional-properties-undefined/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-undefined/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.0.x/additional-properties-undefined/types.gen.ts new file mode 100644 index 000000000..f518627e9 --- /dev/null +++ b/packages/openapi-ts/test/__snapshots__/3.0.x/additional-properties-undefined/types.gen.ts @@ -0,0 +1,7 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type Foo = { + foo: { + [key: string]: unknown; + }; +}; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/types.gen.ts index df5dd49eb..28972bf0b 100644 --- a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/types.gen.ts @@ -642,7 +642,9 @@ export type Pageable = { /** * This is a free-form object without additionalProperties. */ -export type FreeFormObjectWithoutAdditionalProperties = {}; +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: true. @@ -1124,7 +1126,9 @@ export type CallWithParametersData = { /** * This is the parameter that goes into the body */ - body: {} | null; + body: { + [key: string]: unknown; + } | null; headers: { /** * This is the parameter that goes into the header @@ -1599,7 +1603,9 @@ export type TypesData = { /** * This is an object parameter */ - parameterObject: {} | null; + parameterObject: { + [key: string]: unknown; + } | null; /** * This is an array parameter */ @@ -1607,7 +1613,9 @@ export type TypesData = { /** * This is a dictionary parameter */ - parameterDictionary: {} | null; + parameterDictionary: { + [key: string]: unknown; + } | null; /** * This is an enum parameter */ @@ -1632,7 +1640,9 @@ export type TypesResponses = { /** * Response is a simple object */ - 203: {}; + 203: { + [key: string]: unknown; + }; }; export type TypesResponse = TypesResponses[keyof TypesResponses]; 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 df5dd49eb..28972bf0b 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 @@ -642,7 +642,9 @@ export type Pageable = { /** * This is a free-form object without additionalProperties. */ -export type FreeFormObjectWithoutAdditionalProperties = {}; +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: true. @@ -1124,7 +1126,9 @@ export type CallWithParametersData = { /** * This is the parameter that goes into the body */ - body: {} | null; + body: { + [key: string]: unknown; + } | null; headers: { /** * This is the parameter that goes into the header @@ -1599,7 +1603,9 @@ export type TypesData = { /** * This is an object parameter */ - parameterObject: {} | null; + parameterObject: { + [key: string]: unknown; + } | null; /** * This is an array parameter */ @@ -1607,7 +1613,9 @@ export type TypesData = { /** * This is a dictionary parameter */ - parameterDictionary: {} | null; + parameterDictionary: { + [key: string]: unknown; + } | null; /** * This is an enum parameter */ @@ -1632,7 +1640,9 @@ export type TypesResponses = { /** * Response is a simple object */ - 203: {}; + 203: { + [key: string]: unknown; + }; }; export type TypesResponse = TypesResponses[keyof TypesResponses]; 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 df5dd49eb..28972bf0b 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 @@ -642,7 +642,9 @@ export type Pageable = { /** * This is a free-form object without additionalProperties. */ -export type FreeFormObjectWithoutAdditionalProperties = {}; +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: true. @@ -1124,7 +1126,9 @@ export type CallWithParametersData = { /** * This is the parameter that goes into the body */ - body: {} | null; + body: { + [key: string]: unknown; + } | null; headers: { /** * This is the parameter that goes into the header @@ -1599,7 +1603,9 @@ export type TypesData = { /** * This is an object parameter */ - parameterObject: {} | null; + parameterObject: { + [key: string]: unknown; + } | null; /** * This is an array parameter */ @@ -1607,7 +1613,9 @@ export type TypesData = { /** * This is a dictionary parameter */ - parameterDictionary: {} | null; + parameterDictionary: { + [key: string]: unknown; + } | null; /** * This is an enum parameter */ @@ -1632,7 +1640,9 @@ export type TypesResponses = { /** * Response is a simple object */ - 203: {}; + 203: { + [key: string]: unknown; + }; }; export type TypesResponse = TypesResponses[keyof TypesResponses]; 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 df5dd49eb..28972bf0b 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 @@ -642,7 +642,9 @@ export type Pageable = { /** * This is a free-form object without additionalProperties. */ -export type FreeFormObjectWithoutAdditionalProperties = {}; +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: true. @@ -1124,7 +1126,9 @@ export type CallWithParametersData = { /** * This is the parameter that goes into the body */ - body: {} | null; + body: { + [key: string]: unknown; + } | null; headers: { /** * This is the parameter that goes into the header @@ -1599,7 +1603,9 @@ export type TypesData = { /** * This is an object parameter */ - parameterObject: {} | null; + parameterObject: { + [key: string]: unknown; + } | null; /** * This is an array parameter */ @@ -1607,7 +1613,9 @@ export type TypesData = { /** * This is a dictionary parameter */ - parameterDictionary: {} | null; + parameterDictionary: { + [key: string]: unknown; + } | null; /** * This is an enum parameter */ @@ -1632,7 +1640,9 @@ export type TypesResponses = { /** * Response is a simple object */ - 203: {}; + 203: { + [key: string]: unknown; + }; }; export type TypesResponse = TypesResponses[keyof TypesResponses]; 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 df5dd49eb..28972bf0b 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 @@ -642,7 +642,9 @@ export type Pageable = { /** * This is a free-form object without additionalProperties. */ -export type FreeFormObjectWithoutAdditionalProperties = {}; +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: true. @@ -1124,7 +1126,9 @@ export type CallWithParametersData = { /** * This is the parameter that goes into the body */ - body: {} | null; + body: { + [key: string]: unknown; + } | null; headers: { /** * This is the parameter that goes into the header @@ -1599,7 +1603,9 @@ export type TypesData = { /** * This is an object parameter */ - parameterObject: {} | null; + parameterObject: { + [key: string]: unknown; + } | null; /** * This is an array parameter */ @@ -1607,7 +1613,9 @@ export type TypesData = { /** * This is a dictionary parameter */ - parameterDictionary: {} | null; + parameterDictionary: { + [key: string]: unknown; + } | null; /** * This is an enum parameter */ @@ -1632,7 +1640,9 @@ export type TypesResponses = { /** * Response is a simple object */ - 203: {}; + 203: { + [key: string]: unknown; + }; }; export type TypesResponse = TypesResponses[keyof TypesResponses]; 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 df5dd49eb..28972bf0b 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 @@ -642,7 +642,9 @@ export type Pageable = { /** * This is a free-form object without additionalProperties. */ -export type FreeFormObjectWithoutAdditionalProperties = {}; +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: true. @@ -1124,7 +1126,9 @@ export type CallWithParametersData = { /** * This is the parameter that goes into the body */ - body: {} | null; + body: { + [key: string]: unknown; + } | null; headers: { /** * This is the parameter that goes into the header @@ -1599,7 +1603,9 @@ export type TypesData = { /** * This is an object parameter */ - parameterObject: {} | null; + parameterObject: { + [key: string]: unknown; + } | null; /** * This is an array parameter */ @@ -1607,7 +1613,9 @@ export type TypesData = { /** * This is a dictionary parameter */ - parameterDictionary: {} | null; + parameterDictionary: { + [key: string]: unknown; + } | null; /** * This is an enum parameter */ @@ -1632,7 +1640,9 @@ export type TypesResponses = { /** * Response is a simple object */ - 203: {}; + 203: { + [key: string]: unknown; + }; }; export type TypesResponse = TypesResponses[keyof TypesResponses]; 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 df5dd49eb..28972bf0b 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 @@ -642,7 +642,9 @@ export type Pageable = { /** * This is a free-form object without additionalProperties. */ -export type FreeFormObjectWithoutAdditionalProperties = {}; +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: true. @@ -1124,7 +1126,9 @@ export type CallWithParametersData = { /** * This is the parameter that goes into the body */ - body: {} | null; + body: { + [key: string]: unknown; + } | null; headers: { /** * This is the parameter that goes into the header @@ -1599,7 +1603,9 @@ export type TypesData = { /** * This is an object parameter */ - parameterObject: {} | null; + parameterObject: { + [key: string]: unknown; + } | null; /** * This is an array parameter */ @@ -1607,7 +1613,9 @@ export type TypesData = { /** * This is a dictionary parameter */ - parameterDictionary: {} | null; + parameterDictionary: { + [key: string]: unknown; + } | null; /** * This is an enum parameter */ @@ -1632,7 +1640,9 @@ export type TypesResponses = { /** * Response is a simple object */ - 203: {}; + 203: { + [key: string]: unknown; + }; }; export type TypesResponse = TypesResponses[keyof TypesResponses]; 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 df5dd49eb..28972bf0b 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 @@ -642,7 +642,9 @@ export type Pageable = { /** * This is a free-form object without additionalProperties. */ -export type FreeFormObjectWithoutAdditionalProperties = {}; +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: true. @@ -1124,7 +1126,9 @@ export type CallWithParametersData = { /** * This is the parameter that goes into the body */ - body: {} | null; + body: { + [key: string]: unknown; + } | null; headers: { /** * This is the parameter that goes into the header @@ -1599,7 +1603,9 @@ export type TypesData = { /** * This is an object parameter */ - parameterObject: {} | null; + parameterObject: { + [key: string]: unknown; + } | null; /** * This is an array parameter */ @@ -1607,7 +1613,9 @@ export type TypesData = { /** * This is a dictionary parameter */ - parameterDictionary: {} | null; + parameterDictionary: { + [key: string]: unknown; + } | null; /** * This is an enum parameter */ @@ -1632,7 +1640,9 @@ export type TypesResponses = { /** * Response is a simple object */ - 203: {}; + 203: { + [key: string]: unknown; + }; }; export type TypesResponse = TypesResponses[keyof TypesResponses]; 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 df5dd49eb..28972bf0b 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 @@ -642,7 +642,9 @@ export type Pageable = { /** * This is a free-form object without additionalProperties. */ -export type FreeFormObjectWithoutAdditionalProperties = {}; +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: true. @@ -1124,7 +1126,9 @@ export type CallWithParametersData = { /** * This is the parameter that goes into the body */ - body: {} | null; + body: { + [key: string]: unknown; + } | null; headers: { /** * This is the parameter that goes into the header @@ -1599,7 +1603,9 @@ export type TypesData = { /** * This is an object parameter */ - parameterObject: {} | null; + parameterObject: { + [key: string]: unknown; + } | null; /** * This is an array parameter */ @@ -1607,7 +1613,9 @@ export type TypesData = { /** * This is a dictionary parameter */ - parameterDictionary: {} | null; + parameterDictionary: { + [key: string]: unknown; + } | null; /** * This is an enum parameter */ @@ -1632,7 +1640,9 @@ export type TypesResponses = { /** * Response is a simple object */ - 203: {}; + 203: { + [key: string]: unknown; + }; }; export type TypesResponse = TypesResponses[keyof TypesResponses]; 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 df5dd49eb..28972bf0b 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 @@ -642,7 +642,9 @@ export type Pageable = { /** * This is a free-form object without additionalProperties. */ -export type FreeFormObjectWithoutAdditionalProperties = {}; +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: true. @@ -1124,7 +1126,9 @@ export type CallWithParametersData = { /** * This is the parameter that goes into the body */ - body: {} | null; + body: { + [key: string]: unknown; + } | null; headers: { /** * This is the parameter that goes into the header @@ -1599,7 +1603,9 @@ export type TypesData = { /** * This is an object parameter */ - parameterObject: {} | null; + parameterObject: { + [key: string]: unknown; + } | null; /** * This is an array parameter */ @@ -1607,7 +1613,9 @@ export type TypesData = { /** * This is a dictionary parameter */ - parameterDictionary: {} | null; + parameterDictionary: { + [key: string]: unknown; + } | null; /** * This is an enum parameter */ @@ -1632,7 +1640,9 @@ export type TypesResponses = { /** * Response is a simple object */ - 203: {}; + 203: { + [key: string]: unknown; + }; }; export type TypesResponse = TypesResponses[keyof TypesResponses]; 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 df5dd49eb..28972bf0b 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 @@ -642,7 +642,9 @@ export type Pageable = { /** * This is a free-form object without additionalProperties. */ -export type FreeFormObjectWithoutAdditionalProperties = {}; +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: true. @@ -1124,7 +1126,9 @@ export type CallWithParametersData = { /** * This is the parameter that goes into the body */ - body: {} | null; + body: { + [key: string]: unknown; + } | null; headers: { /** * This is the parameter that goes into the header @@ -1599,7 +1603,9 @@ export type TypesData = { /** * This is an object parameter */ - parameterObject: {} | null; + parameterObject: { + [key: string]: unknown; + } | null; /** * This is an array parameter */ @@ -1607,7 +1613,9 @@ export type TypesData = { /** * This is a dictionary parameter */ - parameterDictionary: {} | null; + parameterDictionary: { + [key: string]: unknown; + } | null; /** * This is an enum parameter */ @@ -1632,7 +1640,9 @@ export type TypesResponses = { /** * Response is a simple object */ - 203: {}; + 203: { + [key: string]: unknown; + }; }; export type TypesResponse = TypesResponses[keyof TypesResponses]; 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 df5dd49eb..28972bf0b 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 @@ -642,7 +642,9 @@ export type Pageable = { /** * This is a free-form object without additionalProperties. */ -export type FreeFormObjectWithoutAdditionalProperties = {}; +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: true. @@ -1124,7 +1126,9 @@ export type CallWithParametersData = { /** * This is the parameter that goes into the body */ - body: {} | null; + body: { + [key: string]: unknown; + } | null; headers: { /** * This is the parameter that goes into the header @@ -1599,7 +1603,9 @@ export type TypesData = { /** * This is an object parameter */ - parameterObject: {} | null; + parameterObject: { + [key: string]: unknown; + } | null; /** * This is an array parameter */ @@ -1607,7 +1613,9 @@ export type TypesData = { /** * This is a dictionary parameter */ - parameterDictionary: {} | null; + parameterDictionary: { + [key: string]: unknown; + } | null; /** * This is an enum parameter */ @@ -1632,7 +1640,9 @@ export type TypesResponses = { /** * Response is a simple object */ - 203: {}; + 203: { + [key: string]: unknown; + }; }; export type TypesResponse = TypesResponses[keyof TypesResponses]; 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 df5dd49eb..28972bf0b 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 @@ -642,7 +642,9 @@ export type Pageable = { /** * This is a free-form object without additionalProperties. */ -export type FreeFormObjectWithoutAdditionalProperties = {}; +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: true. @@ -1124,7 +1126,9 @@ export type CallWithParametersData = { /** * This is the parameter that goes into the body */ - body: {} | null; + body: { + [key: string]: unknown; + } | null; headers: { /** * This is the parameter that goes into the header @@ -1599,7 +1603,9 @@ export type TypesData = { /** * This is an object parameter */ - parameterObject: {} | null; + parameterObject: { + [key: string]: unknown; + } | null; /** * This is an array parameter */ @@ -1607,7 +1613,9 @@ export type TypesData = { /** * This is a dictionary parameter */ - parameterDictionary: {} | null; + parameterDictionary: { + [key: string]: unknown; + } | null; /** * This is an enum parameter */ @@ -1632,7 +1640,9 @@ export type TypesResponses = { /** * Response is a simple object */ - 203: {}; + 203: { + [key: string]: unknown; + }; }; export type TypesResponse = TypesResponses[keyof TypesResponses]; 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 df5dd49eb..28972bf0b 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 @@ -642,7 +642,9 @@ export type Pageable = { /** * This is a free-form object without additionalProperties. */ -export type FreeFormObjectWithoutAdditionalProperties = {}; +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: true. @@ -1124,7 +1126,9 @@ export type CallWithParametersData = { /** * This is the parameter that goes into the body */ - body: {} | null; + body: { + [key: string]: unknown; + } | null; headers: { /** * This is the parameter that goes into the header @@ -1599,7 +1603,9 @@ export type TypesData = { /** * This is an object parameter */ - parameterObject: {} | null; + parameterObject: { + [key: string]: unknown; + } | null; /** * This is an array parameter */ @@ -1607,7 +1613,9 @@ export type TypesData = { /** * This is a dictionary parameter */ - parameterDictionary: {} | null; + parameterDictionary: { + [key: string]: unknown; + } | null; /** * This is an enum parameter */ @@ -1632,7 +1640,9 @@ export type TypesResponses = { /** * Response is a simple object */ - 203: {}; + 203: { + [key: string]: unknown; + }; }; export type TypesResponse = TypesResponses[keyof TypesResponses]; 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 df5dd49eb..28972bf0b 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 @@ -642,7 +642,9 @@ export type Pageable = { /** * This is a free-form object without additionalProperties. */ -export type FreeFormObjectWithoutAdditionalProperties = {}; +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: true. @@ -1124,7 +1126,9 @@ export type CallWithParametersData = { /** * This is the parameter that goes into the body */ - body: {} | null; + body: { + [key: string]: unknown; + } | null; headers: { /** * This is the parameter that goes into the header @@ -1599,7 +1603,9 @@ export type TypesData = { /** * This is an object parameter */ - parameterObject: {} | null; + parameterObject: { + [key: string]: unknown; + } | null; /** * This is an array parameter */ @@ -1607,7 +1613,9 @@ export type TypesData = { /** * This is a dictionary parameter */ - parameterDictionary: {} | null; + parameterDictionary: { + [key: string]: unknown; + } | null; /** * This is an enum parameter */ @@ -1632,7 +1640,9 @@ export type TypesResponses = { /** * Response is a simple object */ - 203: {}; + 203: { + [key: string]: unknown; + }; }; export type TypesResponse = TypesResponses[keyof TypesResponses]; 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 df5dd49eb..28972bf0b 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 @@ -642,7 +642,9 @@ export type Pageable = { /** * This is a free-form object without additionalProperties. */ -export type FreeFormObjectWithoutAdditionalProperties = {}; +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: true. @@ -1124,7 +1126,9 @@ export type CallWithParametersData = { /** * This is the parameter that goes into the body */ - body: {} | null; + body: { + [key: string]: unknown; + } | null; headers: { /** * This is the parameter that goes into the header @@ -1599,7 +1603,9 @@ export type TypesData = { /** * This is an object parameter */ - parameterObject: {} | null; + parameterObject: { + [key: string]: unknown; + } | null; /** * This is an array parameter */ @@ -1607,7 +1613,9 @@ export type TypesData = { /** * This is a dictionary parameter */ - parameterDictionary: {} | null; + parameterDictionary: { + [key: string]: unknown; + } | null; /** * This is an enum parameter */ @@ -1632,7 +1640,9 @@ export type TypesResponses = { /** * Response is a simple object */ - 203: {}; + 203: { + [key: string]: unknown; + }; }; export type TypesResponse = TypesResponses[keyof TypesResponses]; diff --git a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/fastify/default/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/fastify/default/types.gen.ts index df5dd49eb..28972bf0b 100644 --- a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/fastify/default/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/fastify/default/types.gen.ts @@ -642,7 +642,9 @@ export type Pageable = { /** * This is a free-form object without additionalProperties. */ -export type FreeFormObjectWithoutAdditionalProperties = {}; +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: true. @@ -1124,7 +1126,9 @@ export type CallWithParametersData = { /** * This is the parameter that goes into the body */ - body: {} | null; + body: { + [key: string]: unknown; + } | null; headers: { /** * This is the parameter that goes into the header @@ -1599,7 +1603,9 @@ export type TypesData = { /** * This is an object parameter */ - parameterObject: {} | null; + parameterObject: { + [key: string]: unknown; + } | null; /** * This is an array parameter */ @@ -1607,7 +1613,9 @@ export type TypesData = { /** * This is a dictionary parameter */ - parameterDictionary: {} | null; + parameterDictionary: { + [key: string]: unknown; + } | null; /** * This is an enum parameter */ @@ -1632,7 +1640,9 @@ export type TypesResponses = { /** * Response is a simple object */ - 203: {}; + 203: { + [key: string]: unknown; + }; }; export type TypesResponse = TypesResponses[keyof TypesResponses]; diff --git a/packages/openapi-ts/test/__snapshots__/3.1.x/additional-properties-undefined/index.ts b/packages/openapi-ts/test/__snapshots__/3.1.x/additional-properties-undefined/index.ts new file mode 100644 index 000000000..56bade120 --- /dev/null +++ b/packages/openapi-ts/test/__snapshots__/3.1.x/additional-properties-undefined/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-undefined/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.1.x/additional-properties-undefined/types.gen.ts new file mode 100644 index 000000000..f518627e9 --- /dev/null +++ b/packages/openapi-ts/test/__snapshots__/3.1.x/additional-properties-undefined/types.gen.ts @@ -0,0 +1,7 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type Foo = { + foo: { + [key: string]: unknown; + }; +}; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/types.gen.ts index 80feb8eba..99c0654c9 100644 --- a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/types.gen.ts @@ -642,7 +642,9 @@ export type Pageable = { /** * This is a free-form object without additionalProperties. */ -export type FreeFormObjectWithoutAdditionalProperties = {}; +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: true. @@ -1134,7 +1136,9 @@ export type CallWithParametersData = { /** * This is the parameter that goes into the body */ - body: {} | null; + body: { + [key: string]: unknown; + } | null; headers: { /** * This is the parameter that goes into the header @@ -1609,7 +1613,9 @@ export type TypesData = { /** * This is an object parameter */ - parameterObject: {} | null; + parameterObject: { + [key: string]: unknown; + } | null; /** * This is an array parameter */ @@ -1617,7 +1623,9 @@ export type TypesData = { /** * This is a dictionary parameter */ - parameterDictionary: {} | null; + parameterDictionary: { + [key: string]: unknown; + } | null; /** * This is an enum parameter */ @@ -1642,7 +1650,9 @@ export type TypesResponses = { /** * Response is a simple object */ - 203: {}; + 203: { + [key: string]: unknown; + }; }; export type TypesResponse = TypesResponses[keyof TypesResponses]; 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 80feb8eba..99c0654c9 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 @@ -642,7 +642,9 @@ export type Pageable = { /** * This is a free-form object without additionalProperties. */ -export type FreeFormObjectWithoutAdditionalProperties = {}; +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: true. @@ -1134,7 +1136,9 @@ export type CallWithParametersData = { /** * This is the parameter that goes into the body */ - body: {} | null; + body: { + [key: string]: unknown; + } | null; headers: { /** * This is the parameter that goes into the header @@ -1609,7 +1613,9 @@ export type TypesData = { /** * This is an object parameter */ - parameterObject: {} | null; + parameterObject: { + [key: string]: unknown; + } | null; /** * This is an array parameter */ @@ -1617,7 +1623,9 @@ export type TypesData = { /** * This is a dictionary parameter */ - parameterDictionary: {} | null; + parameterDictionary: { + [key: string]: unknown; + } | null; /** * This is an enum parameter */ @@ -1642,7 +1650,9 @@ export type TypesResponses = { /** * Response is a simple object */ - 203: {}; + 203: { + [key: string]: unknown; + }; }; export type TypesResponse = TypesResponses[keyof TypesResponses]; 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 80feb8eba..99c0654c9 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 @@ -642,7 +642,9 @@ export type Pageable = { /** * This is a free-form object without additionalProperties. */ -export type FreeFormObjectWithoutAdditionalProperties = {}; +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: true. @@ -1134,7 +1136,9 @@ export type CallWithParametersData = { /** * This is the parameter that goes into the body */ - body: {} | null; + body: { + [key: string]: unknown; + } | null; headers: { /** * This is the parameter that goes into the header @@ -1609,7 +1613,9 @@ export type TypesData = { /** * This is an object parameter */ - parameterObject: {} | null; + parameterObject: { + [key: string]: unknown; + } | null; /** * This is an array parameter */ @@ -1617,7 +1623,9 @@ export type TypesData = { /** * This is a dictionary parameter */ - parameterDictionary: {} | null; + parameterDictionary: { + [key: string]: unknown; + } | null; /** * This is an enum parameter */ @@ -1642,7 +1650,9 @@ export type TypesResponses = { /** * Response is a simple object */ - 203: {}; + 203: { + [key: string]: unknown; + }; }; export type TypesResponse = TypesResponses[keyof TypesResponses]; 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 80feb8eba..99c0654c9 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 @@ -642,7 +642,9 @@ export type Pageable = { /** * This is a free-form object without additionalProperties. */ -export type FreeFormObjectWithoutAdditionalProperties = {}; +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: true. @@ -1134,7 +1136,9 @@ export type CallWithParametersData = { /** * This is the parameter that goes into the body */ - body: {} | null; + body: { + [key: string]: unknown; + } | null; headers: { /** * This is the parameter that goes into the header @@ -1609,7 +1613,9 @@ export type TypesData = { /** * This is an object parameter */ - parameterObject: {} | null; + parameterObject: { + [key: string]: unknown; + } | null; /** * This is an array parameter */ @@ -1617,7 +1623,9 @@ export type TypesData = { /** * This is a dictionary parameter */ - parameterDictionary: {} | null; + parameterDictionary: { + [key: string]: unknown; + } | null; /** * This is an enum parameter */ @@ -1642,7 +1650,9 @@ export type TypesResponses = { /** * Response is a simple object */ - 203: {}; + 203: { + [key: string]: unknown; + }; }; export type TypesResponse = TypesResponses[keyof TypesResponses]; 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 80feb8eba..99c0654c9 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 @@ -642,7 +642,9 @@ export type Pageable = { /** * This is a free-form object without additionalProperties. */ -export type FreeFormObjectWithoutAdditionalProperties = {}; +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: true. @@ -1134,7 +1136,9 @@ export type CallWithParametersData = { /** * This is the parameter that goes into the body */ - body: {} | null; + body: { + [key: string]: unknown; + } | null; headers: { /** * This is the parameter that goes into the header @@ -1609,7 +1613,9 @@ export type TypesData = { /** * This is an object parameter */ - parameterObject: {} | null; + parameterObject: { + [key: string]: unknown; + } | null; /** * This is an array parameter */ @@ -1617,7 +1623,9 @@ export type TypesData = { /** * This is a dictionary parameter */ - parameterDictionary: {} | null; + parameterDictionary: { + [key: string]: unknown; + } | null; /** * This is an enum parameter */ @@ -1642,7 +1650,9 @@ export type TypesResponses = { /** * Response is a simple object */ - 203: {}; + 203: { + [key: string]: unknown; + }; }; export type TypesResponse = TypesResponses[keyof TypesResponses]; 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 80feb8eba..99c0654c9 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 @@ -642,7 +642,9 @@ export type Pageable = { /** * This is a free-form object without additionalProperties. */ -export type FreeFormObjectWithoutAdditionalProperties = {}; +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: true. @@ -1134,7 +1136,9 @@ export type CallWithParametersData = { /** * This is the parameter that goes into the body */ - body: {} | null; + body: { + [key: string]: unknown; + } | null; headers: { /** * This is the parameter that goes into the header @@ -1609,7 +1613,9 @@ export type TypesData = { /** * This is an object parameter */ - parameterObject: {} | null; + parameterObject: { + [key: string]: unknown; + } | null; /** * This is an array parameter */ @@ -1617,7 +1623,9 @@ export type TypesData = { /** * This is a dictionary parameter */ - parameterDictionary: {} | null; + parameterDictionary: { + [key: string]: unknown; + } | null; /** * This is an enum parameter */ @@ -1642,7 +1650,9 @@ export type TypesResponses = { /** * Response is a simple object */ - 203: {}; + 203: { + [key: string]: unknown; + }; }; export type TypesResponse = TypesResponses[keyof TypesResponses]; 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 80feb8eba..99c0654c9 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 @@ -642,7 +642,9 @@ export type Pageable = { /** * This is a free-form object without additionalProperties. */ -export type FreeFormObjectWithoutAdditionalProperties = {}; +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: true. @@ -1134,7 +1136,9 @@ export type CallWithParametersData = { /** * This is the parameter that goes into the body */ - body: {} | null; + body: { + [key: string]: unknown; + } | null; headers: { /** * This is the parameter that goes into the header @@ -1609,7 +1613,9 @@ export type TypesData = { /** * This is an object parameter */ - parameterObject: {} | null; + parameterObject: { + [key: string]: unknown; + } | null; /** * This is an array parameter */ @@ -1617,7 +1623,9 @@ export type TypesData = { /** * This is a dictionary parameter */ - parameterDictionary: {} | null; + parameterDictionary: { + [key: string]: unknown; + } | null; /** * This is an enum parameter */ @@ -1642,7 +1650,9 @@ export type TypesResponses = { /** * Response is a simple object */ - 203: {}; + 203: { + [key: string]: unknown; + }; }; export type TypesResponse = TypesResponses[keyof TypesResponses]; 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 80feb8eba..99c0654c9 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 @@ -642,7 +642,9 @@ export type Pageable = { /** * This is a free-form object without additionalProperties. */ -export type FreeFormObjectWithoutAdditionalProperties = {}; +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: true. @@ -1134,7 +1136,9 @@ export type CallWithParametersData = { /** * This is the parameter that goes into the body */ - body: {} | null; + body: { + [key: string]: unknown; + } | null; headers: { /** * This is the parameter that goes into the header @@ -1609,7 +1613,9 @@ export type TypesData = { /** * This is an object parameter */ - parameterObject: {} | null; + parameterObject: { + [key: string]: unknown; + } | null; /** * This is an array parameter */ @@ -1617,7 +1623,9 @@ export type TypesData = { /** * This is a dictionary parameter */ - parameterDictionary: {} | null; + parameterDictionary: { + [key: string]: unknown; + } | null; /** * This is an enum parameter */ @@ -1642,7 +1650,9 @@ export type TypesResponses = { /** * Response is a simple object */ - 203: {}; + 203: { + [key: string]: unknown; + }; }; export type TypesResponse = TypesResponses[keyof TypesResponses]; 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 80feb8eba..99c0654c9 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 @@ -642,7 +642,9 @@ export type Pageable = { /** * This is a free-form object without additionalProperties. */ -export type FreeFormObjectWithoutAdditionalProperties = {}; +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: true. @@ -1134,7 +1136,9 @@ export type CallWithParametersData = { /** * This is the parameter that goes into the body */ - body: {} | null; + body: { + [key: string]: unknown; + } | null; headers: { /** * This is the parameter that goes into the header @@ -1609,7 +1613,9 @@ export type TypesData = { /** * This is an object parameter */ - parameterObject: {} | null; + parameterObject: { + [key: string]: unknown; + } | null; /** * This is an array parameter */ @@ -1617,7 +1623,9 @@ export type TypesData = { /** * This is a dictionary parameter */ - parameterDictionary: {} | null; + parameterDictionary: { + [key: string]: unknown; + } | null; /** * This is an enum parameter */ @@ -1642,7 +1650,9 @@ export type TypesResponses = { /** * Response is a simple object */ - 203: {}; + 203: { + [key: string]: unknown; + }; }; export type TypesResponse = TypesResponses[keyof TypesResponses]; 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 80feb8eba..99c0654c9 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 @@ -642,7 +642,9 @@ export type Pageable = { /** * This is a free-form object without additionalProperties. */ -export type FreeFormObjectWithoutAdditionalProperties = {}; +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: true. @@ -1134,7 +1136,9 @@ export type CallWithParametersData = { /** * This is the parameter that goes into the body */ - body: {} | null; + body: { + [key: string]: unknown; + } | null; headers: { /** * This is the parameter that goes into the header @@ -1609,7 +1613,9 @@ export type TypesData = { /** * This is an object parameter */ - parameterObject: {} | null; + parameterObject: { + [key: string]: unknown; + } | null; /** * This is an array parameter */ @@ -1617,7 +1623,9 @@ export type TypesData = { /** * This is a dictionary parameter */ - parameterDictionary: {} | null; + parameterDictionary: { + [key: string]: unknown; + } | null; /** * This is an enum parameter */ @@ -1642,7 +1650,9 @@ export type TypesResponses = { /** * Response is a simple object */ - 203: {}; + 203: { + [key: string]: unknown; + }; }; export type TypesResponse = TypesResponses[keyof TypesResponses]; 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 80feb8eba..99c0654c9 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 @@ -642,7 +642,9 @@ export type Pageable = { /** * This is a free-form object without additionalProperties. */ -export type FreeFormObjectWithoutAdditionalProperties = {}; +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: true. @@ -1134,7 +1136,9 @@ export type CallWithParametersData = { /** * This is the parameter that goes into the body */ - body: {} | null; + body: { + [key: string]: unknown; + } | null; headers: { /** * This is the parameter that goes into the header @@ -1609,7 +1613,9 @@ export type TypesData = { /** * This is an object parameter */ - parameterObject: {} | null; + parameterObject: { + [key: string]: unknown; + } | null; /** * This is an array parameter */ @@ -1617,7 +1623,9 @@ export type TypesData = { /** * This is a dictionary parameter */ - parameterDictionary: {} | null; + parameterDictionary: { + [key: string]: unknown; + } | null; /** * This is an enum parameter */ @@ -1642,7 +1650,9 @@ export type TypesResponses = { /** * Response is a simple object */ - 203: {}; + 203: { + [key: string]: unknown; + }; }; export type TypesResponse = TypesResponses[keyof TypesResponses]; 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 80feb8eba..99c0654c9 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 @@ -642,7 +642,9 @@ export type Pageable = { /** * This is a free-form object without additionalProperties. */ -export type FreeFormObjectWithoutAdditionalProperties = {}; +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: true. @@ -1134,7 +1136,9 @@ export type CallWithParametersData = { /** * This is the parameter that goes into the body */ - body: {} | null; + body: { + [key: string]: unknown; + } | null; headers: { /** * This is the parameter that goes into the header @@ -1609,7 +1613,9 @@ export type TypesData = { /** * This is an object parameter */ - parameterObject: {} | null; + parameterObject: { + [key: string]: unknown; + } | null; /** * This is an array parameter */ @@ -1617,7 +1623,9 @@ export type TypesData = { /** * This is a dictionary parameter */ - parameterDictionary: {} | null; + parameterDictionary: { + [key: string]: unknown; + } | null; /** * This is an enum parameter */ @@ -1642,7 +1650,9 @@ export type TypesResponses = { /** * Response is a simple object */ - 203: {}; + 203: { + [key: string]: unknown; + }; }; export type TypesResponse = TypesResponses[keyof TypesResponses]; 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 80feb8eba..99c0654c9 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 @@ -642,7 +642,9 @@ export type Pageable = { /** * This is a free-form object without additionalProperties. */ -export type FreeFormObjectWithoutAdditionalProperties = {}; +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: true. @@ -1134,7 +1136,9 @@ export type CallWithParametersData = { /** * This is the parameter that goes into the body */ - body: {} | null; + body: { + [key: string]: unknown; + } | null; headers: { /** * This is the parameter that goes into the header @@ -1609,7 +1613,9 @@ export type TypesData = { /** * This is an object parameter */ - parameterObject: {} | null; + parameterObject: { + [key: string]: unknown; + } | null; /** * This is an array parameter */ @@ -1617,7 +1623,9 @@ export type TypesData = { /** * This is a dictionary parameter */ - parameterDictionary: {} | null; + parameterDictionary: { + [key: string]: unknown; + } | null; /** * This is an enum parameter */ @@ -1642,7 +1650,9 @@ export type TypesResponses = { /** * Response is a simple object */ - 203: {}; + 203: { + [key: string]: unknown; + }; }; export type TypesResponse = TypesResponses[keyof TypesResponses]; 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 80feb8eba..99c0654c9 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 @@ -642,7 +642,9 @@ export type Pageable = { /** * This is a free-form object without additionalProperties. */ -export type FreeFormObjectWithoutAdditionalProperties = {}; +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: true. @@ -1134,7 +1136,9 @@ export type CallWithParametersData = { /** * This is the parameter that goes into the body */ - body: {} | null; + body: { + [key: string]: unknown; + } | null; headers: { /** * This is the parameter that goes into the header @@ -1609,7 +1613,9 @@ export type TypesData = { /** * This is an object parameter */ - parameterObject: {} | null; + parameterObject: { + [key: string]: unknown; + } | null; /** * This is an array parameter */ @@ -1617,7 +1623,9 @@ export type TypesData = { /** * This is a dictionary parameter */ - parameterDictionary: {} | null; + parameterDictionary: { + [key: string]: unknown; + } | null; /** * This is an enum parameter */ @@ -1642,7 +1650,9 @@ export type TypesResponses = { /** * Response is a simple object */ - 203: {}; + 203: { + [key: string]: unknown; + }; }; export type TypesResponse = TypesResponses[keyof TypesResponses]; 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 80feb8eba..99c0654c9 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 @@ -642,7 +642,9 @@ export type Pageable = { /** * This is a free-form object without additionalProperties. */ -export type FreeFormObjectWithoutAdditionalProperties = {}; +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: true. @@ -1134,7 +1136,9 @@ export type CallWithParametersData = { /** * This is the parameter that goes into the body */ - body: {} | null; + body: { + [key: string]: unknown; + } | null; headers: { /** * This is the parameter that goes into the header @@ -1609,7 +1613,9 @@ export type TypesData = { /** * This is an object parameter */ - parameterObject: {} | null; + parameterObject: { + [key: string]: unknown; + } | null; /** * This is an array parameter */ @@ -1617,7 +1623,9 @@ export type TypesData = { /** * This is a dictionary parameter */ - parameterDictionary: {} | null; + parameterDictionary: { + [key: string]: unknown; + } | null; /** * This is an enum parameter */ @@ -1642,7 +1650,9 @@ export type TypesResponses = { /** * Response is a simple object */ - 203: {}; + 203: { + [key: string]: unknown; + }; }; export type TypesResponse = TypesResponses[keyof TypesResponses]; 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 80feb8eba..99c0654c9 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 @@ -642,7 +642,9 @@ export type Pageable = { /** * This is a free-form object without additionalProperties. */ -export type FreeFormObjectWithoutAdditionalProperties = {}; +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: true. @@ -1134,7 +1136,9 @@ export type CallWithParametersData = { /** * This is the parameter that goes into the body */ - body: {} | null; + body: { + [key: string]: unknown; + } | null; headers: { /** * This is the parameter that goes into the header @@ -1609,7 +1613,9 @@ export type TypesData = { /** * This is an object parameter */ - parameterObject: {} | null; + parameterObject: { + [key: string]: unknown; + } | null; /** * This is an array parameter */ @@ -1617,7 +1623,9 @@ export type TypesData = { /** * This is a dictionary parameter */ - parameterDictionary: {} | null; + parameterDictionary: { + [key: string]: unknown; + } | null; /** * This is an enum parameter */ @@ -1642,7 +1650,9 @@ export type TypesResponses = { /** * Response is a simple object */ - 203: {}; + 203: { + [key: string]: unknown; + }; }; export type TypesResponse = TypesResponses[keyof TypesResponses]; diff --git a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/fastify/default/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/fastify/default/types.gen.ts index 80feb8eba..99c0654c9 100644 --- a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/fastify/default/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/fastify/default/types.gen.ts @@ -642,7 +642,9 @@ export type Pageable = { /** * This is a free-form object without additionalProperties. */ -export type FreeFormObjectWithoutAdditionalProperties = {}; +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; /** * This is a free-form object with additionalProperties: true. @@ -1134,7 +1136,9 @@ export type CallWithParametersData = { /** * This is the parameter that goes into the body */ - body: {} | null; + body: { + [key: string]: unknown; + } | null; headers: { /** * This is the parameter that goes into the header @@ -1609,7 +1613,9 @@ export type TypesData = { /** * This is an object parameter */ - parameterObject: {} | null; + parameterObject: { + [key: string]: unknown; + } | null; /** * This is an array parameter */ @@ -1617,7 +1623,9 @@ export type TypesData = { /** * This is a dictionary parameter */ - parameterDictionary: {} | null; + parameterDictionary: { + [key: string]: unknown; + } | null; /** * This is an enum parameter */ @@ -1642,7 +1650,9 @@ export type TypesResponses = { /** * Response is a simple object */ - 203: {}; + 203: { + [key: string]: unknown; + }; }; export type TypesResponse = TypesResponses[keyof TypesResponses]; diff --git a/packages/openapi-ts/test/sample.cjs b/packages/openapi-ts/test/sample.cjs index 6e34c47cf..772cb7372 100644 --- a/packages/openapi-ts/test/sample.cjs +++ b/packages/openapi-ts/test/sample.cjs @@ -13,7 +13,7 @@ const main = async () => { exclude: '^#/components/schemas/ModelWithCircularReference$', // include: // '^(#/components/schemas/import|#/paths/api/v{api-version}/simple/options)$', - path: './test/spec/3.1.x/transformers-all-of.yaml', + path: './test/spec/3.1.x/additional-properties-undefined.json', // path: 'https://mongodb-mms-prod-build-server.s3.amazonaws.com/openapi/2caffd88277a4e27c95dcefc7e3b6a63a3b03297-v2-2023-11-15.json', }, logs: { @@ -41,7 +41,7 @@ const main = async () => { }, { dates: true, - name: '@hey-api/transformers', + // name: '@hey-api/transformers', }, { // enums: 'typescript', diff --git a/packages/openapi-ts/test/spec/3.0.x/additional-properties-undefined.json b/packages/openapi-ts/test/spec/3.0.x/additional-properties-undefined.json new file mode 100644 index 000000000..3fa6f1d4c --- /dev/null +++ b/packages/openapi-ts/test/spec/3.0.x/additional-properties-undefined.json @@ -0,0 +1,20 @@ +{ + "openapi": "3.0.4", + "info": { + "title": "OpenAPI 3.0.4 additional properties undefined example", + "version": "1" + }, + "components": { + "schemas": { + "Foo": { + "properties": { + "foo": { + "type": "object" + } + }, + "required": ["foo"], + "type": "object" + } + } + } +} diff --git a/packages/openapi-ts/test/spec/3.1.x/additional-properties-undefined.json b/packages/openapi-ts/test/spec/3.1.x/additional-properties-undefined.json new file mode 100644 index 000000000..a5617f6f9 --- /dev/null +++ b/packages/openapi-ts/test/spec/3.1.x/additional-properties-undefined.json @@ -0,0 +1,20 @@ +{ + "openapi": "3.1.1", + "info": { + "title": "OpenAPI 3.1.1 additional properties undefined example", + "version": "1" + }, + "components": { + "schemas": { + "Foo": { + "properties": { + "foo": { + "type": "object" + } + }, + "required": ["foo"], + "type": "object" + } + } + } +}