mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-05 20:57:12 +00:00
Add Taxon documentation to OpenAPI specification
This commit is contained in:
parent
f8a27841f2
commit
a306ace096
2 changed files with 54 additions and 0 deletions
|
|
@ -0,0 +1,49 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Sylius package.
|
||||||
|
*
|
||||||
|
* (c) Sylius Sp. z o.o.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Sylius\Bundle\ApiBundle\OpenApi\Documentation;
|
||||||
|
|
||||||
|
use ApiPlatform\OpenApi\OpenApi;
|
||||||
|
|
||||||
|
final class TaxonDocumentationModifier implements DocumentationModifierInterface
|
||||||
|
{
|
||||||
|
public function __construct(private string $apiRoute)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function modify(OpenApi $docs): OpenApi
|
||||||
|
{
|
||||||
|
$path = sprintf('%s/shop/taxons', $this->apiRoute);
|
||||||
|
|
||||||
|
$paths = $docs->getPaths();
|
||||||
|
$pathItem = $paths->getPath($path);
|
||||||
|
$operation = $pathItem?->getGet();
|
||||||
|
if (null === $operation) {
|
||||||
|
return $docs;
|
||||||
|
}
|
||||||
|
|
||||||
|
$operation = $operation
|
||||||
|
->withSummary('Retrieves the collection of enabled Taxon resources for the current channel.')
|
||||||
|
->withDescription(
|
||||||
|
'Returns the direct enabled children of the Menu Taxon configured for the current channel. ' .
|
||||||
|
"The Menu Taxon is resolved from the active channel configuration. " .
|
||||||
|
"If no Menu Taxon is configured for the channel, the taxon with code 'category' is used as the default root.",
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
|
$pathItem = $pathItem->withGet($operation);
|
||||||
|
$paths->addPath($path, $pathItem);
|
||||||
|
|
||||||
|
return $docs->withPaths($paths);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -106,5 +106,10 @@
|
||||||
<service id="sylius_api.open_api.documentation_modifier.address_log_entry" class="Sylius\Bundle\ApiBundle\OpenApi\Documentation\AddressLogEntryDocumentationModifier">
|
<service id="sylius_api.open_api.documentation_modifier.address_log_entry" class="Sylius\Bundle\ApiBundle\OpenApi\Documentation\AddressLogEntryDocumentationModifier">
|
||||||
<tag name="sylius.open_api.modifier" />
|
<tag name="sylius.open_api.modifier" />
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
|
<service id="sylius_api.open_api.documentation_modifier.taxon" class="Sylius\Bundle\ApiBundle\OpenApi\Documentation\TaxonDocumentationModifier">
|
||||||
|
<argument>%sylius.security.api_route%</argument>
|
||||||
|
<tag name="sylius.open_api.modifier" />
|
||||||
|
</service>
|
||||||
</services>
|
</services>
|
||||||
</container>
|
</container>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue