-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
eab3faa
commit 93a8029
Showing
4 changed files
with
97 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "gcgov/framework-service-documentation", | ||
"type": "framework-service", | ||
"description": "Plugin that enables a route to generate OpenAPI yaml documentation at the /documentation.yaml route", | ||
"license": "MIT", | ||
"autoload": { | ||
"psr-4": { | ||
"gcgov\\framework\\services\\documentation\\": "src/" | ||
} | ||
}, | ||
"require": { | ||
"php": ">=8.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace gcgov\framework\services\documentation\controllers; | ||
|
||
use gcgov\framework\config; | ||
use gcgov\framework\interfaces\controller; | ||
use gcgov\framework\models\controllerDataResponse; | ||
use JetBrains\PhpStorm\NoReturn; | ||
|
||
class documentation implements controller { | ||
|
||
public function __construct() { | ||
|
||
} | ||
|
||
|
||
#[NoReturn] | ||
public function yaml(): void { | ||
$openapi = \OpenApi\Generator::scan( [ config::getRootDir() . '/app', config::getRootDir() . '/vendor/gcgov/framework/src/controllers', config::getRootDir() . '/vendor/gcgov/framework/src/exceptions', config::getRootDir() . '/vendor/gcgov/framework/src/models', config::getRootDir() . '/vendor/gcgov/framework/src/services' ], [ 'exclude' => [ 'vendor' ] ] ); | ||
header( 'Content-Type: text/x-yaml' ); | ||
echo $openapi->toYaml(); | ||
die(); | ||
} | ||
|
||
|
||
public function routes(): controllerDataResponse { | ||
$routes = []; | ||
return new controllerDataResponse( $routes ); | ||
} | ||
|
||
|
||
/** | ||
* Processed after lifecycle is complete with this instance | ||
*/ | ||
public static function _after(): void { | ||
} | ||
|
||
|
||
/** | ||
* Processed prior to __constructor() being called | ||
*/ | ||
public static function _before(): 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,37 @@ | ||
<?php | ||
|
||
namespace gcgov\framework\services\documentation; | ||
|
||
use gcgov\framework\config; | ||
use gcgov\framework\models\route; | ||
|
||
class router | ||
implements | ||
\gcgov\framework\interfaces\router { | ||
|
||
public function getRoutes(): array { | ||
return [ | ||
new route( 'GET', config::getEnvironmentConfig()->getBasePath() . '/documentation.yaml', '\gcgov\framework\services\documentation\controllers\documentation', 'yaml', false ) | ||
]; | ||
} | ||
|
||
|
||
public function authentication( \gcgov\framework\models\routeHandler $routeHandler ): bool { | ||
return false; | ||
} | ||
|
||
|
||
/** | ||
* Processed after lifecycle is complete with this instance | ||
*/ | ||
public static function _after(): void { | ||
} | ||
|
||
|
||
/** | ||
* Processed prior to __constructor() being called | ||
*/ | ||
public static function _before(): void { | ||
} | ||
|
||
} |