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 @@ -106,6 +106,7 @@ class Api(object):
106
106
:param url_scheme: If set to a string (e.g. http, https), then the specs_url and base_url will explicitly use this
107
107
scheme regardless of how the application is deployed. This is necessary for some deployments behind a reverse
108
108
proxy.
109
+ :param str default_swagger_filename: The default swagger filename.
109
110
"""
110
111
111
112
def __init__ (
@@ -136,6 +137,7 @@ def __init__(
136
137
serve_challenge_on_401 = False ,
137
138
format_checker = None ,
138
139
url_scheme = None ,
140
+ default_swagger_filename = "swagger.json" ,
139
141
** kwargs
140
142
):
141
143
self .version = version
@@ -166,6 +168,7 @@ def __init__(
166
168
self ._refresolver = None
167
169
self .format_checker = format_checker
168
170
self .namespaces = []
171
+ self .default_swagger_filename = default_swagger_filename
169
172
170
173
self .ns_paths = dict ()
171
174
@@ -308,7 +311,7 @@ def _register_specs(self, app_or_blueprint):
308
311
app_or_blueprint ,
309
312
SwaggerView ,
310
313
self .default_namespace ,
311
- "/swagger.json" ,
314
+ "/" + self . default_swagger_filename ,
312
315
endpoint = endpoint ,
313
316
resource_class_args = (self ,),
314
317
)
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