Use GenerationTarget::Client to generate typed API client classes from paths plus DTO models from components/schemas.
This keeps API client generation in a PHP-native workflow: no npm-based generators required.
For each API group, the generator creates:
*ApiClientInterface for mocking and test seams*ApiClient concrete implementationTypical output:
generated/
|- Api/
| |- PetsApiClientInterface.php
| `- PetsApiClient.php
`- Model/
|- Pet.php
|- NewPet.php
`- ...
<?php
declare(strict_types=1);
use MaxBeckers\OpenApiGenerator\Config\GenerationTarget;
use MaxBeckers\OpenApiGenerator\Config\GeneratorConfig;
use MaxBeckers\OpenApiGenerator\Config\HttpClientAdapter;
$config = new GeneratorConfig();
$config->specFile = 'openapi.yaml';
$config->outputDir = 'generated';
$config->generationTarget = GenerationTarget::Client;
$config->httpClient = HttpClientAdapter::SymfonyHttpClient;
$config->httpClientVersion = '7.0'; // optional, for adapter-specific breaking changes
$config->modelNamespace = 'App\\Model';
$config->apiNamespace = 'App\\Api';
return $config;
Generated client methods usually follow this flow:
baseUrl and path template values.fromArray().Shared behavior:
toArray()array_map(...)204/no-content operations return voidHttpClientAdapter::SymfonyHttpClient: default, compact code, great for Symfony ecosystemsHttpClientAdapter::Guzzle: good if your stack already uses Guzzle middlewareHttpClientAdapter::Psr18: framework-neutral and portableSet $config->httpClientVersion if the generated transport code ever needs to distinguish between major adapter versions. This mirrors $config->frameworkVersion on the server side and keeps version-aware generation explicit in config rather than inferred from installed packages.
See HTTP Client Adapters for concrete adapter examples.
If enabled in config, generated clients can validate request and response DTOs around HTTP calls.