diff --git a/initializr-web/src/main/java/io/spring/initializr/web/controller/ProjectMetadataController.java b/initializr-web/src/main/java/io/spring/initializr/web/controller/ProjectMetadataController.java index 692d9fec9a..b2d6f0b161 100644 --- a/initializr-web/src/main/java/io/spring/initializr/web/controller/ProjectMetadataController.java +++ b/initializr-web/src/main/java/io/spring/initializr/web/controller/ProjectMetadataController.java @@ -94,6 +94,11 @@ public ResponseEntity serviceCapabilitiesV2() { return serviceCapabilitiesFor(InitializrMetadataVersion.V2); } + @RequestMapping(path = "/dependencies", produces = "application/vnd.initializr.v2.2+json") + public ResponseEntity dependenciesV22(@RequestParam(required = false) String bootVersion) { + return dependenciesFor(InitializrMetadataVersion.V2_2, bootVersion); + } + @RequestMapping(path = "/dependencies", produces = { "application/vnd.initializr.v2.1+json", "application/json" }) public ResponseEntity dependenciesV21(@RequestParam(required = false) String bootVersion) { return dependenciesFor(InitializrMetadataVersion.V2_1, bootVersion); diff --git a/initializr-web/src/test/java/io/spring/initializr/web/controller/ProjectMetadataControllerCustomDefaultsIntegrationTests.java b/initializr-web/src/test/java/io/spring/initializr/web/controller/ProjectMetadataControllerCustomDefaultsIntegrationTests.java index 0dfc64fab5..3fff58c6fe 100755 --- a/initializr-web/src/test/java/io/spring/initializr/web/controller/ProjectMetadataControllerCustomDefaultsIntegrationTests.java +++ b/initializr-web/src/test/java/io/spring/initializr/web/controller/ProjectMetadataControllerCustomDefaultsIntegrationTests.java @@ -88,10 +88,24 @@ void metadataClientEndpoint() { } @Test - void noBootVersion() throws JSONException { - ResponseEntity response = execute("/dependencies", String.class, null, "application/json"); + void dependenciesNoAcceptHeaderWithNoBootVersion() throws JSONException { + validateDependenciesMetadata("*/*", DEFAULT_METADATA_MEDIA_TYPE); + } + + @Test + void dependenciesV21WithNoBootVersion() throws JSONException { + validateDependenciesMetadata("application/vnd.initializr.v2.1+json", DEFAULT_METADATA_MEDIA_TYPE); + } + + @Test + void dependenciesV22WithNoBootVersion() throws JSONException { + validateDependenciesMetadata("application/vnd.initializr.v2.2+json", CURRENT_METADATA_MEDIA_TYPE); + } + + private void validateDependenciesMetadata(String acceptHeader, MediaType expectedMediaType) throws JSONException { + ResponseEntity response = execute("/dependencies", String.class, null, acceptHeader); assertThat(response.getHeaders().getFirst(HttpHeaders.ETAG)).isNotNull(); - validateContentType(response, DEFAULT_METADATA_MEDIA_TYPE); + validateContentType(response, expectedMediaType); validateDependenciesOutput("2.1.4", response.getBody()); }