Skip to content

Read RestTemplate Accept header from entity annotation [SPR-12096] #16712

Closed
@spring-projects-issues

Description

@spring-projects-issues

Christopher Smith opened SPR-12096 and commented

Current best practice is to version REST APIs by media type (application/vnd.example.person-v1+json), but the RestTemplate does not provide a simple mechanism for indicating the Accept header for an entity type when using a general-purpose converter (such as Jackson). Instead, the AcceptHeaderRequestCallback will add all potentially matching media types to the Accept header.

It should be possible to annotate an entity class to specify the media type that RestTemplate will request from the server so that older clients will not send an unversioned request that they can't understand:

@EntityMediaType("application/vnd.example.person-v1+json")
public class Person {
    // stuff
}

Affects: 4.0.6

Issue Links:

0 votes, 5 watchers

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)status: declinedA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions