Comment 11 for bug 1585917

Revision history for this message
Bhagyashri Shewale (bhagyashri-shewale) wrote :

Hi Brian,

Current implementation of schema validation in glance is not compatible to use "oneOf". This will require substantial changes to incorporate "oneOf" implementation which might lead to regression. I have pointed out two issues to use schema suggested by you.

1. Request validation:
As per current implementation we define only properties of schema in the controller and schema is generated at runtime in raw() [2] call. To use "oneOf" we only need "oneOf" and "definitions" while creating schema [3] and properties will be empty {} in this case. So we need to modify Schema class to accept "oneOf" as well as need to make changes in raw method [4] to add "oneOf" to schema if it is present. This way we will able to validate the input request.

[1] https://github.com/openstack/glance/blob/master/glance/api/v2/image_members.py#L335
[2] https://github.com/openstack/glance/blob/master/glance/schema.py#L86
[3] https://github.com/openstack/glance/blob/master/glance/schema.py#L26
[4] https://github.com/openstack/glance/blob/master/glance/schema.py#L85

2. Response will be blank:
If we made changes as suggested in above #1 then empty response will be returned to user because while sending response back it is formatted and filtered with properties [5]. As mentioned in "oneOf" case properties will be empty {}, it will not add any output to the filter response and empty {} will be returned. To avoid this we need to make changes in filter method [6] such that not to use properties for filtering if "oneOf" is used.

[5] https://github.com/openstack/glance/blob/master/glance/api/v2/image_members.py#L301
[6] https://github.com/openstack/glance/blob/master/glance/schema.py#L46