Improving annotation generation#6
Conversation
|
@snake14 When testing CustomReports, I get an error:
|
| $pluginConfigPath = $pluginDir . '/OpenApi/Annotations/config.php'; | ||
| if (is_file($pluginConfigPath)) { | ||
| $pluginRules = require $pluginDir . '/OpenApi/Annotations/config.php'; | ||
| } |
There was a problem hiding this comment.
Maybe nitpick (does the security scanner pick up on this?) but if this is always going to be arrays, it'd be much more secure to have this as json or yaml or something rather than requiring a php.
There was a problem hiding this comment.
Are you planning for us to customise each plugin in pluginDir/OpenApi/Annotations/config.php instead of directly editing the file? Or is this for something else?
There was a problem hiding this comment.
@james-hill-matomo As mentioned in Slack, I'm trying to remove the use of a config file. The main thing that I haven't determined how to do without a config is whether to use GET or POST for each API method. I guess I can just have everything show as GET for now.
|
|
||
| $mediaTypes = []; | ||
| // This simply reuses the example URLs used by the current documentation, but some endpoints don't work because authentication is required | ||
| // TODO - Come up with a way to demo examples for endpoints which require authentication. E.g. hit a live endpoint server-side and replace any potentially sensitive data... |
There was a problem hiding this comment.
That can stay out of scope for now. I don't think the demos will be so important if we can provide a live swagger that users can query their own data with easily.
| if ($default !== '') { | ||
| // TODO - Add some logic to only add default if it matches the type. E.g. false isn't a good default for string | ||
| $schemaMap[] = 'default="' . $default . '"'; | ||
| } |
There was a problem hiding this comment.
Hah - Shame I didn't read this before my other comments about the defaults.
Ah. Yeah. Probably related to Matomo APIs returning 200 type responses when they should be 4xx or 5xx. I can add an extra check. Edit: With the latest commit, annotations are built successfully for the CustomReports plugin. |
|
|
||
| protected function getExampleIfAvailable(string $url): array | ||
| { | ||
| $ch = curl_init($url); |
There was a problem hiding this comment.
Can't we use Http::sendHttpRequestBy instead of using curl directly ?
There was a problem hiding this comment.
@AltamashShaikh Possibly. I forgot that was an option and didn't see it when I was looking for examples in the codebase.
AltamashShaikh
left a comment
There was a problem hiding this comment.
@snake14 Left few comments overall looks good to me.
I just tested Swagger UI and it shows |
|
@james-hill-matomo @AltamashShaikh Any concerns with the last 2-3 commits or am I good to merge once #7 is merged in? |
AltamashShaikh
left a comment
There was a problem hiding this comment.
@snake14 I can see the file being created with not-dry-run option
Pg 4396 add workflows



Description
Making improvements to the annotation generation command. I realised that I should probably get my changes so far reviewed, so I'm creating this PR and branching from it for additional changes.
Issue No
PG-4396
Steps to Replicate the Issue
ddev matomo:console openapidocs:generate-annotations --plugin=CustomAlertsto see the annotations for all of the API methods of that plugin generated.Checklist