Skip to content

Commit

Permalink
Fixing api-platform-demo expected classes
Browse files Browse the repository at this point in the history
  • Loading branch information
Korbeil committed Dec 10, 2019
1 parent c209b22 commit f5014a4
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
@@ -0,0 +1,27 @@
<?php

namespace ApiPlatform\Demo\Authentication;

class ApiKeyAuthentication implements \Jane\OpenApiRuntime\Client\Authentication
{
private $apiKey;
public function __construct(string $apiKey)
{
$this->{'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'});
}
});
}
}
Expand Up @@ -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();
Expand Down

0 comments on commit f5014a4

Please sign in to comment.