forked from loafle/openapi-generator-original
[codegen][python-experimental] Add configuration knob to disable JSON schema validation (#6227)
* Add knob to disable JSON schema structural validation * Add knob to disable JSON schema structural validation * Fix formatting issues * execute sample scripts * execute sample scripts * fix multipleOf validation issue * Add validation log for multipleOf. Add customizable validation checks. add unit tests for JSON schema validation * Add validation log for multipleOf. Add customizable validation checks. add unit tests for JSON schema validation * Add validation log for multipleOf. Add customizable validation checks. add unit tests for JSON schema validation * Add validation log for multipleOf. Add customizable validation checks. add unit tests for JSON schema validation. Fix for python 2 * address review comments
This commit is contained in:
@@ -19,8 +19,15 @@ import urllib3
|
||||
|
||||
import six
|
||||
from six.moves import http_client as httplib
|
||||
from petstore_api.exceptions import ApiValueError
|
||||
|
||||
|
||||
JSON_SCHEMA_VALIDATION_KEYWORDS = {
|
||||
'multipleOf', 'maximum', 'exclusiveMaximum',
|
||||
'minimum', 'exclusiveMinimum', 'maxLength',
|
||||
'minLength', 'pattern', 'maxItems', 'minItems'
|
||||
}
|
||||
|
||||
class Configuration(object):
|
||||
"""NOTE: This class is auto generated by OpenAPI Generator
|
||||
|
||||
@@ -48,6 +55,19 @@ class Configuration(object):
|
||||
then all undeclared properties received by the server are injected into the
|
||||
additional properties map. In that case, there are undeclared properties, and
|
||||
nothing to discard.
|
||||
:param disabled_client_side_validations (string): Comma-separated list of
|
||||
JSON schema validation keywords to disable JSON schema structural validation
|
||||
rules. The following keywords may be specified: multipleOf, maximum,
|
||||
exclusiveMaximum, minimum, exclusiveMinimum, maxLength, minLength, pattern,
|
||||
maxItems, minItems.
|
||||
By default, the validation is performed for data generated locally by the client
|
||||
and data received from the server, independent of any validation performed by
|
||||
the server side. If the input data does not satisfy the JSON schema validation
|
||||
rules specified in the OpenAPI document, an exception is raised.
|
||||
If disabled_client_side_validations is set, structural validation is
|
||||
disabled. This can be useful to troubleshoot data validation problem, such as
|
||||
when the OpenAPI document validation rules do not match the actual API data
|
||||
received by the server.
|
||||
|
||||
:Example:
|
||||
|
||||
@@ -93,6 +113,7 @@ conf = petstore_api.Configuration(
|
||||
api_key=None, api_key_prefix=None,
|
||||
username=None, password=None,
|
||||
discard_unknown_keys=False,
|
||||
disabled_client_side_validations="",
|
||||
):
|
||||
"""Constructor
|
||||
"""
|
||||
@@ -123,6 +144,7 @@ conf = petstore_api.Configuration(
|
||||
"""Password for HTTP basic authentication
|
||||
"""
|
||||
self.discard_unknown_keys = discard_unknown_keys
|
||||
self.disabled_client_side_validations = disabled_client_side_validations
|
||||
self.access_token = None
|
||||
"""access token for OAuth/Bearer
|
||||
"""
|
||||
@@ -201,6 +223,13 @@ conf = petstore_api.Configuration(
|
||||
|
||||
def __setattr__(self, name, value):
|
||||
object.__setattr__(self, name, value)
|
||||
if name == 'disabled_client_side_validations':
|
||||
s = set(filter(None, value.split(',')))
|
||||
for v in s:
|
||||
if v not in JSON_SCHEMA_VALIDATION_KEYWORDS:
|
||||
raise ApiValueError(
|
||||
"Invalid keyword: '{0}''".format(v))
|
||||
self._disabled_client_side_validations = s
|
||||
|
||||
@classmethod
|
||||
def set_default(cls, default):
|
||||
|
||||
Reference in New Issue
Block a user