diff --git a/nova/api/openstack/compute/schemas/versions.py b/nova/api/openstack/compute/schemas/versions.py index 33327c8fb3..7e97eae1ef 100644 --- a/nova/api/openstack/compute/schemas/versions.py +++ b/nova/api/openstack/compute/schemas/versions.py @@ -23,3 +23,110 @@ multi_query = { 'properties': {}, 'additionalProperties': True, } + +_version_obj = { + 'type': 'object', + 'properties': { + 'id': {'type': 'string'}, + 'status': { + 'type': 'string', + 'enum': ['CURRENT', 'SUPPORTED', 'DEPRECATED'], + }, + 'links': { + 'type': 'array', + 'items': { + 'type': 'object', + 'properties': { + 'href': {'type': 'string'}, + 'rel': {'type': 'string'}, + 'type': {'type': 'string'}, + }, + 'required': ['rel', 'href'], + 'additionalProperties': False, + }, + }, + 'min_version': {'type': 'string'}, + 'updated': {'type': 'string', 'format': 'date-time'}, + 'version': {'type': 'string'}, + }, + 'required': ['id', 'status', 'links', 'min_version', 'updated'], + 'additionalProperties': False, +} + +index_response = { + 'type': 'object', + 'properties': { + 'versions': {'type': 'array', 'items': _version_obj} + }, + 'required': ['versions'], + 'additionalProperties': False, +} + +_version_obj_with_media_types = _version_obj +_version_obj_with_media_types['properties'].update({ + 'media-types': { + 'type': 'array', + 'items': { + 'type': 'object', + 'properties': { + 'base': {'type': 'string'}, + 'type': {'type': 'string'}, + }, + 'required': ['base', 'type'], + 'additionalProperties': False, + }, + } +}) + +show_response = { + 'type': 'object', + 'properties': { + 'version': _version_obj_with_media_types + }, + 'required': ['version'], + 'additionalProperties': False, +} + +_legacy_version_obj = { + 'type': 'object', + 'properties': { + 'id': {'type': 'string'}, + 'status': {'type': 'string'}, + 'links': { + 'type': 'array', + 'items': { + 'type': 'object', + 'properties': { + 'href': {'type': 'string'}, + 'rel': {'type': 'string'}, + 'type': {'type': 'string'}, + }, + 'required': ['rel', 'href'], + 'additionalProperties': False, + }, + }, + 'media-types': { + 'type': 'array', + 'items': { + 'type': 'object', + 'properties': { + 'base': {'type': 'string'}, + 'type': {'type': 'string'}, + }, + 'required': ['base', 'type'], + 'additionalProperties': False, + }, + }, + }, + 'required': ['id', 'status', 'links', 'media-types'], + 'additionalProperties': False, +} + +multi_response = { + 'type': 'object', + 'properties': { + 'choices': {'type': 'array', 'items': _legacy_version_obj} + }, + 'required': ['choices'], + 'additionalProperties': False, +} diff --git a/nova/api/openstack/compute/versions.py b/nova/api/openstack/compute/versions.py index dbda92c661..2919904f55 100644 --- a/nova/api/openstack/compute/versions.py +++ b/nova/api/openstack/compute/versions.py @@ -83,6 +83,7 @@ class Versions(wsgi.Resource): super(Versions, self).__init__(None) @validation.query_schema(schema.show_query) + @validation.response_body_schema(schema.index_response) def index(self, req, body=None): """Return all versions.""" builder = views_versions.get_view_builder(req) @@ -90,6 +91,7 @@ class Versions(wsgi.Resource): @wsgi.response(300) @validation.query_schema(schema.multi_query) + @validation.response_body_schema(schema.multi_response) def multi(self, req, body=None): """Return multiple choices.""" builder = views_versions.get_view_builder(req) @@ -111,7 +113,10 @@ class VersionsV2(wsgi.Resource): def __init__(self): super(VersionsV2, self).__init__(None) + # NOTE(stephenfin): Despite being called index, this is actually called as + # a show action @validation.query_schema(schema.show_query) + @validation.response_body_schema(schema.show_response) def index(self, req, body=None): builder = views_versions.get_view_builder(req) ver = 'v2.0' if req.is_legacy_v2() else 'v2.1' diff --git a/nova/api/openstack/compute/versionsV21.py b/nova/api/openstack/compute/versionsV21.py index 0889f03b3c..906a1b49c9 100644 --- a/nova/api/openstack/compute/versionsV21.py +++ b/nova/api/openstack/compute/versionsV21.py @@ -26,6 +26,7 @@ class VersionsController(wsgi.Controller): @wsgi.expected_errors(404) @validation.query_schema(schema.show_query) + @validation.response_body_schema(schema.show_response) def show(self, req, id='v2.1'): builder = views_versions.get_view_builder(req) if req.is_legacy_v2():