Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
- "ubuntu-latest"
- "windows-latest"
php-version:
- "8.1"
- "8.2"
- "8.3"
- "8.4"
- "8.5"
dependencies:
- "lowest"
- "highest"
Expand Down Expand Up @@ -55,7 +55,7 @@ jobs:
operating-system:
- "ubuntu-latest"
php-version:
- "8.4"
- "8.5"
steps:
- name: "Checkout"
uses: "actions/checkout@v2"
Expand Down Expand Up @@ -83,7 +83,7 @@ jobs:
operating-system:
- "ubuntu-latest"
php-version:
- "8.4"
- "8.5"
steps:
- name: "Checkout"
uses: "actions/checkout@v2"
Expand Down Expand Up @@ -111,7 +111,7 @@ jobs:
operating-system:
- "ubuntu-latest"
php-version:
- "8.4"
- "8.5"
steps:
- name: "Checkout"
uses: "actions/checkout@v2"
Expand All @@ -130,7 +130,7 @@ jobs:
- name: "Install highest dependencies"
run: "composer update --no-interaction --no-progress"
- name: "Execute PhpCs"
run: "vendor/bin/phpcs --config-set php_version 7040 && vendor/bin/phpcs -q --report=checkstyle | cs2pr"
run: "vendor/bin/phpcs --config-set php_version 8020 && vendor/bin/phpcs -q --report=checkstyle | cs2pr"
coverage:
name: "Code coverage"
runs-on: "ubuntu-latest"
Expand All @@ -139,7 +139,7 @@ jobs:
operating-system:
- "ubuntu-latest"
php-version:
- "8.4"
- "8.5"
steps:
- name: "Checkout"
uses: "actions/checkout@v2"
Expand Down Expand Up @@ -172,7 +172,7 @@ jobs:
operating-system:
- "ubuntu-latest"
php-version:
- "8.4"
- "8.5"
steps:
- name: "Checkout"
uses: "actions/checkout@v2"
Expand All @@ -191,7 +191,7 @@ jobs:
- name: "Install highest dependencies"
run: "composer update --no-interaction --no-progress"
- name: "Infection"
run: "vendor/bin/roave-infection-static-analysis-plugin --only-covered --test-framework-options=\"--testsuite=unit\""
run: "vendor/bin/roave-infection-static-analysis-plugin --test-framework-options=\"--testsuite=unit\""
env:
INFECTION_BADGE_API_KEY: ${{ secrets.INFECTION_BADGE_API_KEY }}
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
Expand All @@ -203,7 +203,7 @@ jobs:
operating-system:
- "ubuntu-latest"
php-version:
- "8.4"
- "8.5"
steps:
- name: "Checkout"
uses: "actions/checkout@v2"
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ open_api_server:
specs:
petstore:
path: '../spec/petstore.yaml' # path to OpenApi specification
type: yaml # Specification format, either yaml or json. If omitted, the specification file extension will be used.
type: yaml # Specification format, either YAML or JSON. If omitted, the specification file extension will be used.
name_space: PetStore # Namespace for generated DTOs and Interfaces
media_type: 'application/json' # media type from the specification files to use for generating request and response DTOs
#date_time_class: '\Carbon\CarbonImmutable' # FQCN which implements \DateTimeInterface.
Expand All @@ -82,7 +82,7 @@ petstore-api:
## Requirements for your OpenAPI schemas

For the bundle to work properly with your specifications, they should be written in OpenAPI 3.0 format and each
operation must have an unique `operationId`.
operation must have a unique `operationId`.

Currently, there are also the following limitations:
- `number` without `format` is treated as float
Expand All @@ -105,7 +105,7 @@ Be careful with the generate and delete commands, they will delete the entire co
in `root_path` in the `/config/packages/open_api_server.yaml` file. That directory should contain no files except
the code generated by this bundle, as it will be deleted every time you generate the API server code.

For each operation described in the specification, a API call handler interface will be generated that you should implement
For each operation described in the specification, an API call handler interface will be generated that you should implement
to handle the API calls.

## Implementing the API call handlers interfaces
Expand Down Expand Up @@ -195,9 +195,9 @@ public function showPetById(ShowPetByIdRequestDto $request) : ShowPetByIdRespons

## Customizing the API server behavior

During the request handling lyfecycle the API server emits several events that can be used instead
of the built-in Symfony Kernel events as the former provide more context. Theese events allow
hooking into the API server functionality and modify it's behavior.
During the request handling lifecycle the API server emits several events that can be used instead
of the built-in Symfony Kernel events as the former provide more context. These events allow
hooking into the API server functionality and modify its behavior.

The following events are available:

Expand All @@ -218,8 +218,8 @@ The following events are available:
The ResponseDtoEvent event occurs after the request handler class was executed returning a ResponseDto and
before this ResponseDto is serialized to a Response.
This event allows you to modify the ResponseDto contents before it will be serialized. This can be used as an
alternative to modyfing the Response object in a Symfony ResponseEvent, avoiding unnecessary decoding/encoding
of the Response body json.
alternative to modifying the Response object in a Symfony ResponseEvent, avoiding unnecessary decoding/encoding
of the Response body JSON.
Note that the ResponseDTO is not created if the API endpoint has no response body.
- `OnMoon\OpenApiServerBundle\Event\Server\ResponseEvent`

Expand Down
58 changes: 29 additions & 29 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,42 +22,42 @@
}
],
"require": {
"php": "^8.1",
"php": "^8.2",
"ext-json": "*",
"devizzent/cebe-php-openapi": "^1.1.4",
"league/openapi-psr7-validator": "^0.22.0",
"devizzent/cebe-php-openapi": "^1.1.5",
"league/openapi-psr7-validator": "^0.22",
"lukasoppermann/http-status": "^4.0",
"nikic/php-parser": "^4.19|^v5.0",
"nyholm/psr7": "^1.5",
"phpdocumentor/reflection-docblock": "^5.3",
"sspat/reserved-words": "^3.0",
"symfony/cache": "^6.4|^7.0",
"symfony/cache-contracts": "^3.5",
"symfony/config": "^6.4|^7.0",
"symfony/console": "^6.4|^7.0",
"symfony/dependency-injection": "^6.4|^7.0",
"symfony/event-dispatcher": "^6.4|^7.0",
"symfony/http-kernel": "^6.4|^7.0",
"symfony/psr-http-message-bridge": "^6.4|^7.0",
"symfony/routing": "^6.4|^7.0",
"symfony/yaml": "^6.4|^7.0",
"nyholm/psr7": "^1.8",
"phpdocumentor/reflection-docblock": "^6.0",
"sspat/reserved-words": "^3.0.2",
"symfony/cache": "^6.4|^7.4|^8.0",
"symfony/cache-contracts": "^3.6",
"symfony/config": "^6.4|^7.4|^8.0",
"symfony/console": "^6.4|^7.4|^8.0",
"symfony/dependency-injection": "^6.4|^7.4|^8.0",
"symfony/event-dispatcher": "^6.4|^7.4|^8.0",
"symfony/http-kernel": "^6.4|^7.4|^8.0",
"symfony/psr-http-message-bridge": "^6.4|^7.4|^8.0",
"symfony/routing": "^6.4|^7.4|^8.0",
"symfony/yaml": "^6.4|^7.4|^8.0",
"thecodingmachine/safe": "^1.3|^2|^3.1"
},
"require-dev": {
"doctrine/coding-standard": "^12.0",
"matthiasnoback/symfony-config-test": "^5.1",
"matthiasnoback/symfony-dependency-injection-test": "^5.1",
"doctrine/coding-standard": "^14.0",
"matthiasnoback/symfony-config-test": "^6.1",
"matthiasnoback/symfony-dependency-injection-test": "^6.2",
"phpstan/phpstan": "^1.11|^2.1",
"phpstan/phpstan-phpunit": "^1.4|^2.0",
"phpstan/phpstan-strict-rules": "^1.6|^2.0",
"phpunit/phpunit": "^10.5",
"roave/infection-static-analysis-plugin": "^1.35",
"squizlabs/php_codesniffer": "^3.10",
"symfony/browser-kit": "^6.4|^7.0",
"symfony/dom-crawler": "^6.4|^7.0",
"symfony/framework-bundle": "^6.4|^7.0",
"thecodingmachine/phpstan-safe-rule": "^1.2|v1.4",
"vimeo/psalm": "^5.24|^6.10"
"roave/infection-static-analysis-plugin": "^1.40",
"squizlabs/php_codesniffer": "^4.0",
"symfony/browser-kit": "^6.4|^7.4|^8.0",
"symfony/dom-crawler": "^6.4|^7.4|^8.0",
"symfony/framework-bundle": "^6.4|^7.4|^8.0",
"thecodingmachine/phpstan-safe-rule": "^1.4",
"vimeo/psalm": "^5.24|^6.15"
},
"minimum-stability": "stable",
"prefer-stable": true,
Expand Down Expand Up @@ -85,12 +85,12 @@
}
},
"scripts": {
"cs": "phpcs --config-set php_version 8000 && phpcs",
"csfix": "phpcs --config-set php_version 8000 && phpcbf",
"cs": "phpcs --config-set php_version 8020 && phpcs",
"csfix": "phpcs --config-set php_version 8020 && phpcbf",
"psalm": "psalm",
"stan": "phpstan analyse --memory-limit=-1 --xdebug",
"tests": "phpunit --fail-on-warning",
"mutation": "php -d memory_limit=-1 vendor/bin/roave-infection-static-analysis-plugin --only-covered --test-framework-options=\"--testsuite=unit\"",
"mutation": "php -d memory_limit=-1 vendor/bin/roave-infection-static-analysis-plugin --test-framework-options=\"--testsuite=unit\"",
"all": "composer psalm && composer stan && composer tests && composer mutation && composer cs && composer security",
"get-security": "rm -f local-php-security-checker && curl -s https://api.github.com/repos/fabpot/local-php-security-checker/releases/latest | grep -E \"browser_download_url(.+)linux_amd64\" | cut -d : -f 2,3 | tr -d \\\" | xargs -I % curl % -L -o local-php-security-checker && chmod +x local-php-security-checker",
"security": "./local-php-security-checker"
Expand Down
1 change: 0 additions & 1 deletion infection.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
},
"mutators": {
"@default": true,
"IdenticalEqual": false,
"NotIdenticalNotEqual": false,
"MethodCallRemoval": {
"ignore": [
Expand Down
10 changes: 9 additions & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" bootstrap="vendor/autoload.php" colors="true" cacheDirectory=".phpunit.cache">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnTestsThatTriggerErrors="true"
displayDetailsOnTestsThatTriggerNotices="true"
displayDetailsOnTestsThatTriggerWarnings="true"
displayDetailsOnPhpunitDeprecations="true"
bootstrap="vendor/autoload.php" colors="true" cacheDirectory=".phpunit.cache">
<testsuites>
<testsuite name="unit">
<directory>./test/unit</directory>
Expand All @@ -20,5 +25,8 @@
<include>
<directory suffix=".php">./src</directory>
</include>
<exclude>
<directory suffix=".php">./src/Resources/config</directory>
</exclude>
</source>
</phpunit>
5 changes: 0 additions & 5 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@
<directory name="src" />
</projectFiles>
<issueHandlers>
<MixedMethodCall>
<errorLevel type="suppress">
<file name="src/DependencyInjection/Configuration.php" />
</errorLevel>
</MixedMethodCall>
<PropertyNotSetInConstructor errorLevel="suppress"/>
<InternalClass errorLevel="suppress"/>
<InternalMethod errorLevel="suppress"/>
Expand Down
6 changes: 3 additions & 3 deletions src/CodeGenerator/PhpParserGenerators/CodeGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
use OnMoon\OpenApiServerBundle\CodeGenerator\Definitions\PropertyDefinition;
use OnMoon\OpenApiServerBundle\Types\ScalarTypesResolver;
use PhpParser\BuilderFactory;
use PhpParser\Node\Scalar\LNumber;
use PhpParser\Node\DeclareItem;
use PhpParser\Node\Scalar\Int_;
use PhpParser\Node\Stmt\Declare_;
use PhpParser\Node\Stmt\DeclareDeclare;
use PhpParser\PrettyPrinter\Standard;

use function array_map;
Expand Down Expand Up @@ -93,7 +93,7 @@ public function getDocComment(array $lines): string
public function printFile(FileBuilder $fileBuilder): string
{
return (new Standard())->prettyPrintFile([
new Declare_([new DeclareDeclare('strict_types', new LNumber(1))]),
new Declare_([new DeclareItem('strict_types', new Int_(1))]),
$fileBuilder->getNamespace()->getNode(),
]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/CodeGenerator/PhpParserGenerators/DtoCodeGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
use PhpParser\Builder\Param;
use PhpParser\Builder\Property;
use PhpParser\Node\Arg;
use PhpParser\Node\ArrayItem;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\Array_;
use PhpParser\Node\Expr\ArrayDimFetch;
use PhpParser\Node\Expr\ArrayItem;
use PhpParser\Node\Expr\ArrowFunction;
use PhpParser\Node\Expr\Assign;
use PhpParser\Node\Expr\BinaryOp\Identical;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
use OnMoon\OpenApiServerBundle\CodeGenerator\Definitions\GraphDefinition;
use OnMoon\OpenApiServerBundle\Interfaces\RequestHandler;
use PhpParser\Node\Arg;
use PhpParser\Node\ArrayItem;
use PhpParser\Node\Expr\Array_;
use PhpParser\Node\Expr\ArrayDimFetch;
use PhpParser\Node\Expr\ArrayItem;
use PhpParser\Node\Expr\Assign;
use PhpParser\Node\Expr\BinaryOp\Concat;
use PhpParser\Node\Expr\BooleanNot;
Expand Down
7 changes: 0 additions & 7 deletions src/Command/DeleteGeneratedCodeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,6 @@ public function __construct(string $rootPath, ?string $name = null)
parent::__construct($name);
}

/**
* phpcs:disable SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingNativeTypeHint
*
* @var string|null
*/
protected static $defaultName = self::COMMAND;

protected function configure(): void
{
$this
Expand Down
7 changes: 0 additions & 7 deletions src/Command/GenerateApiCodeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@ protected function configure(): void
);
}

/**
* phpcs:disable SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingNativeTypeHint
*
* @var string|null
*/
protected static $defaultName = self::COMMAND;

protected function execute(InputInterface $input, OutputInterface $output): int
{
$keep = (bool) $input->getOption('keep');
Expand Down
5 changes: 4 additions & 1 deletion src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('open_api_server');

/** @psalm-suppress UndefinedMethod */
/**
* @psalm-suppress UndefinedMethod
* @psalm-suppress UnusedMethodCall
*/
$treeBuilder
->getRootNode()
->children()
Expand Down
6 changes: 3 additions & 3 deletions src/DependencyInjection/OpenApiServerExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;

use function Safe\preg_match;
use function Safe\preg_replace;
Expand All @@ -21,8 +21,8 @@ final class OpenApiServerExtension extends Extension implements ExtensionInterfa
/** @param mixed[] $configs */
public function load(array $configs, ContainerBuilder $container): void
{
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.xml');
$loader = new PhpFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.php');

$configuration = new Configuration();
/**
Expand Down
Loading