Feature #8900

Restful Web service: generate WADL

Added by Nicolay Punin about 3 years ago. Updated over 2 years ago.

Status:NewStart date:2011-07-26
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:REST API
Target version:-
Resolution:

Description

Redmine does not generate WADL for his Web Service
(http://en.wikipedia.org/wiki/Web_Application_Description_Language)

It helps to generate Java Rest clients automaticaly.

specification: http://java.net/projects/wadl/sources/svn/content/trunk/www/wadl20090202.pdf

Some QA: http://bitworking.org/news/193/Do-we-need-WADL

History

#1 Updated by Jean-Baptiste Barth about 3 years ago

Nicolay Punin wrote:

It helps to generate Java Rest clients automaticaly.

And it will probably be a bunch of work to maintain it ... manually, no ? Have you tried to generated such an XML description of the Redmine current API, and can you give us some points to convince us to introduce it ?

Maintaining it in a plugin could be a viable option too...

#2 Updated by Nicolay Punin about 3 years ago

1. No manaualy. Wadl generator library helps you. For example, http://rubydoc.info/gems/wadl_generator/0.1.2/WADL/Generator
2. It will increase the attractiveness for java developers.
3. I do not want to use this(http://code.google.com/p/redmine-java-api) library.

  • It supports only 1.2.0. Not 1.3
  • It is a bike :(

4. I am work with redmine Rest API by means of Spring rest template (http://blog.springsource.com/2009/03/27/rest-in-spring-3-resttemplate/).
At least 90% of my code can be automatically Generate by WADL parser. It is very convenient
5. This will be useful for the community.
6. This may be used in java IDE (Eclipse/RubyMine/Idea/Netbeans,etc.)

Maintaining it in a plugin could be a viable option too...

I writed already the plugin for me. It can show or modify project roles and status.
Maybe I'll write a WADL redmine plugin. If I will have a time :)

Something information:

#3 Updated by Terence Mill about 3 years ago

+1

#4 Updated by Siegfried Vogel almost 3 years ago

+1

Would be very helpful to detect and test Redmine RESTful API.

#5 Updated by laurent sauvage almost 3 years ago

+1

#6 Updated by Alex Last over 2 years ago

Redmine Java API supports Redmine 1.3.0

#7 Updated by Alex Last over 2 years ago

Would be just great to generate the client code using some definition file. Until then, you're welcome to use (and improve!) the custom-made Redmine Java API.

#8 Updated by Nicolay Punin over 2 years ago

Redmine Java API is not suitable for my case, because in my redmine installation I have plugins enhancing default REST functionality.
I wrote my own Java client using Sping Rest Template( link: http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/web/client/RestTemplate.html) and JAXB to write less code.

Here is the idea:
Describing entity, for example - a project

9 @XmlRootElement
10 @XmlType( propOrder={ "name", "identifier", "description", "homepage", "status", "public", "roles", "customFields" , "createdOn", "updatedOn"} )
11 public class Project {
12
13 final public static int STATUS_ACTIVE = 1;
14 final public static int STATUS_ARCHIVE = 9;
15
16 private String name;
17 private String homepage;
18 private String identifier;
19 private String description;
20 private boolean is_public;
21 private int status;
22 private List<Role> roles;
23 private List<CustomField> customFields;
24 private String createdOn;
25 private String updatedOn;
26 /// etc....

In the same way describing entities Role and CustomField.
Projects list is described simply:
9 @XmlRootElement
10 @XmlSeeAlso({Project.class})
11 public class Projects extends ArrayList<Project> {
12
13 @XmlElement(name = "project")
14 public List<Project> getProjects() {
15 return this;
16 }
17 }

Instead of standard Redmine API, in my case it is possible to manage project roles and project status (archive/active)

All other job is done by Spring Rest Template, for example this is how we can get projects list:
Map<String, String> vars = new HashMap<String, String>();
69 vars.put("offset", "0");
70 vars.put("limit", "10");
71 Projects projects = restTemplate.getForObject("http://some.redminehost.net/projects.xml?offset={offset}&limit={limit}", Projects.class, vars);
72 return projects.getProjects();

Updating project:
String identifier = project.getIdentifier();
restTemplate.put("http://some.redminehost.net/projects/{identifier}.xml", project, identifier);

And so on for every redmine entity. Of course, this code is placed in separate class and covered with junit tests.

It would be great to generate this boilerplate code automatically.

Also available in: Atom PDF