Merge "api: Migrate to JSON Schema Draft 2020-12"
This commit is contained in:
commit
49c4638fd5
@ -50,7 +50,7 @@ create = {
|
||||
'rxtx_factor': {
|
||||
'type': ['number', 'string'],
|
||||
'pattern': r'^[0-9]+(\.[0-9]+)?$',
|
||||
'minimum': 0, 'exclusiveMinimum': True,
|
||||
'minimum': 1,
|
||||
# maximum's value is limited to db constant's
|
||||
# SQL_SP_FLOAT_MAX (in nova/db/constants.py)
|
||||
'maximum': 3.40282e+38
|
||||
|
@ -31,7 +31,7 @@ create = {
|
||||
# enumerated values. It's changed to a single string value
|
||||
# in 2.64.
|
||||
'type': 'array',
|
||||
'items': [
|
||||
'prefixItems': [
|
||||
{
|
||||
'type': 'string',
|
||||
'enum': ['anti-affinity', 'affinity'],
|
||||
@ -53,7 +53,9 @@ create = {
|
||||
|
||||
create_v215 = copy.deepcopy(create)
|
||||
policies = create_v215['properties']['server_group']['properties']['policies']
|
||||
policies['items'][0]['enum'].extend(['soft-anti-affinity', 'soft-affinity'])
|
||||
policies['prefixItems'][0]['enum'].extend(
|
||||
['soft-anti-affinity', 'soft-affinity']
|
||||
)
|
||||
|
||||
create_v264 = copy.deepcopy(create_v215)
|
||||
del create_v264['properties']['server_group']['properties']['policies']
|
||||
|
@ -271,7 +271,7 @@ class FormatChecker(jsonschema.FormatChecker):
|
||||
class _SchemaValidator(object):
|
||||
"""A validator class
|
||||
|
||||
This class is changed from Draft4Validator to validate minimum/maximum
|
||||
This class is changed from Draft202012Validator to validate minimum/maximum
|
||||
value of a string number(e.g. '10'). This changes can be removed when
|
||||
we tighten up the API definition and the XML conversion.
|
||||
Also FormatCheckers are added for checking data formats which would be
|
||||
@ -279,7 +279,7 @@ class _SchemaValidator(object):
|
||||
|
||||
"""
|
||||
validator = None
|
||||
validator_org = jsonschema.Draft4Validator
|
||||
validator_org = jsonschema.Draft202012Validator
|
||||
|
||||
def __init__(self, schema, relax_additional_properties=False,
|
||||
is_body=True):
|
||||
|
@ -548,9 +548,9 @@ class IntegerTestCase(APIValidationTestCase):
|
||||
self.check_validation_error(self.post, body={'foo': '0xffff'},
|
||||
expected_detail=detail)
|
||||
|
||||
detail = ("Invalid input for field/attribute foo. Value: 1.0."
|
||||
" 1.0 is not of type 'integer', 'string'")
|
||||
self.check_validation_error(self.post, body={'foo': 1.0},
|
||||
detail = ("Invalid input for field/attribute foo. Value: 1.01."
|
||||
" 1.01 is not of type 'integer', 'string'")
|
||||
self.check_validation_error(self.post, body={'foo': 1.01},
|
||||
expected_detail=detail)
|
||||
|
||||
detail = ("Invalid input for field/attribute foo. Value: 1.0."
|
||||
|
Loading…
Reference in New Issue
Block a user