Skip to content

Added endpoint that can return single spec files, #PG-4593#25

Merged
lachiebol merged 4 commits into
5.x-devfrom
PG-4593-single-plugin-spec-from-api
Mar 19, 2026
Merged

Added endpoint that can return single spec files, #PG-4593#25
lachiebol merged 4 commits into
5.x-devfrom
PG-4593-single-plugin-spec-from-api

Conversation

@lachiebol
Copy link
Copy Markdown
Contributor

@lachiebol lachiebol commented Mar 17, 2026

Description

Can now retrieve all spec files with 'matomo' or a specific plugin with it's name

curl -G 'https://www.example-matomo.com/index.php' \
    --data-urlencode 'module=API' \
    --data-urlencode 'method=OpenApiDocs.getOpenApiSpec' \
    --data-urlencode 'spec={plugin_name}' \
    --data-urlencode 'format=json' \
    --data-urlencode 'token_auth=anonymous'

Issue No

Steps to Replicate the Issue

Checklist

  • [✔] Tested locally or on demo2/demo3?
  • [✔] New test case added/updated?
  • [NA] Are all newly added texts included via translation?
  • [NA] Are text sanitized properly? (Eg use of v-text v/s v-html for vue)
  • [NA] Version bumped?

@lachiebol lachiebol requested a review from a team March 17, 2026 22:54
@lachiebol lachiebol added the Needs Review For pull requests that need a code review. label Mar 17, 2026
Comment thread API.php
{
Piwik::checkUserHasSomeViewAccess();

if (strtolower($format) !== 'json') {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also add a validation for $spec, it should be an valid pluginName

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AltamashShaikh I've changed that, also removed the single spec file logic from the endpoint. I don't think it's really required anymore.

Comment thread API.php Outdated
* @throws \Exception If the file is missing, unreadable, or contains invalid JSON.
*/
public function getMatomoOpenApiSpec(string $format = 'json'): array
public function getOpenApiSpec(string $spec, string $format = 'json'): array
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lachiebol Should we change the parameter name to pluginName from spec ?

Suggested change
public function getOpenApiSpec(string $spec, string $format = 'json'): array
public function getOpenApiSpec(string $plugin, string $format = 'json'): array

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is optional

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AltamashShaikh pluginName sounds more accurate, changed that

AltamashShaikh
AltamashShaikh previously approved these changes Mar 18, 2026
Copy link
Copy Markdown
Contributor

@AltamashShaikh AltamashShaikh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left 1 optional comment, looks good to me

@lachiebol
Copy link
Copy Markdown
Contributor Author

Tests failed just fixing...

AltamashShaikh
AltamashShaikh previously approved these changes Mar 18, 2026
@lachiebol lachiebol merged commit 0be8008 into 5.x-dev Mar 19, 2026
7 checks passed
@lachiebol lachiebol deleted the PG-4593-single-plugin-spec-from-api branch March 19, 2026 00:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Review For pull requests that need a code review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants