Skip to content

Add examples for try it out, #PG-5178#38

Merged
lachiebol merged 6 commits into
5.x-devfrom
PG-5178-try-it-out-examples
May 17, 2026
Merged

Add examples for try it out, #PG-5178#38
lachiebol merged 6 commits into
5.x-devfrom
PG-5178-try-it-out-examples

Conversation

@lachiebol
Copy link
Copy Markdown
Contributor

@lachiebol lachiebol commented May 14, 2026

Description

To get updated specs:

core:run-scheduled-tasks "Piwik\Plugins\OpenApiDocs\Tasks.generateConfiguredPluginSpecs" --force

Then you can verify in the UI tab

Issue No

Steps to Replicate the Issue

Checklist

  • [✔/✖] Tested locally or on demo2/demo3?
  • [✔/✖/NA] 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?
  • [✔/✖/NA] Documentation updated?

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.

New examples, have done a quick sense check. But if anything doesn't look right let me know

@lachiebol lachiebol changed the title Pg 5178 try it out examples Add examples for try it out, #PG-5178 May 15, 2026
@lachiebol lachiebol marked this pull request as ready for review May 15, 2026 03:52
foreach ($typeHints as $typePart) {
$typePart = trim($typePart, ' ()');
$normalisedType = $this->getOpenApiTypeFromPhpType($typePart);
$normalisedType = $this->hasSpecificArrayShape($typePart) ? 'array' : $this->getOpenApiTypeFromPhpType($typePart);
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.

If it's a complex array type I'm just leaving it for now. When I implement POST this can be changed

if (
!is_array($example)
|| !$this->isBasicExampleArray($example)
|| !$this->supportsBasicArrayExample($typesMap)
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.

Same here: will remove this logic when adding POST. At the moment it prevents complex param examples from coming through

@lachiebol
Copy link
Copy Markdown
Contributor Author

@AltamashShaikh Will address these concerns in POST request PR

  - Blocking: Generic typed arrays with non-scalar items are now documented as arrays of strings. In Annotations/AnnotationGenerator.php:488, array<int, VisitDescriptor> and
    array<int,array<string,mixed>> are normalized to array, then their subtype is passed through getOpenApiTypeFromPhpType() at Annotations/AnnotationGenerator.php:491. Unknown
    subtypes fall back to string, so a real API like /home/lachlan/matomo-code/matomo_5x-dev/plugins/PrivacyManager/API.php:82 with @param array<int, VisitDescriptor> $visits gets
    emitted as an array of strings. Before this branch, those generic arrays stayed untyped; this change makes the schema actively wrong.
  - Medium: A noticeable part of the new config payload is unreachable, so the branch does not actually add examples for many of the complex parameters it targets.
    normaliseConfiguredParameterExample() explicitly rejects associative and nested arrays at Annotations/AnnotationGenerator.php:653, and the test suite codifies that behavior at
    tests/Unit/AnnotationGeneratorTest.php:1300. But the new config adds several such values, for example config/ParameterExamples.php:24, config/ParameterExamples.php:113, config/
    ParameterExamples.php:158, and config/ParameterExamples.php:191. Those entries will never surface in generated docs, so the branch only improves simple examples, not the complex
    cases it now enumerates.

@lachiebol lachiebol requested a review from AltamashShaikh May 15, 2026 05:42
@lachiebol lachiebol added the Needs Review For pull requests that need a code review. label May 15, 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.

ActivityLog, before schedule task run
period and date are being filled as null, which throws an error

Image

After schedule task run, fixes the issue 👍

Image

@lachiebol lachiebol merged commit bd06476 into 5.x-dev May 17, 2026
7 checks passed
@lachiebol lachiebol deleted the PG-5178-try-it-out-examples branch May 17, 2026 23:13
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