Skip to content

Commit

Permalink
[BUG_FIX] Changes \Swagger namespace to \OpenApi (#158)
Browse files Browse the repository at this point in the history
* [BUG_FIX] Changes  \Swagger namespace to \OpenApi

- Last update on https://github.com/zircote/swagger-php changes  \Swagger namespace to \OpenApi
- Also annotations prefix changed from @oas to @OA.

* Update annotations for testing - @oas -> @OA

* Is OpenApi validation

* Removes else

* Styles fixing

* StyleCI fixes

* StyleCI suggestions

* StyleCI updates.
  • Loading branch information
ejbogantes authored and DarkaOnLine committed Jul 25, 2018
1 parent c081760 commit 691b393
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 27 deletions.
21 changes: 15 additions & 6 deletions src/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Generator
protected $constants;

/**
* @var \Swagger\Annotations\Swagger
* @var \OpenApi\Annotations\OpenApi
*/
protected $swagger;

Expand Down Expand Up @@ -113,10 +113,19 @@ protected function defineConstants()
*/
protected function scanFilesForDocumentation()
{
$this->swagger = \Swagger\scan(
$this->appDir,
['exclude' => $this->excludedDirs]
);
if ($this->isOpenApi()) {
$this->swagger = \OpenApi\scan(
$this->appDir,
['exclude' => $this->excludedDirs]
);
}

if (! $this->isOpenApi()) {
$this->swagger = \Swagger\scan(
$this->appDir,
['exclude' => $this->excludedDirs]
);
}

return $this;
}
Expand All @@ -131,7 +140,7 @@ protected function populateServers()
if (config('l5-swagger.paths.base') !== null) {
if ($this->isOpenApi()) {
$this->swagger->servers = [
new \Swagger\Annotations\Server(['url' => config('l5-swagger.paths.base')]),
new \OpenApi\Annotations\Server(['url' => config('l5-swagger.paths.base')]),
];
}

Expand Down
42 changes: 21 additions & 21 deletions tests/storage/annotations/OpenApi/Anotations.php
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
<?php

/**
* @OAS\Info(
* @OA\Info(
* version="1.0.0",
* title="L5 OpenApi",
* description="L5 Swagger OpenApi description",
* @OAS\Contact(
* @OA\Contact(
* email="[email protected]"
* ),
* @OAS\License(
* @OA\License(
* name="Apache 2.0",
* url="http://www.apache.org/licenses/LICENSE-2.0.html"
* )
* )
*/

/**
* @OAS\Server(
* @OA\Server(
* url=L5_SWAGGER_CONST_HOST,
* description="L5 Swagger OpenApi dynamic host server"
* )
*
* @OAS\Server(
* @OA\Server(
* url="https://projects.dev/api/v1",
* description="L5 Swagger OpenApi Server"
* )
*/

/**
* @OAS\SecurityScheme(
* @OA\SecurityScheme(
* type="oauth2",
* description="Use a global client_id / client_secret and your username / password combo to obtain a token",
* name="Password Based",
* in="header",
* scheme="https",
* securityScheme="Password Based",
* @OAS\Flow(
* @OA\Flow(
* flow="password",
* authorizationUrl="/oauth/authorize",
* tokenUrl="/oauth/token",
Expand All @@ -45,41 +45,41 @@
*/

/**
* @OAS\Tag(
* @OA\Tag(
* name="project",
* description="Everything about your Projects",
* @OAS\ExternalDocumentation(
* @OA\ExternalDocumentation(
* description="Find out more",
* url="http://swagger.io"
* )
* )
*
* @OAS\Tag(
* @OA\Tag(
* name="user",
* description="Operations about user",
* @OAS\ExternalDocumentation(
* @OA\ExternalDocumentation(
* description="Find out more about",
* url="http://swagger.io"
* )
* )
* @OAS\ExternalDocumentation(
* @OA\ExternalDocumentation(
* description="Find out more about Swagger",
* url="http://swagger.io"
* )
*/

/**
* @OAS\Get(
* @OA\Get(
* path="/projects",
* operationId="getProjectsList",
* tags={"Projects"},
* summary="Get list of projects",
* description="Returns list of projects",
* @OAS\Response(
* @OA\Response(
* response=200,
* description="successful operation"
* ),
* @OAS\Response(response=400, description="Bad request"),
* @OA\Response(response=400, description="Bad request"),
* security={
* {"api_key_security_example": {}}
* }
Expand All @@ -89,27 +89,27 @@
*/

/**
* @OAS\Get(
* @OA\Get(
* path="/projects/{id}",
* operationId="getProjectById",
* tags={"Projects"},
* summary="Get project information",
* description="Returns project data",
* @OAS\Parameter(
* @OA\Parameter(
* name="id",
* description="Project id",
* required=true,
* in="path",
* @OAS\Schema(
* @OA\Schema(
* type="integer"
* )
* ),
* @OAS\Response(
* @OA\Response(
* response=200,
* description="successful operation"
* ),
* @OAS\Response(response=400, description="Bad request"),
* @OAS\Response(response=404, description="Resource Not Found"),
* @OA\Response(response=400, description="Bad request"),
* @OA\Response(response=404, description="Resource Not Found"),
* security={
* {
* "oauth2_security_example": {"write:projects", "read:projects"}
Expand Down

0 comments on commit 691b393

Please sign in to comment.