@@ -94,9 +94,9 @@ class Api(object):
94
94
:param FormatChecker format_checker: A jsonschema.FormatChecker object that is hooked into
95
95
the Model validator. A default or a custom FormatChecker can be provided (e.g., with custom
96
96
checkers), otherwise the default action is to not enforce any format validation.
97
- :param specs_url_scheme : If set to a string (e.g. http, https), then the specs_url will explicitly use this scheme
98
- regardless of how the application is deployed. This is necessary for some deployments such as behind an
99
- AWS elastic load balancer so that the user recieves the full swagger URL .
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
+ scheme regardless of how the application is deployed. This is necessary for some deployments behind a reverse
99
+ proxy .
100
100
"""
101
101
102
102
def __init__ (
@@ -126,7 +126,7 @@ def __init__(
126
126
catch_all_404s = False ,
127
127
serve_challenge_on_401 = False ,
128
128
format_checker = None ,
129
- specs_url_scheme = None ,
129
+ url_scheme = None ,
130
130
** kwargs
131
131
):
132
132
self .version = version
@@ -184,7 +184,7 @@ def __init__(
184
184
api = self ,
185
185
path = "/" ,
186
186
)
187
- self .specs_url_scheme = specs_url_scheme
187
+ self .url_scheme = url_scheme
188
188
if app is not None :
189
189
self .app = app
190
190
self .init_app (app )
@@ -205,7 +205,9 @@ def init_app(self, app, **kwargs):
205
205
:param str contact: A contact email for the API (used in Swagger documentation)
206
206
:param str license: The license associated to the API (used in Swagger documentation)
207
207
:param str license_url: The license page URL (used in Swagger documentation)
208
-
208
+ :param url_scheme: If set to a string (e.g. http, https), then the specs_url and base_url will explicitly use
209
+ this scheme regardless of how the application is deployed. This is necessary for some deployments behind a
210
+ reverse proxy.
209
211
"""
210
212
self .app = app
211
213
self .title = kwargs .get ("title" , self .title )
@@ -216,6 +218,7 @@ def init_app(self, app, **kwargs):
216
218
self .contact_email = kwargs .get ("contact_email" , self .contact_email )
217
219
self .license = kwargs .get ("license" , self .license )
218
220
self .license_url = kwargs .get ("license_url" , self .license_url )
221
+ self .url_scheme = kwargs .get ("url_scheme" , self .url_scheme )
219
222
self ._add_specs = kwargs .get ("add_specs" , True )
220
223
221
224
# If app is a blueprint, defer the initialization
@@ -527,9 +530,9 @@ def specs_url(self):
527
530
528
531
:rtype: str
529
532
"""
530
- external = None if self .specs_url_scheme is None else True
533
+ external = None if self .url_scheme is None else True
531
534
return url_for (
532
- self .endpoint ("specs" ), _scheme = self .specs_url_scheme , _external = external
535
+ self .endpoint ("specs" ), _scheme = self .url_scheme , _external = external
533
536
)
534
537
535
538
@property
@@ -539,7 +542,7 @@ def base_url(self):
539
542
540
543
:rtype: str
541
544
"""
542
- return url_for (self .endpoint ("root" ), _external = True )
545
+ return url_for (self .endpoint ("root" ), _scheme = self . url_scheme , _external = True )
543
546
544
547
@property
545
548
def base_path (self ):
0 commit comments