Skip to content

Commit

Permalink
Merge pull request #207 from php-api-clients/introduce-qa-settings
Browse files Browse the repository at this point in the history
Introduce QA settings
  • Loading branch information
WyriHaximus authored Oct 16, 2023
2 parents da1c26f + cb5a28d commit a39ed4d
Show file tree
Hide file tree
Showing 70 changed files with 1,234 additions and 379 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"php": "^8.2",
"api-clients/contracts": "^0.1",
"api-clients/github": "^0.2@dev",
"api-clients/openapi-client-utils": "dev-main",
"ckr/arraymerger": "^3.0",
"codeinc/http-reason-phrase-lookup": "^1.0",
"delight-im/random": "^1.0",
Expand Down
94 changes: 73 additions & 21 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions example/openapi-client-miele.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,9 @@ voter:
- ApiClients\Tools\OpenApiClientGenerator\Voter\ListOperation\PageAndPerPageInQuery
streamOperation:
- ApiClients\Tools\OpenApiClientGenerator\Voter\StreamOperation\DownloadInOperationId
qa:
phpcs:
enabled: true
phpstan:
enabled: true
configFilePath: etc/phpstan-extension.neon
6 changes: 6 additions & 0 deletions example/openapi-client-one.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,9 @@ voter:
- ApiClients\Tools\OpenApiClientGenerator\Voter\ListOperation\PageAndPerPageInQuery
streamOperation:
- ApiClients\Tools\OpenApiClientGenerator\Voter\StreamOperation\DownloadInOperationId
qa:
phpcs:
enabled: true
phpstan:
enabled: true
configFilePath: etc/phpstan-extension.neon
6 changes: 6 additions & 0 deletions example/openapi-client-subsplit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,9 @@ subSplit:
sectionPackage:
name: github-{{ section }}
repository: [email protected]:php-api-clients/github-{{ section }}.git
qa:
phpcs:
enabled: true
phpstan:
enabled: true
configFilePath: etc/phpstan-extension.neon
10 changes: 10 additions & 0 deletions example/templates/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
{% endfor %}
{% endif %}
"api-clients/contracts": "^0.1",
"api-clients/openapi-client-utils": "dev-main",
"devizzent/cebe-php-openapi": "^1",
"eventsauce/object-hydrator": "^1.1",
"league/openapi-psr7-validator": "^0.21",
Expand Down Expand Up @@ -48,6 +49,15 @@
"api-clients/{{ suggest.name }}": "{{ suggest.reason }}"{% if not loop.last %},{% endif %}
{% endfor %}
},
{% endif %}
{% if qa.phpstan.enabled is constant('true') and qa.phpstan.configFilePath is not constant('null') %}
"extra": {
"phpstan": {
"includes": [
"{{ qa.phpstan.configFilePath }}"
]
}
},
{% endif %}
"config": {
"sort-packages": true,
Expand Down
1 change: 1 addition & 0 deletions example/templates/etc/qa/phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
includes:
- ../../vendor/wyrihaximus/async-test-utilities/rules.neon
- ../phpstan-extension.neon
2 changes: 2 additions & 0 deletions src/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use ApiClients\Tools\OpenApiClientGenerator\Configuration\Destination;
use ApiClients\Tools\OpenApiClientGenerator\Configuration\EntryPoints;
use ApiClients\Tools\OpenApiClientGenerator\Configuration\Namespace_;
use ApiClients\Tools\OpenApiClientGenerator\Configuration\QA;
use ApiClients\Tools\OpenApiClientGenerator\Configuration\Schemas;
use ApiClients\Tools\OpenApiClientGenerator\Configuration\State;
use ApiClients\Tools\OpenApiClientGenerator\Configuration\SubSplit;
Expand All @@ -32,6 +33,7 @@ public function __construct(
public SubSplit|null $subSplit,
public Schemas|null $schemas,
public Voter|null $voter,
public QA|null $qa,
) {
}
}
17 changes: 17 additions & 0 deletions src/Configuration/QA.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

namespace ApiClients\Tools\OpenApiClientGenerator\Configuration;

use ApiClients\Tools\OpenApiClientGenerator\Configuration\QA\Tool;

final readonly class QA
{
public function __construct(
public Tool|null $phpcs,
public Tool|null $phpstan,
public Tool|null $psalm,
) {
}
}
17 changes: 17 additions & 0 deletions src/Configuration/QA/Tool.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

namespace ApiClients\Tools\OpenApiClientGenerator\Configuration\QA;

use EventSauce\ObjectHydrator\MapFrom;

final readonly class Tool
{
public function __construct(
public bool $enabled,
#[MapFrom('configFilePath')]
public string|null $configFilePath,
) {
}
}
5 changes: 2 additions & 3 deletions src/Gatherer/WebHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ public static function gather(
PathItem $webhook,
SchemaRegistry $schemaRegistry,
): \ApiClients\Tools\OpenApiClientGenerator\Representation\WebHook {
if ($webhook->post?->requestBody === null || ! property_exists($webhook->post->requestBody, 'content')) {
// var_export(json_decode(json_encode($webhook->getSerializableData())));
if ($webhook->post?->requestBody === null && ! property_exists($webhook->post->requestBody, 'content')) {

Check failure on line 27 in src/Gatherer/WebHook.php

View workflow job for this annotation

GitHub Actions / Continuous Integration / Continuous Integration / Run stan on PHP 8.2 with locked dependency preference

Cannot access property $requestBody on cebe\openapi\spec\Operation|null.

Check failure on line 27 in src/Gatherer/WebHook.php

View workflow job for this annotation

GitHub Actions / Continuous Integration / Continuous Integration / Run stan on PHP 8.2 with highest dependency preference

Cannot access property $requestBody on cebe\openapi\spec\Operation|null.
throw new RuntimeException('Missing request body content to deal with');
}

Expand All @@ -45,7 +44,7 @@ public static function gather(
),
$header->schema,
$schemaRegistry,
), ExampleData::determiteType($headerSpec->example));
), ExampleData::determiteType($header->example));
}

return new \ApiClients\Tools\OpenApiClientGenerator\Representation\WebHook(
Expand Down
2 changes: 1 addition & 1 deletion src/Gatherer/WebHookHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static function gather(

return Hydrator::gather(
$baseNamespace,
'Internal\\WebHook\\' . Utils::className($event),
'WebHook\\' . Utils::className($event),
'🪝',
...$schemaClasses,
);
Expand Down
Loading

0 comments on commit a39ed4d

Please sign in to comment.