Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion initializr-docs/src/main/asciidoc/configuration-guide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ generate assets based on available candidates.
A project is defined by `ProjectDescription` which consists of the following properties:

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

Configuration file formats are configurable in the same way as above:

[source,yaml,indent=0]
----
initializr:
configuration-file-formats:
- name: Properties
id: properties
default: true
- name: YAML
id: yaml
default: false
----

NOTE: `Properties` and `YAML` configuration file formats are supported out-of-the-box.
If you need to support additional configuration formats, you must implement the
`ConfigurationFileFormat` abstraction and provide a `ConfigurationFileFormatFactory` that can
generate it.



[[create-instance-text-only-settings]]
Expand Down
15 changes: 13 additions & 2 deletions initializr-docs/src/main/asciidoc/metadata-format.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@ sent to the service. A good structure for a user agent is `clientId/clientVersio
== Service Capabilities
Any third party client can retrieve the capabilities of the service by issuing a
`GET` on the root URL using the following `Accept` header:
`application/vnd.initializr.v2.2+json`. Please note that the metadata may evolve in a
`application/vnd.initializr.v2.3+json`. Please note that the metadata may evolve in a
non backward compatible way in the future so adding this header ensures the service
returns the metadata format you expect.

The following versions are supported:

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

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

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



=== Configuration file format
The `configurationFileFormat` element provides a list of possible configuration file formats for the project:

.Configuration file format example
include::{snippets}/metadataWithCurrentAcceptHeader/response-fields/configurationFileFormat.values.0.adoc[]



=== Platform versions
The `bootVersion` element provides the list of available platform versions

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public abstract class AbstractInitializrIntegrationTests {

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

protected static final MediaType CURRENT_METADATA_MEDIA_TYPE = InitializrMetadataVersion.V2_2.getMediaType();
protected static final MediaType CURRENT_METADATA_MEDIA_TYPE = InitializrMetadataVersion.V2_3.getMediaType();

private static final ObjectMapper objectMapper = new ObjectMapper();

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

protected void validateCurrentMetadata(ResponseEntity<String> response) {
validateContentType(response, CURRENT_METADATA_MEDIA_TYPE);
validateMetadata(response.getBody(), "2.2.0");
validateMetadata(response.getBody(), "2.3.0");
}

protected void validateDefaultMetadata(String json) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import io.spring.initializr.metadata.InitializrMetadataBuilder;
import io.spring.initializr.metadata.InitializrMetadataProvider;
import io.spring.initializr.web.AbstractFullStackInitializrIntegrationTests;
import io.spring.initializr.web.mapper.InitializrMetadataVersion;
import org.json.JSONException;
import org.json.JSONObject;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -100,7 +101,13 @@ void dependenciesV21WithNoBootVersion() throws JSONException {

@Test
void dependenciesV22WithNoBootVersion() throws JSONException {
validateDependenciesMetadata("application/vnd.initializr.v2.2+json", CURRENT_METADATA_MEDIA_TYPE);
validateDependenciesMetadata("application/vnd.initializr.v2.2+json",
InitializrMetadataVersion.V2_2.getMediaType());
}

@Test
void dependenciesV23WithNoBootVersion() throws JSONException {
validateDependenciesMetadata("application/vnd.initializr.v2.3+json", CURRENT_METADATA_MEDIA_TYPE);
}

private void validateDependenciesMetadata(String acceptHeader, MediaType expectedMediaType) throws JSONException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,26 +93,24 @@ void metadataWithInvalidPlatformVersion() {
@Test
void metadataWithCurrentAcceptHeader() {
getRequests().setFields("_links.maven-project", "dependencies.values[0]", "type.values[0]",
"javaVersion.values[0]", "packaging.values[0]", "bootVersion.values[0]", "language.values[0]");
ResponseEntity<String> response = invokeHome(null, "application/vnd.initializr.v2.2+json");
"javaVersion.values[0]", "packaging.values[0]", "bootVersion.values[0]", "language.values[0]",
"configurationFileFormat.values[0]");
ResponseEntity<String> response = invokeHome(null, "application/vnd.initializr.v2.3+json");
assertThat(response.getHeaders().getFirst(HttpHeaders.ETAG)).isNotNull();
validateContentType(response, AbstractInitializrIntegrationTests.CURRENT_METADATA_MEDIA_TYPE);
validateMetadata(response.getBody(), "2.2.0");
validateCurrentMetadata(response);
}

@Test
void metadataWithSeveralVersionsAndQualifier() {
ResponseEntity<String> response = invokeHome(null, "application/vnd.initializr.v2+json;q=0.9",
"application/vnd.initializr.v2.2+json");
validateContentType(response, AbstractInitializrIntegrationTests.CURRENT_METADATA_MEDIA_TYPE);
"application/vnd.initializr.v2.3+json");
validateCurrentMetadata(response);
}

@Test
void metadataWithSeveralVersionAndPreferenceOnInvalidVersion() {
ResponseEntity<String> response = invokeHome(null, "application/vnd.initializr.v5.4+json",
"application/vnd.initializr.v2.2+json;q=0.9");
validateContentType(response, AbstractInitializrIntegrationTests.CURRENT_METADATA_MEDIA_TYPE);
"application/vnd.initializr.v2.3+json;q=0.9");
validateCurrentMetadata(response);
}

Expand Down