Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mapping to a Map<String, ConfigObject> in the documentation #39162

Merged
merged 1 commit into from
Mar 6, 2024
Merged
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
33 changes: 33 additions & 0 deletions docs/src/main/asciidoc/config-mappings.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -414,10 +414,43 @@
server.form.landing-page=index.html
----

The configuration property needs to specify an additional name to act as the key. In this case the `form()` `Map` will

Check warning on line 417 in docs/src/main/asciidoc/config-mappings.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.Fluff] Depending on the context, consider using 'Rewrite the sentence, or use 'must', instead of' rather than 'needs to'. Raw Output: {"message": "[Quarkus.Fluff] Depending on the context, consider using 'Rewrite the sentence, or use 'must', instead of' rather than 'needs to'.", "location": {"path": "docs/src/main/asciidoc/config-mappings.adoc", "range": {"start": {"line": 417, "column": 28}}}, "severity": "INFO"}

Check warning on line 417 in docs/src/main/asciidoc/config-mappings.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.TermsSuggestions] Depending on the context, consider using 'because' or 'while' rather than 'as'. Raw Output: {"message": "[Quarkus.TermsSuggestions] Depending on the context, consider using 'because' or 'while' rather than 'as'.", "location": {"path": "docs/src/main/asciidoc/config-mappings.adoc", "range": {"start": {"line": 417, "column": 71}}}, "severity": "INFO"}
contain three elements with the keys `login-page`, `error-page` and `landing-page`.

It also works for groups:
[source,java]
----
@ConfigMapping(prefix = "server")
public interface Servers {
@WithParentName
Map<String, Server> allServers();
}

public interface Server {
String host();

int port();

String login();

String error();

String landing();
}
----
.application.properties
[source,properties]
----
server."my-server".host=localhost
server."my-server".port=8080
server."my-server".login=login.html
server."my-server".error=error.html
server."my-server".landing=index.html
----
In this case the `allServers()` `Map` will
contain one `Server` element with the key `my-server`.

=== Defaults

Check warning on line 453 in docs/src/main/asciidoc/config-mappings.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.HeadingPunctuation] Do not use end punctuation in headings. Raw Output: {"message": "[Quarkus.HeadingPunctuation] Do not use end punctuation in headings.", "location": {"path": "docs/src/main/asciidoc/config-mappings.adoc", "range": {"start": {"line": 453, "column": 1}}}, "severity": "INFO"}

The `@WithDefault` annotation allows to set a default property into a mapping (and prevent and error if the
configuration value is not available in any `ConfigSource`):
Expand Down
Loading