From 92a1efa790a49e18842be5509639bbd936a0f933 Mon Sep 17 00:00:00 2001 From: Shubham Tiwari Date: Sun, 15 Sep 2024 15:58:57 +0530 Subject: [PATCH 01/10] chore: C# resolve datatype for optionalParams and skip isOverriden flag --- .../oai/api/CsharpApiResourceBuilder.java | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java b/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java index 5163292bd..a10622e33 100644 --- a/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java +++ b/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java @@ -104,15 +104,19 @@ public void updateHttpMethod(CodegenOperation co) { } } + private void setDataType(CodegenParameter codegenParameter) { + for (CodegenModel codegenModel : getAllModels()) + if (codegenModel.classname.equals(codegenParameter.dataType)) + codegenParameter.dataType = getApiName() + "Resource" + ApplicationConstants.DOT + codegenParameter.dataType; + } + private void resolveIngressModel(CodegenOperation codegenOperation) { // Required params are used in parameters in C#, Check Params.mustache. - for (CodegenParameter codegenParameter: codegenOperation.requiredParams) { - for (CodegenModel codegenModel : getAllModels()) { - if (codegenModel.classname.equals(codegenParameter.paramName)) { - codegenParameter.dataType = getApiName() + "Resource" + ApplicationConstants.DOT + codegenParameter.dataType; - } - } - + for (CodegenParameter codegenParameter: codegenOperation.requiredParams) + setDataType(codegenParameter); + + for (CodegenParameter codegenParameter: codegenOperation.optionalParams) { + setDataType(codegenParameter); } } @@ -191,12 +195,15 @@ public Set getDistinctResponseModel(List response for (CodegenModel codegenModel: responseModels) { for (CodegenProperty property: codegenModel.vars) { property.nameInCamelCase = StringHelper.camelize(property.nameInSnakeCase); + Boolean isOverriden = property.isOverridden; + property.isOverridden = null; if (Arrays.stream(EnumConstants.Operation.values()) - .anyMatch(value -> value.getValue().equals(property.nameInCamelCase)) + .anyMatch(value -> value.getValue().equals(property.nameInCamelCase)) || isNestedModelPresentWithPropertyName(property)) { property.nameInCamelCase = "_" + property.nameInCamelCase; } distinctResponseModels.add(property); + property.isOverridden = isOverriden; } } return distinctResponseModels; @@ -298,7 +305,7 @@ private void rearrangeBeforeAfter(final List parameters) { } public boolean isNestedModelPresentWithPropertyName(final CodegenProperty property) { - if (nestedModels == null || nestedModels.size() < 1) return false; + if (nestedModels == null || nestedModels.size() < 1) return false; Optional foundModel = nestedModels.stream() .filter(model -> model.classname.equals(property.name)) .findFirst(); From 2512f3ffd188b08170dd85121b5f40c40397c4b0 Mon Sep 17 00:00:00 2001 From: Shubham Tiwari Date: Mon, 16 Sep 2024 14:57:12 +0530 Subject: [PATCH 02/10] chore: handling missing parent params in node --- .../oai/api/NodeApiResourceBuilder.java | 7 +++++ .../resources/twilio-node/api-single.mustache | 26 ++++++++++++++----- .../twilio-node/getDependent.mustache | 6 +++++ 3 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 src/main/resources/twilio-node/getDependent.mustache diff --git a/src/main/java/com/twilio/oai/api/NodeApiResourceBuilder.java b/src/main/java/com/twilio/oai/api/NodeApiResourceBuilder.java index 59ca136e8..2b72a0006 100644 --- a/src/main/java/com/twilio/oai/api/NodeApiResourceBuilder.java +++ b/src/main/java/com/twilio/oai/api/NodeApiResourceBuilder.java @@ -12,6 +12,7 @@ import java.util.Objects; import java.util.stream.Collectors; +import io.swagger.v3.oas.models.parameters.Parameter; import org.openapitools.codegen.CodegenModel; import org.openapitools.codegen.CodegenOperation; import org.openapitools.codegen.CodegenParameter; @@ -63,6 +64,12 @@ public ApiResourceBuilder updateOperations(final Resolver code dependent.setClassName(resourceName + "Import"); dependent.setImportName(resourceName + " as " + dependent.getType()); } + if(!dependent.isInstanceDependent()) { + for(Parameter pathParam : dependent.getPathParams()) { + if(!pathParam.getName().startsWith(dependent.getResourceName())) + pathParam.addExtension("x-is-non-parent-param", true); + } + } }); } diff --git a/src/main/resources/twilio-node/api-single.mustache b/src/main/resources/twilio-node/api-single.mustache index 086c0b1e3..e29311822 100644 --- a/src/main/resources/twilio-node/api-single.mustache +++ b/src/main/resources/twilio-node/api-single.mustache @@ -169,15 +169,27 @@ export function {{apiName}}ListInstance(version: {{apiVersionClass}}{{#listPathP {{#dependents}} {{^instanceDependent}} + Object.defineProperty(instance, "{{mountName}}", { - get: function {{mountName}}() { - if (!instance._{{mountName}}) { - instance._{{mountName}} = {{className}}(instance._version{{#listPathParams}}, instance._solution.{{paramName}}{{/listPathParams}}); - } - return instance._{{mountName}}; - } + {{^pathParams}} + {{>getDependent}} + {{/pathParams}} + {{#pathParams.0}} + {{#extensions.x-is-non-parent-param}} + get: function() { + return ({{#pathParams}}{{#extensions.x-is-non-parent-param}}{{name}}: {{schema.type}}{{^-last}} ,{{/-last}}{{/extensions.x-is-non-parent-param}}{{/pathParams}}) => { + if (!instance._{{mountName}}) { + instance._{{mountName}} = {{className}}(instance._version, {{#pathParams}}{{#extensions.x-is-non-parent-param}}{{name}}{{^-last}} ,{{/-last}}{{/extensions.x-is-non-parent-param}}{{/pathParams}}); + } + return instance._{{mountName}}; + }; + } + {{/extensions.x-is-non-parent-param}} + {{^extensions.x-is-non-parent-param}} + {{>getDependent}} + {{/extensions.x-is-non-parent-param}} + {{/pathParams.0}} }); - {{/instanceDependent}} {{/dependents}} {{#operations}} diff --git a/src/main/resources/twilio-node/getDependent.mustache b/src/main/resources/twilio-node/getDependent.mustache new file mode 100644 index 000000000..058989971 --- /dev/null +++ b/src/main/resources/twilio-node/getDependent.mustache @@ -0,0 +1,6 @@ +get: function {{mountName}}() { + if (!instance._{{mountName}}) { + instance._{{mountName}} = {{className}}(instance._version{{#listPathParams}}, instance._solution.{{paramName}}{{/listPathParams}}); + } + return instance._{{mountName}}; +} From 8fdf1faf02ea73eadcfcf5efb3d36b7f12587dac Mon Sep 17 00:00:00 2001 From: Shubham Tiwari Date: Mon, 16 Sep 2024 14:58:11 +0530 Subject: [PATCH 03/10] chore: skipping overriden flag in distinctResponseModels --- .../java/com/twilio/oai/api/ApiResourceBuilder.java | 7 +++++-- .../com/twilio/oai/api/JavaApiResourceBuilder.java | 10 ++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/twilio/oai/api/ApiResourceBuilder.java b/src/main/java/com/twilio/oai/api/ApiResourceBuilder.java index 36287c360..7b8cb4573 100644 --- a/src/main/java/com/twilio/oai/api/ApiResourceBuilder.java +++ b/src/main/java/com/twilio/oai/api/ApiResourceBuilder.java @@ -93,7 +93,7 @@ public ApiResourceBuilder updateOperations(Resolver codegenPar } public void updateHttpMethod(CodegenOperation co) { - + } protected void resolveParam(final Resolver codegenParameterIResolver, @@ -191,7 +191,7 @@ public CodegenModel getModel(String modelName ) { } return null; } - + public void addNestedModel(final CodegenModel codegenModel) { // TODO: Temporary fix, planning to use hashmap, set is inserting duplicate values. Iterator iterator = nestedModels.iterator(); @@ -290,12 +290,15 @@ protected Set getDistinctResponseModel(List respo for (CodegenModel codegenModel : responseModels) { for (CodegenProperty property : codegenModel.vars) { property.nameInCamelCase = StringHelper.camelize(property.nameInSnakeCase); + Boolean isOverriden = property.isOverridden; + property.isOverridden = null; if (Arrays .stream(Operation.values()) .anyMatch(value -> value.getValue().equals(property.nameInCamelCase))) { property.nameInCamelCase = "_" + property.nameInCamelCase; } distinctResponseModels.add(property); + property.isOverridden = isOverriden; } } return distinctResponseModels; diff --git a/src/main/java/com/twilio/oai/api/JavaApiResourceBuilder.java b/src/main/java/com/twilio/oai/api/JavaApiResourceBuilder.java index 7c71de2ca..6cbdba128 100644 --- a/src/main/java/com/twilio/oai/api/JavaApiResourceBuilder.java +++ b/src/main/java/com/twilio/oai/api/JavaApiResourceBuilder.java @@ -610,8 +610,14 @@ private CodegenModel getConcatenatedResponseModel(List responseMod resModel.vendorExtensions.forEach( (key, value) -> codegenModel.vendorExtensions.merge(key, value, (oldValue, newValue) -> newValue)); } - - resModel.vars.stream().filter(Predicate.not(codegenProperties::contains)).forEach(codegenProperties::add); + resModel.vars.forEach(var -> { + Boolean isOverriden = var.isOverridden; + var.isOverridden = null; + if(!codegenProperties.contains(var)) + codegenProperties.add(var); + var.isOverridden = isOverriden; + }); +// resModel.vars.stream().filter(Predicate.not(codegenProperties::contains)).forEach(codegenProperties::add); } codegenProperties.forEach(prop -> prop.baseName = StringHelper.camelize(prop.baseName, true)); From e305bdac470fd13b3ce9405b0314bfcbce02776d Mon Sep 17 00:00:00 2001 From: Shubham Tiwari Date: Mon, 16 Sep 2024 18:20:51 +0530 Subject: [PATCH 04/10] chore: adding non instance parent param --- .../com/twilio/oai/api/NodeApiResourceBuilder.java | 4 ++-- src/main/resources/twilio-node/api-single.mustache | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/twilio/oai/api/NodeApiResourceBuilder.java b/src/main/java/com/twilio/oai/api/NodeApiResourceBuilder.java index 2b72a0006..186aa053f 100644 --- a/src/main/java/com/twilio/oai/api/NodeApiResourceBuilder.java +++ b/src/main/java/com/twilio/oai/api/NodeApiResourceBuilder.java @@ -66,8 +66,8 @@ public ApiResourceBuilder updateOperations(final Resolver code } if(!dependent.isInstanceDependent()) { for(Parameter pathParam : dependent.getPathParams()) { - if(!pathParam.getName().startsWith(dependent.getResourceName())) - pathParam.addExtension("x-is-non-parent-param", true); + if(pathParam.getName().startsWith(co.baseName)) + pathParam.addExtension("x-is-non-instance-parent-param", true); } } }); diff --git a/src/main/resources/twilio-node/api-single.mustache b/src/main/resources/twilio-node/api-single.mustache index e29311822..b51480d71 100644 --- a/src/main/resources/twilio-node/api-single.mustache +++ b/src/main/resources/twilio-node/api-single.mustache @@ -175,19 +175,19 @@ export function {{apiName}}ListInstance(version: {{apiVersionClass}}{{#listPathP {{>getDependent}} {{/pathParams}} {{#pathParams.0}} - {{#extensions.x-is-non-parent-param}} + {{#extensions.x-is-non-instance-parent-param}} get: function() { - return ({{#pathParams}}{{#extensions.x-is-non-parent-param}}{{name}}: {{schema.type}}{{^-last}} ,{{/-last}}{{/extensions.x-is-non-parent-param}}{{/pathParams}}) => { + return ({{#pathParams}}{{#extensions.x-is-non-instance-parent-param}}{{name}}: {{schema.type}}{{^-last}} ,{{/-last}}{{/extensions.x-is-non-instance-parent-param}}{{/pathParams}}) => { if (!instance._{{mountName}}) { - instance._{{mountName}} = {{className}}(instance._version, {{#pathParams}}{{#extensions.x-is-non-parent-param}}{{name}}{{^-last}} ,{{/-last}}{{/extensions.x-is-non-parent-param}}{{/pathParams}}); + instance._{{mountName}} = {{className}}(instance._version, {{#pathParams}}{{#extensions.x-is-non-instance-parent-param}}{{name}}{{^-last}} ,{{/-last}}{{/extensions.x-is-non-instance-parent-param}}{{/pathParams}}); } return instance._{{mountName}}; }; } - {{/extensions.x-is-non-parent-param}} - {{^extensions.x-is-non-parent-param}} + {{/extensions.x-is-non-instance-parent-param}} + {{^extensions.x-is-non-instance-parent-param}} {{>getDependent}} - {{/extensions.x-is-non-parent-param}} + {{/extensions.x-is-non-instance-parent-param}} {{/pathParams.0}} }); {{/instanceDependent}} From 5aac46c7c9f43dba42db1a4145a506c8416cab10 Mon Sep 17 00:00:00 2001 From: Shubham Tiwari Date: Mon, 16 Sep 2024 18:57:53 +0530 Subject: [PATCH 05/10] chore: reverting to previous version of goimports --- examples/go/Dockerfile-goimports | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/go/Dockerfile-goimports b/examples/go/Dockerfile-goimports index 7747b9bfa..82ea98f65 100644 --- a/examples/go/Dockerfile-goimports +++ b/examples/go/Dockerfile-goimports @@ -1,6 +1,6 @@ FROM golang:1.18 ENV GOPATH /go -RUN go install golang.org/x/tools/cmd/goimports@latest +RUN go install golang.org/x/tools/cmd/goimports@v0.24.0 CMD goimports -w /local From fc290869dc7e6e7e5c8fc32480cbb7ee74136847 Mon Sep 17 00:00:00 2001 From: Shubham Tiwari Date: Mon, 16 Sep 2024 19:06:10 +0530 Subject: [PATCH 06/10] chore: adding node examples --- examples/node/src/rest/api/v2010/account/call.ts | 1 - examples/node/src/rest/flexApi/v1/credential.ts | 1 - 2 files changed, 2 deletions(-) diff --git a/examples/node/src/rest/api/v2010/account/call.ts b/examples/node/src/rest/api/v2010/account/call.ts index 08edabcb0..81442a4d0 100644 --- a/examples/node/src/rest/api/v2010/account/call.ts +++ b/examples/node/src/rest/api/v2010/account/call.ts @@ -375,7 +375,6 @@ export function CallListInstance( return instance._feedbackCallSummary; }, }); - instance.create = function create( params: CallListInstanceCreateOptions, callback?: (error: Error | null, items: CallInstance) => any, diff --git a/examples/node/src/rest/flexApi/v1/credential.ts b/examples/node/src/rest/flexApi/v1/credential.ts index 7cf3bf7a3..9669f10c0 100644 --- a/examples/node/src/rest/flexApi/v1/credential.ts +++ b/examples/node/src/rest/flexApi/v1/credential.ts @@ -65,7 +65,6 @@ export function CredentialListInstance(version: V1): CredentialListInstance { return instance._newCredentials; }, }); - instance.toJSON = function toJSON() { return instance._solution; }; From fbe061553e82aa94c8d4920ed3c1e9694bec490d Mon Sep 17 00:00:00 2001 From: Shubham Tiwari Date: Tue, 17 Sep 2024 11:44:43 +0530 Subject: [PATCH 07/10] chore: reverting node patchwork --- .../node/src/rest/api/v2010/account/call.ts | 1 + .../node/src/rest/flexApi/v1/credential.ts | 1 + .../oai/api/NodeApiResourceBuilder.java | 7 ----- .../resources/twilio-node/api-single.mustache | 26 +++++-------------- 4 files changed, 9 insertions(+), 26 deletions(-) diff --git a/examples/node/src/rest/api/v2010/account/call.ts b/examples/node/src/rest/api/v2010/account/call.ts index 81442a4d0..08edabcb0 100644 --- a/examples/node/src/rest/api/v2010/account/call.ts +++ b/examples/node/src/rest/api/v2010/account/call.ts @@ -375,6 +375,7 @@ export function CallListInstance( return instance._feedbackCallSummary; }, }); + instance.create = function create( params: CallListInstanceCreateOptions, callback?: (error: Error | null, items: CallInstance) => any, diff --git a/examples/node/src/rest/flexApi/v1/credential.ts b/examples/node/src/rest/flexApi/v1/credential.ts index 9669f10c0..7cf3bf7a3 100644 --- a/examples/node/src/rest/flexApi/v1/credential.ts +++ b/examples/node/src/rest/flexApi/v1/credential.ts @@ -65,6 +65,7 @@ export function CredentialListInstance(version: V1): CredentialListInstance { return instance._newCredentials; }, }); + instance.toJSON = function toJSON() { return instance._solution; }; diff --git a/src/main/java/com/twilio/oai/api/NodeApiResourceBuilder.java b/src/main/java/com/twilio/oai/api/NodeApiResourceBuilder.java index 186aa053f..59ca136e8 100644 --- a/src/main/java/com/twilio/oai/api/NodeApiResourceBuilder.java +++ b/src/main/java/com/twilio/oai/api/NodeApiResourceBuilder.java @@ -12,7 +12,6 @@ import java.util.Objects; import java.util.stream.Collectors; -import io.swagger.v3.oas.models.parameters.Parameter; import org.openapitools.codegen.CodegenModel; import org.openapitools.codegen.CodegenOperation; import org.openapitools.codegen.CodegenParameter; @@ -64,12 +63,6 @@ public ApiResourceBuilder updateOperations(final Resolver code dependent.setClassName(resourceName + "Import"); dependent.setImportName(resourceName + " as " + dependent.getType()); } - if(!dependent.isInstanceDependent()) { - for(Parameter pathParam : dependent.getPathParams()) { - if(pathParam.getName().startsWith(co.baseName)) - pathParam.addExtension("x-is-non-instance-parent-param", true); - } - } }); } diff --git a/src/main/resources/twilio-node/api-single.mustache b/src/main/resources/twilio-node/api-single.mustache index b51480d71..086c0b1e3 100644 --- a/src/main/resources/twilio-node/api-single.mustache +++ b/src/main/resources/twilio-node/api-single.mustache @@ -169,27 +169,15 @@ export function {{apiName}}ListInstance(version: {{apiVersionClass}}{{#listPathP {{#dependents}} {{^instanceDependent}} - Object.defineProperty(instance, "{{mountName}}", { - {{^pathParams}} - {{>getDependent}} - {{/pathParams}} - {{#pathParams.0}} - {{#extensions.x-is-non-instance-parent-param}} - get: function() { - return ({{#pathParams}}{{#extensions.x-is-non-instance-parent-param}}{{name}}: {{schema.type}}{{^-last}} ,{{/-last}}{{/extensions.x-is-non-instance-parent-param}}{{/pathParams}}) => { - if (!instance._{{mountName}}) { - instance._{{mountName}} = {{className}}(instance._version, {{#pathParams}}{{#extensions.x-is-non-instance-parent-param}}{{name}}{{^-last}} ,{{/-last}}{{/extensions.x-is-non-instance-parent-param}}{{/pathParams}}); - } - return instance._{{mountName}}; - }; - } - {{/extensions.x-is-non-instance-parent-param}} - {{^extensions.x-is-non-instance-parent-param}} - {{>getDependent}} - {{/extensions.x-is-non-instance-parent-param}} - {{/pathParams.0}} + get: function {{mountName}}() { + if (!instance._{{mountName}}) { + instance._{{mountName}} = {{className}}(instance._version{{#listPathParams}}, instance._solution.{{paramName}}{{/listPathParams}}); + } + return instance._{{mountName}}; + } }); + {{/instanceDependent}} {{/dependents}} {{#operations}} From 24af05311bd7aecaca270f756c41fa89a4b2bc56 Mon Sep 17 00:00:00 2001 From: Shubham Date: Tue, 17 Sep 2024 12:49:55 +0530 Subject: [PATCH 08/10] chore: delete src/main/resources/twilio-node/getDependent.mustache --- src/main/resources/twilio-node/getDependent.mustache | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 src/main/resources/twilio-node/getDependent.mustache diff --git a/src/main/resources/twilio-node/getDependent.mustache b/src/main/resources/twilio-node/getDependent.mustache deleted file mode 100644 index 058989971..000000000 --- a/src/main/resources/twilio-node/getDependent.mustache +++ /dev/null @@ -1,6 +0,0 @@ -get: function {{mountName}}() { - if (!instance._{{mountName}}) { - instance._{{mountName}} = {{className}}(instance._version{{#listPathParams}}, instance._solution.{{paramName}}{{/listPathParams}}); - } - return instance._{{mountName}}; -} From 600fdd302654409aaf2f5e39221414dc74d794dd Mon Sep 17 00:00:00 2001 From: Shubham Date: Wed, 18 Sep 2024 11:03:11 +0530 Subject: [PATCH 09/10] chore: add comment for logic --- src/main/java/com/twilio/oai/api/ApiResourceBuilder.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/twilio/oai/api/ApiResourceBuilder.java b/src/main/java/com/twilio/oai/api/ApiResourceBuilder.java index 7b8cb4573..1f835b76a 100644 --- a/src/main/java/com/twilio/oai/api/ApiResourceBuilder.java +++ b/src/main/java/com/twilio/oai/api/ApiResourceBuilder.java @@ -290,6 +290,7 @@ protected Set getDistinctResponseModel(List respo for (CodegenModel codegenModel : responseModels) { for (CodegenProperty property : codegenModel.vars) { property.nameInCamelCase = StringHelper.camelize(property.nameInSnakeCase); + // When we have responseModel referencing a schema, isOverriden flag is set to false (which is null by default). This makes the property different. See assistants api ListAssistantResponse Boolean isOverriden = property.isOverridden; property.isOverridden = null; if (Arrays From f19fb8f049e7d356a8417ab89099196fc365a9df Mon Sep 17 00:00:00 2001 From: Shubham Tiwari Date: Wed, 18 Sep 2024 12:03:22 +0530 Subject: [PATCH 10/10] chore: isOverriden flag same as false and null --- src/main/java/com/twilio/oai/api/ApiResourceBuilder.java | 7 ++++--- .../java/com/twilio/oai/api/CsharpApiResourceBuilder.java | 7 ++++--- .../java/com/twilio/oai/api/JavaApiResourceBuilder.java | 7 ++++--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/twilio/oai/api/ApiResourceBuilder.java b/src/main/java/com/twilio/oai/api/ApiResourceBuilder.java index 7b8cb4573..4bf02ae1b 100644 --- a/src/main/java/com/twilio/oai/api/ApiResourceBuilder.java +++ b/src/main/java/com/twilio/oai/api/ApiResourceBuilder.java @@ -290,15 +290,16 @@ protected Set getDistinctResponseModel(List respo for (CodegenModel codegenModel : responseModels) { for (CodegenProperty property : codegenModel.vars) { property.nameInCamelCase = StringHelper.camelize(property.nameInSnakeCase); - Boolean isOverriden = property.isOverridden; - property.isOverridden = null; + Boolean isOverridden = property.isOverridden; + if(isOverridden != null && isOverridden == false) + property.isOverridden = null; if (Arrays .stream(Operation.values()) .anyMatch(value -> value.getValue().equals(property.nameInCamelCase))) { property.nameInCamelCase = "_" + property.nameInCamelCase; } distinctResponseModels.add(property); - property.isOverridden = isOverriden; + property.isOverridden = isOverridden; } } return distinctResponseModels; diff --git a/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java b/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java index a10622e33..3bfb70e19 100644 --- a/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java +++ b/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java @@ -195,15 +195,16 @@ public Set getDistinctResponseModel(List response for (CodegenModel codegenModel: responseModels) { for (CodegenProperty property: codegenModel.vars) { property.nameInCamelCase = StringHelper.camelize(property.nameInSnakeCase); - Boolean isOverriden = property.isOverridden; - property.isOverridden = null; + Boolean isOverridden = property.isOverridden; + if(isOverridden != null && isOverridden == false) + property.isOverridden = null; if (Arrays.stream(EnumConstants.Operation.values()) .anyMatch(value -> value.getValue().equals(property.nameInCamelCase)) || isNestedModelPresentWithPropertyName(property)) { property.nameInCamelCase = "_" + property.nameInCamelCase; } distinctResponseModels.add(property); - property.isOverridden = isOverriden; + property.isOverridden = isOverridden; } } return distinctResponseModels; diff --git a/src/main/java/com/twilio/oai/api/JavaApiResourceBuilder.java b/src/main/java/com/twilio/oai/api/JavaApiResourceBuilder.java index 6cbdba128..75b20d804 100644 --- a/src/main/java/com/twilio/oai/api/JavaApiResourceBuilder.java +++ b/src/main/java/com/twilio/oai/api/JavaApiResourceBuilder.java @@ -611,11 +611,12 @@ private CodegenModel getConcatenatedResponseModel(List responseMod (key, value) -> codegenModel.vendorExtensions.merge(key, value, (oldValue, newValue) -> newValue)); } resModel.vars.forEach(var -> { - Boolean isOverriden = var.isOverridden; - var.isOverridden = null; + Boolean isOverridden = var.isOverridden; + if(isOverridden != null && isOverridden == false) + var.isOverridden = null; if(!codegenProperties.contains(var)) codegenProperties.add(var); - var.isOverridden = isOverriden; + var.isOverridden = isOverridden; }); // resModel.vars.stream().filter(Predicate.not(codegenProperties::contains)).forEach(codegenProperties::add); }