Skip to content

Commit dddc7fc

Browse files
Merge pull request #40 from matomo-org/PG-5170-plugin-cleanup
Prepare plugin for release, #PG-5170
2 parents bd06476 + 11cce0b commit dddc7fc

748 files changed

Lines changed: 4181 additions & 4100 deletions

File tree

Some content is hidden

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

.github/workflows/matomo-tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Action for running tests
22
# This file has been automatically created.
33
# To recreate it you can run this command
4-
# ./console generate:test-action --plugin="OpenApiDocs" --php-versions="7.2,8.4" --schedule-cron="0 19 * * 6"
4+
# ./console generate:test-action --plugin="ApiReference" --php-versions="7.2,8.4" --schedule-cron="0 19 * * 6"
55

6-
name: Plugin OpenApiDocs Tests
6+
name: Plugin ApiReference Tests
77

88
on:
99
pull_request:
@@ -49,7 +49,7 @@ jobs:
4949
- name: Run tests
5050
uses: matomo-org/github-action-tests@main
5151
with:
52-
plugin-name: 'OpenApiDocs'
52+
plugin-name: 'ApiReference'
5353
php-version: ${{ matrix.php }}
5454
test-type: 'PluginTests'
5555
matomo-test-branch: ${{ matrix.target }}

.github/workflows/phpcs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
tools: cs2pr
3131
- name: Install dependencies
3232
run:
33-
composer init --name=matomo/openapidocs --quiet;
33+
composer init --name=matomo/apireference --quiet;
3434
composer --no-plugins config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true -n;
3535
composer config repositories.matomo-coding-standards vcs https://github.com/matomo-org/matomo-coding-standards -n;
3636
composer require matomo-org/matomo-coding-standards:dev-master;

.github/workflows/phpstan.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ permissions:
1515
statuses: read
1616

1717
env:
18-
PLUGIN_NAME: OpenApiDocs
18+
PLUGIN_NAME: ApiReference
1919

2020
jobs:
2121
phpstan:

API.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,26 @@
77
* @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
88
*/
99

10-
namespace Piwik\Plugins\OpenApiDocs;
10+
namespace Piwik\Plugins\ApiReference;
1111

1212
use Piwik\Piwik;
13-
use Piwik\Plugins\OpenApiDocs\Generation\PluginListProvider;
13+
use Piwik\Plugins\ApiReference\Generation\PluginListProvider;
1414
use Piwik\Plugin\Manager;
15-
use Piwik\Plugins\OpenApiDocs\Specs\SpecGenerator;
16-
use Piwik\Plugins\OpenApiDocs\Specs\PathResolver;
15+
use Piwik\Plugins\ApiReference\Specs\SpecGenerator;
16+
use Piwik\Plugins\ApiReference\Specs\PathResolver;
1717

1818
/**
1919
* Provides Reporting API endpoints for reading OpenAPI plugin configuration and specifications.
2020
*
2121
* Exposes endpoints to return the effective plugin list for spec generation, read pre-generated spec files,
2222
* or generate plugin OpenAPI specifications on demand.
2323
*
24-
* @method static \Piwik\Plugins\OpenApiDocs\API getInstance()
24+
* @method static \Piwik\Plugins\ApiReference\API getInstance()
2525
*/
2626
class API extends \Piwik\Plugin\API
2727
{
2828
/**
29-
* Returns the plugin names used for OpenApiDocs spec generation.
29+
* Returns the plugin names used for ApiReference spec generation.
3030
*
3131
* @return array<int, string>
3232
*/
@@ -38,7 +38,7 @@ public function getAllowedPlugins(): array
3838
}
3939

4040
/**
41-
* Returns metadata for the plugins used by OpenApiDocs spec generation.
41+
* Returns metadata for the plugins used by ApiReference spec generation.
4242
*
4343
* @return array<string, array{description: string}>
4444
*/
@@ -74,7 +74,7 @@ public function getOpenApiSpec(string $pluginName, string $format = 'json'): arr
7474

7575
$filePath = $this->getSpecFilePath($pluginName);
7676
if (!$this->isSpecFileReadable($filePath)) {
77-
throw new \Exception('OpenAPI spec file was not found. Generate it first via openapidocs:generate-spec-file.');
77+
throw new \Exception('OpenAPI spec file was not found. Generate it first via apireference:generate-spec-file.');
7878
}
7979

8080
$specContents = $this->readSpecFile($filePath);

Annotations/AnnotationGenerator.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99

1010
declare(strict_types=1);
1111

12-
namespace Piwik\Plugins\OpenApiDocs\Annotations;
12+
namespace Piwik\Plugins\ApiReference\Annotations;
1313

14-
use Matomo\Dependencies\OpenApiDocs\phpDocumentor\Reflection\DocBlock\Description;
15-
use Matomo\Dependencies\OpenApiDocs\phpDocumentor\Reflection\DocBlock\Tags\Param;
16-
use Matomo\Dependencies\OpenApiDocs\phpDocumentor\Reflection\DocBlock\Tags\TagWithType;
17-
use Matomo\Dependencies\OpenApiDocs\phpDocumentor\Reflection\DocBlockFactory;
14+
use Matomo\Dependencies\ApiReference\phpDocumentor\Reflection\DocBlock\Description;
15+
use Matomo\Dependencies\ApiReference\phpDocumentor\Reflection\DocBlock\Tags\Param;
16+
use Matomo\Dependencies\ApiReference\phpDocumentor\Reflection\DocBlock\Tags\TagWithType;
17+
use Matomo\Dependencies\ApiReference\phpDocumentor\Reflection\DocBlockFactory;
1818
use Piwik\Exception\PluginNotFoundException;
1919
use Piwik\API\DocumentationGenerator;
2020
use Piwik\API\NoDefaultValue;
@@ -23,9 +23,9 @@
2323
use Piwik\Http;
2424
use Piwik\Piwik;
2525
use Piwik\Plugin\Manager;
26-
use Piwik\Plugins\OpenApiDocs\Artifact\ArtifactWriter;
27-
use Piwik\Plugins\OpenApiDocs\OpenApiDocs;
28-
use Piwik\Plugins\OpenApiDocs\Specs\PathResolver;
26+
use Piwik\Plugins\ApiReference\Artifact\ArtifactWriter;
27+
use Piwik\Plugins\ApiReference\ApiReference;
28+
use Piwik\Plugins\ApiReference\Specs\PathResolver;
2929
use Piwik\SettingsPiwik;
3030
use Piwik\Url;
3131
use Piwik\UrlHelper;
@@ -116,7 +116,7 @@ public function __construct(
116116
$this->missingImportantDataWarnings = [];
117117
$this->allowLocalRequests = $allowLocalRequests;
118118
$this->parameterExamples = null;
119-
$this->currentPluginDir = Manager::getInstance()::getPluginDirectory('OpenApiDocs');
119+
$this->currentPluginDir = Manager::getInstance()::getPluginDirectory('ApiReference');
120120
}
121121

122122
/**
@@ -136,7 +136,7 @@ public function generatePluginApiAnnotations(string $pluginName, bool $writeToFi
136136
{
137137
BaseValidator::check('plugin', $pluginName, [new NotEmpty()]);
138138

139-
if (in_array($pluginName, OpenApiDocs::PLUGIN_BLOCKLIST, true)) {
139+
if (in_array($pluginName, ApiReference::PLUGIN_BLOCKLIST, true)) {
140140
throw new \RuntimeException('OpenAPI doc generation is blocked for ' . $pluginName . '.');
141141
}
142142

@@ -224,7 +224,7 @@ public function getContentForGeneratedAnnotationsFile(array $annotations, string
224224
$lines = [
225225
'<?php',
226226
'',
227-
'namespace Piwik\\Plugins\\OpenApiDocs\\tmp\\annotations;',
227+
'namespace Piwik\\Plugins\\ApiReference\\tmp\\annotations;',
228228
'',
229229
'/**',
230230
];
@@ -1089,7 +1089,7 @@ protected function getExampleIfAvailable(string $url, bool $useLocalToken = fals
10891089
// If the flag to use a temp token is set, get a token and update the request URL
10901090
$tempUrl = $url . '&hideIdSubDatable=1';
10911091
if ($useLocalToken) {
1092-
$token = Piwik::requestTemporarySystemAuthToken('OpenApiDocs', 24);
1092+
$token = Piwik::requestTemporarySystemAuthToken('ApiReference', 24);
10931093
$tempUrl = str_replace('&token_auth=anonymous', '&token_auth=' . $token, $tempUrl);
10941094
}
10951095
try {
@@ -1288,7 +1288,7 @@ public function convertExampleXmlToObject(string $xml): array
12881288
// Handle any attributes
12891289
$grouped = [];
12901290
foreach ($node->attributes() as $attribute) {
1291-
$grouped[OpenApiDocs::OA_XML_ATTRIBUTES_TEMP_PROPERTY_NAME][] = [$attribute->getName() => (string) $attribute];
1291+
$grouped[ApiReference::OA_XML_ATTRIBUTES_TEMP_PROPERTY_NAME][] = [$attribute->getName() => (string) $attribute];
12921292
}
12931293

12941294
// Group children by tag name; repeated names become arrays
@@ -1476,7 +1476,7 @@ protected function buildMediaTypePropertiesArray(string $format, string $example
14761476
$jsonSchema = $format === 'json' ? $this->buildSchemaAnnotationFromJsonExample($decodedExampleValue) : [];
14771477
$xmlSchema = $format === 'xml' ? $this->buildSchemaAnnotationFromXmlExample($decodedExampleValue) : [];
14781478
// If the XML example contains the temporary property to assist in building XML attributes in the schema, replace with newly encoded array with property removed
1479-
if ($format === 'xml' && strpos($exampleValue, OpenApiDocs::OA_XML_ATTRIBUTES_TEMP_PROPERTY_NAME) !== false) {
1479+
if ($format === 'xml' && strpos($exampleValue, ApiReference::OA_XML_ATTRIBUTES_TEMP_PROPERTY_NAME) !== false) {
14801480
$exampleValue = json_encode($decodedExampleValue);
14811481
}
14821482

@@ -1718,7 +1718,7 @@ public function buildSchemaAnnotationFromXmlExample(array &$xmlArrayObject, stri
17181718
protected function removeTempOaXmlAttributeProperty(array &$decodedExampleValue): void
17191719
{
17201720
foreach ($decodedExampleValue as $key => &$value) {
1721-
if ($key === OpenApiDocs::OA_XML_ATTRIBUTES_TEMP_PROPERTY_NAME) {
1721+
if ($key === ApiReference::OA_XML_ATTRIBUTES_TEMP_PROPERTY_NAME) {
17221722
unset($decodedExampleValue[$key]);
17231723
// Add the attributes as actual properties so that they are visible in the example
17241724
foreach ($value as $attributeName => $attributeValue) {
@@ -1794,8 +1794,8 @@ public function buildPropertyAnnotationFromXmlExample(string $propName, array $v
17941794
$key = null;
17951795
foreach ($keys as $candidate) {
17961796
if (
1797-
$candidate !== OpenApiDocs::OA_XML_ATTRIBUTES_TEMP_PROPERTY_NAME
1798-
&& $candidate !== OpenApiDocs::OA_XML_ATTRIBUTES_DEFAULT_KEY_NAME
1797+
$candidate !== ApiReference::OA_XML_ATTRIBUTES_TEMP_PROPERTY_NAME
1798+
&& $candidate !== ApiReference::OA_XML_ATTRIBUTES_DEFAULT_KEY_NAME
17991799
) {
18001800
$key = $candidate;
18011801
break;
@@ -1807,8 +1807,8 @@ public function buildPropertyAnnotationFromXmlExample(string $propName, array $v
18071807

18081808
// Special handling for XML attributes (metadata-only)
18091809
if (
1810-
$key === OpenApiDocs::OA_XML_ATTRIBUTES_TEMP_PROPERTY_NAME
1811-
|| $key === OpenApiDocs::OA_XML_ATTRIBUTES_DEFAULT_KEY_NAME
1810+
$key === ApiReference::OA_XML_ATTRIBUTES_TEMP_PROPERTY_NAME
1811+
|| $key === ApiReference::OA_XML_ATTRIBUTES_DEFAULT_KEY_NAME
18121812
) {
18131813
$hasAttributes = true;
18141814
$childLines = array_merge($childLines, $this->buildXmlAttributeSchemaLines($value));

Annotations/ApiMethodInfoExtractor.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99

1010
declare(strict_types=1);
1111

12-
namespace Piwik\Plugins\OpenApiDocs\Annotations;
12+
namespace Piwik\Plugins\ApiReference\Annotations;
1313

1414
use Piwik\Exception\PluginNotFoundException;
1515
use Piwik\API\Proxy;
1616
use Piwik\API\Request;
1717
use Piwik\Plugin\Manager;
18-
use Piwik\Plugins\OpenApiDocs\Artifact\ArtifactWriter;
19-
use Piwik\Plugins\OpenApiDocs\Specs\PathResolver;
18+
use Piwik\Plugins\ApiReference\Artifact\ArtifactWriter;
19+
use Piwik\Plugins\ApiReference\Specs\PathResolver;
2020
use Piwik\Validators\BaseValidator;
2121
use Piwik\Validators\NotEmpty;
2222

Annotations/GlobalApiComponents.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
88
*/
99

10-
namespace Piwik\Plugins\OpenApiDocs\Annotations;
10+
namespace Piwik\Plugins\ApiReference\Annotations;
1111

1212
/**
1313
* Global components for generating OpenAPI specs for the Matomo Reporting API.

OpenApiDocs.php renamed to ApiReference.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
* @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
88
*/
99

10-
namespace Piwik\Plugins\OpenApiDocs;
10+
namespace Piwik\Plugins\ApiReference;
1111

12-
class OpenApiDocs extends \Piwik\Plugin
12+
class ApiReference extends \Piwik\Plugin
1313
{
1414
public const DEFAULT_SPEC_VERSION = '1.0.0';
1515
public const OA_XML_ATTRIBUTES_TEMP_PROPERTY_NAME = 'oaXmlAttributes';
@@ -30,17 +30,17 @@ public function registerEvents()
3030
public function getClientSideTranslationKeys(&$translationKeys): void
3131
{
3232
$translationKeys[] = 'CoreHome_LearnMoreFullStop';
33-
$translationKeys[] = 'OpenApiDocs_ReportingApiMoreInformation';
34-
$translationKeys[] = 'OpenApiDocs_ReportingApiReference';
35-
$translationKeys[] = 'OpenApiDocs_ReportingApiSummary';
36-
$translationKeys[] = 'OpenApiDocs_SwaggerApi';
37-
$translationKeys[] = 'OpenApiDocs_SwaggerPagePluginEmpty';
38-
$translationKeys[] = 'OpenApiDocs_SwaggerPageRequestFailed';
39-
$translationKeys[] = 'OpenApiDocs_SwaggerPageSpecLoadFailed';
40-
$translationKeys[] = 'OpenApiDocs_SwaggerPageSearchNoResults';
41-
$translationKeys[] = 'OpenApiDocs_SwaggerPageSearchPlaceholder';
42-
$translationKeys[] = 'OpenApiDocs_UserAuthentication';
43-
$translationKeys[] = 'OpenApiDocs_UserAuthenticationManageTokens';
44-
$translationKeys[] = 'OpenApiDocs_UserAuthenticationUsingTokenAuth';
33+
$translationKeys[] = 'ApiReference_ReportingApiMoreInformation';
34+
$translationKeys[] = 'ApiReference_ReportingApiReference';
35+
$translationKeys[] = 'ApiReference_ReportingApiSummary';
36+
$translationKeys[] = 'ApiReference_SwaggerApi';
37+
$translationKeys[] = 'ApiReference_SwaggerPagePluginEmpty';
38+
$translationKeys[] = 'ApiReference_SwaggerPageRequestFailed';
39+
$translationKeys[] = 'ApiReference_SwaggerPageSpecLoadFailed';
40+
$translationKeys[] = 'ApiReference_SwaggerPageSearchNoResults';
41+
$translationKeys[] = 'ApiReference_SwaggerPageSearchPlaceholder';
42+
$translationKeys[] = 'ApiReference_UserAuthentication';
43+
$translationKeys[] = 'ApiReference_UserAuthenticationManageTokens';
44+
$translationKeys[] = 'ApiReference_UserAuthenticationUsingTokenAuth';
4545
}
4646
}

Artifact/ArtifactWriter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
declare(strict_types=1);
1111

12-
namespace Piwik\Plugins\OpenApiDocs\Artifact;
12+
namespace Piwik\Plugins\ApiReference\Artifact;
1313

1414
use Piwik\Filesystem;
1515

CHANGELOG.md

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
11
## Changelog
2-
3-
5.0.2-b1 - 2026-03-16
4-
- Added support for string literal union types
5-
- Added API endpoint to retrieve static matomo swagger file
6-
- Added support for deactivated plugins
7-
- Removed token auth support
8-
9-
5.0.1-b1 - 2026-02-16
10-
- Added class and function level docs
11-
- Updated spec generation command to allow single swagger file generation
12-
13-
5.0.0-b1
14-
- Initial implementation of plugin and POC generating documentation from annotations
2+
5.0.0
3+
- Initial release of ApiReference plugin

0 commit comments

Comments
 (0)