-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(php): allow to pass raw boolean to api #18520
Conversation
thanks for the PR cc |
modules/openapi-generator/src/main/resources/php-nextgen/ObjectSerializer.mustache
Show resolved
Hide resolved
d535e53
to
9c238cc
Compare
I have just applied this in my prod env in order to consume PowerDNS's api. |
6bd2f35
to
561d540
Compare
can you please update the sample when you've time? |
sure, my bad, sorry |
no problem. it looks good overall can you please add a test in https://github.com/OpenAPITools/openapi-generator/blob/master/samples/client/petstore/php/OpenAPIClient-php/tests/ObjectSerializerTest.php to ensure the fix is covered moving forward? |
Good call. There's already some singleton BooleanFormatForQueryString, I'll try to leverage that. |
This allows users to use APIs that require booleans in query params not to be cast to int, e.g. `&foo=true`. Currently, `true` is cast to `1` so it's passed as `&foo=1`. That might not be supported by the target API. The fix contains copy-pasted function from guzzlehttp/psr7 `Query::build()` with minor tweak.
php petstore tests also passed:
|
This allows users to use APIs that require booleans in query params not to be cast to int, e.g.
&foo=true
. Currently,true
is cast to1
so it's passed as&foo=1
. That might not be supported by the target API.The fix contains copy-pasted function from guzzlehttp/psr7
Query::build()
with minor tweaks.https://github.com/guzzle/psr7/blob/540ec79fb2f2e96591febb0de464bc16ac2ea341/src/Query.php#L73
Related to #2204
There's a proposal by me to include the functionality in guzzlehttp/psr7 guzzle/psr7#603
PR checklist
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*
.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master
(upcoming 7.1.0 minor release - breaking changes with fallbacks),8.0.x
(breaking changes without fallbacks)