99
1010declare (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 ;
1818use Piwik \Exception \PluginNotFoundException ;
1919use Piwik \API \DocumentationGenerator ;
2020use Piwik \API \NoDefaultValue ;
2323use Piwik \Http ;
2424use Piwik \Piwik ;
2525use 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 ;
2929use Piwik \SettingsPiwik ;
3030use Piwik \Url ;
3131use 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 ));
0 commit comments