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 HAL-FORMS target template element property #1427

Closed
toedter opened this issue Jan 9, 2021 · 7 comments
Closed

Support HAL-FORMS target template element property #1427

toedter opened this issue Jan 9, 2021 · 7 comments
Assignees
Labels
in: mediatypes Media type related functionality type: enhancement
Milestone

Comments

@toedter
Copy link

toedter commented Jan 9, 2021

In the HAL-FORMS Spec (see https://rwcbook.github.io/hal-forms/#_code_target_code), an optional target property could be defined for each template element. It would be great if Spring HATEOAS would support this when creating a HAL-FORMS affordance.

An example would look like:

{
  "_links": {
    "self": {
      "href": "http://movies.com/api/movies"
    }
  },
  "_templates": {
    "default": {
      "title": "Create Rating",
      "method": "post",
      "contentType": "",
      "properties": [
        {
          "name": "movie-id",
          "prompt": "Movie ID",
          "required": true
        },
        {
          "name": "rating",
          "prompt": "Rating",
          "required": true
        }
      ],
      "target": "http://movies.com/api/ratings"
    }
  }
}
@gregturn
Copy link
Contributor

I wonder what would be best. Media type specific annotations you can apply to domain objects?

I would favor that. And because annotations don’t support null, we’d need a separate annotation for each custom attribute we support.

@odrotbohm
Copy link
Member

I think it essentially just allows us to bind other link targets rather than only working on the (self) link the affordances are bound to from the start.

@toedter
Copy link
Author

toedter commented Jan 13, 2021

I think that would be a good idea so we could have the "target link" in the generic model and render it at runtime for the used media type.

odrotbohm added a commit that referenced this issue Jan 20, 2021
We now explicitly set the target attribute of HAL FORMS templates if the target of the affordance does not equal the target of the self link.
@odrotbohm
Copy link
Member

The latest snapshots render the target element for all affordances not pointing to the URI of the self link you usually start with to build up affordances. Do you think that'll work?

@odrotbohm odrotbohm self-assigned this Jan 20, 2021
@odrotbohm odrotbohm added this to the 1.3 M2 milestone Jan 20, 2021
@odrotbohm odrotbohm added in: mediatypes Media type related functionality type: enhancement labels Jan 20, 2021
@toedter
Copy link
Author

toedter commented Jan 20, 2021

thx, I will check.

@shanman190
Copy link

I've got a pretty similar use case and I think this will work out quite nicely. I was finding it a bit awkward that you could only have affordances on the self link with the latest 1.2.3 release even though you could specify a target other than self (it just wouldn't be rendered). It's good to see that affordances will be able to have a target other than self.

Is there a rough estimate around when 1.3.0 might be available for consumption?

@odrotbohm
Copy link
Member

The milestone containing this functionality is already available from our repositories. We're shooting for a GA release right before the Spring Data 2021.0.0 one as it consumes Spring HATEOAS as dependency. The former is scheduled for mid April roundabout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: mediatypes Media type related functionality type: enhancement
Projects
None yet
Development

No branches or pull requests

4 participants