[openstack-dev] [Nova] RFC: Generate API sample files from API schemas

Vishvananda Ishaya vishvananda at gmail.com
Thu Feb 6 18:16:35 UTC 2014


On Feb 6, 2014, at 5:38 AM, Kenichi Oomichi <oomichi at mxs.nes.nec.co.jp> wrote:

> 
> Hi,
> 
> I'd like to propose one idea that autogenerates API sample files from API
> schema for Nova v3 API.
> 
> We are working on API validation for v3 API, the works require API schema
> which is defined with JSONSchema for each API. On the other hand, API sample
> files of v3 API are autogenerated from the template files of v3 API under
> nova/tests/integrated/v3/api_samples, as api_samples's README.rst[1].
> The API schema files are similar to the template files, because both represent
> the API parameter structures and each API name.
> 
> For example, the template file of keypairs is
> --------------------------------------------------------------------------
>  {
>      "keypair": {
>          "name": "%(keypair_name)s"
>      }
>  }
> --------------------------------------------------------------------------
> 
> and the API schema file is
> --------------------------------------------------------------------------
>  create = {
>      'type': 'object',
>      'properties': {
>          'keypair': {
>              'type': 'object',
>              'properties': {
>                  'name': {
>                      'type': 'string', 'minLength': 1, 'maxLength': 255,
>                      'pattern': '^[a-zA-Z0-9 _-]+$'
>                  },
>                  'public_key': {'type': 'string'},
>              },
>              'required': ['name'],
>              'additionalProperties': False,
>          },
>      },
>      'required': ['keypair'],
>      'additionalProperties': False,
>  }
> --------------------------------------------------------------------------
> 
> When implementing new v3 API, we need to write/review both files and that
> would be hard works. For reducing the workload, I'd like to propose one
> idea[2] that autogenerates API sample files from API schema instead of
> template files. We would not need to write a template file of a request.

+1

The template files were there because we didn’t have a clear schema defined.

It would be awesome to get rid of the templates.

Vish

> 
> The XML support is dropped from Nova v3 API, and the decision could make
> this implementation easier. The NOTE is that we still need response template
> files even if implementing this idea, because API schema files of response
> don't exist.
> 
> Any comments are welcome.
> 
> 
> Thanks
> Ken'ichi Ohmichi
> 
> ---
> [1]: https://github.com/openstack/nova/blob/master/nova/tests/integrated/api_samples/README.rst
> [2]: https://review.openstack.org/#/c/71465/
> 
> 
> _______________________________________________
> OpenStack-dev mailing list
> OpenStack-dev at lists.openstack.org
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 455 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20140206/0e1f65f4/attachment.pgp>


More information about the OpenStack-dev mailing list