diff --git a/nova/api/openstack/compute/schemas/flavors.py b/nova/api/openstack/compute/schemas/flavors.py index f0cecb3dc493..6f4d609e6554 100644 --- a/nova/api/openstack/compute/schemas/flavors.py +++ b/nova/api/openstack/compute/schemas/flavors.py @@ -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 diff --git a/nova/api/openstack/compute/schemas/server_groups.py b/nova/api/openstack/compute/schemas/server_groups.py index 102c6df869ec..fee2cbd30b98 100644 --- a/nova/api/openstack/compute/schemas/server_groups.py +++ b/nova/api/openstack/compute/schemas/server_groups.py @@ -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'] diff --git a/nova/api/validation/validators.py b/nova/api/validation/validators.py index b0e9478d35e2..e09bdb427bf6 100644 --- a/nova/api/validation/validators.py +++ b/nova/api/validation/validators.py @@ -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): diff --git a/nova/tests/unit/test_api_validation.py b/nova/tests/unit/test_api_validation.py index 4937722446e8..ea515702ac64 100644 --- a/nova/tests/unit/test_api_validation.py +++ b/nova/tests/unit/test_api_validation.py @@ -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."