Skip to content

Commit 5690791

Browse files
committed
Document the java info contribution
Closes gh-45566
1 parent aa9cc4a commit 5690791

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/docs/antora/modules/api/pages/rest/actuator/info.adoc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,13 @@ The following table describes the structure of the `process` section of the resp
6666

6767
[cols="2,1,3"]
6868
include::partial$rest/actuator/info/response-fields-beneath-process.adoc[]
69+
70+
71+
72+
[[info.retrieving.response-structure.java]]
73+
==== Java Response Structure
74+
75+
The following table describes the structure of the `java` section of the response:
76+
77+
[cols="2,1,3"]
78+
include::partial$rest/actuator/info/response-fields-beneath-java.adoc[]

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/info/InfoEndpointDocumentationTests.java

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.springframework.boot.actuate.info.GitInfoContributor;
2828
import org.springframework.boot.actuate.info.InfoContributor;
2929
import org.springframework.boot.actuate.info.InfoEndpoint;
30+
import org.springframework.boot.actuate.info.JavaInfoContributor;
3031
import org.springframework.boot.actuate.info.OsInfoContributor;
3132
import org.springframework.boot.actuate.info.ProcessInfoContributor;
3233
import org.springframework.boot.info.BuildProperties;
@@ -55,7 +56,8 @@ class InfoEndpointDocumentationTests extends MockMvcEndpointDocumentationTests {
5556
void info() throws Exception {
5657
this.mockMvc.perform(get("/actuator/info"))
5758
.andExpect(status().isOk())
58-
.andDo(MockMvcRestDocumentation.document("info", gitInfo(), buildInfo(), osInfo(), processInfo()));
59+
.andDo(MockMvcRestDocumentation.document("info", gitInfo(), buildInfo(), osInfo(), processInfo(),
60+
javaInfo()));
5961
}
6062

6163
private ResponseFieldsSnippet gitInfo() {
@@ -100,6 +102,35 @@ private ResponseFieldsSnippet processInfo() {
100102
.type(JsonFieldType.NUMBER));
101103
}
102104

105+
private ResponseFieldsSnippet javaInfo() {
106+
return responseFields(beneathPath("java"),
107+
fieldWithPath("version").description("Java version, if available.")
108+
.type(JsonFieldType.STRING)
109+
.optional(),
110+
fieldWithPath("vendor").description("Vendor details."),
111+
fieldWithPath("vendor.name").description("Vendor name, if available.")
112+
.type(JsonFieldType.STRING)
113+
.optional(),
114+
fieldWithPath("vendor.version").description("Vendor version, if available.")
115+
.type(JsonFieldType.STRING)
116+
.optional(),
117+
fieldWithPath("runtime").description("Runtime details."),
118+
fieldWithPath("runtime.name").description("Runtime name, if available.")
119+
.type(JsonFieldType.STRING)
120+
.optional(),
121+
fieldWithPath("runtime.version").description("Runtime version, if available.")
122+
.type(JsonFieldType.STRING)
123+
.optional(),
124+
fieldWithPath("jvm").description("JVM details."),
125+
fieldWithPath("jvm.name").description("JVM name, if available.").type(JsonFieldType.STRING).optional(),
126+
fieldWithPath("jvm.vendor").description("JVM vendor, if available.")
127+
.type(JsonFieldType.STRING)
128+
.optional(),
129+
fieldWithPath("jvm.version").description("JVM version, if available.")
130+
.type(JsonFieldType.STRING)
131+
.optional());
132+
}
133+
103134
@Configuration(proxyBeanMethods = false)
104135
static class TestConfiguration {
105136

@@ -139,6 +170,11 @@ ProcessInfoContributor processInfoContributor() {
139170
return new ProcessInfoContributor();
140171
}
141172

173+
@Bean
174+
JavaInfoContributor javaInfoContributor() {
175+
return new JavaInfoContributor();
176+
}
177+
142178
}
143179

144180
}

0 commit comments

Comments
 (0)