Skip to content

Commit 19849ce

Browse files
authored
chore: php object array fix (#640)
<!-- 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 # twilio php fix ### 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 38396ff commit 19849ce

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

examples/php/src/Twilio/Rest/FlexApi/V1/Credential/NewCredentialsList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function create(string $testString, array $options = []): NewCredentialsI
8787
'TestEnum' =>
8888
$options['testEnum'],
8989
'TestObjectArray' =>
90-
Serialize::map($options['testObjectArray'], function ($e) { return $e; }),
90+
Serialize::map($options['testObjectArray'], function ($e) { return Serialize::jsonObject($e); }),
9191
'TestAnyType' =>
9292
Serialize::jsonObject($options['testAnyType']),
9393
'TestAnyArray' =>

src/main/java/com/twilio/oai/common/ApplicationConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public class ApplicationConstants {
2828
public static final String OBJECT = "Object";
2929
public static final String STRING = "string";
3030
public static final String ARRAY = "array";
31+
public static final String OBJECT_ARRAY = "object[]";
3132
public static final String ENUM_VARS = "enumVars";
3233

3334
public static final String LIST_INSTANCE = "ListInstance";

src/main/java/com/twilio/oai/resolver/php/PhpParameterResolver.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import static com.twilio.oai.common.ApplicationConstants.ARRAY;
1111
import static com.twilio.oai.common.ApplicationConstants.OBJECT;
12+
import static com.twilio.oai.common.ApplicationConstants.OBJECT_ARRAY;
1213
import static com.twilio.oai.common.ApplicationConstants.SERIALIZE_VEND_EXT;
1314
import static com.twilio.oai.common.ApplicationConstants.STRING;
1415
import static com.twilio.oai.resolver.php.PhpPropertyResolver.MAP_STRING;
@@ -55,7 +56,7 @@ public void resolveSerialize(CodegenParameter codegenParameter) {
5556
if (codegenParameter.dataType != null && codegenParameter.dataType.contains("[]")) {
5657
codegenParameter.vendorExtensions.put(SERIALIZE_VEND_EXT, SERIALIZE_ARRAY_MAP);
5758
codegenParameter.vendorExtensions.put(SERIALIZE_VEND_EXT + LanguageConventionResolver.HYPHEN + MAP_STRING, true);
58-
if (codegenParameter.dataType.contains(ARRAY)) {
59+
if (codegenParameter.dataType.contains(ARRAY) || codegenParameter.dataType.contains(OBJECT_ARRAY)) {
5960
codegenParameter.vendorExtensions.put(SERIALIZE_VEND_EXT + LanguageConventionResolver.HYPHEN + ARRAY_OF_ARRAY_STRING, SERIALIZE_ARRAY_JSON_OBJECT);
6061
}
6162
}

0 commit comments

Comments
 (0)