Skip to content

Commit 5581a21

Browse files
committed
Merge pull request #1697 from YangSiJun528
* pr/1697: Document configuration file format v2.3 in metadata Upgrade integration tests to metadata v2.3 Closes gh-1697
2 parents fdb04fa + 423b0c4 commit 5581a21

File tree

5 files changed

+49
-14
lines changed

5 files changed

+49
-14
lines changed

initializr-docs/src/main/asciidoc/configuration-guide.adoc

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ generate assets based on available candidates.
5353
A project is defined by `ProjectDescription` which consists of the following properties:
5454

5555
* Basic coordinates such as `groupId`, `artifactId`, `name`, `description`
56-
* The `BuildSystem` and `Packaging`
56+
* The `BuildSystem`, `Packaging` and `ConfigurationFileFormat`
5757
* The JVM `Language`
5858
* The requested dependencies, indexed by ID
5959
* A platform `Version` used by the project. This can be used to tune available
@@ -341,6 +341,25 @@ NOTE: `Jar` and `War` packaging types are available out-of-the-box. For addition
341341
packaging formats, you need to implement the `Packaging` abstraction and provide a
342342
`PackagingFactory` that corresponds to it.
343343

344+
Configuration file formats are configurable in the same way as above:
345+
346+
[source,yaml,indent=0]
347+
----
348+
initializr:
349+
configuration-file-formats:
350+
- name: Properties
351+
id: properties
352+
default: true
353+
- name: YAML
354+
id: yaml
355+
default: false
356+
----
357+
358+
NOTE: `Properties` and `YAML` configuration file formats are supported out-of-the-box.
359+
If you need to support additional configuration formats, you must implement the
360+
`ConfigurationFileFormat` abstraction and provide a `ConfigurationFileFormatFactory` that can
361+
generate it.
362+
344363

345364

346365
[[create-instance-text-only-settings]]

initializr-docs/src/main/asciidoc/metadata-format.adoc

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,16 @@ sent to the service. A good structure for a user agent is `clientId/clientVersio
1414
== Service Capabilities
1515
Any third party client can retrieve the capabilities of the service by issuing a
1616
`GET` on the root URL using the following `Accept` header:
17-
`application/vnd.initializr.v2.2+json`. Please note that the metadata may evolve in a
17+
`application/vnd.initializr.v2.3+json`. Please note that the metadata may evolve in a
1818
non backward compatible way in the future so adding this header ensures the service
1919
returns the metadata format you expect.
2020

2121
The following versions are supported:
2222

2323
* `v2` initial version, with support of V1 version format only
2424
* `v2.1` support compatibility range and dependencies links
25-
* `v2.2` (current) support for V1 and V2 version formats.
25+
* `v2.2` support for V1 and V2 version formats.
26+
* `v2.3` (current) support for selecting the configuration file format.
2627

2728
This is an example output for a service running at `start.example.com`:
2829

@@ -45,6 +46,8 @@ component responsible to generate the project (for instance, generate an executa
4546
_jar_ project).
4647
* Java version: the supported java versions
4748
* Language: the language to use (e.g. Java)
49+
* Configuration file format: the supported configuration formats for the generated
50+
project (e.g. `application.properties`, `application.yml`)
4851
* Boot version: the platform version to use
4952
* Additional basic information such as: `groupId`, `artifactId`, `version`, `name`,
5053
`description` and `packageName`.
@@ -168,6 +171,14 @@ include::{snippets}/metadataWithCurrentAcceptHeader/response-fields/language.val
168171

169172

170173

174+
=== Configuration file format
175+
The `configurationFileFormat` element provides a list of possible configuration file formats for the project:
176+
177+
.Configuration file format example
178+
include::{snippets}/metadataWithCurrentAcceptHeader/response-fields/configurationFileFormat.values.0.adoc[]
179+
180+
181+
171182
=== Platform versions
172183
The `bootVersion` element provides the list of available platform versions
173184

initializr-web/src/test/java/io/spring/initializr/web/AbstractInitializrIntegrationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public abstract class AbstractInitializrIntegrationTests {
7272

7373
protected static final MediaType DEFAULT_METADATA_MEDIA_TYPE = InitializrMetadataVersion.V2_1.getMediaType();
7474

75-
protected static final MediaType CURRENT_METADATA_MEDIA_TYPE = InitializrMetadataVersion.V2_2.getMediaType();
75+
protected static final MediaType CURRENT_METADATA_MEDIA_TYPE = InitializrMetadataVersion.V2_3.getMediaType();
7676

7777
private static final ObjectMapper objectMapper = new ObjectMapper();
7878

@@ -133,7 +133,7 @@ protected void validateDefaultMetadata(ResponseEntity<String> response) {
133133

134134
protected void validateCurrentMetadata(ResponseEntity<String> response) {
135135
validateContentType(response, CURRENT_METADATA_MEDIA_TYPE);
136-
validateMetadata(response.getBody(), "2.2.0");
136+
validateMetadata(response.getBody(), "2.3.0");
137137
}
138138

139139
protected void validateDefaultMetadata(String json) {

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import io.spring.initializr.metadata.InitializrMetadataBuilder;
2121
import io.spring.initializr.metadata.InitializrMetadataProvider;
2222
import io.spring.initializr.web.AbstractFullStackInitializrIntegrationTests;
23+
import io.spring.initializr.web.mapper.InitializrMetadataVersion;
2324
import org.json.JSONException;
2425
import org.json.JSONObject;
2526
import org.junit.jupiter.api.Test;
@@ -100,7 +101,13 @@ void dependenciesV21WithNoBootVersion() throws JSONException {
100101

101102
@Test
102103
void dependenciesV22WithNoBootVersion() throws JSONException {
103-
validateDependenciesMetadata("application/vnd.initializr.v2.2+json", CURRENT_METADATA_MEDIA_TYPE);
104+
validateDependenciesMetadata("application/vnd.initializr.v2.2+json",
105+
InitializrMetadataVersion.V2_2.getMediaType());
106+
}
107+
108+
@Test
109+
void dependenciesV23WithNoBootVersion() throws JSONException {
110+
validateDependenciesMetadata("application/vnd.initializr.v2.3+json", CURRENT_METADATA_MEDIA_TYPE);
104111
}
105112

106113
private void validateDependenciesMetadata(String acceptHeader, MediaType expectedMediaType) throws JSONException {

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,26 +93,24 @@ void metadataWithInvalidPlatformVersion() {
9393
@Test
9494
void metadataWithCurrentAcceptHeader() {
9595
getRequests().setFields("_links.maven-project", "dependencies.values[0]", "type.values[0]",
96-
"javaVersion.values[0]", "packaging.values[0]", "bootVersion.values[0]", "language.values[0]");
97-
ResponseEntity<String> response = invokeHome(null, "application/vnd.initializr.v2.2+json");
96+
"javaVersion.values[0]", "packaging.values[0]", "bootVersion.values[0]", "language.values[0]",
97+
"configurationFileFormat.values[0]");
98+
ResponseEntity<String> response = invokeHome(null, "application/vnd.initializr.v2.3+json");
9899
assertThat(response.getHeaders().getFirst(HttpHeaders.ETAG)).isNotNull();
99-
validateContentType(response, AbstractInitializrIntegrationTests.CURRENT_METADATA_MEDIA_TYPE);
100-
validateMetadata(response.getBody(), "2.2.0");
100+
validateCurrentMetadata(response);
101101
}
102102

103103
@Test
104104
void metadataWithSeveralVersionsAndQualifier() {
105105
ResponseEntity<String> response = invokeHome(null, "application/vnd.initializr.v2+json;q=0.9",
106-
"application/vnd.initializr.v2.2+json");
107-
validateContentType(response, AbstractInitializrIntegrationTests.CURRENT_METADATA_MEDIA_TYPE);
106+
"application/vnd.initializr.v2.3+json");
108107
validateCurrentMetadata(response);
109108
}
110109

111110
@Test
112111
void metadataWithSeveralVersionAndPreferenceOnInvalidVersion() {
113112
ResponseEntity<String> response = invokeHome(null, "application/vnd.initializr.v5.4+json",
114-
"application/vnd.initializr.v2.2+json;q=0.9");
115-
validateContentType(response, AbstractInitializrIntegrationTests.CURRENT_METADATA_MEDIA_TYPE);
113+
"application/vnd.initializr.v2.3+json;q=0.9");
116114
validateCurrentMetadata(response);
117115
}
118116

0 commit comments

Comments
 (0)