Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arrays should always be arrays #20

Closed
darobin opened this issue Aug 7, 2015 · 5 comments
Closed

Arrays should always be arrays #20

darobin opened this issue Aug 7, 2015 · 5 comments
Assignees
Labels

Comments

@darobin
Copy link
Member

darobin commented Aug 7, 2015

This was already mentioned in #15, but it is enough of a problem that it warrants its own bug.

Some fields are clearly meant to hold arrays, and when they contain multiple items they do. But if by chance they hold only a single item they become scalars. This is a painful antipattern to use, it constantly causes failures. I am finding myself having to write code to test for arrays pretty much everywhere.

@jean-gui
Copy link
Contributor

Unfortunately, that looks like a bug upstream but it doesn't to be worked on. Quickly looking at this library's code, it seems fairly hard to fix without a deep knowledge of the lib

@darobin
Copy link
Member Author

darobin commented Aug 12, 2015

Ok, I guess we'll just have to live with it for the time being then. If it could be documented visibly, it would be helpful. This is almost certain to trip people up.

I am now detecting this in all cases for the w3capi library, and fixing the data that is returned. Maybe this means that I should make a client-side version of it. @tripu @tagawa Are you aware of this problem?

@tripu
Copy link
Member

tripu commented Aug 12, 2015

We are now, @darobin; thanks! w3c/apiary#11
We support only a subset of all the entities and fields that the API returns; in our simple examples we didn't stumbled upon this issue. But we will have to handle those cases, of course.

@vivienlacourba
Copy link
Member

Assigning that issue to @jean-gui who found a workaround that ensures collections are always returned as JSON array even if they only have one element.

@vivienlacourba
Copy link
Member

Fixed by @jean-gui and deployed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants