Skip to content

Commit aca3cd6

Browse files
committed
Now defaulting to not do local requests
1 parent 8a8a1d1 commit aca3cd6

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

Annotations/AnnotationGenerator.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,22 @@ class AnnotationGenerator
9494
*/
9595
protected $missingImportantDataWarnings;
9696

97+
/**
98+
* @var bool
99+
*/
100+
protected $allowLocalRequests;
101+
97102
public function __construct(
98103
DocumentationGenerator $generator,
99104
?PathResolver $pathResolver = null,
100-
?ArtifactWriter $artifactWriter = null
105+
?ArtifactWriter $artifactWriter = null,
106+
bool $allowLocalRequests = false
101107
) {
102108
$this->generator = $generator;
103109
$this->pathResolver = $pathResolver ?? new PathResolver();
104110
$this->artifactWriter = $artifactWriter ?? new ArtifactWriter();
105111
$this->missingImportantDataWarnings = [];
112+
$this->allowLocalRequests = $allowLocalRequests;
106113
$this->currentPluginDir = Manager::getInstance()::getPluginDirectory('OpenApiDocs');
107114
}
108115

@@ -859,6 +866,7 @@ protected function getApplicableDemoExampleUrls(string $pluginName, string $meth
859866
*/
860867
protected function getDemoReportMetadata(): array
861868
{
869+
862870
if (is_array($this->reportMetadata) && count($this->reportMetadata)) {
863871
return $this->reportMetadata;
864872
}
@@ -929,6 +937,7 @@ protected function getExampleIfAvailable(string $url, bool $useLocalToken = fals
929937
}
930938
}
931939

940+
932941
// Include a specific parameter for the TSV requests.
933942
if ($format === 'tsv') {
934943
$url .= '&convertToUnicode=0';
@@ -1229,7 +1238,9 @@ protected function determineResponses(array $rules, string $plugin, string $meth
12291238
$exampleValue = $this->getExampleIfAvailable($url);
12301239
// If the example lookup failed, try making the same request locally using a local token.
12311240
if (empty($exampleValue)) {
1232-
$exampleValue = $this->getExampleIfAvailable($url, true);
1241+
if($this->allowLocalRequests) {
1242+
$exampleValue = $this->getExampleIfAvailable($url, true);
1243+
}
12331244
}
12341245
if (strlen($exampleValue) > self::EXAMPLE_CHAR_LIMIT) {
12351246
$exampleValue = $this->cutExampleCloseToCharLimit($exampleValue, $type);

0 commit comments

Comments
 (0)