spring-projects / spring-projects/spring-hateoas

Request: Support subclasses for @ExposesResourceFor

Open
#2,159 0 comments 0 reactions 0 assignees View on GitHub

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.