Skip to content

Commit be9e883

Browse files
committed
Cleaned up code
1 parent 5a1e8be commit be9e883

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

Annotations/AnnotationGenerator.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public function generatePluginApiAnnotations(string $pluginName, bool $writeToFi
122122
$pluginMetadata = Proxy::getInstance()->getMetadata()[$className] ?? [];
123123

124124
$annotations = [[sprintf('@OA\Tag(name="%s")', $pluginName)]];
125-
// I decided to not include the description in the tag annotation so that it automatically pulls the API class comment as the description.
125+
126126
if (!empty($pluginMetadata['__documentation'])) {
127127
$tagLines = $this->buildLinesForAnnotationObject('@OA\Tag', [
128128
sprintf('name="%s"', $pluginName),
@@ -1772,6 +1772,7 @@ public function buildSchemaObjectArrays(array $typesMap, string $default = '', s
17721772
* @param string $plugin The name of the plugin. E.g. CustomReports
17731773
* @param array $params The compiled list of method parameters and key information about them, like type.
17741774
* @param array $responses compiled list of method expected responses and key information about them, like type.
1775+
* @param string $description The method level description
17751776
* @param bool $isPost Indicates whether the operation is a POST. The default is false, meaning it's GET.
17761777
*
17771778
* @return string[] The array of all the lines of the operation annotation object.

Specs/SpecGenerator.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ public function generateSpec(array $pluginNames, string $format = 'json', string
7272
BaseValidator::check('pluginName', $pluginName, [new NotEmpty()]);
7373
Manager::getInstance()->checkIsPluginActivated($pluginName);
7474

75-
$pluginDir = Manager::getInstance()::getPluginDirectory($pluginName);
76-
// $pluginAnnotationsSource = $pluginDir . '/API.php';
7775
$pluginAnnotationsSource = $currentPluginDir . '/tmp/annotations/' . $pluginName . 'GeneratedAnnotations.php';
7876
try {
7977
$openapi = (new Generator(StaticContainer::get(NullLogger::class)))->generate([
@@ -82,9 +80,9 @@ public function generateSpec(array $pluginNames, string $format = 'json', string
8280
} catch (\Throwable $e) {
8381
throw new \Exception('There was an error testing the API annotations for plugin ' . $pluginName, 0, $e);
8482
}
85-
// if (trim($openapi->toYaml()) === 'openapi: ' . OpenApi::DEFAULT_VERSION) {
86-
// throw new \Exception("The $pluginName plugin's API class does not appear to be annotated yet.");
87-
// }
83+
if (trim($openapi->toYaml()) === 'openapi: ' . OpenApi::DEFAULT_VERSION) {
84+
throw new \Exception("The $pluginName plugin's API class does not appear to be annotated yet.");
85+
}
8886
$pluginDirs[$pluginName] = $pluginAnnotationsSource;
8987
}
9088

0 commit comments

Comments
 (0)