dbopendata / db-fahrplan-api

DB Fahrplan API
31 stars 1 forks source link

Output lists of elements ALWAYS as array, regardless whether it is one element or many #7

Open highsource opened 8 years ago

highsource commented 8 years ago

The probably comes from XML ->JSON conersion:

"Notes":{
    "Note":{
      "key":"BR",
      "priority":"450",
      "routeIdxFrom":"0",
      "routeIdxTo":"9",
      "$":"Bordrestaurant"
      }
    }

If there's just one Note, it is output as a single item, in case there are many, as an array. This makes this structure undeterministic and harder to work with.

Please output element lists always as lists, regardless of whether they have one element or many:

"Notes":{
    "Note":[{
      "key":"BR",
      "priority":"450",
      "routeIdxFrom":"0",
      "routeIdxTo":"9",
      "$":"Bordrestaurant"
      }]
    }
highsource commented 8 years ago

Bei JourneyDetail ( Names ) scheint es ja so zu sein das dort auch eine Liste von Name enthalten sein kann, daher währe es sinnvoll eine Liste mit einem Element zu übergeben, um bei der Verarbeiten nicht unterscheiden zu müssen ob es ein Element ist oder eine Liste mit Elementen. Dies gilt auch für andere Felder.

http://data.deutschebahn.com/apis/fahrplan/#comment-2538938311

marcelbuesing commented 8 years ago

+1 This is critical. It's pretty difficult to work around this. I think this affects all array attributes in the API.

highsource commented 8 years ago

Absolutely.

mRs- commented 7 years ago

And the swagger code generated files are obsolete then…