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

Render empty _embedded content for empty collections [DATAREST-479] #858

Closed
spring-projects-issues opened this issue Feb 18, 2015 · 1 comment
Assignees
Labels

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented Feb 18, 2015

Lijo Jacob opened DATAREST-479 and commented


{
    "version": 0,
    "displayName": "Test Product",
    "_links": {
        "self": {
            "href": "http://localhost/services/data/products/123465"
        },
        "fixedParentCategories": {
            "href": "http://localhost/services/data/products/123465/fixedParentCategories"
        }
    }

{
    "_embedded": {
        "categories": [
            {
                "version": 0,
                "displayName": "Test category",
                "_links": {
                    "self": {
                        "href": "http://localhost:8080/services/data/categories/54c9963a8c21fbd950b6f1cf"
                    },
                }
            }
        ]
    }
}

It clearly says that the items are of type categories. But when the fixedParentCategories is empty, the response is a 404 error code. This does not help us identify what type of items can go into this collection. A response like this would help the UI identify the type that can be added to this list.

{
    "_embedded": {
        "categories": []
    }
}

I did some debugging to find that now the type ("categories" above) is identified by peeking at the first element in the collection.

org.springframework.hateoas.core.EmbeddedWrappers.AbstractEmbeddedWrapper.getRelTargetType()

This may have to change to use the link property's type declaration to identify the target type


Reference URL: http://stackoverflow.com/questions/28590871/spring-data-rest-webmvc-hateoas-how-to-identify-target-type-in-a-link-property

Issue Links:

  • DATAREST-542 ResourceProcessor not invoked for empty collections

Referenced from: commits 17305f4, 0264211

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented May 18, 2015

Oliver Drotbohm commented

This should be in place now. Feel free to give the snapshots a spin

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

2 participants