Skip to content

Commit ea6fd54

Browse files
committed
Rename config variables: RESTPLUS_* -> RESTX_*
1 parent 3da9017 commit ea6fd54

11 files changed

+24
-22
lines changed

doc/mask.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Flask-RESTX support partial object fetching (aka. fields mask)
55
by supplying a custom header in the request.
66

77
By default the header is ``X-Fields``
8-
but it can be changed with the ``RESTPLUS_MASK_HEADER`` parameter.
8+
but it can be changed with the ``RESTX_MASK_HEADER`` parameter.
99

1010
Syntax
1111
------
@@ -65,7 +65,7 @@ The header will be exposed as a Swagger parameter each time you use the
6565

6666
As Swagger does not permit exposing a global header once
6767
it can make your Swagger specifications a lot more verbose.
68-
You can disable this behavior by setting ``RESTPLUS_MASK_SWAGGER`` to ``False``.
68+
You can disable this behavior by setting ``RESTX_MASK_SWAGGER`` to ``False``.
6969

7070
You can also specify a default mask that will be applied if no header mask is found.
7171

doc/swagger.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ The ``@api.expect()`` decorator
125125
The ``@api.expect()`` decorator allows you to specify the expected input fields.
126126
It accepts an optional boolean parameter ``validate`` indicating whether the payload should be validated.
127127
The validation behavior can be customized globally either
128-
by setting the ``RESTPLUS_VALIDATE`` configuration to ``True``
128+
by setting the ``RESTX_VALIDATE`` configuration to ``True``
129129
or passing ``validate=True`` to the API constructor.
130130

131131
The following examples are equivalent:
@@ -215,7 +215,7 @@ An example of application-wide validation by config:
215215

216216
.. code-block:: python
217217
218-
app.config['RESTPLUS_VALIDATE'] = True
218+
app.config['RESTX_VALIDATE'] = True
219219
220220
api = Api(app)
221221

flask_restx/api.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,9 @@ def _init_app(self, app):
215215
self._configure_namespace_logger(app, ns)
216216

217217
self._register_apidoc(app)
218-
self._validate = self._validate if self._validate is not None else app.config.get('RESTPLUS_VALIDATE', False)
219-
app.config.setdefault('RESTPLUS_MASK_HEADER', 'X-Fields')
220-
app.config.setdefault('RESTPLUS_MASK_SWAGGER', True)
218+
self._validate = self._validate if self._validate is not None else app.config.get('RESTX_VALIDATE', False)
219+
app.config.setdefault('RESTX_MASK_HEADER', 'X-Fields')
220+
app.config.setdefault('RESTX_MASK_SWAGGER', True)
221221

222222
def __getattr__(self, name):
223223
try:

flask_restx/marshalling.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ def wrapper(*args, **kwargs):
247247
resp = f(*args, **kwargs)
248248
mask = self.mask
249249
if has_app_context():
250-
mask_header = current_app.config['RESTPLUS_MASK_HEADER']
250+
mask_header = current_app.config['RESTX_MASK_HEADER']
251251
mask = request.headers.get(mask_header) or mask
252252
if isinstance(resp, tuple):
253253
data, code, headers = unpack(resp)

flask_restx/representations.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
def output_json(data, code, headers=None):
1313
'''Makes a Flask response with a JSON encoded body'''
1414

15-
settings = current_app.config.get('RESTPLUS_JSON', {})
15+
settings = current_app.config.get('RESTX_JSON', {})
1616

1717
# If we're in debug mode, and the indent is not set, we set it to a
1818
# reasonable value here. Note that this won't override any existing value

flask_restx/resource.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
class Resource(MethodView):
1414
'''
15-
Represents an abstract RESTPlus resource.
15+
Represents an abstract RESTX resource.
1616
1717
Concrete resources should extend from this class
1818
and expose methods for each supported HTTP method.

flask_restx/swagger.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -468,9 +468,9 @@ def parameters_for(self, doc):
468468

469469
# Handle fields mask
470470
mask = doc.get('__mask__')
471-
if (mask and current_app.config['RESTPLUS_MASK_SWAGGER']):
471+
if (mask and current_app.config['RESTX_MASK_SWAGGER']):
472472
param = {
473-
'name': current_app.config['RESTPLUS_MASK_HEADER'],
473+
'name': current_app.config['RESTX_MASK_HEADER'],
474474
'in': 'header',
475475
'type': 'string',
476476
'format': 'mask',

tests/conftest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def post_json(self, url, data, status=200, **kwargs):
3737
return json.loads(response.data.decode('utf8'))
3838

3939
def get_specs(self, prefix='', status=200, **kwargs):
40-
'''Get a Swagger specification for a RestPlus API'''
40+
'''Get a Swagger specification for a RESTX API'''
4141
return self.get_json('{0}/swagger.json'.format(prefix), status=status, **kwargs)
4242

4343

tests/legacy/test_api_legacy.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,11 @@ def test_exception_header_forwarding_doesnt_duplicate_headers(self, api):
318318

319319
def test_read_json_settings_from_config(self, app, client):
320320
class TestConfig(object):
321-
RESTPLUS_JSON = {'indent': 2,
322-
'sort_keys': True,
323-
'separators': (', ', ': ')}
321+
RESTX_JSON = {
322+
'indent': 2,
323+
'sort_keys': True,
324+
'separators': (', ', ': ')
325+
}
324326

325327
app.config.from_object(TestConfig)
326328
api = restx.Api(app)
@@ -343,7 +345,7 @@ def default(self, obj):
343345
return 'cabbage'
344346

345347
class TestConfig(object):
346-
RESTPLUS_JSON = {'cls': CabageEncoder}
348+
RESTX_JSON = {'cls': CabageEncoder}
347349

348350
app.config.from_object(TestConfig)
349351
api = restx.Api(app)

tests/test_fields_mask.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ def get(self):
757757
'boolean': True
758758
}
759759

760-
app.config['RESTPLUS_MASK_HEADER'] = 'X-Mask'
760+
app.config['RESTX_MASK_HEADER'] = 'X-Mask'
761761
data = client.get_json('/test/', headers={'X-Mask': '{name,age}'})
762762

763763
assert data == {'name': 'John Doe', 'age': 42}
@@ -963,7 +963,7 @@ def get(self):
963963
'boolean': True
964964
}
965965

966-
app.config['RESTPLUS_MASK_HEADER'] = 'X-Mask'
966+
app.config['RESTX_MASK_HEADER'] = 'X-Mask'
967967
specs = client.get_specs()
968968

969969
op = specs['paths']['/test/']['get']
@@ -992,7 +992,7 @@ def get(self):
992992
'boolean': True
993993
}
994994

995-
app.config['RESTPLUS_MASK_SWAGGER'] = False
995+
app.config['RESTX_MASK_SWAGGER'] = False
996996
specs = client.get_specs()
997997

998998
op = specs['paths']['/test/']['get']

tests/test_payload.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def test_format_checker_object_on_constructor(self, app, client):
110110
assert 'ipv4' in out['errors']['ip']
111111

112112
def test_validation_false_in_config(self, app, client):
113-
app.config['RESTPLUS_VALIDATE'] = False
113+
app.config['RESTX_VALIDATE'] = False
114114
api = restx.Api(app)
115115

116116
fields = api.model('Person', {
@@ -132,7 +132,7 @@ def post(self):
132132
assert out == {}
133133

134134
def test_validation_in_config(self, app, client):
135-
app.config['RESTPLUS_VALIDATE'] = True
135+
app.config['RESTX_VALIDATE'] = True
136136
api = restx.Api(app)
137137

138138
fields = api.model('Person', {

0 commit comments

Comments
 (0)