Giter Club home page Giter Club logo

Comments (4)

gregturn avatar gregturn commented on August 27, 2024

This tutorial is in need of some love. The document posted above isn't a HAL document, hinting that one of the controller endpoints isn't returning a ResourceSupport/Resource/Resources/PagedResources type, hence NOT engaging the HAL serializers. HAL serializers would NOT render the extra attributes when they are null.

from tut-rest.

davidjlynn avatar davidjlynn commented on August 27, 2024

Took a clean copy of the repo and getting the same results (but with less nulls as you mentioned). However this may be a misunderstanding on my end. Running on the URL http://localhost:8080/dsyer/bookmarks/3:

{
    "bookmark": {
        "id": 3,
        "uri": "http://bookmark.com/1/dsyer",
        "description": "A description"
    },
    "_links": {
        "bookmark-uri": {
            "href": "http://bookmark.com/1/dsyer"
        },
        "bookmarks": {
            "href": "http://localhost:8080/dsyer/bookmarks"
        },
        "self": {
            "href": "http://localhost:8080/dsyer/bookmarks/3"
        }
    }
}

However I was expecting bookmarks to not be nested, like so:

{
    "id": 3,
    "uri": "http://bookmark.com/1/dsyer",
    "description": "A description",
    "_links": {
        "bookmark-uri": {
            "href": "http://bookmark.com/1/dsyer"
        },
        "bookmarks": {
            "href": "http://localhost:8080/dsyer/bookmarks"
        },
        "self": {
            "href": "http://localhost:8080/dsyer/bookmarks/3"
        }
    }
}

Details in http://stateless.co/hal_specification.html are where I am making the assumption that I shouldn't be nesting, however I have been unable to find a clear demonstration.

from tut-rest.

gregturn avatar gregturn commented on August 27, 2024

The class definition of BookmarkResource is:

class BookmarkResource extends ResourceSupport {

	private final Bookmark bookmark;
    ...
}

That is why Bookmark is nested. Because it's nested inside the BookmarkResource. This is fine in the HAL spec, since it matches the class structure.

That being said, I'm in the middle of overhauling this tutorial, and frankly, it looks like we could just use Resource<Bookmark> to accomplish the same thing. That would be one less type of manage and would have the next effect of simplifying the HAL structure as you imagine it, but not having this structure.

from tut-rest.

gregturn avatar gregturn commented on August 27, 2024

This tutorial was completely rewritten as of 63d3937.

I suggest you read it from the top and be sure to let us know if you spot any issues!

from tut-rest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.