spring-projects / spring-projects/spring-hateoas
Request: Support subclasses for @ExposesResourceFor
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 476
- PR merge metrics
- No merged PRs in 30d
Description
With Spring HATEOAS 1.5.6, I am writing a REST controller (/activity) that can return multiple subtypes of ActivityDto (ActivityMentionDto, ActivityReplyDto, etc.). I want to be able to annotate the controller with @ExposesResourceFor(ActivityDto.class) and use EntityLinks to generate self links for the concrete classes. However, this produces this error at runtime:
Cannot determine link for com.example/ActivityMentionDto! No EntityLinks instance found supporting the domain type!
As @ExposesResourceFor takes only a single Class parameter and is not repeatable, I would like @ExposesResourceFor to support subclasses of the declared type in the absence of a more specific declaration.
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 by tracing @ExposesResourceFor and EntityLinks for the declared ActivityDto type, then examine how links are resolved for ActivityMentionDto and other subclasses. Confirm the current runtime failure and define tests showing that a declared base type supports subclasses when no more specific declaration exists.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100