From aca3cd6b001369199216b88cb52e134c1a3764be Mon Sep 17 00:00:00 2001 From: Lachlan Reynolds Date: Wed, 8 Apr 2026 16:48:03 +1200 Subject: [PATCH 1/2] Now defaulting to not do local requests --- Annotations/AnnotationGenerator.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Annotations/AnnotationGenerator.php b/Annotations/AnnotationGenerator.php index 0a699aa..682add0 100644 --- a/Annotations/AnnotationGenerator.php +++ b/Annotations/AnnotationGenerator.php @@ -94,15 +94,22 @@ class AnnotationGenerator */ protected $missingImportantDataWarnings; + /** + * @var bool + */ + protected $allowLocalRequests; + public function __construct( DocumentationGenerator $generator, ?PathResolver $pathResolver = null, - ?ArtifactWriter $artifactWriter = null + ?ArtifactWriter $artifactWriter = null, + bool $allowLocalRequests = false ) { $this->generator = $generator; $this->pathResolver = $pathResolver ?? new PathResolver(); $this->artifactWriter = $artifactWriter ?? new ArtifactWriter(); $this->missingImportantDataWarnings = []; + $this->allowLocalRequests = $allowLocalRequests; $this->currentPluginDir = Manager::getInstance()::getPluginDirectory('OpenApiDocs'); } @@ -859,6 +866,7 @@ protected function getApplicableDemoExampleUrls(string $pluginName, string $meth */ protected function getDemoReportMetadata(): array { + if (is_array($this->reportMetadata) && count($this->reportMetadata)) { return $this->reportMetadata; } @@ -929,6 +937,7 @@ protected function getExampleIfAvailable(string $url, bool $useLocalToken = fals } } + // Include a specific parameter for the TSV requests. if ($format === 'tsv') { $url .= '&convertToUnicode=0'; @@ -1229,7 +1238,9 @@ protected function determineResponses(array $rules, string $plugin, string $meth $exampleValue = $this->getExampleIfAvailable($url); // If the example lookup failed, try making the same request locally using a local token. if (empty($exampleValue)) { - $exampleValue = $this->getExampleIfAvailable($url, true); + if($this->allowLocalRequests) { + $exampleValue = $this->getExampleIfAvailable($url, true); + } } if (strlen($exampleValue) > self::EXAMPLE_CHAR_LIMIT) { $exampleValue = $this->cutExampleCloseToCharLimit($exampleValue, $type); From bfc0f98f06e6565e58a4679b43f7bb44fb660d87 Mon Sep 17 00:00:00 2001 From: Lachlan Reynolds Date: Wed, 8 Apr 2026 16:50:46 +1200 Subject: [PATCH 2/2] didn't push phpcs changes --- Annotations/AnnotationGenerator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Annotations/AnnotationGenerator.php b/Annotations/AnnotationGenerator.php index 682add0..28f1118 100644 --- a/Annotations/AnnotationGenerator.php +++ b/Annotations/AnnotationGenerator.php @@ -1238,7 +1238,7 @@ protected function determineResponses(array $rules, string $plugin, string $meth $exampleValue = $this->getExampleIfAvailable($url); // If the example lookup failed, try making the same request locally using a local token. if (empty($exampleValue)) { - if($this->allowLocalRequests) { + if ($this->allowLocalRequests) { $exampleValue = $this->getExampleIfAvailable($url, true); } }