Skip to content

Commit

Permalink
[typescript-fetch] add oneOf string union & array support (OpenAPIToo…
Browse files Browse the repository at this point in the history
  • Loading branch information
thesn10 committed Nov 27, 2024
1 parent 17dac43 commit 2dd6b47
Showing 1 changed file with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -784,25 +784,23 @@ private ExtendedCodegenModel processCodeGenModel(ExtendedCodegenModel cm) {
cm.hasStringOneOf = cm.oneOf.contains("string");
cm.hasStringArrayOneOf = cm.oneOf.contains("Array<string>");

cm.oneOfModels = Optional.ofNullable(cm.getComposedSchemas())
List<CodegenProperty> 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)
Expand Down

0 comments on commit 2dd6b47

Please sign in to comment.