From 9824a6ba3cd2703c53d83f88d21455000e008590 Mon Sep 17 00:00:00 2001 From: Bez Hermoso Date: Fri, 25 Jul 2014 17:31:24 -0700 Subject: [PATCH] Added default value handling. --- Formatter/SwaggerFormatter.php | 7 ++++++- Tests/Formatter/SwaggerFormatterTest.php | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Formatter/SwaggerFormatter.php b/Formatter/SwaggerFormatter.php index 3ab0cef..6b9cb53 100644 --- a/Formatter/SwaggerFormatter.php +++ b/Formatter/SwaggerFormatter.php @@ -360,7 +360,8 @@ class SwaggerFormatter implements FormatterInterface $prop['subType'], isset($prop['children']) ? $prop['children'] : null, $prop['description'] ?: $prop['dataType'], - $models); + $models + ); break; } } @@ -396,6 +397,10 @@ class SwaggerFormatter implements FormatterInterface $parameter['enum'] = $enum; } + if ($prop['default'] !== null) { + $parameter['defaultValue'] = $prop['default']; + } + $parameters[] = $parameter; } diff --git a/Tests/Formatter/SwaggerFormatterTest.php b/Tests/Formatter/SwaggerFormatterTest.php index d8f543f..488849b 100644 --- a/Tests/Formatter/SwaggerFormatterTest.php +++ b/Tests/Formatter/SwaggerFormatterTest.php @@ -230,7 +230,6 @@ class SwaggerFormatterTest extends WebTestCase ), 'responseMessages' => array( - array( 'code' => 200, 'message' => 'See standard HTTP status code reason for 200', @@ -650,12 +649,14 @@ With multiple lines.', 'paramType' => 'form', 'name' => 'c', 'type' => 'boolean', + 'defaultValue' => false, ), array ( 'paramType' => 'form', 'name' => 'd', 'type' => 'string', + 'defaultValue' => 'DefaultTest', ), ), 'responseMessages' => @@ -693,12 +694,14 @@ With multiple lines.', 'paramType' => 'form', 'name' => 'c', 'type' => 'boolean', + 'defaultValue' => false, ), array ( 'paramType' => 'form', 'name' => 'd', 'type' => 'string', + 'defaultValue' => 'DefaultTest', ), ), 'responseMessages' =>