From 0d17c10b70c77626ef0a800b99b4c82c4ea0224b Mon Sep 17 00:00:00 2001 From: Bez Hermoso Date: Thu, 4 Sep 2014 11:19:02 -0700 Subject: [PATCH] Collection handling fix. --- Formatter/SwaggerFormatter.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Formatter/SwaggerFormatter.php b/Formatter/SwaggerFormatter.php index d56316d..8599959 100644 --- a/Formatter/SwaggerFormatter.php +++ b/Formatter/SwaggerFormatter.php @@ -448,19 +448,20 @@ class SwaggerFormatter implements FormatterInterface case DataTypes::COLLECTION: $type = 'array'; - if ($prop['subType'] === DataTypes::MODEL) { - $ref = $this->registerModel( - $prop['subType'], - isset($prop['children']) ? $prop['children'] : null, - $prop['description'] ?: $prop['dataType'] - ); - $items = array( - '$ref' => $ref - ); + if ($prop['subType'] === null) { + $items = array('type' => 'string'); } elseif (isset($this->typeMap[$prop['subType']])) { $items = array('type' => $this->typeMap[$prop['subType']]); } else { - $items = array('type' => 'string'); + $ref = + $this->registerModel( + $prop['subType'], + isset($prop['children']) ? $prop['children'] : null, + $prop['description'] ?: $prop['dataType'] + ); + $items = array( + '$ref' => $ref, + ); } break; }