OpenApiFileLoader example

$data = json_decode($openApi->toJson(), true, 512, \JSON_THROW_ON_ERROR);
        $data['paths'] ??= [];

        $schemaPaths = [$this->schemaPath];

        if (!empty($bundleName)) {
            $schemaPaths = $this->bundleSchemaPathCollection->getSchemaPaths($api$bundleName);
        } else {
            $schemaPaths = array_merge($schemaPaths$this->bundleSchemaPathCollection->getSchemaPaths($api$bundleName));
        }

        $loader = new OpenApiFileLoader($schemaPaths);

        /** @var OpenApiSpec $finalSpecs */
        $finalSpecs = array_replace_recursive($data$loader->loadOpenapiSpecification());

        return $finalSpecs;
    }

    /** * @param array<string, EntityDefinition>|list<EntityDefinition&SalesChannelDefinitionInterface> $definitions * * @return array<string, array{name: string, translatable: array<int|string, mixed>, properties: array<string, mixed>}> */
$data = json_decode($openApi->toJson(), true, 512, \JSON_THROW_ON_ERROR);
        $data['paths'] ??= [];

        $schemaPaths = [$this->schemaPath];

        if (!empty($bundleName)) {
            $schemaPaths = $this->bundleSchemaPathCollection->getSchemaPaths($api$bundleName);
        } else {
            $schemaPaths = array_merge($schemaPaths$this->bundleSchemaPathCollection->getSchemaPaths($api$bundleName));
        }

        $loader = new OpenApiFileLoader($schemaPaths);

        /** @var OpenApiSpec $finalSpecs */
        $finalSpecs = array_replace_recursive($data$loader->loadOpenapiSpecification());

        return $finalSpecs;
    }

    /** * {@inheritdoc} * * @param array<string, EntityDefinition>|array<string, EntityDefinition&SalesChannelDefinitionInterface> $definitions * * @return never */
/** * @covers \Shopware\Core\Framework\Api\ApiDefinition\Generator\OpenApiFileLoader * * @internal */
class OpenApiFileLoaderTest extends TestCase
{
    public function testMergingOfFiles(): void
    {
        $paths = [__DIR__ . '/_fixtures/Api/ApiDefinition/Generator/Schema/StoreApi'];
        $fsLoader = new OpenApiFileLoader($paths);

        $spec = $fsLoader->loadOpenapiSpecification();

        static::assertArrayHasKey('paths', $spec);
        static::assertArrayHasKey('components', $spec);
        static::assertArrayHasKey('/_action/order_delivery/{orderDeliveryId}/state/{transition}', $spec['paths']);
        static::assertArrayHasKey('schemas', $spec['components']);
        static::assertCount(2, $spec['components']['schemas']);
    }

    public function testEmptyFileLoader(): void
    {
Home | Imprint | This part of the site doesn't use cookies.