File tree 2 files changed +23
-0
lines changed
2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -657,6 +657,8 @@ def register_model(self, model):
657
657
if name not in self .api .models :
658
658
raise ValueError ("Model {0} not registered" .format (name ))
659
659
specs = self .api .models [name ]
660
+ if name in self ._registered_models :
661
+ return ref (model )
660
662
self ._registered_models [name ] = specs
661
663
if isinstance (specs , ModelBase ):
662
664
for parent in specs .__parents__ :
Original file line number Diff line number Diff line change @@ -2057,6 +2057,27 @@ def get(self):
2057
2057
2058
2058
client .get_specs (status = 500 )
2059
2059
2060
+ def test_recursive_model (self , api , client ):
2061
+ fields = api .model ('Person' , {
2062
+ 'name' : restx .fields .String ,
2063
+ 'age' : restx .fields .Integer ,
2064
+ 'birthdate' : restx .fields .DateTime ,
2065
+ })
2066
+
2067
+ fields ["children" ] = restx .fields .List (
2068
+ restx .fields .Nested (fields ),
2069
+ default = [],
2070
+ )
2071
+
2072
+ @api .route ('/recursive-model/' )
2073
+ @api .doc (get = {'model' : fields })
2074
+ class ModelAsDict (restx .Resource ):
2075
+ @api .marshal_with (fields )
2076
+ def get (self ):
2077
+ return {}
2078
+
2079
+ client .get_specs (status = 200 )
2080
+
2060
2081
def test_specs_no_duplicate_response_keys (self , api , client ):
2061
2082
"""
2062
2083
This tests that the swagger.json document will not be written with duplicate object keys
You can’t perform that action at this time.
0 commit comments