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

2014-02-06 Thread Kenichi Oomichi

Hi Chris,

> -Original Message-
> From: Christopher Yeoh [mailto:cbky...@gmail.com]
> Sent: Friday, February 07, 2014 8:53 AM
> To: openstack-dev@lists.openstack.org
> Subject: Re: [openstack-dev] [Nova] RFC: Generate API sample files from API 
> schemas
> 
> On Thu, 6 Feb 2014 13:38:22 +
> Kenichi Oomichi  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 to automating this. The more the better :-)
> 
> There's probably some details to sort out such as wanting to generate
> multiple template files from the same schema file where parameters are
> optional. Because the generation of the api samples doubles as real
> integration testcases which often pick up issues which the normal
> unittests don't. But I'd love to see these autogenerated (they are a
> bit of pain to create manually).

oh, that is a difficult request, but it is interesting.
I will write it on TODO list in the next patchset.

> Longer term I'd like us to think about how we can use the schema
> files to automate more of the doc generation too (given full Pecan/WSME
> support is likely still a reasonable way off).

Yes, I agree with your idea completely.
It would be nice to autogenarate API specification doc[1].
We could check the API difference between current version and previous one
(Icehouse to Juno) if the above your idea completes. That would be great
for users and developers.

One more idea is that autogenerates API schema files for Tempest's negative
test generator. The negative test generator needs not only request body
definitions but also http-method and url. The API specification doc also
needs bot http-method and url, so it is good to write them on API schema of
API validation.

These ideas are the next steps anyway, I feel:-)


Thanks
Ken'ichi Ohmichi

---
[1]: http://api.openstack.org/api-ref.html

___
OpenStack-dev mailing list
OpenStack-dev@lists.openstack.org
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev


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

2014-02-06 Thread Christopher Yeoh
On Thu, 6 Feb 2014 13:38:22 +
Kenichi Oomichi  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 to automating this. The more the better :-) 

There's probably some details to sort out such as wanting to generate
multiple template files from the same schema file where parameters are
optional. Because the generation of the api samples doubles as real
integration testcases which often pick up issues which the normal
unittests don't. But I'd love to see these autogenerated (they are a
bit of pain to create manually).

Longer term I'd like us to think about how we can use the schema
files to automate more of the doc generation too (given full Pecan/WSME
support is likely still a reasonable way off).

Chris

___
OpenStack-dev mailing list
OpenStack-dev@lists.openstack.org
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev


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

2014-02-06 Thread Rochelle.RochelleGrober
+1

Really lots more than just +1

This leads to so many more efficiencies and increase in effectiveness.

--Rocky

-Original Message-
From: Vishvananda Ishaya [mailto:vishvana...@gmail.com] 
Sent: Thursday, February 06, 2014 10:17 AM
To: OpenStack Development Mailing List (not for usage questions)
Subject: Re: [openstack-dev] [Nova] RFC: Generate API sample files from API 
schemas


On Feb 6, 2014, at 5:38 AM, Kenichi Oomichi  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/ap
> i_samples/README.rst
> [2]: https://review.openstack.org/#/c/71465/
> 
> 
> ___
> OpenStack-dev mailing list
> OpenStack-dev@lists.openstack.org
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev


___
OpenStack-dev mailing list
OpenStack-dev@lists.openstack.org
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev


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

2014-02-06 Thread Vishvananda Ishaya

On Feb 6, 2014, at 5:38 AM, Kenichi Oomichi  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@lists.openstack.org
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev



signature.asc
Description: Message signed with OpenPGP using GPGMail
___
OpenStack-dev mailing list
OpenStack-dev@lists.openstack.org
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev


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

2014-02-06 Thread Kenichi Oomichi

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.

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@lists.openstack.org
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev