← Back to team overview

dhis2-devs team mailing list archive

Re: Inconsistency between schema and api ?

 

Hello,
Thanks for the clarification. So, I can rely on the fact that the schema
property "collectionName" will be consistent with the actual object field,
correct?

Just for my curiosity/understanding - while I'm all for API stability (and
not breaking stuff or let say break it carefully), I fail to see how
updating the schema to be consistent would actually break anything ?

Matin

On Sat, Jan 6, 2018 at 2:55 PM, Lars Helge Øverland <lars@xxxxxxxxx> wrote:

> Hi Martin,
>
> this is correct and a good observation.
>
> If you look in the source code you can see that we have specified a JSON
> field name directly on the get method:
>
> @JsonProperty( "organisationUnits" )
>
> https://github.com/dhis2/dhis2-core/blob/master/dhis-2/
> dhis-api/src/main/java/org/hisp/dhis/organisationunit/
> OrganisationUnitGroup.java
>
> This was done to improve on a bad naming choice ("members") in the past
> and to expose a more sensible name in the API. This is then reflected in
> the schemas API as you observed. We hope to change the Java property name
> in the future but it requires a bit of refactoring.
>
> You can get the name of collections as they are actually rendered in the
> API through the "collectionName" schema property in the mean time. You
> could say that we should have a dedicated consistent schema property for
> the "API field", we could perhaps work on that.
>
> best,
>
> Lars
>
>
>
>
>
>
>
>
>
> On 6 January 2018 at 14:26, Martin Van Aken <martin@xxxxxxxxxxxxxxxx>
> wrote:
>
>> Hello!
>>
>> I'm making a new DHIS2 App and so make use of the API through d2. I think
>> I found an inconsistency between the schema as exposed under api/schemas
>> and the real field returned.
>>
>> Having access to the schema is very handy to directly know for example
>> which field to show & how (as we have access to their property types).
>>
>> - When using organisationUnitGroups, for example
>> https://play.dhis2.org/demo/api/organisationUnitGroups/RXL3lPSK8oG.json
>> we get a field named "organisationUnits" with a list of ids of the linked
>> unit.
>> - But on the schema (https://play.dhis2.org/demo/a
>> pi/schemas/organisationUnitGroup) the link to organisationUnit is
>> actually referenced under the field name "members"
>>
>> There are similar situation for OU (organisationUnitGroups vs just
>> "groups") and probably other.
>>
>> Is it something I'm missing or is that a mistake? If this is a bug, let
>> me know if I can fill a PR (with some direction from the team).
>>
>> Thanks,
>>
>> Martin
>>
>>
>> --
>> *Martin Van Aken - **Freelance Enthusiast Developer*
>>
>> Mobile : +32 486 899 652
>>
>> Follow me on Twitter : @martinvanaken <http://twitter.com/martinvanaken>
>> Call me on Skype : vanakenm
>> Hang out with me : martin@xxxxxxxxxxxxxxxx
>> Contact me on LinkedIn : http://www.linkedin.com/in/martinvanaken
>> Company website : www.joyouscoding.com
>>
>> _______________________________________________
>> Mailing list: https://launchpad.net/~dhis2-devs
>> Post to     : dhis2-devs@xxxxxxxxxxxxxxxxxxx
>> Unsubscribe : https://launchpad.net/~dhis2-devs
>> More help   : https://help.launchpad.net/ListHelp
>>
>>
>
>
> --
> Lars Helge Øverland
> Lead developer, DHIS 2
> University of Oslo
> Skype: larshelgeoverland
> lars@xxxxxxxxx
> http://www.dhis2.org <https://www.dhis2.org/>
>
>


-- 
*Martin Van Aken - **Freelance Enthusiast Developer*

Mobile : +32 486 899 652

Follow me on Twitter : @martinvanaken <http://twitter.com/martinvanaken>
Call me on Skype : vanakenm
Hang out with me : martin@xxxxxxxxxxxxxxxx
Contact me on LinkedIn : http://www.linkedin.com/in/martinvanaken
Company website : www.joyouscoding.com

Follow ups

References