-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
110 changed files
with
7,623 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/Tests export-ignore | ||
/phpunit.xml.dist export-ignore | ||
/.gitattributes export-ignore | ||
/.gitignore export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
composer.lock | ||
phpunit.xml | ||
vendor/ | ||
.phpunit.result.cache |
145 changes: 145 additions & 0 deletions
145
src/Symfony/Component/OpenApi/Builder/OpenApiBuilder.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\OpenApi\Builder; | ||
|
||
use Symfony\Component\OpenApi\Configurator\CallbackRequestConfigurator; | ||
use Symfony\Component\OpenApi\Configurator\ComponentsConfigurator; | ||
use Symfony\Component\OpenApi\Configurator\EncodingConfigurator; | ||
use Symfony\Component\OpenApi\Configurator\ExampleConfigurator; | ||
use Symfony\Component\OpenApi\Configurator\InfoConfigurator; | ||
use Symfony\Component\OpenApi\Configurator\LinkConfigurator; | ||
use Symfony\Component\OpenApi\Configurator\MediaTypeConfigurator; | ||
use Symfony\Component\OpenApi\Configurator\OperationConfigurator; | ||
use Symfony\Component\OpenApi\Configurator\ParameterConfigurator; | ||
use Symfony\Component\OpenApi\Configurator\PathItemConfigurator; | ||
use Symfony\Component\OpenApi\Configurator\QueryParameterConfigurator; | ||
use Symfony\Component\OpenApi\Configurator\QueryParametersConfigurator; | ||
use Symfony\Component\OpenApi\Configurator\ReferenceConfigurator; | ||
use Symfony\Component\OpenApi\Configurator\RequestBodyConfigurator; | ||
use Symfony\Component\OpenApi\Configurator\ResponseConfigurator; | ||
use Symfony\Component\OpenApi\Configurator\ResponsesConfigurator; | ||
use Symfony\Component\OpenApi\Configurator\SchemaConfigurator; | ||
use Symfony\Component\OpenApi\Configurator\SecuritySchemeConfigurator; | ||
use Symfony\Component\OpenApi\Configurator\ServerConfigurator; | ||
use Symfony\Component\OpenApi\Configurator\TagConfigurator; | ||
|
||
/** | ||
* @author Titouan Galopin <galopintitouan@gmail.com> | ||
* @author Selency Team <tech@selency.fr> | ||
*/ | ||
class OpenApiBuilder implements OpenApiBuilderInterface | ||
{ | ||
public function schema(SchemaConfigurator|ReferenceConfigurator|string $definition = null): SchemaConfigurator|ReferenceConfigurator | ||
{ | ||
return SchemaConfigurator::createFromDefinition($definition); | ||
} | ||
|
||
public function callbackRequest(): CallbackRequestConfigurator | ||
{ | ||
return new CallbackRequestConfigurator(); | ||
} | ||
|
||
public function components(): ComponentsConfigurator | ||
{ | ||
return new ComponentsConfigurator(); | ||
} | ||
|
||
public function content(): MediaTypeConfigurator | ||
{ | ||
return new MediaTypeConfigurator(); | ||
} | ||
|
||
public function encoding(): EncodingConfigurator | ||
{ | ||
return new EncodingConfigurator(); | ||
} | ||
|
||
public function example(): ExampleConfigurator | ||
{ | ||
return new ExampleConfigurator(); | ||
} | ||
|
||
public function info(): InfoConfigurator | ||
{ | ||
return new InfoConfigurator(); | ||
} | ||
|
||
public function link(): LinkConfigurator | ||
{ | ||
return new LinkConfigurator(); | ||
} | ||
|
||
public function mediaType(): MediaTypeConfigurator | ||
{ | ||
return new MediaTypeConfigurator(); | ||
} | ||
|
||
public function operation(): OperationConfigurator | ||
{ | ||
return new OperationConfigurator($this); | ||
} | ||
|
||
public function parameter(string $name): ParameterConfigurator | ||
{ | ||
return new ParameterConfigurator($name); | ||
} | ||
|
||
public function queryParameter(string $name): QueryParameterConfigurator | ||
{ | ||
return new QueryParameterConfigurator($name); | ||
} | ||
|
||
public function queryParameters(): QueryParametersConfigurator | ||
{ | ||
return new QueryParametersConfigurator($this); | ||
} | ||
|
||
public function pathItem(): PathItemConfigurator | ||
{ | ||
return new PathItemConfigurator($this); | ||
} | ||
|
||
public function reference(string $ref): ReferenceConfigurator | ||
{ | ||
return new ReferenceConfigurator($ref); | ||
} | ||
|
||
public function requestBody(): RequestBodyConfigurator | ||
{ | ||
return new RequestBodyConfigurator(); | ||
} | ||
|
||
public function response(): ResponseConfigurator | ||
{ | ||
return new ResponseConfigurator(); | ||
} | ||
|
||
public function responses(): ResponsesConfigurator | ||
{ | ||
return new ResponsesConfigurator(); | ||
} | ||
|
||
public function securityScheme(): SecuritySchemeConfigurator | ||
{ | ||
return new SecuritySchemeConfigurator(); | ||
} | ||
|
||
public function server(string $url): ServerConfigurator | ||
{ | ||
return new ServerConfigurator($url); | ||
} | ||
|
||
public function tag(): TagConfigurator | ||
{ | ||
return new TagConfigurator(); | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
src/Symfony/Component/OpenApi/Builder/OpenApiBuilderInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\OpenApi\Builder; | ||
|
||
use Symfony\Component\OpenApi\Configurator\CallbackRequestConfigurator; | ||
use Symfony\Component\OpenApi\Configurator\ComponentsConfigurator; | ||
use Symfony\Component\OpenApi\Configurator\EncodingConfigurator; | ||
use Symfony\Component\OpenApi\Configurator\ExampleConfigurator; | ||
use Symfony\Component\OpenApi\Configurator\InfoConfigurator; | ||
use Symfony\Component\OpenApi\Configurator\LinkConfigurator; | ||
use Symfony\Component\OpenApi\Configurator\MediaTypeConfigurator; | ||
use Symfony\Component\OpenApi\Configurator\OperationConfigurator; | ||
use Symfony\Component\OpenApi\Configurator\ParameterConfigurator; | ||
use Symfony\Component\OpenApi\Configurator\PathItemConfigurator; | ||
use Symfony\Component\OpenApi\Configurator\QueryParameterConfigurator; | ||
use Symfony\Component\OpenApi\Configurator\QueryParametersConfigurator; | ||
use Symfony\Component\OpenApi\Configurator\ReferenceConfigurator; | ||
use Symfony\Component\OpenApi\Configurator\RequestBodyConfigurator; | ||
use Symfony\Component\OpenApi\Configurator\ResponseConfigurator; | ||
use Symfony\Component\OpenApi\Configurator\ResponsesConfigurator; | ||
use Symfony\Component\OpenApi\Configurator\SchemaConfigurator; | ||
use Symfony\Component\OpenApi\Configurator\SecuritySchemeConfigurator; | ||
use Symfony\Component\OpenApi\Configurator\ServerConfigurator; | ||
use Symfony\Component\OpenApi\Configurator\TagConfigurator; | ||
|
||
/** | ||
* @author Titouan Galopin <galopintitouan@gmail.com> | ||
* @author Selency Team <tech@selency.fr> | ||
*/ | ||
interface OpenApiBuilderInterface | ||
{ | ||
public function schema(SchemaConfigurator|ReferenceConfigurator|string $definition = null): SchemaConfigurator|ReferenceConfigurator; | ||
|
||
public function callbackRequest(): CallbackRequestConfigurator; | ||
|
||
public function components(): ComponentsConfigurator; | ||
|
||
public function content(): MediaTypeConfigurator; | ||
|
||
public function encoding(): EncodingConfigurator; | ||
|
||
public function example(): ExampleConfigurator; | ||
|
||
public function info(): InfoConfigurator; | ||
|
||
public function link(): LinkConfigurator; | ||
|
||
public function mediaType(): MediaTypeConfigurator; | ||
|
||
public function operation(): OperationConfigurator; | ||
|
||
public function parameter(string $name): ParameterConfigurator; | ||
|
||
public function queryParameter(string $name): QueryParameterConfigurator; | ||
|
||
public function queryParameters(): QueryParametersConfigurator; | ||
|
||
public function pathItem(): PathItemConfigurator; | ||
|
||
public function reference(string $ref): ReferenceConfigurator; | ||
|
||
public function requestBody(): RequestBodyConfigurator; | ||
|
||
public function response(): ResponseConfigurator; | ||
|
||
public function responses(): ResponsesConfigurator; | ||
|
||
public function securityScheme(): SecuritySchemeConfigurator; | ||
|
||
public function server(string $url): ServerConfigurator; | ||
|
||
public function tag(): TagConfigurator; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CHANGELOG | ||
========= | ||
|
||
6.3 | ||
--- | ||
|
||
* Add the component as experimental | ||
|
48 changes: 48 additions & 0 deletions
48
src/Symfony/Component/OpenApi/Compiler/DocumentationCompiler.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\OpenApi\Compiler; | ||
|
||
use Symfony\Component\OpenApi\Configurator\DocumentationConfigurator; | ||
use Symfony\Component\OpenApi\Documentation\DocumentationInterface; | ||
use Symfony\Component\OpenApi\Loader\ComponentsLoaderInterface; | ||
use Symfony\Component\OpenApi\Model\OpenApi; | ||
|
||
/** | ||
* @author Titouan Galopin <galopintitouan@gmail.com> | ||
* @author Selency Team <tech@selency.fr> | ||
*/ | ||
class DocumentationCompiler implements DocumentationCompilerInterface | ||
{ | ||
/** | ||
* @param iterable<ComponentsLoaderInterface> $componentsLoaders | ||
*/ | ||
public function __construct(private iterable $componentsLoaders = []) | ||
{ | ||
} | ||
|
||
public function compile(DocumentationInterface $doc): OpenApi | ||
{ | ||
// Instanciate root configurator | ||
$rootConfigurator = new DocumentationConfigurator(); | ||
|
||
// Load components for this doc | ||
foreach ($this->componentsLoaders as $loader) { | ||
$doc->loadComponents($rootConfigurator, $loader); | ||
} | ||
|
||
// Apply user documentation details | ||
$doc->configure($rootConfigurator); | ||
|
||
// Compile the documentation | ||
return $rootConfigurator->build($doc->getIdentifier(), $doc->getVersion()); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/Symfony/Component/OpenApi/Compiler/DocumentationCompilerInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\OpenApi\Compiler; | ||
|
||
use Symfony\Component\OpenApi\Documentation\DocumentationInterface; | ||
use Symfony\Component\OpenApi\Model\OpenApi; | ||
|
||
/** | ||
* @author Titouan Galopin <galopintitouan@gmail.com> | ||
* @author Selency Team <tech@selency.fr> | ||
*/ | ||
interface DocumentationCompilerInterface | ||
{ | ||
public function compile(DocumentationInterface $doc): OpenApi; | ||
} |
47 changes: 47 additions & 0 deletions
47
src/Symfony/Component/OpenApi/Configurator/CallbackRequestConfigurator.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\OpenApi\Configurator; | ||
|
||
use Symfony\Component\OpenApi\Model\CallbackRequest; | ||
use Symfony\Component\OpenApi\Model\PathItem; | ||
use Symfony\Component\OpenApi\Model\Reference; | ||
|
||
/** | ||
* @author Titouan Galopin <galopintitouan@gmail.com> | ||
* @author Selency Team <tech@selency.fr> | ||
*/ | ||
class CallbackRequestConfigurator | ||
{ | ||
use Traits\ExtensionsTrait; | ||
|
||
private string $expression = ''; | ||
private PathItem|Reference|null $definition = null; | ||
|
||
public function build(): CallbackRequest | ||
{ | ||
return new CallbackRequest($this->expression, $this->definition, $this->specificationExtensions); | ||
} | ||
|
||
public function expression(string $expression): static | ||
{ | ||
$this->expression = $expression; | ||
|
||
return $this; | ||
} | ||
|
||
public function definition(ReferenceConfigurator|PathItemConfigurator $definition): static | ||
{ | ||
$this->definition = $definition->build(); | ||
|
||
return $this; | ||
} | ||
} |
Oops, something went wrong.