File tree 2 files changed +26
-1
lines changed
2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -97,6 +97,7 @@ class Api(object):
97
97
:param url_scheme: If set to a string (e.g. http, https), then the specs_url and base_url will explicitly use this
98
98
scheme regardless of how the application is deployed. This is necessary for some deployments behind a reverse
99
99
proxy.
100
+ :param str default_swagger_filename: The default swagger filename.
100
101
"""
101
102
102
103
def __init__ (
@@ -127,6 +128,7 @@ def __init__(
127
128
serve_challenge_on_401 = False ,
128
129
format_checker = None ,
129
130
url_scheme = None ,
131
+ default_swagger_filename = "swagger.json" ,
130
132
** kwargs
131
133
):
132
134
self .version = version
@@ -157,6 +159,7 @@ def __init__(
157
159
self ._refresolver = None
158
160
self .format_checker = format_checker
159
161
self .namespaces = []
162
+ self .default_swagger_filename = default_swagger_filename
160
163
161
164
self .ns_paths = dict ()
162
165
@@ -299,7 +302,7 @@ def _register_specs(self, app_or_blueprint):
299
302
app_or_blueprint ,
300
303
SwaggerView ,
301
304
self .default_namespace ,
302
- "/swagger.json" ,
305
+ "/" + self . default_swagger_filename ,
303
306
endpoint = endpoint ,
304
307
resource_class_args = (self ,),
305
308
)
Original file line number Diff line number Diff line change @@ -3323,3 +3323,25 @@ def get(self):
3323
3323
3324
3324
path = data ["paths" ]["/with-parser/" ]
3325
3325
assert "parameters" not in path
3326
+
3327
+ def test_nondefault_swagger_filename (self , app , client ):
3328
+ api = restx .Api (doc = "/doc/test" , default_swagger_filename = "test.json" )
3329
+ ns = restx .Namespace ("ns1" )
3330
+
3331
+ @ns .route ("/test1" )
3332
+ class Ns (restx .Resource ):
3333
+ @ns .doc ("Docs" )
3334
+ def get (self ):
3335
+ pass
3336
+
3337
+ api .add_namespace (ns )
3338
+ api .init_app (app )
3339
+
3340
+ resp = client .get ("/test.json" )
3341
+ assert resp .status_code == 200
3342
+ assert resp .content_type == "application/json"
3343
+ resp = client .get ("/doc/test" )
3344
+ assert resp .status_code == 200
3345
+ assert resp .content_type == "text/html; charset=utf-8"
3346
+ resp = client .get ("/ns1/test1" )
3347
+ assert resp .status_code == 200
You can’t perform that action at this time.
0 commit comments