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

Support collections of hybrid types #16

Open
loic-yvonnet opened this issue Mar 26, 2015 · 0 comments
Open

Support collections of hybrid types #16

loic-yvonnet opened this issue Mar 26, 2015 · 0 comments

Comments

@loic-yvonnet
Copy link

Currently, a collection can contain members of a single type. The type of the first member overwrites others.

Let’s say we have a resource /cars/ which is a Collection of cars. There are 2 subtypes of cars in the Web API: sandero and audi. The representation sent back from GET /cars/ contains both a sandero and an audi (in this order). Currently, requesting the available operations on the audi will result in showing the sandero’s operations.

The reason is that the DOM layout is expected to contain 2 levels of spans (cf. line 246 element.parent().parent() in hydra.js) to return the right type associated with the selection. Arrays (which are used for collections), contrary to objects, have only one level of span around them.

A fix could consist simply in adding the additional required span level for arrays (line 300).

      if (_.isArray(data)) {
        result += '[<br>' + indent;
        for (i = 0; i < data.length; i++) {
          result += '<span>'; // new line
          result += '  ';
          result += this.renderResponse(data[i], indent + '  ', (i === data.length - 1));
          result += indent;
          result += '</span>'; // new line
        }
        result += ']';
      }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant