Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: adding exception for v2010 apis #572

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions src/main/java/com/twilio/oai/TwilioGoGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ String removeStatusCode(String modelName) {
}

String removeDigits(String modelName) {
if(modelName == null || modelName.isEmpty())
if(modelName == null || modelName.isEmpty() || modelName.contains("2010"))
return modelName;
return modelName.replaceFirst("\\d{3}", "");
}
Expand Down Expand Up @@ -169,17 +169,17 @@ public OperationsMap postProcessOperationsWithModels(final OperationsMap objs, L
final List<CodegenOperation> opList = ops.getOperation();

final Map<String, CodegenModel> models = allModels
.stream()
.map(m -> m.get("model"))
.map(CodegenModel.class::cast)
.collect(Collectors.toMap(CodegenModel::getName, Function.identity()));
.stream()
.map(m -> m.get("model"))
.map(CodegenModel.class::cast)
.collect(Collectors.toMap(CodegenModel::getName, Function.identity()));

// get the model for the return type
final Optional<CodegenModel> returnModel = opList
.stream()
.filter(op -> models.containsKey(op.returnType))
.map(op -> models.get(op.returnType))
.findFirst();
.stream()
.filter(op -> models.containsKey(op.returnType))
.map(op -> models.get(op.returnType))
.findFirst();

for (final CodegenOperation co : opList) {
Utility.populateCrudOperations(co);
Expand All @@ -193,9 +193,9 @@ public OperationsMap postProcessOperationsWithModels(final OperationsMap objs, L
// filter the fields in the model and get only the array typed field. Also, make sure there is only one field of type list/array
if (returnModel.isPresent()) {
CodegenProperty field = returnModel.get().allVars
.stream()
.filter(v -> v.dataType.startsWith("[]"))
.collect(toSingleton());
.stream()
.filter(v -> v.dataType.startsWith("[]"))
.collect(toSingleton());

co.returnContainer = co.returnType;
co.returnType = field.dataType;
Expand All @@ -209,9 +209,9 @@ public OperationsMap postProcessOperationsWithModels(final OperationsMap objs, L
CodegenModel model = (CodegenModel) modelMap.get("model");
final Optional<CodegenModel> returnModelOther = Optional.ofNullable(model);
CodegenProperty field = returnModelOther.get().allVars
.stream()
.filter(v -> v.dataType.startsWith("[]"))
.collect(toSingleton());
.stream()
.filter(v -> v.dataType.startsWith("[]"))
.collect(toSingleton());

co.returnContainer = co.returnType;
co.returnType = field.dataType;
Expand Down
Loading