Use this adapter when generating clients for projects that already use Symfony contracts.
$config->generationTarget = GenerationTarget::Client;
$config->httpClient = HttpClientAdapter::SymfonyHttpClient;
$config->httpClientVersion = '7.0';
public function __construct(
private readonly HttpClientInterface $httpClient,
private readonly string $baseUrl,
) {
}
$response = $this->httpClient->request(
'GET',
$this->baseUrl . "/pets/{$petId}",
);
For operations with a request body, the generator sends:
[
'json' => $body->toArray(),
]
For operations with query parameters, the generator sends:
[
'query' => $query,
]
Pet::fromArray($response->toArray())array_map(static fn(array $item) => Pet::fromArray($item), $response->toArray())symfony/http-client.