1515use Piwik \Plugins \OpenApiDocs \Specs \PathResolver ;
1616
1717/**
18- * API for plugin OpenApiDocs
18+ * Provides Reporting API endpoints for reading OpenAPI plugin configuration and specifications.
1919 *
20- * Exposes endpoints to fetch pre-generated OpenAPI specs or generate plugin-specific
21- * OpenAPI docs on demand.
20+ * Exposes endpoints to return the configured plugin whitelist, read pre-generated spec files,
21+ * or generate plugin OpenAPI specifications on demand.
2222 *
2323 * @method static \Piwik\Plugins\OpenApiDocs\API getInstance()
2424 */
2525class API extends \Piwik \Plugin \API
2626{
2727 /**
28- * Return the OpenApiDocs plugin whitelist from config/plugins.php .
28+ * Returns the plugin names configured for OpenApiDocs spec generation .
2929 *
30- * /index.php?module=API&method=OpenApiDocs.getPluginWhitelist
31- *
32- * @return array<int, string>
33- * @throws \Exception
30+ * @return array<int, string> The configured whitelist of plugin names from
31+ * `config/plugins.php`.
3432 */
3533 public function getPluginWhitelist (): array
3634 {
@@ -45,15 +43,14 @@ public function getPluginWhitelist(): array
4543 }
4644
4745 /**
48- * Get a pre-generated OpenAPI spec file if it exists. This endpoint only reads
49- * the generated JSON file and does not trigger spec generation.
46+ * Returns a previously generated OpenAPI specification for a plugin.
5047 *
51- * /index.php?module=API&method=OpenApiDocs.getOpenApiSpec&spec=CustomAlerts
48+ * Reads the stored JSON spec file for the requested plugin and does not trigger
49+ * spec generation.
5250 *
53- * @param string $pluginName Plugin name used in the generated filename.
54- * @param string $format Output format. Only `json` is supported.
55- * @return array<string, mixed> The decoded OpenAPI specification payload.
56- * @throws \Exception If the file is missing, unreadable, or contains invalid JSON.
51+ * @param string $pluginName The plugin name whose generated OpenAPI spec file should be read.
52+ * @param string $format The response format to read. Only `json` is supported.
53+ * @return array<string, mixed> The decoded OpenAPI specification data from the generated JSON file.
5754 */
5855 public function getOpenApiSpec (string $ pluginName , string $ format = 'json ' ): array
5956 {
@@ -131,14 +128,12 @@ protected function getSpecPathResolver(): PathResolver
131128 }
132129
133130 /**
134- * Get the generated API documentation data for the specified plugin.
135- *
136- * /index.php?module=API&method=OpenApiDocs.getGeneratedOpenApiSpec&plugin=CustomAlerts
131+ * Generates an OpenAPI specification for one or more plugins and returns it immediately.
137132 *
138- * @param string $plugin Name of the plugin to get the JSON for. E.g. TagManager or CustomerAlerts
139- * @param string $format String to indicate JSON or YAML .
140- * @return string | array
141- * @throws \Exception
133+ * @param string $plugin The plugin name to generate, or a comma-separated list of plugin names.
134+ * @param string $format The response format to generate. Supported values are `json` and `yaml` .
135+ * @return array< string, mixed>|string The generated OpenAPI specification as decoded JSON data for
136+ * `json`, or as a YAML string for `yaml`.
142137 */
143138 public function getGeneratedOpenApiSpec (string $ plugin , string $ format )
144139 {
0 commit comments