Use this adapter when your application standardizes on Guzzle.
$config->generationTarget = GenerationTarget::Client;
$config->httpClient = HttpClientAdapter::Guzzle;
public function __construct(
private readonly ClientInterface $httpClient,
private readonly string $baseUrl,
) {
}
$url = rtrim($this->baseUrl, '/') . '/pets/' . rawurlencode((string) $petId)
. ($queryString === '' ? '' : '?' . $queryString);
$options = [];
$options[RequestOptions::JSON] = $body->toRequestArray();
$options[RequestOptions::HTTP_ERRORS] = false;
$response = $this->httpClient->request('PUT', $url, $options);
The generated code decodes response JSON explicitly and rejects non-JSON
content types or invalid JSON with an UnexpectedValueException:
$data = $this->decodeJsonResponse($response->getHeaderLine('Content-Type'), (string) $response->getBody(), 'updatePet');
Then maps the payload to generated models via fromArray().
RequestOptions constants for predictable option names.