Correct the wrong usage of 'format' jsonschema keyword in servers API

'format' keyword works for any types. That means for 'port' field,
'null' value never passed the format checks. We should use 'oneOf'
keyword instead of it.

Change-Id: Ic51e9e1c6efadce0a0b4d20a114ca75799fb36a5
Partial-Bug: #1552888
This commit is contained in:
He Jie Xu 2016-03-04 14:52:51 +08:00
parent 4b47b5b6c6
commit a9691bfb92
2 changed files with 7 additions and 2 deletions

View File

@ -35,8 +35,8 @@ base_create = {
'properties': {
'fixed_ip': parameter_types.ip_address,
'port': {
'type': ['string', 'null'],
'format': 'uuid'
'oneOf': [{'type': 'string', 'format': 'uuid'},
{'type': 'null'}]
},
'uuid': {'type': 'string'},
},

View File

@ -2434,6 +2434,11 @@ class ServersControllerCreateTest(test.TestCase):
self._check_admin_password_len(server)
self.assertEqual(FAKE_UUID, server['id'])
def test_create_instance_with_none_value_port(self):
self.body['server'] = {'networks': [{'port': None, 'uuid': FAKE_UUID}]}
self.body['server']['name'] = 'test'
self._test_create_instance()
def test_create_instance_private_flavor(self):
values = {
'name': 'fake_name',