@@ -3256,3 +3256,49 @@ def test_build_request_body_parameters_schema(self):
3256
3256
assert result ["schema" ]["type" ] == "object"
3257
3257
assert result ["schema" ]["properties" ]["test1" ]["type" ] == "integer"
3258
3258
assert result ["schema" ]["properties" ]["test2" ]["type" ] == "string"
3259
+
3260
+ def test_expect_unused_model (self , app , api , client ):
3261
+ from flask_restx import fields
3262
+
3263
+ api .model (
3264
+ "SomeModel" , {"param" : fields .String , "count" : fields .Integer ,},
3265
+ )
3266
+
3267
+ @api .route ("/with-parser/" , endpoint = "with-parser" )
3268
+ class WithParserResource (restx .Resource ):
3269
+ def get (self ):
3270
+ return {}
3271
+
3272
+ app .config ["RESTX_INCLUDE_ALL_MODELS" ] = True
3273
+ data = client .get_specs ()
3274
+ assert "/with-parser/" in data ["paths" ]
3275
+
3276
+ path = data ["paths" ]["/with-parser/" ]
3277
+ assert "parameters" not in path
3278
+
3279
+ model = data ["definitions" ]["SomeModel" ]
3280
+ assert model == {
3281
+ "properties" : {"count" : {"type" : "integer" }, "param" : {"type" : "string" }},
3282
+ "type" : "object" ,
3283
+ }
3284
+
3285
+ def test_not_expect_unused_model (self , app , api , client ):
3286
+ # This is the default configuration, RESTX_INCLUDE_ALL_MODELS=False
3287
+
3288
+ from flask_restx import fields
3289
+
3290
+ api .model (
3291
+ "SomeModel" , {"param" : fields .String , "count" : fields .Integer ,},
3292
+ )
3293
+
3294
+ @api .route ("/with-parser/" , endpoint = "with-parser" )
3295
+ class WithParserResource (restx .Resource ):
3296
+ def get (self ):
3297
+ return {}
3298
+
3299
+ data = client .get_specs ()
3300
+ assert "/with-parser/" in data ["paths" ]
3301
+ assert "definitions" not in data
3302
+
3303
+ path = data ["paths" ]["/with-parser/" ]
3304
+ assert "parameters" not in path
0 commit comments