diff --git a/.gitignore b/.gitignore index a67d42b..62f1787 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ composer.phar /vendor/ +composer.lock # Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control # You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..4c468ca --- /dev/null +++ b/composer.json @@ -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" + } +} diff --git a/src/controllers/documentation.php b/src/controllers/documentation.php new file mode 100644 index 0000000..b89fc90 --- /dev/null +++ b/src/controllers/documentation.php @@ -0,0 +1,45 @@ + [ '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 { + } + +} diff --git a/src/router.php b/src/router.php new file mode 100644 index 0000000..e4aa61f --- /dev/null +++ b/src/router.php @@ -0,0 +1,37 @@ +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 { + } + +}