spring-projects / spring-projects/spring-hateoas
CurieProvider with multiple curies and namespaces assigned manually.
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 476
- PR merge metrics
- No merged PRs in 30d
Description
I am trying to use multiple curies like this:
@Bean
public CurieProvider curieProvider() {
return new DefaultCurieProvider(HashMap.ofEntries(
Tuple.of("h3h3", new UriTemplate("http://localhost:8080/rest-api#{rel}")),
Tuple.of("h4h4", new UriTemplate("http://localhost:8080/rest-api#{rel}-revision")))
.toJavaMap(), "h3h3");
}
With resources annotated like this:
@Relation(value = "h3h3:lineup", collectionRelation = "h3h3:lineups")
public class LineupResource extends ResourceSupport {}
@Relation(value = "h3h3:thing", collectionRelation = "h3h3:things")
public class ThingResource extends ResourceSupport {}
For collections this scenario works perfectly fine. But in case of GET on single resource curies section is missing in response payload because CurieProvider.getNamespacedRelFrom is equal to my link rel:
https://github.com/spring-projects/spring-hateoas/blob/6bed9bec403f2ca45f4fd319c6ee3d79738f36f7/src/main/java/org/springframework/hateoas/hal/Jackson2HalModule.java#L174
Get response:
{
"code": "L1",
"_links": {
"self": {
"href": "http://192.168.209.95:8080/lineups/L1"
},
"h3h3:things": {
"href": "http://192.168.209.95:8080/lineups/L1/things"
}
}
}
Is it intended behavior?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the CurieProvider configuration and the @Relation annotations in the issue, then inspect Jackson2HalModule.java around line 174. Reproduce the single-resource GET and compare it with the collection response; done means the intended curie serialization behavior is established and covered for multiple namespaces.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100