Project

General

Profile

Actions

Defect #7661

open

xml attributes names should be consistent throughout ALL REST API

Added by Alex Last about 13 years ago. Updated about 13 years ago.

Status:
New
Priority:
Normal
Category:
REST API
Target version:
-
Start date:
2011-02-19
Due date:
% Done:

0%

Estimated time:
Resolution:
Affected version:

Description

"User" returned by Redmine's REST API in response to getUser() command, has separate login, firstname, lastname attributes in the XML.
at the same time, XML returned on getIssues() request has "assignee" and "author" elements with "name" attribute in them, which includes "firstname_space_lastname". This inconsistency in the xml element names makes it harder to use automated parsing (say, with Simple XML or Google GSon libraries), where I could just add "attribute name" tags in Java beans themselves and let those libraries do the transformation for me. instead of that, I have to maintain several XML mapping files (Java beans <==> XML) for different REST XML responses.

proposal: use the same XML attribute names throughout all REST API.

Some lines from my current Castor XML mapping file for Redmine issues:

    <class name="org.redmine.ta.beans.Issue">
        <map-to xml="issue"/>

        <field name="id" type="integer">
            <bind-xml name="id" node="element" />
        </field>
        <field name="assignee" type="org.redmine.ta.beans.User">
            <bind-xml name="assigned_to" />
        </field>
        <field name="author" type="org.redmine.ta.beans.User">
            <bind-xml name="author" />
        </field>

    <class name="org.redmine.ta.beans.User">
        <field name="id" type="integer">
            <bind-xml name="id" node="attribute" />
        </field>
        <field name="fullName" type="string">
            <bind-xml name="name" node="attribute" />
        </field>
    </class>

and now file to parse Users:

<mapping>
    <description>Redmine XML -> Java API binding. see
        https://code.google.com/p/redmine-java-api</description>

    <class name="org.redmine.ta.beans.User">
        <map-to xml="user" />

        <field name="id" type="integer">
            <bind-xml name="id" node="element" />
        </field>
        <field name="login" type="string">
            <bind-xml name="login" node="element" />
        </field>
        <!--  note: "pasword" field is only used when creating a user using the API -->
        <field name="password" type="string">
            <bind-xml name="password" node="element" />
        </field>
        <field name="firstName" type="string">
            <bind-xml name="firstname" node="element" />
        </field>
        <field name="lastName" type="string">
            <bind-xml name="lastname" node="element" />
        </field>
        <field name="mail" type="string">
            <bind-xml name="mail" node="element" />
        </field>
        <field name="createdOn" type="string" 
            handler="org.redmine.ta.internal.RedmineLongDateHandler">
            <bind-xml name="created_on" node="element" />
        </field>
        <field name="lastLoginOn" type="string" 
            handler="org.redmine.ta.internal.RedmineLongDateHandler">
            <bind-xml name="last_login_on" node="element" />
        </field>
    </class>
</mapping>

Actions

Also available in: Atom PDF