Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions Annotations/AnnotationGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -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);
Expand Down
Loading