Skip to content

Added endpoint to retrieve static single swagger file, #PG-4593#22

Merged
lachiebol merged 8 commits into
5.x-devfrom
PG-4593-singlefile-endpoint
Mar 6, 2026
Merged

Added endpoint to retrieve static single swagger file, #PG-4593#22
lachiebol merged 8 commits into
5.x-devfrom
PG-4593-singlefile-endpoint

Conversation

@lachiebol
Copy link
Copy Markdown
Contributor

@lachiebol lachiebol commented Mar 6, 2026

Description

Test with /index.php?module=API&method=OpenApiDocs.getMatomoOpenApiSpec&format=JSON

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)
  • [✔] Version bumped?
  • [✔] I have understood, reviewed, and tested all AI outputs before use
  • [✔] All AI instructions respect security, IP, and privacy rules

@lachiebol lachiebol requested a review from a team March 6, 2026 01:02
@lachiebol lachiebol added the Needs Review For pull requests that need a code review. label Mar 6, 2026
@lachiebol lachiebol marked this pull request as ready for review March 6, 2026 01:02
Comment thread API.php
Comment thread API.php
AltamashShaikh
AltamashShaikh previously approved these changes Mar 6, 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 comment around format and permission rest looks good to me.

@lachiebol lachiebol requested a review from AltamashShaikh March 6, 2026 03:03
@lachiebol
Copy link
Copy Markdown
Contributor Author

@AltamashShaikh Format should be fixed now, I checked developer doc examples and they used the anonymous user which has view access

https://demo.matomo.cloud/?module=API&method=CustomDimensions.getConfiguredCustomDimensions&idSite=1&format=xml&token_auth=anonymous

Comment thread API.php Outdated
* @return array<string, mixed> The decoded OpenAPI specification payload.
* @throws \Exception If the file is missing, unreadable, or contains invalid JSON.
*/
public function getMatomoOpenApiSpec(): 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.

Suggested change
public function getMatomoOpenApiSpec(): array
public function getMatomoOpenApiSpec(string $format = 'json'): array

Comment thread API.php Outdated
Piwik::checkUserHasSomeViewAccess();

$request = Request::fromRequest();
$format = strtolower($request->getStringParameter('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.

@lachiebol You can have format as a function parameter and Dependency injection, will ensure that it passes that parameter.

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.

Much cleaner, good to know :)

@lachiebol lachiebol requested a review from AltamashShaikh March 6, 2026 03:13
@lachiebol
Copy link
Copy Markdown
Contributor Author

Just realised yours had default param which is probably better

Comment thread API.php
Comment thread API.php Outdated
AltamashShaikh
AltamashShaikh previously approved these changes Mar 6, 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 optional comments

@lachiebol lachiebol merged commit 5cfce34 into 5.x-dev Mar 6, 2026
7 checks passed
@lachiebol lachiebol deleted the PG-4593-singlefile-endpoint branch March 6, 2026 03:20
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