Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object and Endpoint names need to Java Compliant so that the SKD can be automatically generated #29

Open
dmccarthy-dev opened this issue Jul 28, 2014 · 2 comments

Comments

@dmccarthy-dev
Copy link

Hi,

The Swagger JSON generated on the api framework isn't Java compliant and it needs to be if we are going to generate an Android compliant jar. As the plugin automatically generates the JSON based on your function and object names it will require significant changes to your code. At the moment the issues that stick out are:

  • some of your endpoints have a '-' in their name. In the SDK they equate to method names; java doesn't allow '-' in method names.
  • there are issues with model objects and their cases, the swagger code generator created the files with lower case e.g. account.java and name the class inside that file with a capital at the start e.g. public class Account. The result is that files won't compile! You may need to capitalise your object models, even if this goes against the python ethos. In the generate-graph-api-sdk.sh file I added a line to capitalise the files (ls | awk '{system("mv " $0 " " toupper(substr($0,1,1)) substr($0,2))}') but there are still problems with capital letters in the VApi.java file.
  • Some of the JSON is missing a type. When this is the case the auto-generated Java has method signatures that are missing the Object definition. e.g. public Status createAccount(details) where it should be public Status createAccount( AccountDetails details).
  • It would also be great if ye used the extra_actions feature of the django-tastypie-swagger plugin to add a description to improve the API documentation (http://django-tastypie-swagger.readthedocs.org/en/latest/#using-extra-actions).

To generate the SDK pull the latest version of the vagrant environment, run the provision script, start openi, cd to the openi_android_sdk module and run the build-graph-api-sdk.sh file.

  1. git clone https://github.com/OPENi-ict/openi-dev-env
  2. cd openi-dev-env
  3. vagrant up
  4. vagrant halt
  5. vagrant up
  6. vagrant ssh
    ---- From within the machine ----
  7. sh provision_openi.sh
  8. sh tmux_openi.sh
  9. to exit tmux hit ctrl+b together follow by d
  10. cd /home/vagrant/repos/openi_android_sdk/
  11. sh build-graph-api-sdk.sh dev.openi-ict.eu

We had the same problems with the cloudlet framework but with the help of Velti we managed to update the JSON to eliminate the problems. If I cannot be contacted for assistance you may try Timos.

@mpetyx
Copy link
Contributor

mpetyx commented Jul 28, 2014

Hello Donal,
I noticed the problem and I think this is clearly a version issue.
I will try to automatically update the swagger version from 1.1 to 1.2, otherwise we will have to do this by hand.
Either way, this is my major priority at the moment!
Do you write directly the swagger json description of the cloudlet or this is exported with some tool (like we used until now the tastypie-swagger)?

@dmccarthy-dev
Copy link
Author

We write it by hand.

I did some digging around the django-tastypie-swagger plugin and I don't think that a 1.2 compliant version is available. You'll have to fix the issues with the 1.1 version.

Its down to the names that you give your objects in python, they are translated into swagger JSON by the plugin. What ever you name your objects dictates the JSON which dictates the Java Object and method signatures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants