Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
limenet committed Apr 18, 2024
1 parent cc0de55 commit 67fb8ba
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Valantic\PimcoreApiDocumentationBundle\Http\Controller\ApiControllerInterface;

/**
* This is the class that loads and manages your bundle configuration.
Expand All @@ -16,8 +17,12 @@
*/
class ValanticPimcoreApiDocumentationExtension extends Extension
{
public const TAG_CONTROLLERS = 'valantic.pimcore_api_doc.controller';

public function load(array $configs, ContainerBuilder $container): void
{
$container->registerForAutoconfiguration(ApiControllerInterface::class)->addTag(self::TAG_CONTROLLERS);

$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);

Expand Down
3 changes: 0 additions & 3 deletions src/Http/Controller/ApiControllerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,4 @@

namespace Valantic\PimcoreApiDocumentationBundle\Http\Controller;

use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;

#[AutoconfigureTag('valantic.pimcore_api_doc.controller')]
interface ApiControllerInterface {}
5 changes: 2 additions & 3 deletions src/Service/ControllerMethodParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,9 @@ private function parseRequest(\ReflectionMethod $method): ?RequestDoc
/** @var class-string $requestClass */
$requestClass = $requestClassType->getName();

if (!$requestClass instanceof ApiRequestInterface) {
if (!is_subclass_of($requestClass, ApiRequestInterface::class)) {
return null;
}

$requestDoc = new RequestDoc();

foreach ($requestParameter->getAttributes() as $attribute) {
Expand Down Expand Up @@ -179,7 +178,7 @@ private function parseRequest(\ReflectionMethod $method): ?RequestDoc
continue;
}

if (($attribute->getName() === MapRequestPayload::class) && $requestClass instanceof HasJsonPayload) {
if (($attribute->getName() === MapRequestPayload::class) && is_subclass_of($requestClass, HasJsonPayload::class)) {
$requestDoc->setComponentSchemaDoc($this->schemaGenerator->generateForRequest($requestClass));
$requestDoc->setRequestBody([
'content' => [
Expand Down
5 changes: 4 additions & 1 deletion src/Service/DocsGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
namespace Valantic\PimcoreApiDocumentationBundle\Service;

use League\Csv\Exception;
use Symfony\Component\DependencyInjection\Attribute\TaggedIterator;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Yaml\Yaml;
use Valantic\PimcoreApiDocumentationBundle\Contract\Service\ControllerMethodParserInterface;
use Valantic\PimcoreApiDocumentationBundle\Contract\Service\DocsGeneratorInterface;
use Valantic\PimcoreApiDocumentationBundle\DependencyInjection\ValanticPimcoreApiDocumentationExtension;
use Valantic\PimcoreApiDocumentationBundle\Model\Doc\ControllerDoc;

readonly class DocsGenerator implements DocsGeneratorInterface
Expand All @@ -17,7 +19,8 @@
* @param array<class-string> $controllers
*/
public function __construct(
private array $controllers,
#[TaggedIterator(ValanticPimcoreApiDocumentationExtension::TAG_CONTROLLERS)]
private iterable $controllers,
private ControllerMethodParserInterface $controllerMethodParser,
private ParameterBagInterface $parameterBag,
) {}
Expand Down

0 comments on commit 67fb8ba

Please sign in to comment.