Add support for the configurationFileFormat option in the Spring CLI when it is available
spring init --list shows configurationFileFormat as an option to choose between properties or yaml however the cli does not recognize that as a valid option. See example below.
# Truncated example from spring init --list
Parameters
+-------------------------+------------------------------------------+------------------+
| Id | Description | Default value |
+-------------------------+------------------------------------------+------------------+
| artifactId | project coordinates (infer archive name) | demo |
| bootVersion | spring boot version | 4.0.5 |
| configurationFileFormat | configuration file format | properties |
| description | project description | |
| groupId | project coordinates | com.example |
| javaVersion | language level | 17 |
| language | programming language | java |
| name | project name (infer application name) | |
| packageName | root package | com.example.demo |
| packaging | project packaging | jar |
| type | project type | gradle-project |
| version | project version | 0.0.1-SNAPSHOT |
+-------------------------+------------------------------------------+------------------+
coder@debian-13:~$ spring --version
spring init \
--groupId=org.example \
--artifactId=exmple-project \
--javaVersion=25 \
--type=maven-project \
--configurationFileFormat=yaml
Spring CLI v4.0.5
configurationFileFormat is not a recognized option
coder@debian-13:~$
@shawnweeks thanks for the report. That's an unfortunate mismatch between the help as produced by the CLI and the options that the CLI itself does support. The purpose of Parameters is mostly meant to document default values.
configurationFileFormat has been added recently in v2.3 and the CLI is pinned to v2.2 (as it should). I don't understand why it sees the extra parameter. WDYT @mhalbritter?
That's because we send:
curlie https://start.spring.io -H "Accept: text/plain,application/vnd.initializr.v2.1+json,application/vnd.initializr.v2+json" -H "User-Agent: SpringBootCli/4.0.5"
which uses text/plain on the server, and then the server renders all properties of InitializrMetadata, which also includes configurationFileFormat.
We should instead send something like application/vnd.initializr.v2.1+text (which is text/plain but versioned), and then the server can filter out the configurationFileFormat.
Or we fix the CLI so that it renders its own output. Right now, we render it as text on the start.spring.io server, and then pass it down to the CLI, which just prints it. The CLI could also fetch the JSON and render the tables themselves. We'd have to check if all the information is contained in the JSON, though.
Hi @mhalbritter I’d be happy to take a look at this if it’s still available.
From the discussion, it sounds like the most targeted fix would be to update the CLI request to use a versioned text media type (for example application/vnd.initializr.v2.1+text) so unsupported newer parameters are filtered from the help output.
If that aligns with the preferred direction, please feel free to assign it to me.
I'd prefer if we don't render the help text for the CLI on the server. Instead parse the JSON, and create those tables in the CLI. But let me check with the team first.
"Hi, I'd like to work on this. I'm planning to add --configurationFileFormat as a recognized CLI option in InitCommand and wire it through ProjectGenerationRequest. Will submit a PR shortly."
Thanks for tracking this. I noticed the earlier PR was closed while the team discusses the preferred direction. I’d be happy to help with implementation or tests once the approach is decided.
We've opened https://github.com/spring-io/initializr/issues/1800 to fix the table display on the server side. We'll consider the missing --configurationFileFormat=yaml support as an enhancement and look at a robust solution in 4.x.
Thanks for the clarification and for discussing the direction internally. The updated scope and the server-side fix in spring-io/initializr#1800 make sense. I’ll follow the 4.x enhancement discussion for the broader CLI support.