Skip to content
GitLab
    • Explore Projects Groups Snippets
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Merge requests
  • !14323

[PHP] \GuzzleHttp\json_encode is deprecated, use \GuzzleHttp\Utils::jsonEncode instead

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/lddsb/master into master 2 years ago
  • Overview 3
  • Commits 1
  • Pipelines 0
  • Changes 8

Created by: lddsb

  • perf: \GuzzleHttp\json_encode is deprecated, use \GuzzleHttp\Utils::jsonEncode instead

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    Commit all changed files. This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*. For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master (6.3.0) (minor release - breaking changes with fallbacks), 7.0.x (breaking changes without fallbacks)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.
Compare
  • master (base)

and
  • latest version
    20557469
    1 commit, 2 years ago

8 files
+ 63
- 63

    Preferences

    File browser
    Compare changes
modules/openapi-g‎enerator/…/…/…/php‎
api.mu‎stache‎ +2 -2
samples/client/pe‎tstore/…/…/lib/Api‎
AnotherFa‎keApi.php‎ +2 -2
Default‎Api.php‎ +1 -1
FakeA‎pi.php‎ +28 -28
FakeClassname‎Tags123Api.php‎ +2 -2
PetAp‎i.php‎ +11 -11
StoreA‎pi.php‎ +5 -5
UserA‎pi.php‎ +12 -12
modules/openapi-generator/src/main/resources/php/api.mustache
+ 2
- 2
  • View file @ 20557469

  • Edit in single-file editor

  • Open in Web IDE


@@ -674,7 +674,7 @@ use {{invokerPackage}}\ObjectSerializer;
if (isset(${{paramName}})) {
if (stripos($headers['Content-Type'], 'application/json') !== false) {
# if Content-Type contains "application/json", json_encode the body
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization(${{paramName}}));
$httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization(${{paramName}}));
} else {
$httpBody = ${{paramName}};
}
@@ -699,7 +699,7 @@ use {{invokerPackage}}\ObjectSerializer;
} elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
# if Content-Type contains "application/json", json_encode the form parameters
$httpBody = \GuzzleHttp\json_encode($formParams);
$httpBody = \GuzzleHttp\Utils::jsonEncode($formParams);
} else {
// for HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($formParams);
samples/client/petstore/php/OpenAPIClient-php/lib/Api/AnotherFakeApi.php
+ 2
- 2
  • View file @ 20557469

  • Edit in single-file editor

  • Open in Web IDE


@@ -354,7 +354,7 @@ class AnotherFakeApi
if (isset($client)) {
if (stripos($headers['Content-Type'], 'application/json') !== false) {
# if Content-Type contains "application/json", json_encode the body
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($client));
$httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($client));
} else {
$httpBody = $client;
}
@@ -375,7 +375,7 @@ class AnotherFakeApi
} elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
# if Content-Type contains "application/json", json_encode the form parameters
$httpBody = \GuzzleHttp\json_encode($formParams);
$httpBody = \GuzzleHttp\Utils::jsonEncode($formParams);
} else {
// for HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($formParams);
samples/client/petstore/php/OpenAPIClient-php/lib/Api/DefaultApi.php
+ 1
- 1
  • View file @ 20557469

  • Edit in single-file editor

  • Open in Web IDE


@@ -348,7 +348,7 @@ class DefaultApi
} elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
# if Content-Type contains "application/json", json_encode the form parameters
$httpBody = \GuzzleHttp\json_encode($formParams);
$httpBody = \GuzzleHttp\Utils::jsonEncode($formParams);
} else {
// for HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($formParams);
samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php
+ 28
- 28
  • View file @ 20557469

  • Edit in single-file editor

  • Open in Web IDE


@@ -405,7 +405,7 @@ class FakeApi
} elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
# if Content-Type contains "application/json", json_encode the form parameters
$httpBody = \GuzzleHttp\json_encode($formParams);
$httpBody = \GuzzleHttp\Utils::jsonEncode($formParams);
} else {
// for HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($formParams);
@@ -637,7 +637,7 @@ class FakeApi
if (isset($pet)) {
if (stripos($headers['Content-Type'], 'application/json') !== false) {
# if Content-Type contains "application/json", json_encode the body
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($pet));
$httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($pet));
} else {
$httpBody = $pet;
}
@@ -658,7 +658,7 @@ class FakeApi
} elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
# if Content-Type contains "application/json", json_encode the form parameters
$httpBody = \GuzzleHttp\json_encode($formParams);
$httpBody = \GuzzleHttp\Utils::jsonEncode($formParams);
} else {
// for HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($formParams);
@@ -905,7 +905,7 @@ class FakeApi
if (isset($body)) {
if (stripos($headers['Content-Type'], 'application/json') !== false) {
# if Content-Type contains "application/json", json_encode the body
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($body));
$httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($body));
} else {
$httpBody = $body;
}
@@ -926,7 +926,7 @@ class FakeApi
} elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
# if Content-Type contains "application/json", json_encode the form parameters
$httpBody = \GuzzleHttp\json_encode($formParams);
$httpBody = \GuzzleHttp\Utils::jsonEncode($formParams);
} else {
// for HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($formParams);
@@ -1173,7 +1173,7 @@ class FakeApi
if (isset($outer_composite)) {
if (stripos($headers['Content-Type'], 'application/json') !== false) {
# if Content-Type contains "application/json", json_encode the body
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($outer_composite));
$httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($outer_composite));
} else {
$httpBody = $outer_composite;
}
@@ -1194,7 +1194,7 @@ class FakeApi
} elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
# if Content-Type contains "application/json", json_encode the form parameters
$httpBody = \GuzzleHttp\json_encode($formParams);
$httpBody = \GuzzleHttp\Utils::jsonEncode($formParams);
} else {
// for HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($formParams);
@@ -1441,7 +1441,7 @@ class FakeApi
if (isset($body)) {
if (stripos($headers['Content-Type'], 'application/json') !== false) {
# if Content-Type contains "application/json", json_encode the body
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($body));
$httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($body));
} else {
$httpBody = $body;
}
@@ -1462,7 +1462,7 @@ class FakeApi
} elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
# if Content-Type contains "application/json", json_encode the form parameters
$httpBody = \GuzzleHttp\json_encode($formParams);
$httpBody = \GuzzleHttp\Utils::jsonEncode($formParams);
} else {
// for HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($formParams);
@@ -1709,7 +1709,7 @@ class FakeApi
if (isset($body)) {
if (stripos($headers['Content-Type'], 'application/json') !== false) {
# if Content-Type contains "application/json", json_encode the body
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($body));
$httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($body));
} else {
$httpBody = $body;
}
@@ -1730,7 +1730,7 @@ class FakeApi
} elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
# if Content-Type contains "application/json", json_encode the form parameters
$httpBody = \GuzzleHttp\json_encode($formParams);
$httpBody = \GuzzleHttp\Utils::jsonEncode($formParams);
} else {
// for HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($formParams);
@@ -1983,7 +1983,7 @@ class FakeApi
if (isset($outer_object_with_enum_property)) {
if (stripos($headers['Content-Type'], 'application/json') !== false) {
# if Content-Type contains "application/json", json_encode the body
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($outer_object_with_enum_property));
$httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($outer_object_with_enum_property));
} else {
$httpBody = $outer_object_with_enum_property;
}
@@ -2004,7 +2004,7 @@ class FakeApi
} elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
# if Content-Type contains "application/json", json_encode the form parameters
$httpBody = \GuzzleHttp\json_encode($formParams);
$httpBody = \GuzzleHttp\Utils::jsonEncode($formParams);
} else {
// for HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($formParams);
@@ -2203,7 +2203,7 @@ class FakeApi
if (isset($body)) {
if (stripos($headers['Content-Type'], 'application/json') !== false) {
# if Content-Type contains "application/json", json_encode the body
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($body));
$httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($body));
} else {
$httpBody = $body;
}
@@ -2224,7 +2224,7 @@ class FakeApi
} elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
# if Content-Type contains "application/json", json_encode the form parameters
$httpBody = \GuzzleHttp\json_encode($formParams);
$httpBody = \GuzzleHttp\Utils::jsonEncode($formParams);
} else {
// for HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($formParams);
@@ -2423,7 +2423,7 @@ class FakeApi
if (isset($file_schema_test_class)) {
if (stripos($headers['Content-Type'], 'application/json') !== false) {
# if Content-Type contains "application/json", json_encode the body
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($file_schema_test_class));
$httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($file_schema_test_class));
} else {
$httpBody = $file_schema_test_class;
}
@@ -2444,7 +2444,7 @@ class FakeApi
} elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
# if Content-Type contains "application/json", json_encode the form parameters
$httpBody = \GuzzleHttp\json_encode($formParams);
$httpBody = \GuzzleHttp\Utils::jsonEncode($formParams);
} else {
// for HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($formParams);
@@ -2664,7 +2664,7 @@ class FakeApi
if (isset($user)) {
if (stripos($headers['Content-Type'], 'application/json') !== false) {
# if Content-Type contains "application/json", json_encode the body
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($user));
$httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($user));
} else {
$httpBody = $user;
}
@@ -2685,7 +2685,7 @@ class FakeApi
} elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
# if Content-Type contains "application/json", json_encode the form parameters
$httpBody = \GuzzleHttp\json_encode($formParams);
$httpBody = \GuzzleHttp\Utils::jsonEncode($formParams);
} else {
// for HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($formParams);
@@ -2946,7 +2946,7 @@ class FakeApi
if (isset($client)) {
if (stripos($headers['Content-Type'], 'application/json') !== false) {
# if Content-Type contains "application/json", json_encode the body
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($client));
$httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($client));
} else {
$httpBody = $client;
}
@@ -2967,7 +2967,7 @@ class FakeApi
} elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
# if Content-Type contains "application/json", json_encode the form parameters
$httpBody = \GuzzleHttp\json_encode($formParams);
$httpBody = \GuzzleHttp\Utils::jsonEncode($formParams);
} else {
// for HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($formParams);
@@ -3387,7 +3387,7 @@ class FakeApi
} elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
# if Content-Type contains "application/json", json_encode the form parameters
$httpBody = \GuzzleHttp\json_encode($formParams);
$httpBody = \GuzzleHttp\Utils::jsonEncode($formParams);
} else {
// for HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($formParams);
@@ -3718,7 +3718,7 @@ class FakeApi
} elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
# if Content-Type contains "application/json", json_encode the form parameters
$httpBody = \GuzzleHttp\json_encode($formParams);
$httpBody = \GuzzleHttp\Utils::jsonEncode($formParams);
} else {
// for HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($formParams);
@@ -4043,7 +4043,7 @@ class FakeApi
} elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
# if Content-Type contains "application/json", json_encode the form parameters
$httpBody = \GuzzleHttp\json_encode($formParams);
$httpBody = \GuzzleHttp\Utils::jsonEncode($formParams);
} else {
// for HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($formParams);
@@ -4254,7 +4254,7 @@ class FakeApi
if (isset($request_body)) {
if (stripos($headers['Content-Type'], 'application/json') !== false) {
# if Content-Type contains "application/json", json_encode the body
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($request_body));
$httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($request_body));
} else {
$httpBody = $request_body;
}
@@ -4275,7 +4275,7 @@ class FakeApi
} elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
# if Content-Type contains "application/json", json_encode the form parameters
$httpBody = \GuzzleHttp\json_encode($formParams);
$httpBody = \GuzzleHttp\Utils::jsonEncode($formParams);
} else {
// for HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($formParams);
@@ -4516,7 +4516,7 @@ class FakeApi
} elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
# if Content-Type contains "application/json", json_encode the form parameters
$httpBody = \GuzzleHttp\json_encode($formParams);
$httpBody = \GuzzleHttp\Utils::jsonEncode($formParams);
} else {
// for HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($formParams);
@@ -4858,7 +4858,7 @@ class FakeApi
} elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
# if Content-Type contains "application/json", json_encode the form parameters
$httpBody = \GuzzleHttp\json_encode($formParams);
$httpBody = \GuzzleHttp\Utils::jsonEncode($formParams);
} else {
// for HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($formParams);
samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeClassnameTags123Api.php
+ 2
- 2
  • View file @ 20557469

  • Edit in single-file editor

  • Open in Web IDE


@@ -354,7 +354,7 @@ class FakeClassnameTags123Api
if (isset($client)) {
if (stripos($headers['Content-Type'], 'application/json') !== false) {
# if Content-Type contains "application/json", json_encode the body
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($client));
$httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($client));
} else {
$httpBody = $client;
}
@@ -375,7 +375,7 @@ class FakeClassnameTags123Api
} elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
# if Content-Type contains "application/json", json_encode the form parameters
$httpBody = \GuzzleHttp\json_encode($formParams);
$httpBody = \GuzzleHttp\Utils::jsonEncode($formParams);
} else {
// for HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($formParams);
0 Assignees
None
Assign to
0 Reviewers
None
Request review from
Labels
2
Client: PHP Enhancement: Code Cleanup
2
Client: PHP Enhancement: Code Cleanup
    Assign labels
  • Manage project labels

Milestone
6.3.0
6.3.0 (expired)
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
2
2 participants
Administrator
William Cheng
Reference: OpenAPITools/openapi-generator!14323
Source branch: github/fork/lddsb/master

Menu

Explore Projects Groups Snippets