Repository: DarkaOnLine/L5-Swagger (PHP)

Issue:
[Feature Request] Support for OpenAPI 3.1
- L5-Swagger Version: 8.3.3 (`composer show | grep l5-swagger`)
- PHP Version (`php -v`): 8.0.21
- OS: Ubuntu 20.04.4 LTS

### Description:
According to this page, the latest spec supported seems to be OpenAPI 3.0: https://github.com/DarkaOnLine/L5-Swagger/wiki/Installation-&-Configuration
Will there also be support for OpenAPI 3.1? It allows for some usefull extra features regarding $refs and other things

### Steps To Reproduce:
No steps as it's a feature request
<!--

Your issue will be addressed much more quickly if you can provide us exact steps to reproduce the problem from scratch.

-->



Discussion:
See: https://www.openapis.org/blog/2021/02/16/migrating-from-openapi-3-0-to-3-1-0
We use https://github.com/zircote/swagger-php under the hood to parse annotations to OpenApi. So this question/suggestion should got to SwaggerPHP. 
I saw that https://github.com/zircote/swagger-php already supports 3.1, but i don't see any way to pass the version to the generator of swagger-php
Oh I missed this. Hmm but they only allow to use this with the `--version` or `Generator::setVersion()`
So we could have new config key and set version here: https://github.com/DarkaOnLine/L5-Swagger/blob/master/src/Generator.php#L207 - this should do the trick.

Would you be wiling to contribute and submit PR for this?
Yeah something like that would fix it, i know it works as I extended and overrided somethings to test it  and it's doable to pass it through
Would you be wiling to contribute and submit PR for this? Or should I add this to my todo list :) 
Sadly using 3.1 isn't an option as the used swagger-ui doesn't support it yet. Is there a way to use something else than swagger-ui? I know there are others out there that already support 3.1. That said, it does seem that swagger-ui is actively working on 3.1 support. So  maybe I should wait a little longer.



Patch:
diff --git a/Dockerfile b/Dockerfile
index 369ff67..b8267ea 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -62,7 +62,9 @@ RUN /usr/local/bin/php -dxdebug.mode=off /usr/local/bin/composer config reposito
 
 RUN /usr/local/bin/php -dxdebug.mode=off /usr/local/bin/composer require 'darkaonline/l5-swagger:dev-master'
 
-RUN ln -s /app/tests/storage/annotations/ app/annotations
+RUN cp -r /app/tests/storage/annotations /app/l5-swagger-app/app/Annotations
+
+RUN for f in $(find app/Annotations/* -name '*.php'); do sed -i 's/namespace Tests\\storage\\annotations/namespace App\\Annotations/' $f; done
 
 RUN chown -R $user:$user .
 #
diff --git a/config/l5-swagger.php b/config/l5-swagger.php
index b540d6c..160c782 100644
--- a/config/l5-swagger.php
+++ b/config/l5-swagger.php
@@ -140,6 +140,12 @@
              * @see \OpenApi\scan
             */
             'exclude' => [],
+
+            /*
+             * Allows to generate specs either for OpenAPI 3.0.0 or OpenAPI 3.1.0.
+             * By default the spec will be in version 3.0.0
+             */
+            'open_api_spec_version' => env('L5_SWAGGER_OPEN_API_SPEC_VERSION', \OpenApi\Annotations\OpenApi::DEFAULT_VERSION),
         ],
 
         /*
diff --git a/src/Generator.php b/src/Generator.php
index 58d10f2..b0cecc4 100644
--- a/src/Generator.php
+++ b/src/Generator.php
@@ -200,6 +200,11 @@ protected function createOpenApiGenerator(): OpenApiGenerator
     {
         $generator = new OpenApiGenerator();
 
+        // OpenApi spec version.
+        $generator->setVersion(
+            $this->scanOptions['open_api_spec_version'] ?? OpenApi::DEFAULT_VERSION
+        );
+
         // Processors.
         $this->setProcessors($generator);
 


Test patch:
diff --git a/tests/GeneratorTest.php b/tests/GeneratorTest.php
index a711df6..728c75b 100644
--- a/tests/GeneratorTest.php
+++ b/tests/GeneratorTest.php
@@ -171,6 +171,7 @@ public function canGenerateWithScanOptions(): void
 
         $cfg['scanOptions']['pattern'] = 'L5SwaggerAnnotationsExample*.*';
         $cfg['scanOptions']['analyser'] = new TokenAnalyser;
+        $cfg['scanOptions']['open_api_spec_version'] = '3.1.0';
         $cfg['scanOptions']['processors'] = [
             new CleanUnmerged,
         ];
@@ -189,8 +190,10 @@ public function canGenerateWithScanOptions(): void
 
         $this->assertTrue(file_exists($this->jsonDocsFile()));
 
-        $this->get(route('l5-swagger.default.docs'))
-            ->assertSee('L5 Swagger')
+        $response = $this->get(route('l5-swagger.default.docs'));
+
+        $response->assertSee('L5 Swagger')
+            ->assertSee('3.1.0')
             ->assertSee('my-default-host.com')
             ->assertSee('getProjectsList')
             ->assertSee('getProductsList')