spring-boot icon indicating copy to clipboard operation
spring-boot copied to clipboard

Add support for the configurationFileFormat option in the Spring CLI when it is available

Open shawnweeks opened this issue 7 months ago • 9 comments

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 avatar Apr 08 '26 13:04 shawnweeks

@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?

snicoll avatar Apr 08 '26 15:04 snicoll

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.

mhalbritter avatar Apr 09 '26 07:04 mhalbritter

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.

mhalbritter avatar Apr 09 '26 09:04 mhalbritter

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.

GollapudiSrikanth avatar Apr 15 '26 21:04 GollapudiSrikanth

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.

mhalbritter avatar Apr 16 '26 06:04 mhalbritter

"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."

karansahani78 avatar Apr 16 '26 19:04 karansahani78

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.

codingkiddo avatar May 12 '26 17:05 codingkiddo

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.

philwebb avatar May 20 '26 15:05 philwebb

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.

karansahani78 avatar May 21 '26 20:05 karansahani78