diff --git a/packages/core/src/generators/interface.ts b/packages/core/src/generators/interface.ts index 907e23752..837a20166 100644 --- a/packages/core/src/generators/interface.ts +++ b/packages/core/src/generators/interface.ts @@ -46,7 +46,11 @@ export const generateInterface = ({ scalar.type === 'object' && !context?.output.override?.useTypeOverInterfaces ) { - model += `export interface ${name} ${scalar.value}\n`; + // If `scalar.value` is 'unknown', replace it with `{}` to avoid type error + const blankInterfaceValue = + scalar.value === 'unknown' ? '{}' : scalar.value; + + model += `export interface ${name} ${blankInterfaceValue}\n`; } else { model += `export type ${name} = ${scalar.value};\n`; } diff --git a/packages/core/src/getters/object.ts b/packages/core/src/getters/object.ts index cc0ba6389..ea4d2cb73 100644 --- a/packages/core/src/getters/object.ts +++ b/packages/core/src/getters/object.ts @@ -202,16 +202,10 @@ export const getObject = ({ }; } - const useTypeOverInterfaces = context?.output.override?.useTypeOverInterfaces; - const blankValue = - item.type === 'object' - ? '{ [key: string]: any }' - : useTypeOverInterfaces - ? 'unknown' - : '{}'; - return { - value: blankValue + nullable, + value: + (item.type === 'object' ? '{ [key: string]: any }' : 'unknown') + + nullable, imports: [], schemas: [], isEnum: false, diff --git a/tests/specifications/regressions.yaml b/tests/specifications/regressions.yaml index afe264f47..963cdbf5c 100644 --- a/tests/specifications/regressions.yaml +++ b/tests/specifications/regressions.yaml @@ -19,6 +19,11 @@ components: items: type: string nullable: true + BlankSchema: {} + NotDifinedType: + properties: + id: + description: not defined type schema paths: /endpointA: get: