Skip to content

Commit

Permalink
Fixed tags and security
Browse files Browse the repository at this point in the history
  • Loading branch information
kocsismate committed May 4, 2015
1 parent 5b013a9 commit 898c3fe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
9 changes: 5 additions & 4 deletions src/Swagger2/SwaggerSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,17 +146,18 @@ public function generate()
$result= Generator::addItemToArrayIfNotEmpty($result, "schemes", $this->schemes);
$result= Generator::addItemToArrayIfNotEmpty($result, "consumes", $this->consumes);
$result= Generator::addItemToArrayIfNotEmpty($result, "produces", $this->produces);
foreach ($this->tags as $tag) {
$result = Generator::pushGeneratableToArrayIfNotEmpty($result, "tags", $tag);
}
$result["paths"]= $this->paths !== null ? $this->paths->generate() : null;
$result= Generator::addGeneratableToArrayIfNotEmpty($result, "definitions", $this->definitions);
$result= Generator::addGeneratableToArrayIfNotEmpty($result, "parameters", $this->parameters);
$result= Generator::addGeneratableToArrayIfNotEmpty($result, "responses", $this->responses);
$result= Generator::addGeneratableToArrayIfNotEmpty($result, "securityDefinitions", $this->securityDefinitions);
foreach ($this->security as $security) {
$result = Generator::pushGeneratableToArrayIfNotEmpty($result["security"], $security);
}
foreach ($this->tags as $tag) {
$result = Generator::pushGeneratableToArrayIfNotEmpty($result["tags"], $tag);
$result = Generator::pushGeneratableToArrayIfNotEmpty($result, "security", $security);
}

$result= Generator::addGeneratableToArrayIfNotEmpty($result, "externalDocs", $this->externalDocs);

if ($this->cache !== null) {
Expand Down
5 changes: 3 additions & 2 deletions src/Utilities/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,16 @@ public static function addGeneratableToArrayIfNotEmpty($array, $key, Generatable

/**
* @param array $array
* @param string $key
* @param \WoohooLabs\SpecGenerator\GeneratableInterface $value
* @return array
*/
public static function pushGeneratableToArrayIfNotEmpty($array, GeneratableInterface $value = null)
public static function pushGeneratableToArrayIfNotEmpty(array $array, $key, GeneratableInterface $value = null)
{
if ($value !== null) {
$generation= $value->generate();
if (is_array($generation) === true && empty($generation) === false) {
$array[] = $generation;
$array[$key][] = $generation;
}
}

Expand Down

0 comments on commit 898c3fe

Please sign in to comment.