Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
uderline committed Feb 24, 2022
2 parents fc96c6a + 5b0042f commit adea982
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function generate(): array
$this->loadController($reflectionClass);
$this->loadSchema($reflectionClass);
$this->loadServer($reflectionClass);
$this->loadSchemaSecurity($reflectionClass);
$this->loadSecurityScheme($reflectionClass);
}

$this->description['paths'] = $this->generatorHttp->build();
Expand All @@ -88,6 +88,7 @@ public function makeFinalArray(): array
'servers' => $this->description['servers'] ?? [],
'paths' => $this->description['paths'],
'components' => $this->description['components'],
'security' => $this->description['security'],
];

ApiDescriptionChecker::check($definition);
Expand Down Expand Up @@ -154,7 +155,7 @@ private function loadServer(ReflectionClass $reflectionClass): void
* @param ReflectionClass $reflectionClass
* @return void
*/
private function loadSchemaSecurity(ReflectionClass $reflectionClass): void
private function loadSecurityScheme(ReflectionClass $reflectionClass): void
{
if (count($reflectionClass->getAttributes(SecurityScheme::class))) {
$securitySchemas = $reflectionClass->getAttributes(SecurityScheme::class);
Expand All @@ -164,6 +165,11 @@ private function loadSchemaSecurity(ReflectionClass $reflectionClass): void
$key = array_keys($data)[0];
$this->description['components']['securitySchemes'][$key] = $data[$key];
}

$this->description['security'] = array_map(
fn(string $canonicalName) => [$canonicalName => []],
array_keys($this->description['components']['securitySchemes'])
);
}
}
}

0 comments on commit adea982

Please sign in to comment.