From 442eb05275a5f0f269bdff57f8fbbf141af70337 Mon Sep 17 00:00:00 2001 From: Lachlan Reynolds Date: Tue, 21 Apr 2026 16:21:44 +1200 Subject: [PATCH] docs: updated API documentation to be more consistent --- API.php | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/API.php b/API.php index ffbb3e4..c5edaa9 100644 --- a/API.php +++ b/API.php @@ -15,22 +15,20 @@ use Piwik\Plugins\OpenApiDocs\Specs\PathResolver; /** - * API for plugin OpenApiDocs + * Provides Reporting API endpoints for reading OpenAPI plugin configuration and specifications. * - * Exposes endpoints to fetch pre-generated OpenAPI specs or generate plugin-specific - * OpenAPI docs on demand. + * Exposes endpoints to return the configured plugin whitelist, read pre-generated spec files, + * or generate plugin OpenAPI specifications on demand. * * @method static \Piwik\Plugins\OpenApiDocs\API getInstance() */ class API extends \Piwik\Plugin\API { /** - * Return the OpenApiDocs plugin whitelist from config/plugins.php. + * Returns the plugin names configured for OpenApiDocs spec generation. * - * /index.php?module=API&method=OpenApiDocs.getPluginWhitelist - * - * @return array - * @throws \Exception + * @return array The configured whitelist of plugin names from + * `config/plugins.php`. */ public function getPluginWhitelist(): array { @@ -45,15 +43,14 @@ public function getPluginWhitelist(): array } /** - * Get a pre-generated OpenAPI spec file if it exists. This endpoint only reads - * the generated JSON file and does not trigger spec generation. + * Returns a previously generated OpenAPI specification for a plugin. * - * /index.php?module=API&method=OpenApiDocs.getOpenApiSpec&spec=CustomAlerts + * Reads the stored JSON spec file for the requested plugin and does not trigger + * spec generation. * - * @param string $pluginName Plugin name used in the generated filename. - * @param string $format Output format. Only `json` is supported. - * @return array The decoded OpenAPI specification payload. - * @throws \Exception If the file is missing, unreadable, or contains invalid JSON. + * @param string $pluginName The plugin name whose generated OpenAPI spec file should be read. + * @param string $format The response format to read. Only `json` is supported. + * @return array The decoded OpenAPI specification data from the generated JSON file. */ public function getOpenApiSpec(string $pluginName, string $format = 'json'): array { @@ -131,14 +128,12 @@ protected function getSpecPathResolver(): PathResolver } /** - * Get the generated API documentation data for the specified plugin. - * - * /index.php?module=API&method=OpenApiDocs.getGeneratedOpenApiSpec&plugin=CustomAlerts + * Generates an OpenAPI specification for one or more plugins and returns it immediately. * - * @param string $plugin Name of the plugin to get the JSON for. E.g. TagManager or CustomerAlerts - * @param string $format String to indicate JSON or YAML. - * @return string | array - * @throws \Exception + * @param string $plugin The plugin name to generate, or a comma-separated list of plugin names. + * @param string $format The response format to generate. Supported values are `json` and `yaml`. + * @return array|string The generated OpenAPI specification as decoded JSON data for + * `json`, or as a YAML string for `yaml`. */ public function getGeneratedOpenApiSpec(string $plugin, string $format) {