Introduced default-value parameter to JsonSerializableParser

JSP is now able to set a default value for scalar types
This makes merging the parser result with other parser results easier
and gives some additional info when creating docs

Removed PHP doc comment block
This commit is contained in:
Florian Strübe 2015-11-09 23:34:37 +01:00
parent be90e8aad6
commit aa10f9a2da
2 changed files with 8 additions and 4 deletions

View File

@ -59,7 +59,8 @@ class JsonSerializableParser implements ParserInterface
'subType' => null, 'subType' => null,
'required' => null, 'required' => null,
'description' => null, 'description' => null,
'readonly' => null 'readonly' => null,
'default' => is_scalar($item) ? $item : null,
); );
if ($type == 'object' && $item instanceof \JsonSerializable) { if ($type == 'object' && $item instanceof \JsonSerializable) {

View File

@ -46,13 +46,15 @@ class JsonSerializableParserTest extends \PHPUnit_Framework_TestCase
array( array(
'property' => 'id', 'property' => 'id',
'expected' => array( 'expected' => array(
'dataType' => 'integer' 'dataType' => 'integer',
'default' => 123
) )
), ),
array( array(
'property' => 'name', 'property' => 'name',
'expected' => array( 'expected' => array(
'dataType' => 'string' 'dataType' => 'string',
'default' => 'My name',
) )
), ),
array( array(
@ -66,7 +68,8 @@ class JsonSerializableParserTest extends \PHPUnit_Framework_TestCase
'subType' => null, 'subType' => null,
'required' => null, 'required' => null,
'description' => null, 'description' => null,
'readonly' => null 'readonly' => null,
'default' => null,
) )
) )
) )