diff --git a/nova/api/openstack/placement/handlers/allocation.py b/nova/api/openstack/placement/handlers/allocation.py index 545957c29e29..2105ef28c8ea 100644 --- a/nova/api/openstack/placement/handlers/allocation.py +++ b/nova/api/openstack/placement/handlers/allocation.py @@ -32,6 +32,7 @@ ALLOCATION_SCHEMA = { "properties": { "allocations": { "type": "array", + "minItems": 1, "items": { "type": "object", "properties": { diff --git a/nova/tests/functional/api/openstack/placement/gabbits/allocations.yaml b/nova/tests/functional/api/openstack/placement/gabbits/allocations.yaml index 86b6e7072118..e91ebb80b059 100644 --- a/nova/tests/functional/api/openstack/placement/gabbits/allocations.yaml +++ b/nova/tests/functional/api/openstack/placement/gabbits/allocations.yaml @@ -48,6 +48,16 @@ tests: content-type: application/json status: 400 +- name: put an allocation empty list + PUT: /allocations/599ffd2d-526a-4b2e-8683-f13ad25f9958 + request_headers: + content-type: application/json + data: + allocations: [] + status: 400 + response_strings: + - "Failed validating 'minItems'" + - name: put an allocation violate schema PUT: /allocations/599ffd2d-526a-4b2e-8683-f13ad25f9958 request_headers: