diff --git a/src/OpenApi/Tests/fixtures/api-platform-demo/expected/Authentication/ApiKeyAuthentication.php b/src/OpenApi/Tests/fixtures/api-platform-demo/expected/Authentication/ApiKeyAuthentication.php new file mode 100644 index 0000000000..302fab0a97 --- /dev/null +++ b/src/OpenApi/Tests/fixtures/api-platform-demo/expected/Authentication/ApiKeyAuthentication.php @@ -0,0 +1,27 @@ +{'apiKey'} = $apiKey; + } + public function getPlugin() : \Http\Client\Common\Plugin + { + return new \Http\Client\Common\Plugin\AuthenticationPlugin(new class($this->{'apiKey'}) implements \Http\Message\Authentication + { + private $apiKey; + public function __construct(string $apiKey) + { + $this->{'apiKey'} = $apiKey; + } + public function authenticate(\Psr\Http\Message\RequestInterface $request) + { + return $request->withHeader('Authorization', $this->{'apiKey'}); + } + }); + } +} \ No newline at end of file diff --git a/src/OpenApi/Tests/fixtures/api-platform-demo/expected/Client.php b/src/OpenApi/Tests/fixtures/api-platform-demo/expected/Client.php index f9e81dc13f..b9d286f66e 100644 --- a/src/OpenApi/Tests/fixtures/api-platform-demo/expected/Client.php +++ b/src/OpenApi/Tests/fixtures/api-platform-demo/expected/Client.php @@ -288,10 +288,15 @@ public function putReviewItem(string $id, $requestBody, string $fetch = self::FE { return $this->executePsr7Endpoint(new \ApiPlatform\Demo\Endpoint\PutReviewItem($id, $requestBody), $fetch); } - public static function create($httpClient = null) + public static function create($httpClient = null, \Jane\OpenApiRuntime\Client\Authentication $authentication = null) { if (null === $httpClient) { $httpClient = \Http\Discovery\HttpClientDiscovery::find(); + $plugins = array(); + if (null !== $authentication) { + $plugins[] = $authentication->getPlugin(); + } + $httpClient = new \Http\Client\Common\PluginClient($httpClient, $plugins); } $messageFactory = \Http\Discovery\MessageFactoryDiscovery::find(); $streamFactory = \Http\Discovery\StreamFactoryDiscovery::find();