-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
10 changed files
with
147 additions
and
94 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
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,38 @@ | ||
<?php | ||
/* | ||
* PSX is an open source PHP framework to develop RESTful APIs. | ||
* For the current version and information visit <https://phpsx.org> | ||
* | ||
* Copyright 2010-2023 Christoph Kappestein <[email protected]> | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
namespace PSX\Api\Generator; | ||
|
||
use PSX\Api\SecurityInterface; | ||
|
||
/** | ||
* ConfigurationAwareInterface | ||
* | ||
* @see https://typeschema.org/ | ||
* @author Christoph Kappestein <[email protected]> | ||
* @license http://www.apache.org/licenses/LICENSE-2.0 | ||
* @link https://phpsx.org | ||
*/ | ||
interface ConfigurationAwareInterface | ||
{ | ||
public function setBaseUrl(?string $baseUrl): void; | ||
|
||
public function setSecurity(?SecurityInterface $security): void; | ||
} |
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,71 @@ | ||
<?php | ||
/* | ||
* PSX is an open source PHP framework to develop RESTful APIs. | ||
* For the current version and information visit <https://phpsx.org> | ||
* | ||
* Copyright 2010-2023 Christoph Kappestein <[email protected]> | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
namespace PSX\Api\Generator; | ||
|
||
use PSX\Api\SecurityInterface; | ||
use PSX\Api\SpecificationInterface; | ||
|
||
/** | ||
* ConfigurationTrait | ||
* | ||
* @author Christoph Kappestein <[email protected]> | ||
* @license http://www.apache.org/licenses/LICENSE-2.0 | ||
* @link https://phpsx.org | ||
*/ | ||
trait ConfigurationTrait | ||
{ | ||
protected ?string $baseUrl; | ||
protected ?SecurityInterface $security = null; | ||
|
||
public function setBaseUrl(?string $baseUrl): void | ||
{ | ||
$this->baseUrl = $baseUrl; | ||
} | ||
|
||
public function setSecurity(?SecurityInterface $security): void | ||
{ | ||
$this->security = $security; | ||
} | ||
|
||
protected function getBaseUrl(SpecificationInterface $specification): ?string | ||
{ | ||
$baseUrl = $specification->getBaseUrl(); | ||
if (!empty($baseUrl)) { | ||
return $baseUrl; | ||
} elseif (!empty($this->baseUrl)) { | ||
return $this->baseUrl; | ||
} else { | ||
return null; | ||
} | ||
} | ||
|
||
protected function getSecurity(SpecificationInterface $specification): ?SecurityInterface | ||
{ | ||
$security = $specification->getSecurity(); | ||
if ($security instanceof SecurityInterface) { | ||
return $security; | ||
} elseif ($this->security instanceof SecurityInterface) { | ||
return $this->security; | ||
} else { | ||
return null; | ||
} | ||
} | ||
} |
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
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 |
---|---|---|
|
@@ -20,14 +20,15 @@ | |
|
||
namespace PSX\Api\Generator\Spec; | ||
|
||
use PSX\Api\Generator\ConfigurationAwareInterface; | ||
use PSX\Api\GeneratorInterface; | ||
|
||
/** | ||
* @author Christoph Kappestein <[email protected]> | ||
* @license http://www.apache.org/licenses/LICENSE-2.0 | ||
* @link https://phpsx.org | ||
*/ | ||
abstract class ApiAbstract implements GeneratorInterface | ||
abstract class ApiAbstract implements GeneratorInterface, ConfigurationAwareInterface | ||
{ | ||
public const FLOW_AUTHORIZATION_CODE = 0; | ||
public const FLOW_IMPLICIT = 1; | ||
|
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
Oops, something went wrong.