Adapt to changes in REST Docs for documenting query parameters
See gh-32623
This commit is contained in:
@@ -23,7 +23,7 @@ The endpoint uses query parameters to limit the events that it returns.
|
||||
The following table shows the supported query parameters:
|
||||
|
||||
[cols="2,4"]
|
||||
include::{snippets}/auditevents/filtered/request-parameters.adoc[]
|
||||
include::{snippets}/auditevents/filtered/query-parameters.adoc[]
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ Otherwise, the `cacheManager` must be specified.
|
||||
The following table shows the supported query parameters:
|
||||
|
||||
[cols="2,4"]
|
||||
include::{snippets}/caches/named/request-parameters.adoc[]
|
||||
include::{snippets}/caches/named/query-parameters.adoc[]
|
||||
|
||||
|
||||
|
||||
@@ -85,4 +85,4 @@ Otherwise, the `cacheManager` must be specified.
|
||||
The following table shows the supported query parameters:
|
||||
|
||||
[cols="2,4"]
|
||||
include::{snippets}/caches/evict-named/request-parameters.adoc[]
|
||||
include::{snippets}/caches/evict-named/query-parameters.adoc[]
|
||||
|
||||
@@ -45,7 +45,7 @@ The endpoint uses query parameters to <<metrics.drilling-down,drill down>> into
|
||||
The following table shows the single supported query parameter:
|
||||
|
||||
[cols="2,4"]
|
||||
include::{snippets}/metrics/metric-with-tags/request-parameters.adoc[]
|
||||
include::{snippets}/metrics/metric-with-tags/query-parameters.adoc[]
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ The endpoint uses query parameters to limit the samples that it returns.
|
||||
The following table shows the supported query parameters:
|
||||
|
||||
[cols="2,4"]
|
||||
include::{snippets}/prometheus/names/request-parameters.adoc[]
|
||||
include::{snippets}/prometheus/names/query-parameters.adoc[]
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ The endpoint uses query parameters to limit the sessions that it returns.
|
||||
The following table shows the single required query parameter:
|
||||
|
||||
[cols="2,4"]
|
||||
include::{snippets}/sessions/username/request-parameters.adoc[]
|
||||
include::{snippets}/sessions/username/query-parameters.adoc[]
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.docu
|
||||
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
|
||||
import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields;
|
||||
import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName;
|
||||
import static org.springframework.restdocs.request.RequestDocumentation.requestParameters;
|
||||
import static org.springframework.restdocs.request.RequestDocumentation.queryParameters;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
@@ -76,7 +76,7 @@ class AuditEventsEndpointDocumentationTests extends MockMvcEndpointDocumentation
|
||||
.param("principal", "alice").param("after", queryTimestamp).param("type", "logout"))
|
||||
.andExpect(status().isOk())
|
||||
.andDo(document("auditevents/filtered",
|
||||
requestParameters(
|
||||
queryParameters(
|
||||
parameterWithName("after").description(
|
||||
"Restricts the events to those that occurred after the given time. Optional."),
|
||||
parameterWithName("principal").description(
|
||||
|
||||
@@ -38,7 +38,7 @@ import org.springframework.restdocs.request.ParameterDescriptor;
|
||||
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
|
||||
import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields;
|
||||
import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName;
|
||||
import static org.springframework.restdocs.request.RequestDocumentation.requestParameters;
|
||||
import static org.springframework.restdocs.request.RequestDocumentation.queryParameters;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
@@ -55,7 +55,7 @@ class CachesEndpointDocumentationTests extends MockMvcEndpointDocumentationTests
|
||||
fieldWithPath("cacheManager").description("Cache manager name."),
|
||||
fieldWithPath("target").description("Fully qualified name of the native cache."));
|
||||
|
||||
private static final List<ParameterDescriptor> requestParameters = Collections
|
||||
private static final List<ParameterDescriptor> queryParameters = Collections
|
||||
.singletonList(parameterWithName("cacheManager").description(
|
||||
"Name of the cacheManager to qualify the cache. May be omitted if the cache name is unique.")
|
||||
.optional());
|
||||
@@ -74,7 +74,7 @@ class CachesEndpointDocumentationTests extends MockMvcEndpointDocumentationTests
|
||||
@Test
|
||||
void namedCache() throws Exception {
|
||||
this.mockMvc.perform(get("/actuator/caches/cities")).andExpect(status().isOk()).andDo(MockMvcRestDocumentation
|
||||
.document("caches/named", requestParameters(requestParameters), responseFields(levelFields)));
|
||||
.document("caches/named", queryParameters(queryParameters), responseFields(levelFields)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -87,7 +87,7 @@ class CachesEndpointDocumentationTests extends MockMvcEndpointDocumentationTests
|
||||
void evictNamedCache() throws Exception {
|
||||
this.mockMvc.perform(delete("/actuator/caches/countries?cacheManager=anotherCacheManager"))
|
||||
.andExpect(status().isNoContent())
|
||||
.andDo(MockMvcRestDocumentation.document("caches/evict-named", requestParameters(requestParameters)));
|
||||
.andDo(MockMvcRestDocumentation.document("caches/evict-named", queryParameters(queryParameters)));
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
|
||||
@@ -30,7 +30,7 @@ import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.docu
|
||||
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
|
||||
import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields;
|
||||
import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName;
|
||||
import static org.springframework.restdocs.request.RequestDocumentation.requestParameters;
|
||||
import static org.springframework.restdocs.request.RequestDocumentation.queryParameters;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
@@ -69,7 +69,7 @@ class MetricsEndpointDocumentationTests extends MockMvcEndpointDocumentationTest
|
||||
.perform(get("/actuator/metrics/jvm.memory.max").param("tag", "area:nonheap").param("tag",
|
||||
"id:Compressed Class Space"))
|
||||
.andExpect(status().isOk())
|
||||
.andDo(document("metrics/metric-with-tags", requestParameters(parameterWithName("tag")
|
||||
.andDo(document("metrics/metric-with-tags", queryParameters(parameterWithName("tag")
|
||||
.description("A tag to use for drill-down in the form `name:value`."))));
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.springframework.context.annotation.Import;
|
||||
|
||||
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
|
||||
import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName;
|
||||
import static org.springframework.restdocs.request.RequestDocumentation.requestParameters;
|
||||
import static org.springframework.restdocs.request.RequestDocumentation.queryParameters;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
@@ -62,7 +62,7 @@ class PrometheusScrapeEndpointDocumentationTests extends MockMvcEndpointDocument
|
||||
.perform(get("/actuator/prometheus").param("includedNames",
|
||||
"jvm_memory_used_bytes,jvm_memory_committed_bytes"))
|
||||
.andExpect(status().isOk())
|
||||
.andDo(document("prometheus/names", requestParameters(parameterWithName("includedNames")
|
||||
.andDo(document("prometheus/names", queryParameters(parameterWithName("includedNames")
|
||||
.description("Restricts the samples to those that match the names. Optional.").optional())));
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.docu
|
||||
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
|
||||
import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields;
|
||||
import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName;
|
||||
import static org.springframework.restdocs.request.RequestDocumentation.requestParameters;
|
||||
import static org.springframework.restdocs.request.RequestDocumentation.queryParameters;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
@@ -88,7 +88,7 @@ class SessionsEndpointDocumentationTests extends MockMvcEndpointDocumentationTes
|
||||
.andDo(document("sessions/username",
|
||||
responseFields(fieldWithPath("sessions").description("Sessions for the given username."))
|
||||
.andWithPrefix("sessions.[].", sessionFields),
|
||||
requestParameters(parameterWithName("username").description("Name of the user."))));
|
||||
queryParameters(parameterWithName("username").description("Name of the user."))));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user