Skip to content

Commit eaab8b4

Browse files
committed
Fixing scoping to make spec generation work
1 parent 7773ba7 commit eaab8b4

49 files changed

Lines changed: 4456 additions & 32 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Annotations/GlobalApiComponents.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
/**
1717
* @OA\OpenApi(
18-
* openapi="3.1.0",
1918
* security={{"MatomoToken": {}}},
2019
* @OA\ExternalDocumentation(
2120
* description="Matomo Reporting API developer page",
@@ -58,7 +57,7 @@
5857
* description="Generic Matomo success payload.",
5958
* required={"result","message"},
6059
* additionalProperties=true,
61-
* @OA\Property(property="result", type="string", enum={"success"}, example="success"),
60+
* @OA\Property(property="result", type="string", example="success"),
6261
* @OA\Property(property="message", type="string", example="ok"),
6362
* @OA\Property(property="code", type="integer", example="200")
6463
* )
@@ -70,7 +69,7 @@
7069
* description="Generic Matomo error payload.",
7170
* required={"result","message"},
7271
* additionalProperties=true,
73-
* @OA\Property(property="result", type="string", enum={"error"}, example="error"),
72+
* @OA\Property(property="result", type="string", example="error"),
7473
* @OA\Property(property="message", type="string", example="There was an error"),
7574
* @OA\Property(property="code", type="integer")
7675
* )

Specs/SpecGenerator.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,13 @@ public function generateSpec(array $pluginNames, string $format = 'json', string
8282
throw new \Exception('There was an error testing the API annotations for plugin ' . $pluginName, 0, $e);
8383
}
8484
if (trim($openapi->toYaml()) === 'openapi: ' . OpenApi::DEFAULT_VERSION) {
85-
var_dump($openapi->toYaml());
8685
throw new \Exception("The $pluginName plugin's API class does not appear to be annotated yet.");
8786
}
8887
$pluginDirs[$pluginName] = $pluginAnnotationsSource;
8988
}
9089

9190
$generator = new Generator(StaticContainer::get(LoggerInterface::class));
92-
$openapi = $generator->generate(array_merge([
91+
$openapi = $generator->setVersion(OpenApi::VERSION_3_1_0)->generate(array_merge([
9392
$currentPluginDir . '/Annotations/GlobalApiComponents.php',
9493
], $pluginDirs));
9594

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"require": {
3-
"zircote/swagger-php": "^5.4"
3+
"zircote/swagger-php": "^5.4",
4+
"doctrine/annotations": "^2.0"
45
},
56
"replace": {
67
"monolog/monolog": "*",

composer.lock

Lines changed: 203 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scoper.inc.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,26 @@
5656
'force-no-global-alias' => $forceNoGlobalAlias,
5757
'prefix' => 'Matomo\\Dependencies\\' . $pluginName,
5858
'finders' => $finders,
59-
'patchers' => [],
59+
'patchers' => [
60+
// Patcher for making sure that AbstractAnnotation is looking for the correct root
61+
static function (string $filePath, string $prefix, string $content) use ($isRenamingReferences): string {
62+
if ($isRenamingReferences) {
63+
return $content;
64+
}
65+
66+
// Fix the string reference of a scoped dependency in the Math lib
67+
$escapedPrefix = str_replace('\\', '\\\\', $prefix);
68+
if ($filePath === __DIR__ . '/vendor/zircote/swagger-php/src/Annotations/AbstractAnnotation.php') {
69+
$content = str_replace(
70+
'OpenApi\\\\Annotations\\\\',
71+
"{$escapedPrefix}\\\\OpenApi\\\\Annotations\\\\",
72+
$content
73+
);
74+
}
75+
76+
return $content;
77+
},
78+
],
6079
'include-namespaces' => $namespacesToIncludeRegexes,
6180
'exclude-namespaces' => $namespacesToExclude,
6281
'exclude-constants' => [

vendor/autoload_original.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@
2222

2323
require_once __DIR__ . '/composer/autoload_real.php';
2424

25-
return ComposerAutoloaderInitc8345434bce3699d515e040a2b2da4fa::getLoader();
25+
return ComposerAutoloaderInitc02410b41ab976b8400bb73dedbf07dc::getLoader();

vendor/composer/autoload_psr4.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'),
1010
'Symfony\\Component\\Yaml\\' => array($vendorDir . '/symfony/yaml'),
1111
'Symfony\\Component\\Finder\\' => array($vendorDir . '/symfony/finder'),
12+
'Psr\\Cache\\' => array($vendorDir . '/psr/cache/src'),
1213
'PhpParser\\' => array($vendorDir . '/nikic/php-parser/lib/PhpParser'),
1314
'OpenApi\\' => array($vendorDir . '/zircote/swagger-php/src'),
15+
'Doctrine\\Common\\Lexer\\' => array($vendorDir . '/doctrine/lexer/src'),
16+
'Doctrine\\Common\\Annotations\\' => array($vendorDir . '/doctrine/annotations/lib/Doctrine/Common/Annotations'),
1417
);

vendor/composer/autoload_real.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// autoload_real.php @generated by Composer
44

5-
class ComposerAutoloaderInitc8345434bce3699d515e040a2b2da4fa
5+
class ComposerAutoloaderInitc02410b41ab976b8400bb73dedbf07dc
66
{
77
private static $loader;
88

@@ -22,16 +22,16 @@ public static function getLoader()
2222
return self::$loader;
2323
}
2424

25-
spl_autoload_register(array('ComposerAutoloaderInitc8345434bce3699d515e040a2b2da4fa', 'loadClassLoader'), true, true);
25+
spl_autoload_register(array('ComposerAutoloaderInitc02410b41ab976b8400bb73dedbf07dc', 'loadClassLoader'), true, true);
2626
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
27-
spl_autoload_unregister(array('ComposerAutoloaderInitc8345434bce3699d515e040a2b2da4fa', 'loadClassLoader'));
27+
spl_autoload_unregister(array('ComposerAutoloaderInitc02410b41ab976b8400bb73dedbf07dc', 'loadClassLoader'));
2828

2929
require __DIR__ . '/autoload_static.php';
30-
call_user_func(\Composer\Autoload\ComposerStaticInitc8345434bce3699d515e040a2b2da4fa::getInitializer($loader));
30+
call_user_func(\Composer\Autoload\ComposerStaticInitc02410b41ab976b8400bb73dedbf07dc::getInitializer($loader));
3131

3232
$loader->register(true);
3333

34-
$filesToLoad = \Composer\Autoload\ComposerStaticInitc8345434bce3699d515e040a2b2da4fa::$files;
34+
$filesToLoad = \Composer\Autoload\ComposerStaticInitc02410b41ab976b8400bb73dedbf07dc::$files;
3535
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
3636
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
3737
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;

0 commit comments

Comments
 (0)