Skip to content

Commit

Permalink
fix property datatype in language resolver (#582)
Browse files Browse the repository at this point in the history
# 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 <stiwari@twilio.com>
  • Loading branch information
sbansla and tiwarishubham635 authored Jul 2, 2024
1 parent c81ce44 commit 81057f9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ public ApiResourceBuilder updateResponseModel(Resolver<CodegenProperty> codegenP
codegenOperationList.forEach(codegenOperation -> {
codegenOperation.responses.forEach(response -> {
String modelName = response.dataType;
if (response.dataType != null && response.dataType.startsWith(EnumConstants.CsharpDataTypes.LIST.getValue())){
modelName = response.baseType;
}
Optional<CodegenModel> responseModel = Utility.getModel(allModels, modelName, recordKey, codegenOperation);
if (responseModel.isEmpty()) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ public CodegenProperty resolve(CodegenProperty codegenProperty, ApiResourceBuild

protected void resolveProperties(CodegenProperty codegenProperty, ApiResourceBuilder apiResourceBuilder) {
mapper
.properties()
.getString(codegenProperty.dataFormat)
.ifPresent(dataType -> codegenProperty.dataType = dataType);
.properties()
.getString(codegenProperty.dataFormat)
.or(() -> mapper.properties().getString(codegenProperty.dataType))
.ifPresent(dataType -> codegenProperty.dataType = dataType);
}

protected void resolveSerialize(CodegenProperty codegenProperty) {
Expand Down

0 comments on commit 81057f9

Please sign in to comment.