psr7 icon indicating copy to clipboard operation
psr7 copied to clipboard

feat: add support for keeping boolean values "as is" in query

Open simPod opened this issue 10 months ago • 0 comments

I've stumbled upon this for like milion times now.

This is a follow up of https://github.com/guzzle/psr7/pull/391

Currently, there's no way not to cast boolean values to int in a query. http_build_query() casts booleans to ints, however, that is not always the wanted behaviour when constructing a query to call some API.

E.g. Swagger sends =true =false for params of type boolean. There are APIs that require this value format (e.g. https://github.com/PowerDNS/pdns).

This has been discussed many times over and over and the conclusion I make of it is that the behaviour should be configurable since it depends on the target API (e.g. see https://github.com/OpenAPITools/openapi-generator/issues/2204).

Therefore, I propose a flag that allows switch the behaviour in Query::build(). It should be BC compatible with the default value.

simPod avatar Apr 27 '24 10:04 simPod