getSchemaPaths example

$openApi->merge($this->pathBuilder->getPathActions($definition$this->getResourceUri($definition)));
                $openApi->merge([$this->pathBuilder->getTag($definition)]);
            }
        }

        $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;
    }

    
$this->bundleWithSchemas = $this->createMock(Bundle::class);
        $this->bundleWithSchemas->method('getPath')->willReturn(__DIR__ . '/_fixtures/BundleWithApiSchema');
        $this->bundleWithoutSchemas = $this->createMock(Bundle::class);
        $this->bundleWithoutSchemas->method('getPath')->willReturn(__DIR__ . '/_fixtures/BundleWithoutApiSchema');
        $this->customBundleSchemas = new ShopwareBundleWithName();
    }

    public function testGetPathsForStoreApi(): void
    {
        $factory = new BundleSchemaPathCollection([$this->bundleWithSchemas, $this->bundleWithoutSchemas]);

        $paths = $factory->getSchemaPaths(DefinitionService::STORE_API, null);
        static::assertContains(__DIR__ . '/_fixtures/BundleWithApiSchema/Resources/Schema/StoreApi', $paths);
        static::assertNotContains(__DIR__ . '/_fixtures/BundleWithoutApiSchema/Resources/Schema/StoreApi', $paths);
    }

    public function testGetPathsForAdminApi(): void
    {
        $factory = new BundleSchemaPathCollection([$this->bundleWithSchemas, $this->bundleWithoutSchemas]);

        $paths = $factory->getSchemaPaths(DefinitionService::API, null);
        static::assertContains(__DIR__ . '/_fixtures/BundleWithApiSchema/Resources/Schema/AdminApi', $paths);
        static::assertNotContains(__DIR__ . '/_fixtures/BundleWithoutApiSchema/Resources/Schema/AdminApi', $paths);
    }


        $this->addGeneralInformation($openApi);
        $this->addContentTypeParameter($openApi);

        $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;
    }

    
Home | Imprint | This part of the site doesn't use cookies.