Skip to content

Commit

Permalink
OpenApi + Swagger
Browse files Browse the repository at this point in the history
  • Loading branch information
laryjulien committed Nov 17, 2021
1 parent ebd6034 commit 63a1b89
Show file tree
Hide file tree
Showing 46 changed files with 117 additions and 88 deletions.
2 changes: 1 addition & 1 deletion src/Core/Bridge/Symfony/Bundle/Command/SwaggerCommand.php
Expand Up @@ -14,9 +14,9 @@
namespace ApiPlatform\Core\Bridge\Symfony\Bundle\Command;

use ApiPlatform\Core\Metadata\Resource\Factory\ResourceNameCollectionFactoryInterface;
use ApiPlatform\Core\Swagger\Serializer\ApiGatewayNormalizer;
use ApiPlatform\Core\Swagger\Serializer\DocumentationNormalizer;
use ApiPlatform\Documentation\Documentation;
use ApiPlatform\OpenApi\Serializer\ApiGatewayNormalizer;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Exception\InvalidOptionException;
use Symfony\Component\Console\Input\InputInterface;
Expand Down
11 changes: 6 additions & 5 deletions src/Core/OpenApi/Factory/OpenApiFactory.php
Expand Up @@ -24,13 +24,14 @@
use ApiPlatform\Core\Metadata\Resource\Factory\ResourceMetadataFactoryInterface;
use ApiPlatform\Core\Metadata\Resource\Factory\ResourceNameCollectionFactoryInterface;
use ApiPlatform\Core\Metadata\Resource\ResourceMetadata;
use ApiPlatform\Core\OpenApi\Model;
use ApiPlatform\Core\OpenApi\Model\ExternalDocumentation;
use ApiPlatform\Core\OpenApi\Model\PathItem;
use ApiPlatform\Core\OpenApi\OpenApi;
use ApiPlatform\Core\OpenApi\Options;
use ApiPlatform\Core\Operation\Factory\SubresourceOperationFactoryInterface;
use ApiPlatform\Core\PathResolver\OperationPathResolverInterface;
use ApiPlatform\OpenApi\Factory\OpenApiFactoryInterface;
use ApiPlatform\OpenApi\Model;
use ApiPlatform\OpenApi\Model\ExternalDocumentation;
use ApiPlatform\OpenApi\Model\PathItem;
use ApiPlatform\OpenApi\OpenApi;
use ApiPlatform\OpenApi\Options;
use ApiPlatform\State\Pagination\PaginationOptions;
use Psr\Container\ContainerInterface;
use Symfony\Component\PropertyInfo\Type;
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Swagger/Serializer/DocumentationNormalizer.php
Expand Up @@ -32,13 +32,13 @@
use ApiPlatform\Core\Metadata\Resource\ApiResourceToLegacyResourceMetadataTrait;
use ApiPlatform\Core\Metadata\Resource\Factory\ResourceMetadataFactoryInterface;
use ApiPlatform\Core\Metadata\Resource\ResourceMetadata;
use ApiPlatform\Core\OpenApi\OpenApi;
use ApiPlatform\Core\Operation\Factory\SubresourceOperationFactoryInterface;
use ApiPlatform\Core\PathResolver\OperationPathResolverInterface;
use ApiPlatform\Documentation\Documentation;
use ApiPlatform\Exception\ResourceClassNotFoundException;
use ApiPlatform\Exception\RuntimeException;
use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface;
use ApiPlatform\OpenApi\OpenApi;
use Psr\Container\ContainerInterface;
use Symfony\Component\PropertyInfo\Type;
use Symfony\Component\Serializer\NameConverter\NameConverterInterface;
Expand Down
2 changes: 1 addition & 1 deletion src/Documentation/Action/DocumentationAction.php
Expand Up @@ -15,9 +15,9 @@

use ApiPlatform\Core\Api\FormatsProviderInterface;
use ApiPlatform\Core\Metadata\Resource\Factory\ResourceNameCollectionFactoryInterface;
use ApiPlatform\Core\OpenApi\Factory\OpenApiFactoryInterface;
use ApiPlatform\Documentation\Documentation;
use ApiPlatform\Documentation\DocumentationInterface;
use ApiPlatform\OpenApi\Factory\OpenApiFactoryInterface;
use ApiPlatform\Util\RequestAttributesExtractor;
use Symfony\Component\HttpFoundation\Request;

Expand Down
9 changes: 4 additions & 5 deletions src/OpenApi/Factory/OpenApiFactory.php
Expand Up @@ -20,18 +20,17 @@
use ApiPlatform\Core\Metadata\Property\Factory\PropertyMetadataFactoryInterface as LegacyPropertyMetadataFactoryInterface;
use ApiPlatform\Core\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface as LegacyPropertyNameCollectionFactoryInterface;
use ApiPlatform\Core\Metadata\Resource\Factory\ResourceNameCollectionFactoryInterface;
use ApiPlatform\Core\OpenApi\Factory\OpenApiFactoryInterface;
use ApiPlatform\Core\OpenApi\Model;
use ApiPlatform\Core\OpenApi\Model\ExternalDocumentation;
use ApiPlatform\Core\OpenApi\OpenApi;
use ApiPlatform\Core\OpenApi\Options;
use ApiPlatform\Core\PathResolver\OperationPathResolverInterface;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Operation;
use ApiPlatform\Metadata\Property\Factory\PropertyMetadataFactoryInterface;
use ApiPlatform\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface;
use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface;
use ApiPlatform\Metadata\Resource\ResourceMetadataCollection;
use ApiPlatform\OpenApi\Model;
use ApiPlatform\OpenApi\Model\ExternalDocumentation;
use ApiPlatform\OpenApi\OpenApi;
use ApiPlatform\OpenApi\Options;
use ApiPlatform\State\Pagination\PaginationOptions;
use Psr\Container\ContainerInterface;
use Symfony\Component\PropertyInfo\Type;
Expand Down
Expand Up @@ -11,9 +11,9 @@

declare(strict_types=1);

namespace ApiPlatform\Core\OpenApi\Factory;
namespace ApiPlatform\OpenApi\Factory;

use ApiPlatform\Core\OpenApi\OpenApi;
use ApiPlatform\OpenApi\OpenApi;

interface OpenApiFactoryInterface
{
Expand Down
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Core\OpenApi\Model;
namespace ApiPlatform\OpenApi\Model;

final class Components
{
Expand Down
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Core\OpenApi\Model;
namespace ApiPlatform\OpenApi\Model;

final class Contact
{
Expand Down
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Core\OpenApi\Model;
namespace ApiPlatform\OpenApi\Model;

final class Encoding
{
Expand Down
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Core\OpenApi\Model;
namespace ApiPlatform\OpenApi\Model;

trait ExtensionTrait
{
Expand Down
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Core\OpenApi\Model;
namespace ApiPlatform\OpenApi\Model;

final class ExternalDocumentation
{
Expand Down
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Core\OpenApi\Model;
namespace ApiPlatform\OpenApi\Model;

final class Info
{
Expand Down
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Core\OpenApi\Model;
namespace ApiPlatform\OpenApi\Model;

final class License
{
Expand Down
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Core\OpenApi\Model;
namespace ApiPlatform\OpenApi\Model;

final class Link
{
Expand Down
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Core\OpenApi\Model;
namespace ApiPlatform\OpenApi\Model;

final class MediaType
{
Expand Down
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Core\OpenApi\Model;
namespace ApiPlatform\OpenApi\Model;

final class OAuthFlow
{
Expand Down
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Core\OpenApi\Model;
namespace ApiPlatform\OpenApi\Model;

final class OAuthFlows
{
Expand Down
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Core\OpenApi\Model;
namespace ApiPlatform\OpenApi\Model;

final class Operation
{
Expand Down
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Core\OpenApi\Model;
namespace ApiPlatform\OpenApi\Model;

final class Parameter
{
Expand Down
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Core\OpenApi\Model;
namespace ApiPlatform\OpenApi\Model;

final class PathItem
{
Expand Down
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Core\OpenApi\Model;
namespace ApiPlatform\OpenApi\Model;

final class Paths
{
Expand Down
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Core\OpenApi\Model;
namespace ApiPlatform\OpenApi\Model;

final class RequestBody
{
Expand Down
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Core\OpenApi\Model;
namespace ApiPlatform\OpenApi\Model;

final class Response
{
Expand Down
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Core\OpenApi\Model;
namespace ApiPlatform\OpenApi\Model;

use ApiPlatform\Core\JsonSchema\Schema as JsonSchema;

Expand Down
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Core\OpenApi\Model;
namespace ApiPlatform\OpenApi\Model;

final class SecurityScheme
{
Expand Down
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Core\OpenApi\Model;
namespace ApiPlatform\OpenApi\Model;

final class Server
{
Expand Down
10 changes: 5 additions & 5 deletions src/Core/OpenApi/OpenApi.php → src/OpenApi/OpenApi.php
Expand Up @@ -11,13 +11,13 @@

declare(strict_types=1);

namespace ApiPlatform\Core\OpenApi;
namespace ApiPlatform\OpenApi;

use ApiPlatform\Core\OpenApi\Model\Components;
use ApiPlatform\Core\OpenApi\Model\ExtensionTrait;
use ApiPlatform\Core\OpenApi\Model\Info;
use ApiPlatform\Core\OpenApi\Model\Paths;
use ApiPlatform\Documentation\DocumentationInterface;
use ApiPlatform\OpenApi\Model\Components;
use ApiPlatform\OpenApi\Model\ExtensionTrait;
use ApiPlatform\OpenApi\Model\Info;
use ApiPlatform\OpenApi\Model\Paths;

final class OpenApi implements DocumentationInterface
{
Expand Down
2 changes: 1 addition & 1 deletion src/Core/OpenApi/Options.php → src/OpenApi/Options.php
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Core\OpenApi;
namespace ApiPlatform\OpenApi;

final class Options
{
Expand Down
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Core\Swagger\Serializer;
namespace ApiPlatform\OpenApi\Serializer;

use Symfony\Component\Serializer\Exception\UnexpectedValueException;
use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface;
Expand Down
Expand Up @@ -11,10 +11,10 @@

declare(strict_types=1);

namespace ApiPlatform\Core\OpenApi\Serializer;
namespace ApiPlatform\OpenApi\Serializer;

use ApiPlatform\Core\OpenApi\Model\Paths;
use ApiPlatform\Core\OpenApi\OpenApi;
use ApiPlatform\OpenApi\Model\Paths;
use ApiPlatform\OpenApi\OpenApi;
use Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer;
use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/Command/OpenApiCommand.php
Expand Up @@ -13,7 +13,7 @@

namespace ApiPlatform\Symfony\Bundle\Command;

use ApiPlatform\Core\OpenApi\Factory\OpenApiFactoryInterface;
use ApiPlatform\OpenApi\Factory\OpenApiFactoryInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputInterface;
Expand Down
12 changes: 6 additions & 6 deletions src/Symfony/Bundle/Resources/config/openapi.xml
Expand Up @@ -5,7 +5,7 @@
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

<services>
<service id="api_platform.openapi.normalizer" class="ApiPlatform\Core\OpenApi\Serializer\OpenApiNormalizer" public="false">
<service id="api_platform.openapi.normalizer" class="ApiPlatform\OpenApi\Serializer\OpenApiNormalizer" public="false">
<argument type="service">
<service class="Symfony\Component\Serializer\Serializer">
<argument type="collection">
Expand All @@ -27,9 +27,9 @@
<!-- Just after the DocumentationNormalizer see swagger.xml -->
<tag name="serializer.normalizer" priority="-795" />
</service>
<service id="ApiPlatform\Core\OpenApi\Serializer\OpenApiNormalizer" alias="api_platform.openapi.normalizer" />
<service id="ApiPlatform\OpenApi\Serializer\OpenApiNormalizer" alias="api_platform.openapi.normalizer" />

<service id="api_platform.openapi.options" class="ApiPlatform\Core\OpenApi\Options">
<service id="api_platform.openapi.options" class="ApiPlatform\OpenApi\Options">
<argument>%api_platform.title%</argument>
<argument>%api_platform.description%</argument>
<argument>%api_platform.version%</argument>
Expand All @@ -48,7 +48,7 @@
<argument>%api_platform.openapi.license.name%</argument>
<argument>%api_platform.openapi.license.url%</argument>
</service>
<service id="ApiPlatform\Core\OpenApi\Options" alias="api_platform.openapi.options" />
<service id="ApiPlatform\OpenApi\Options" alias="api_platform.openapi.options" />

<service id="api_platform.openapi.factory.next" class="ApiPlatform\OpenApi\Factory\OpenApiFactory" public="false">
<argument type="service" id="api_platform.metadata.resource.name_collection_factory" />
Expand Down Expand Up @@ -81,15 +81,15 @@
<argument type="service" id="api_platform.pagination_options" />
</service>
<service id="api_platform.openapi.factory" alias="api_platform.openapi.factory.next" />
<service id="ApiPlatform\Core\OpenApi\Factory\OpenApiFactoryInterface" alias="api_platform.openapi.factory" />
<service id="ApiPlatform\OpenApi\Factory\OpenApiFactoryInterface" alias="api_platform.openapi.factory" />

<service id="api_platform.openapi.command" class="ApiPlatform\Symfony\Bundle\Command\OpenApiCommand">
<argument type="service" id="api_platform.openapi.factory.next" />
<argument type="service" id="api_platform.serializer" />
<tag name="console.command" />
</service>

<service id="api_platform.openapi.normalizer.api_gateway" class="ApiPlatform\Core\Swagger\Serializer\ApiGatewayNormalizer" public="false" decorates="api_platform.openapi.normalizer" decoration-priority="-1">
<service id="api_platform.openapi.normalizer.api_gateway" class="ApiPlatform\OpenApi\Serializer\ApiGatewayNormalizer" public="false" decorates="api_platform.openapi.normalizer" decoration-priority="-1">
<argument type="service" id="api_platform.openapi.normalizer.api_gateway.inner" />
<tag name="serializer.normalizer" priority="-780" />
</service>
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/Resources/config/swagger.xml
Expand Up @@ -37,7 +37,7 @@
<tag name="serializer.normalizer" priority="-790" />
</service>

<service id="api_platform.swagger.normalizer.api_gateway" class="ApiPlatform\Core\Swagger\Serializer\ApiGatewayNormalizer" public="false" decorates="api_platform.swagger.normalizer.documentation" decoration-priority="-1">
<service id="api_platform.swagger.normalizer.api_gateway" class="ApiPlatform\OpenApi\Serializer\ApiGatewayNormalizer" public="false" decorates="api_platform.swagger.normalizer.documentation" decoration-priority="-1">
<argument type="service" id="api_platform.swagger.normalizer.api_gateway.inner" />
<tag name="serializer.normalizer" priority="-780" />
</service>
Expand Down

0 comments on commit 63a1b89

Please sign in to comment.