@@ -1517,9 +1517,6 @@ def test_model_as_nested_dict(self, api, client):
1517
1517
})
1518
1518
1519
1519
fields = api .model ('Person' , {
1520
- 'name' : restplus .fields .String ,
1521
- 'age' : restplus .fields .Integer ,
1522
- 'birthdate' : restplus .fields .DateTime ,
1523
1520
'address' : restplus .fields .Nested (address_fields )
1524
1521
})
1525
1522
@@ -1537,8 +1534,16 @@ def post(self):
1537
1534
1538
1535
assert 'definitions' in data
1539
1536
assert 'Person' in data ['definitions' ]
1537
+ assert data ['definitions' ]['Person' ] == {
1538
+ 'properties' : {
1539
+ 'address' : {
1540
+ '$ref' : '#/definitions/Address'
1541
+ },
1542
+ },
1543
+ 'type' : 'object'
1544
+ }
1540
1545
1541
- assert 'Address' in data ['definitions' ]. keys ()
1546
+ assert 'Address' in data ['definitions' ]
1542
1547
assert data ['definitions' ]['Address' ] == {
1543
1548
'properties' : {
1544
1549
'road' : {
@@ -1552,6 +1557,50 @@ def post(self):
1552
1557
assert path ['get' ]['responses' ]['200' ]['schema' ]['$ref' ] == '#/definitions/Person'
1553
1558
assert path ['post' ]['responses' ]['200' ]['schema' ]['$ref' ] == '#/definitions/Person'
1554
1559
1560
+ def test_model_as_nested_dict_with_details (self , api , client ):
1561
+ address_fields = api .model ('Address' , {
1562
+ 'road' : restplus .fields .String ,
1563
+ })
1564
+
1565
+ fields = api .model ('Person' , {
1566
+ 'address' : restplus .fields .Nested (address_fields , description = 'description' , readonly = True )
1567
+ })
1568
+
1569
+ @api .route ('/model-as-dict/' )
1570
+ class ModelAsDict (restplus .Resource ):
1571
+ @api .doc (model = fields )
1572
+ def get (self ):
1573
+ return {}
1574
+
1575
+ @api .doc (model = 'Person' )
1576
+ def post (self ):
1577
+ return {}
1578
+
1579
+ data = client .get_specs ()
1580
+
1581
+ assert 'definitions' in data
1582
+ assert 'Person' in data ['definitions' ]
1583
+ assert data ['definitions' ]['Person' ] == {
1584
+ 'properties' : {
1585
+ 'address' : {
1586
+ 'description' : 'description' ,
1587
+ 'readOnly' : True ,
1588
+ 'allOf' : [{'$ref' : '#/definitions/Address' }]
1589
+ },
1590
+ },
1591
+ 'type' : 'object'
1592
+ }
1593
+
1594
+ assert 'Address' in data ['definitions' ]
1595
+ assert data ['definitions' ]['Address' ] == {
1596
+ 'properties' : {
1597
+ 'road' : {
1598
+ 'type' : 'string'
1599
+ },
1600
+ },
1601
+ 'type' : 'object'
1602
+ }
1603
+
1555
1604
def test_model_as_flat_dict_with_marchal_decorator (self , api , client ):
1556
1605
fields = api .model ('Person' , {
1557
1606
'name' : restplus .fields .String ,
0 commit comments