Skip to content

Commit 417971c

Browse files
committed
moving guzzle6 warning to readme
1 parent 01fc074 commit 417971c

File tree

5 files changed

+17
-18
lines changed

5 files changed

+17
-18
lines changed

src/Generator/ClientFactoryGenerator.php

+1-7
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@
1313

1414
class ClientFactoryGenerator extends GeneratorAbstract
1515
{
16-
private const PSR18_EXCEPTION_WARNING = [
17-
'If using Guzzle 6, make sure to configure Guzzle to not throw exceptions',
18-
'on HTTP error status codes, or this client will violate PSR-18.',
19-
'e.g. new Client([\'base_uri\' => $baseUri, \'http_errors\' => false, ...])',
20-
];
21-
2216
private ContainerImplementationStrategy $containerImplementation;
2317

2418
public function __construct(
@@ -83,7 +77,7 @@ protected function generateCreate(Specification $specification): ClassMethod
8377
->addParams($params)
8478
->addStmts($statements)
8579
->setReturnType($clientClassName)
86-
->composeDocBlock($params, $clientClassName, [], self::PSR18_EXCEPTION_WARNING)
80+
->composeDocBlock($params, $clientClassName, [])
8781
->getNode();
8882
}
8983
}

template/README.md.twig

+8-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ dhlabs/api-client-generator
1616
```
1717

1818
## Usage
19-
{% set serverUrl = specification.serverUrls() is not empty ? specification.serverUrls()|first : '<server-base-url>' %}
2019
{% set requestClass = static('\\DoclerLabs\\ApiClientGenerator\\Naming\\RequestNaming', 'getClassName', exampleOperation) %}
2120

2221
```php
@@ -25,8 +24,15 @@ dhlabs/api-client-generator
2524
use {{ namespace }}\{{ static('\\DoclerLabs\\ApiClientGenerator\\Naming\\ClientNaming', 'getFactoryClassName', specification) }};
2625
use {{ namespace }}\Request\{{ requestClass }};
2726
27+
/**
28+
* If using Guzzle 6, make sure to configure Guzzle to not throw exceptions
29+
* on HTTP error status codes, or this client will violate PSR-18.
30+
* e.g. new Client(['base_uri' => $baseUri, 'http_errors' => false, ...])
31+
*/
32+
$client = ...; // any PSR-18 HTTP CLIENT
33+
2834
$factory = new {{ static('\\DoclerLabs\\ApiClientGenerator\\Naming\\ClientNaming', 'getFactoryClassName', specification) }}();
29-
$client = $factory->create('{{ serverUrl }}', ['timeout' => 2]);
35+
$client = $factory->create($client);
3036
3137
$request = new {{ requestClass }}();
3238
$result = $client->{{ exampleOperation.getName() }}($request);

test/suite/functional/Generator/ClientFactory/ClientFactoryDefault.php

-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616
class SwaggerPetstoreClientFactory
1717
{
1818
/**
19-
* If using Guzzle 6, make sure to configure Guzzle to not throw exceptions
20-
* on HTTP error status codes, or this client will violate PSR-18.
21-
* e.g. new Client(['base_uri' => $baseUri, 'http_errors' => false, ...])
22-
*
2319
* @param ClientInterface $client
2420
*
2521
* @return SwaggerPetstoreClient

test/suite/functional/Generator/ClientFactory/ClientFactoryNyholmMessage.php

-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616
class SwaggerPetstoreClientFactory
1717
{
1818
/**
19-
* If using Guzzle 6, make sure to configure Guzzle to not throw exceptions
20-
* on HTTP error status codes, or this client will violate PSR-18.
21-
* e.g. new Client(['base_uri' => $baseUri, 'http_errors' => false, ...])
22-
*
2319
* @param ClientInterface $client
2420
*
2521
* @return SwaggerPetstoreClient

test/suite/functional/Meta/ReadmeMd/README.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,15 @@ dhlabs/api-client-generator
2323
use Test\SwaggerPetstoreClientFactory;
2424
use Test\Request\FindPetsRequest;
2525

26+
/**
27+
* If using Guzzle 6, make sure to configure Guzzle to not throw exceptions
28+
* on HTTP error status codes, or this client will violate PSR-18.
29+
* e.g. new Client(['base_uri' => $baseUri, 'http_errors' => false, ...])
30+
*/
31+
$client = ...; // any PSR-18 HTTP CLIENT
32+
2633
$factory = new SwaggerPetstoreClientFactory();
27-
$client = $factory->create('http://petstore.swagger.io/api', ['timeout' => 2]);
34+
$client = $factory->create($client);
2835

2936
$request = new FindPetsRequest();
3037
$result = $client->findPets($request);

0 commit comments

Comments
 (0)