Skip to content

Commit

Permalink
Merge 6d70c49 into 64d820b
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkaOnLine committed Sep 21, 2022
2 parents 64d820b + 6d70c49 commit 475c4f8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Expand Up @@ -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 .
#
Expand Down
6 changes: 6 additions & 0 deletions config/l5-swagger.php
Expand Up @@ -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),
],

/*
Expand Down
5 changes: 5 additions & 0 deletions src/Generator.php
Expand Up @@ -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);

Expand Down
7 changes: 5 additions & 2 deletions tests/GeneratorTest.php
Expand Up @@ -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,
];
Expand All @@ -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')
Expand Down

0 comments on commit 475c4f8

Please sign in to comment.