From 4128a8a4dc5c1b19d97ed8c776b89883b8bfbd56 Mon Sep 17 00:00:00 2001 From: soartec-lab Date: Mon, 19 Feb 2024 08:58:05 +0900 Subject: [PATCH 1/4] Revert "fix(core): implement `{}` insterd of `unknown` for blank schema interface (#1219)" This reverts commit 97552e46ffce0f13afc15d7edb19c398c5dd3f50. --- packages/core/src/getters/object.ts | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) 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, From 7da42a8394b4054f14acb9d4363575d26063eae1 Mon Sep 17 00:00:00 2001 From: soartec-lab Date: Mon, 19 Feb 2024 00:03:05 +0000 Subject: [PATCH 2/4] fix(core): fix unintended conversion of blank schema --- packages/core/src/generators/interface.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/core/src/generators/interface.ts b/packages/core/src/generators/interface.ts index 907e23752..ab2fbafe0 100644 --- a/packages/core/src/generators/interface.ts +++ b/packages/core/src/generators/interface.ts @@ -46,7 +46,10 @@ 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 blankIntefaceValue = scalar.value === 'unknown' ? '{}' : scalar.value; + + model += `export interface ${name} ${blankIntefaceValue}\n`; } else { model += `export type ${name} = ${scalar.value};\n`; } From 564dd8ee2015b91ce23089c7d11fd3cc9ec88b1f Mon Sep 17 00:00:00 2001 From: soartec-lab Date: Thu, 29 Feb 2024 00:37:57 +0000 Subject: [PATCH 3/4] fix(core): typo of variable name --- packages/core/src/generators/interface.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/core/src/generators/interface.ts b/packages/core/src/generators/interface.ts index ab2fbafe0..837a20166 100644 --- a/packages/core/src/generators/interface.ts +++ b/packages/core/src/generators/interface.ts @@ -47,9 +47,10 @@ export const generateInterface = ({ !context?.output.override?.useTypeOverInterfaces ) { // If `scalar.value` is 'unknown', replace it with `{}` to avoid type error - const blankIntefaceValue = scalar.value === 'unknown' ? '{}' : scalar.value; + const blankInterfaceValue = + scalar.value === 'unknown' ? '{}' : scalar.value; - model += `export interface ${name} ${blankIntefaceValue}\n`; + model += `export interface ${name} ${blankInterfaceValue}\n`; } else { model += `export type ${name} = ${scalar.value};\n`; } From e765b4c6c3bef8b9d2609df453064621b65dd08e Mon Sep 17 00:00:00 2001 From: soartec-lab Date: Thu, 29 Feb 2024 23:59:46 +0000 Subject: [PATCH 4/4] chore(core): add regression test cases --- tests/specifications/regressions.yaml | 5 +++++ 1 file changed, 5 insertions(+) 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: