kiva / backbone.siren

Converts Siren JSON representations into Backbone Models
MIT License
14 stars 3 forks source link

should complain when collections are not arrays #12

Closed apsoto closed 11 years ago

apsoto commented 11 years ago

This is a bug in my API that I discovered when I returned only a direct entity instead an array with one item in the entities collection.

This ticket is just documenting that bbSiren should log an error when any of the collections (entities, links, actions) is NOT an array?

gxxcastillo commented 11 years ago

Yeah, I've gone back and forth on how much validation backbone.siren should be doing. So far I've only logged warnings if something is bad enough to cause serious breakages. Here are all the current warnings in backbone.siren core:

warn('Action is missing a name, unable to add top level method', action);
warn('Missing href or "self" link');
warn('Action is missing a name, unable to add top level method', action);

At the same time I don't feel strongly about this and I haven't really put much thought into what would constitute a serious enough problem to merit validating to the siren spec.

gxxcastillo commented 11 years ago

Going to leave this as a job for a separate "siren validator" should there ever be one.