Skip to content

Commit 81057f9

Browse files
fix property datatype in language resolver (#582)
# Fixes # 1. Property was not getting properly resolved if it was resolved by LanguageResolver for java Java Code change because of this: Object data type will be replaced by Map<String, Object> 2. Added json body in update operation in csharp generation. ### Checklist - [x] I acknowledge that all my contributions will be made under the project's license - [ ] Run `make test-docker` - [ ] Verify affected language: - [ ] Generate [twilio-go](https://github.com/twilio/twilio-go) from our [OpenAPI specification](https://github.com/twilio/twilio-oai) using the [build_twilio_go.py](./examples/build_twilio_go.py) using `python examples/build_twilio_go.py path/to/twilio-oai/spec/yaml path/to/twilio-go` and inspect the diff - [ ] Run `make test` in `twilio-go` - [ ] Create a pull request in `twilio-go` - [ ] Provide a link below to the pull request - [ ] I have made a material change to the repo (functionality, testing, spelling, grammar) - [ ] I have read the [Contribution Guidelines](https://github.com/twilio/twilio-oai-generator/blob/main/CONTRIBUTING.md) and my PR follows them - [ ] I have titled the PR appropriately - [ ] I have updated my branch with the main branch - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] I have added the necessary documentation about the functionality in the appropriate .md file - [ ] I have added inline documentation to the code I modified If you have questions, please create a GitHub Issue in this repository. --------- Co-authored-by: Shubham <[email protected]>
1 parent c81ce44 commit 81057f9

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ public ApiResourceBuilder updateResponseModel(Resolver<CodegenProperty> codegenP
171171
codegenOperationList.forEach(codegenOperation -> {
172172
codegenOperation.responses.forEach(response -> {
173173
String modelName = response.dataType;
174+
if (response.dataType != null && response.dataType.startsWith(EnumConstants.CsharpDataTypes.LIST.getValue())){
175+
modelName = response.baseType;
176+
}
174177
Optional<CodegenModel> responseModel = Utility.getModel(allModels, modelName, recordKey, codegenOperation);
175178
if (responseModel.isEmpty()) {
176179
return;

src/main/java/com/twilio/oai/resolver/LanguagePropertyResolver.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@ public CodegenProperty resolve(CodegenProperty codegenProperty, ApiResourceBuild
3535

3636
protected void resolveProperties(CodegenProperty codegenProperty, ApiResourceBuilder apiResourceBuilder) {
3737
mapper
38-
.properties()
39-
.getString(codegenProperty.dataFormat)
40-
.ifPresent(dataType -> codegenProperty.dataType = dataType);
38+
.properties()
39+
.getString(codegenProperty.dataFormat)
40+
.or(() -> mapper.properties().getString(codegenProperty.dataType))
41+
.ifPresent(dataType -> codegenProperty.dataType = dataType);
4142
}
4243

4344
protected void resolveSerialize(CodegenProperty codegenProperty) {

0 commit comments

Comments
 (0)