From 2dd6b47821ef5fd8a7aecea973f0db13aec66f42 Mon Sep 17 00:00:00 2001 From: thesn10 <38666407+thesn10@users.noreply.github.com> Date: Wed, 27 Nov 2024 03:44:39 +0100 Subject: [PATCH] [typescript-fetch] add oneOf string union & array support (#19909) --- .../languages/TypeScriptFetchClientCodegen.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java index 2169c7a86253..f855abb36555 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java @@ -784,25 +784,23 @@ private ExtendedCodegenModel processCodeGenModel(ExtendedCodegenModel cm) { cm.hasStringOneOf = cm.oneOf.contains("string"); cm.hasStringArrayOneOf = cm.oneOf.contains("Array"); - cm.oneOfModels = Optional.ofNullable(cm.getComposedSchemas()) + List oneOfsList = Optional.ofNullable(cm.getComposedSchemas()) .map(CodegenComposedSchemas::getOneOf) - .orElse(Collections.emptyList()).stream() + .orElse(Collections.emptyList()); + + cm.oneOfModels = oneOfsList.stream() .filter(CodegenProperty::getIsModel) .map(CodegenProperty::getBaseType) .filter(Objects::nonNull) .collect(Collectors.toCollection(TreeSet::new)); - cm.oneOfStringEnums = Optional.ofNullable(cm.getComposedSchemas()) - .map(CodegenComposedSchemas::getOneOf) - .orElse(Collections.emptyList()).stream() + cm.oneOfStringEnums = oneOfsList.stream() .filter(CodegenProperty::getIsEnum) .map(CodegenProperty::getAllowableValuesList) .flatMap(Collection::stream) .collect(Collectors.toCollection(TreeSet::new)); - cm.oneOfArrays = Optional.ofNullable(cm.getComposedSchemas()) - .map(CodegenComposedSchemas::getOneOf) - .orElse(Collections.emptyList()).stream() + cm.oneOfArrays = oneOfsList.stream() .filter(CodegenProperty::getIsArray) .map(CodegenProperty::getComplexType) .filter(Objects::nonNull)