Skip to content

Commit 2c7370a

Browse files
committed
Add support for v2.3 metadata endpoint
1 parent 934e0bc commit 2c7370a

File tree

3 files changed

+265
-1
lines changed

3 files changed

+265
-1
lines changed

initializr-web/src/main/java/io/spring/initializr/web/controller/ProjectMetadataController.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import io.spring.initializr.web.mapper.InitializrMetadataJsonMapper;
3232
import io.spring.initializr.web.mapper.InitializrMetadataV21JsonMapper;
3333
import io.spring.initializr.web.mapper.InitializrMetadataV22JsonMapper;
34+
import io.spring.initializr.web.mapper.InitializrMetadataV23JsonMapper;
3435
import io.spring.initializr.web.mapper.InitializrMetadataV2JsonMapper;
3536
import io.spring.initializr.web.mapper.InitializrMetadataVersion;
3637
import io.spring.initializr.web.project.InvalidProjectRequestException;
@@ -77,6 +78,11 @@ public ResponseEntity<String> serviceCapabilitiesHal() {
7778
return serviceCapabilitiesFor(InitializrMetadataVersion.V2_1, HAL_JSON_CONTENT_TYPE);
7879
}
7980

81+
@GetMapping(path = { "/", "/metadata/client" }, produces = { "application/vnd.initializr.v2.3+json" })
82+
public ResponseEntity<String> serviceCapabilitiesV23() {
83+
return serviceCapabilitiesFor(InitializrMetadataVersion.V2_3);
84+
}
85+
8086
@GetMapping(path = { "/", "/metadata/client" }, produces = { "application/vnd.initializr.v2.2+json" })
8187
public ResponseEntity<String> serviceCapabilitiesV22() {
8288
return serviceCapabilitiesFor(InitializrMetadataVersion.V2_2);
@@ -93,6 +99,11 @@ public ResponseEntity<String> serviceCapabilitiesV2() {
9399
return serviceCapabilitiesFor(InitializrMetadataVersion.V2);
94100
}
95101

102+
@GetMapping(path = "/dependencies", produces = "application/vnd.initializr.v2.3+json")
103+
public ResponseEntity<String> dependenciesV23(@RequestParam(required = false) String bootVersion) {
104+
return dependenciesFor(InitializrMetadataVersion.V2_3, bootVersion);
105+
}
106+
96107
@GetMapping(path = "/dependencies", produces = "application/vnd.initializr.v2.2+json")
97108
public ResponseEntity<String> dependenciesV22(@RequestParam(required = false) String bootVersion) {
98109
return dependenciesFor(InitializrMetadataVersion.V2_2, bootVersion);
@@ -185,7 +196,8 @@ protected InitializrMetadataJsonMapper createMetadataJsonMapper(InitializrMetada
185196
return switch (metadataVersion) {
186197
case V2 -> new InitializrMetadataV2JsonMapper();
187198
case V2_1 -> new InitializrMetadataV21JsonMapper();
188-
default -> new InitializrMetadataV22JsonMapper();
199+
case V2_2 -> new InitializrMetadataV22JsonMapper();
200+
default -> new InitializrMetadataV23JsonMapper();
189201
};
190202
}
191203

initializr-web/src/test/java/io/spring/initializr/web/controller/ProjectMetadataControllerIntegrationTests.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ void metadataWithV22AcceptHeader() {
7272
validateMetadata(response, InitializrMetadataVersion.V2_2.getMediaType(), "2.2.0", JSONCompareMode.STRICT);
7373
}
7474

75+
@Test
76+
void metadataWithV23AcceptHeader() {
77+
ResponseEntity<String> response = invokeHome(null, "application/vnd.initializr.v2.3+json");
78+
validateMetadata(response, InitializrMetadataVersion.V2_3.getMediaType(), "2.3.0", JSONCompareMode.STRICT);
79+
}
80+
7581
@Test
7682
void metadataWithInvalidPlatformVersion() {
7783
try {
Lines changed: 246 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,246 @@
1+
{
2+
"_links": {
3+
"dependencies": {
4+
"href": "http://@host@/dependencies{?bootVersion}",
5+
"templated": true
6+
},
7+
"maven-build": {
8+
"href": "http://@host@/pom.xml?type=maven-build{&dependencies,packaging,javaVersion,language,bootVersion,groupId,artifactId,version,name,description,packageName,configurationFileFormat}",
9+
"templated": true
10+
},
11+
"maven-project": {
12+
"href": "http://@host@/starter.zip?type=maven-project{&dependencies,packaging,javaVersion,language,bootVersion,groupId,artifactId,version,name,description,packageName,configurationFileFormat}",
13+
"templated": true
14+
},
15+
"gradle-build": {
16+
"href": "http://@host@/build.gradle?type=gradle-build{&dependencies,packaging,javaVersion,language,bootVersion,groupId,artifactId,version,name,description,packageName,configurationFileFormat}",
17+
"templated": true
18+
},
19+
"gradle-project": {
20+
"href": "http://@host@/starter.zip?type=gradle-project{&dependencies,packaging,javaVersion,language,bootVersion,groupId,artifactId,version,name,description,packageName,configurationFileFormat}",
21+
"templated": true
22+
}
23+
},
24+
"dependencies": {
25+
"type": "hierarchical-multi-select",
26+
"values": [
27+
{
28+
"name": "Core",
29+
"values": [
30+
{
31+
"id": "web",
32+
"name": "Web",
33+
"description": "Web dependency description",
34+
"_links": {
35+
"guide": {
36+
"href": "https://example.com/guide",
37+
"title": "Building a RESTful Web Service"
38+
},
39+
"reference": {
40+
"href": "https://example.com/doc"
41+
}
42+
}
43+
},
44+
{
45+
"id": "security",
46+
"name": "Security"
47+
},
48+
{
49+
"id": "data-jpa",
50+
"name": "Data JPA"
51+
}
52+
]
53+
},
54+
{
55+
"name": "Other",
56+
"values": [
57+
{
58+
"id": "org.acme:foo",
59+
"name": "Foo",
60+
"_links": {
61+
"guide": [
62+
{
63+
"href": "https://example.com/guide1"
64+
},
65+
{
66+
"href": "https://example.com/guide2",
67+
"title": "Some guide for foo"
68+
}
69+
],
70+
"reference": {
71+
"href": "https://example.com/{bootVersion}/doc",
72+
"templated": true
73+
}
74+
}
75+
},
76+
{
77+
"id": "org.acme:bar",
78+
"name": "Bar"
79+
},
80+
{
81+
"id": "org.acme:biz",
82+
"name": "Biz",
83+
"versionRange": "2.6.0-SNAPSHOT"
84+
},
85+
{
86+
"id": "org.acme:bur",
87+
"name": "Bur",
88+
"versionRange": "[2.4.4,2.5.0-SNAPSHOT)"
89+
},
90+
{
91+
"id": "my-api",
92+
"name": "My API"
93+
}
94+
]
95+
}
96+
]
97+
},
98+
"type": {
99+
"type": "action",
100+
"default": "maven-project",
101+
"values": [
102+
{
103+
"id": "maven-build",
104+
"name": "Maven POM",
105+
"action": "/pom.xml",
106+
"tags": {
107+
"build": "maven",
108+
"format": "build"
109+
}
110+
},
111+
{
112+
"id": "maven-project",
113+
"name": "Maven Project",
114+
"action": "/starter.zip",
115+
"tags": {
116+
"build": "maven",
117+
"format": "project"
118+
}
119+
},
120+
{
121+
"id": "gradle-build",
122+
"name": "Gradle Config",
123+
"action": "/build.gradle",
124+
"tags": {
125+
"build": "gradle",
126+
"format": "build"
127+
}
128+
},
129+
{
130+
"id": "gradle-project",
131+
"name": "Gradle Project",
132+
"action": "/starter.zip",
133+
"tags": {
134+
"build": "gradle",
135+
"format": "project"
136+
}
137+
}
138+
]
139+
},
140+
"packaging": {
141+
"type": "single-select",
142+
"default": "jar",
143+
"values": [
144+
{
145+
"id": "jar",
146+
"name": "Jar"
147+
},
148+
{
149+
"id": "war",
150+
"name": "War"
151+
}
152+
]
153+
},
154+
"javaVersion": {
155+
"type": "single-select",
156+
"default": "1.8",
157+
"values": [
158+
{
159+
"id": "1.6",
160+
"name": "1.6"
161+
},
162+
{
163+
"id": "1.7",
164+
"name": "1.7"
165+
},
166+
{
167+
"id": "1.8",
168+
"name": "1.8"
169+
}
170+
]
171+
},
172+
"language": {
173+
"type": "single-select",
174+
"default": "java",
175+
"values": [
176+
{
177+
"id": "groovy",
178+
"name": "Groovy"
179+
},
180+
{
181+
"id": "java",
182+
"name": "Java"
183+
},
184+
{
185+
"id": "kotlin",
186+
"name": "Kotlin"
187+
}
188+
]
189+
},
190+
"configurationFileFormat": {
191+
"type": "single-select",
192+
"default": "properties",
193+
"values": [
194+
{
195+
"id": "properties",
196+
"name": "Properties"
197+
},
198+
{
199+
"id": "yaml",
200+
"name": "YAML"
201+
}
202+
]
203+
},
204+
"bootVersion": {
205+
"type": "single-select",
206+
"default": "2.4.4",
207+
"values": [
208+
{
209+
"id": "2.5.0-SNAPSHOT",
210+
"name": "Latest SNAPSHOT"
211+
},
212+
{
213+
"id": "2.4.4",
214+
"name": "2.4.4"
215+
},
216+
{
217+
"id": "2.3.10.RELEASE",
218+
"name": "2.3.10"
219+
}
220+
]
221+
},
222+
"groupId": {
223+
"type": "text",
224+
"default": "com.example"
225+
},
226+
"artifactId": {
227+
"type": "text",
228+
"default": "demo"
229+
},
230+
"version": {
231+
"type": "text",
232+
"default": "0.0.1-SNAPSHOT"
233+
},
234+
"name": {
235+
"type": "text",
236+
"default": "demo"
237+
},
238+
"description": {
239+
"type": "text",
240+
"default": "Demo project for Spring Boot"
241+
},
242+
"packageName": {
243+
"type": "text",
244+
"default": "com.example.demo"
245+
}
246+
}

0 commit comments

Comments
 (0)