Skip to content

Instantly share code, notes, and snippets.

@BusterNeece
Created December 28, 2021 21:09
Show Gist options
  • Save BusterNeece/230f1bf619740b0564b88a69978de82c to your computer and use it in GitHub Desktop.
Save BusterNeece/230f1bf619740b0564b88a69978de82c to your computer and use it in GitHub Desktop.

Revisions

  1. BusterNeece created this gist Dec 28, 2021.
    60 changes: 60 additions & 0 deletions rector.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,60 @@
    <?php

    use Rector\Php80\Rector\Class_\AnnotationToAttributeRector;
    use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

    return static function (ContainerConfigurator $containerConfigurator): void {
    $services = $containerConfigurator->services();

    $openApiAnnotationsRaw = [
    'AdditionalProperties',
    'Attachable',
    'Components',
    'Contact',
    'Delete',
    'Discriminator',
    'Examples',
    'ExternalDocumentation',
    'Flow',
    'Get',
    'Head',
    'Header',
    'Info',
    'Items',
    'JsonContent',
    'License',
    'Link',
    'MediaType',
    'OpenApi',
    'Operation',
    'Options',
    'Parameter',
    'Patch',
    'PatchItem',
    'PathParameter',
    'Post',
    'Property',
    'Put',
    'RequestBody',
    'Response',
    'Schema',
    'SecurityScheme',
    'Server',
    'ServerVariable',
    'Tag',
    'Trace',
    'Xml',
    'XmlContent',
    ];

    $openApiAnnotations = [];
    foreach ($openApiAnnotationsRaw as $className) {
    $openApiAnnotations[] = new \Rector\Php80\ValueObject\AnnotationToAttribute(
    'OpenApi\\Annotations\\' . $className,
    'OpenApi\\Attributes\\' . $className
    );
    }

    $services->set(AnnotationToAttributeRector::class)
    ->configure($openApiAnnotations);
    };