From 1caba68fd184ebdb2a19fb1a23dc4669a6f66ba9 Mon Sep 17 00:00:00 2001 From: Ken'ichi Ohmichi Date: Wed, 2 Sep 2015 07:14:42 +0000 Subject: [PATCH] Add JSON-Schema note to api_plugins.rst Nova v2.1 API validates a request with JSON-Schema, and there are some specific usage on that. This patch adds it to the rst file for the implementation hint. Change-Id: I4edac8b6b53d198f2a237bb163b8975528319c9b --- doc/source/api_plugins.rst | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/doc/source/api_plugins.rst b/doc/source/api_plugins.rst index a5407a53b533..c7ac22f8b23f 100644 --- a/doc/source/api_plugins.rst +++ b/doc/source/api_plugins.rst @@ -123,6 +123,39 @@ code still needs modularity. Here are rules for how to separate modules: in existing extended models. New extended attributes needn't any namespace prefix anymore. +JSON-Schema +~~~~~~~~~~~ + +The v2.1 API validates a REST request body with JSON-Schema library. +Valid body formats are defined with JSON-Schema in the directory +'nova/api/openstack/compute/schemas'. Each definition is used at the +corresponding method with the ``validation.schema`` decorator like:: + + @validation.schema(schema.update_something) + def update(self, req, id, body): + .... + +Nova supports the extension of JSON-Schema definitions based on the +loaded API extensions for some APIs. Stevedore library tries to find +specific name methods which return additional parameters and extends +them to the original JSON-Schema definitions. +The following are the combinations of extensible API and method name +which returns additional parameters: + +* Create a server API - get_server_create_schema() +* Update a server API - get_server_update_schema() +* Rebuild a server API - get_server_rebuild_schema() +* Resize a server API - get_server_resize_schema() + +For example, keypairs extension(Keypairs class) contains the method +get_server_create_schema() which returns:: + + { + 'key_name': parameter_types.name, + } + +then the parameter key_name is allowed on Create a server API. + Support files -------------