0

As part of development I would like to maintain the two different versions of response.I have used produces key word as part of request mapping to differentiate the implementation.

when version = 1.0 the method for first implementation should be called,when version 2.0 then method for second implementation should be called.

But in my case its always the method with lower version is getting called.

**

@RequestMapping(value = "/example", method = GET,produces= HAL_JSON_VALUE+";version=1")
public void method1(){
System.out.println("in method1");
}
@RequestMapping(value = "/example", method = GET,produces= HAL_JSON_VALUE+";version=2")
public void method2(){
System.out.println("in method2");
}

**

1 Answers1

0

Spring MVC does not take into account media type parameters during content negotiation. See this issue for more background on that.

REST API providers usually choose to include that version number in the type itself, like application/vnd.github.v3+json.

Brian Clozel
  • 56,583
  • 15
  • 167
  • 176