I’m trying to document the API using Spring RESTDocs on Spring 3.3.2.
However, the following error appears.
Query parameters with the following names were not found in the request: [password, driverId, loginState, regId, deviceDiv]
org.springframework.restdocs.snippet.SnippetException: Query parameters with the following names were not found in the request: [password, driverId, loginState, regId, deviceDiv]
And source code here.
@DisplayName("기사 로그인 API")
@Test
void checkMatchLogin() throws Exception {
//given
given(driverService.driverLogin(
anyInt(),
anyString(),
anyInt(),
anyInt(),
anyString(),
anyString())).willReturn("true");
mockMvc.perform(
// when
RestDocumentationRequestBuilders.post("/api/driver/login")
.param("driverId", "2")
.param("password", "2222")
.param("loginState", "1")
.param("deviceDiv", "1")
.param("regId", "please_input_gcm_code")
)
// then
.andDo(print())
.andExpect(status().isOk())
.andDo(document("driver-login",
preprocessResponse(prettyPrint()),
queryParameters(
parameterWithName("driverId").description("driverId"),
parameterWithName("password").description("password"),
parameterWithName("loginState").description("loginState"),
parameterWithName("deviceDiv").description("deviceDiv"),
parameterWithName("regId").description("GCM Key")
),
responseFields(
fieldWithPath("code").type(JsonFieldType.NUMBER)
.description("code"),
fieldWithPath("message").type(JsonFieldType.STRING)
.description("message"),
fieldWithPath("data").type(JsonFieldType.BOOLEAN)
.description("data")
)
));
}
I looked up official documents and searched stack overflow, but I couldn’t find them.
Is it too simple for me to find it?
Give them a hand.
Thank you.
Reference check
- https://docs.spring.io/spring-restdocs/docs/current/reference/htmlsingle/#documenting-your-api-query-parameters
Change Parameters : queryParameters
- relaxedQueryParameters : not worked
- requestParameters : not worked
New contributor
Soo-Bin Kong is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.