Skip to content

Commit fd38690

Browse files
chore: handle list of objects (#659)
<!-- We appreciate the effort for this pull request but before that please make sure you read the contribution guidelines, then fill out the blanks below. Please format the PR title appropriately based on the type of change: <type>[!]: <description> Where <type> is one of: docs, chore, feat, fix, test, misc. Add a '!' after the type for breaking changes (e.g. feat!: new breaking feature). **All third-party contributors acknowledge that any contributions they provide will be made under the same open-source license that the open-source project is provided under.** Please enter each Issue number you are resolving in your PR after one of the following words [Fixes, Closes, Resolves]. This will auto-link these issues and close them when this PR is merged! e.g. Fixes #1 Closes #2 --> # Fixes # In case of list of objects, we need to serialize using objectToJson() Preview changes - twilio/twilio-java#874 ### 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.
1 parent 8d0667f commit fd38690

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/NewCredentialsCreator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ private void addPostParams(final Request request) {
258258
}
259259
if (testAnyArray != null) {
260260
for (Object prop : testAnyArray) {
261-
request.addPostParam("TestAnyArray", prop.toString());
261+
request.addPostParam("TestAnyArray", Converter.objectToJson(prop));
262262
}
263263

264264
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,8 @@ private void processDataTypesForParams(List<CodegenParameter> finalQueryParamLis
431431
cp.vendorExtensions.put("x-is-other-data-type", true);
432432
} else if (cp.isArray && cp.baseType.equalsIgnoreCase(STRING)) {
433433
cp.vendorExtensions.put("x-is-string-array", true);
434+
} else if (cp.isArray && cp.items != null && cp.items.isAnyType) {
435+
cp.vendorExtensions.put("x-is-anytype-array", true);
434436
}
435437

436438
}

src/main/resources/twilio-java/postParams.mustache

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,16 @@
2929
}
3030
{{/vendorExtensions.x-is-string-array}}
3131
{{^vendorExtensions.x-is-string-array}}
32+
{{#vendorExtensions.x-is-anytype-array}}
33+
for ({{baseType}} prop : {{paramName}}) {
34+
request.addPostParam("{{baseName}}", Converter.objectToJson(prop));
35+
}
36+
{{/vendorExtensions.x-is-anytype-array}}
37+
{{^vendorExtensions.x-is-anytype-array}}
3238
for ({{baseType}} prop : {{paramName}}) {
3339
request.addPostParam("{{baseName}}", prop.toString());
3440
}
41+
{{/vendorExtensions.x-is-anytype-array}}
3542
{{/vendorExtensions.x-is-string-array}}
3643
{{/isEnum}}
3744
{{/isArray}}

0 commit comments

Comments
 (0)