Skip to content

Commit a39ed4d

Browse files
authored
Merge pull request #207 from php-api-clients/introduce-qa-settings
Introduce QA settings
2 parents da1c26f + cb5a28d commit a39ed4d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1234
-379
lines changed

composer.json

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"php": "^8.2",
1313
"api-clients/contracts": "^0.1",
1414
"api-clients/github": "^0.2@dev",
15+
"api-clients/openapi-client-utils": "dev-main",
1516
"ckr/arraymerger": "^3.0",
1617
"codeinc/http-reason-phrase-lookup": "^1.0",
1718
"delight-im/random": "^1.0",

composer.lock

+73-21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/openapi-client-miele.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,9 @@ voter:
3232
- ApiClients\Tools\OpenApiClientGenerator\Voter\ListOperation\PageAndPerPageInQuery
3333
streamOperation:
3434
- ApiClients\Tools\OpenApiClientGenerator\Voter\StreamOperation\DownloadInOperationId
35+
qa:
36+
phpcs:
37+
enabled: true
38+
phpstan:
39+
enabled: true
40+
configFilePath: etc/phpstan-extension.neon

example/openapi-client-one.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,9 @@ voter:
3232
- ApiClients\Tools\OpenApiClientGenerator\Voter\ListOperation\PageAndPerPageInQuery
3333
streamOperation:
3434
- ApiClients\Tools\OpenApiClientGenerator\Voter\StreamOperation\DownloadInOperationId
35+
qa:
36+
phpcs:
37+
enabled: true
38+
phpstan:
39+
enabled: true
40+
configFilePath: etc/phpstan-extension.neon

example/openapi-client-subsplit.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,9 @@ subSplit:
4747
sectionPackage:
4848
name: github-{{ section }}
4949
repository: [email protected]:php-api-clients/github-{{ section }}.git
50+
qa:
51+
phpcs:
52+
enabled: true
53+
phpstan:
54+
enabled: true
55+
configFilePath: etc/phpstan-extension.neon

example/templates/composer.json

+10
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
{% endfor %}
1717
{% endif %}
1818
"api-clients/contracts": "^0.1",
19+
"api-clients/openapi-client-utils": "dev-main",
1920
"devizzent/cebe-php-openapi": "^1",
2021
"eventsauce/object-hydrator": "^1.1",
2122
"league/openapi-psr7-validator": "^0.21",
@@ -48,6 +49,15 @@
4849
"api-clients/{{ suggest.name }}": "{{ suggest.reason }}"{% if not loop.last %},{% endif %}
4950
{% endfor %}
5051
},
52+
{% endif %}
53+
{% if qa.phpstan.enabled is constant('true') and qa.phpstan.configFilePath is not constant('null') %}
54+
"extra": {
55+
"phpstan": {
56+
"includes": [
57+
"{{ qa.phpstan.configFilePath }}"
58+
]
59+
}
60+
},
5161
{% endif %}
5262
"config": {
5363
"sort-packages": true,

example/templates/etc/qa/phpstan.neon

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
includes:
22
- ../../vendor/wyrihaximus/async-test-utilities/rules.neon
3+
- ../phpstan-extension.neon

src/Configuration.php

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use ApiClients\Tools\OpenApiClientGenerator\Configuration\Destination;
88
use ApiClients\Tools\OpenApiClientGenerator\Configuration\EntryPoints;
99
use ApiClients\Tools\OpenApiClientGenerator\Configuration\Namespace_;
10+
use ApiClients\Tools\OpenApiClientGenerator\Configuration\QA;
1011
use ApiClients\Tools\OpenApiClientGenerator\Configuration\Schemas;
1112
use ApiClients\Tools\OpenApiClientGenerator\Configuration\State;
1213
use ApiClients\Tools\OpenApiClientGenerator\Configuration\SubSplit;
@@ -32,6 +33,7 @@ public function __construct(
3233
public SubSplit|null $subSplit,
3334
public Schemas|null $schemas,
3435
public Voter|null $voter,
36+
public QA|null $qa,
3537
) {
3638
}
3739
}

src/Configuration/QA.php

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace ApiClients\Tools\OpenApiClientGenerator\Configuration;
6+
7+
use ApiClients\Tools\OpenApiClientGenerator\Configuration\QA\Tool;
8+
9+
final readonly class QA
10+
{
11+
public function __construct(
12+
public Tool|null $phpcs,
13+
public Tool|null $phpstan,
14+
public Tool|null $psalm,
15+
) {
16+
}
17+
}

src/Configuration/QA/Tool.php

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace ApiClients\Tools\OpenApiClientGenerator\Configuration\QA;
6+
7+
use EventSauce\ObjectHydrator\MapFrom;
8+
9+
final readonly class Tool
10+
{
11+
public function __construct(
12+
public bool $enabled,
13+
#[MapFrom('configFilePath')]
14+
public string|null $configFilePath,
15+
) {
16+
}
17+
}

src/Gatherer/WebHook.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ public static function gather(
2424
PathItem $webhook,
2525
SchemaRegistry $schemaRegistry,
2626
): \ApiClients\Tools\OpenApiClientGenerator\Representation\WebHook {
27-
if ($webhook->post?->requestBody === null || ! property_exists($webhook->post->requestBody, 'content')) {
28-
// var_export(json_decode(json_encode($webhook->getSerializableData())));
27+
if ($webhook->post?->requestBody === null && ! property_exists($webhook->post->requestBody, 'content')) {
2928
throw new RuntimeException('Missing request body content to deal with');
3029
}
3130

@@ -45,7 +44,7 @@ public static function gather(
4544
),
4645
$header->schema,
4746
$schemaRegistry,
48-
), ExampleData::determiteType($headerSpec->example));
47+
), ExampleData::determiteType($header->example));
4948
}
5049

5150
return new \ApiClients\Tools\OpenApiClientGenerator\Representation\WebHook(

src/Gatherer/WebHookHydrator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public static function gather(
2626

2727
return Hydrator::gather(
2828
$baseNamespace,
29-
'Internal\\WebHook\\' . Utils::className($event),
29+
'WebHook\\' . Utils::className($event),
3030
'🪝',
3131
...$schemaClasses,
3232
);

0 commit comments

Comments
 (0)