|
|
@@ -0,0 +1,41 @@
|
|
|
+<?php
|
|
|
+declare(strict_types=1);
|
|
|
+
|
|
|
+namespace App\OpenApi;
|
|
|
+
|
|
|
+use ApiPlatform\Core\OpenApi\Factory\OpenApiFactoryInterface;
|
|
|
+use ApiPlatform\Core\OpenApi\OpenApi;
|
|
|
+use ApiPlatform\Core\OpenApi\Model;
|
|
|
+
|
|
|
+final class OpenApiFactory implements OpenApiFactoryInterface
|
|
|
+{
|
|
|
+ const PATH_TO_EXCLUDE = [
|
|
|
+ '/api/dolibarr_bills/{id}',
|
|
|
+ '/api/dolibarr_contract_lines/{id}',
|
|
|
+ '/api/dolibarr_contracts/{ref}',
|
|
|
+ ];
|
|
|
+
|
|
|
+ private $decorated;
|
|
|
+
|
|
|
+ public function __construct(OpenApiFactoryInterface $decorated)
|
|
|
+ {
|
|
|
+ $this->decorated = $decorated;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function __invoke(array $context = []): OpenApi
|
|
|
+ {
|
|
|
+ $openApi = $this->decorated->__invoke($context);
|
|
|
+
|
|
|
+ $paths = $openApi->getPaths()->getPaths();
|
|
|
+
|
|
|
+ $filteredPaths = new Model\Paths();
|
|
|
+ foreach ($paths as $path => $pathItem) {
|
|
|
+ if (in_array($path, self::PATH_TO_EXCLUDE)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $filteredPaths->addPath($path, $pathItem);
|
|
|
+ }
|
|
|
+
|
|
|
+ return $openApi->withPaths($filteredPaths);
|
|
|
+ }
|
|
|
+}
|