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)