Defect #7661


xml attributes names should be consistent throughout ALL REST API

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

Target version:
Start date:
Due date:
% Done:


Estimated time:
Affected version:


"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 name="assignee" type="org.redmine.ta.beans.User">
            <bind-xml name="assigned_to" />
        <field name="author" type="org.redmine.ta.beans.User">
            <bind-xml name="author" />

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

and now file to parse Users:

    <description>Redmine XML -> Java API binding. see</description>

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

        <field name="id" type="integer">
            <bind-xml name="id" node="element" />
        <field name="login" type="string">
            <bind-xml name="login" node="element" />
        <!--  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 name="firstName" type="string">
            <bind-xml name="firstname" node="element" />
        <field name="lastName" type="string">
            <bind-xml name="lastname" node="element" />
        <field name="mail" type="string">
            <bind-xml name="mail" node="element" />
        <field name="createdOn" type="string" 
            <bind-xml name="created_on" node="element" />
        <field name="lastLoginOn" type="string" 
            <bind-xml name="last_login_on" node="element" />

Actions #1

Updated by Jean-Philippe Lang over 13 years ago

I think that user's name (aka fullName) can be usefull when displaying a list of issue.
Can't we just add this read-only property to the users API?

Actions #2

Updated by Alex Last over 13 years ago

full name is definitely useful, but my suggestion is to use the same attribute names in all REST API responses.
e.g. instead of "fullname" or ambiguous "name" we could have "first_name", "last_name", "login" in both "issues.xml" and "users.xml" responses. I think the GUI layer should be able to glue "first_name" and "last_name" together itself.

Side note: I don't see a need in separate first and last name fields at all, btw. when I create a user in Redmine or any other system, I'd be fine with providing just "name" and I don't care which part of it is the 1st name and which one - the family one. but that's just my preference :).


Also available in: Atom PDF