ePages-de / ePages-de/restdocs-api-spec
MockMvcRestDocumentationWrapper doesn't seem to deal with "relaxed" fields
- Dominant language
- Kotlin
- Stars
- 427
- Forks
- 116
- Avg merge
- 23h 54m
- Merged PRs (30d)
- 1
Description
This is probably a feature request more than anything.
When the MockMvcRestDocumentationWrapper.document drop in replacement is used in snippets like below, the tests start generating errors despite the relaxed* factories for snippets used
```
this.getMockMvc().perform(
RestDocumentationRequestBuilders.post(copyHref).headers(getMockMvcHeaders(super.getTestToken()))
.content(locatorjson).accept(APPLICATION_HAL_JSON)
.contentType(APPLICATION_HAL_JSON))
.andDo(
document("file/copy_file", REQUEST_PREPROCESSOR, RESPONSE_PREPROCESSOR,
requestHeaders(
headerWithName(HttpHeaders.AUTHORIZATION).description(""),
headerWithName(HttpHeaders.ACCEPT).description("")
),
responseHeaders(
headerWithName(HttpHeaders.CONTENT_TYPE)
.description(""),
headerWithName(HttpHeaders.LOCATION).description("")
),
relaxedRequestFields(
fieldWithPath("href").description(""),
fieldWithPath("name").optional().description("")
)
)
)
.andExpect(status().isCreated()).andReturn();
```
then with the request
```
Accept: application/hal+json
{
"href" : "value1",
"id" : null,
"name" : "value2",
"allRenditions" : false
}
```
I see the following error
```
The following parts of the payload were not documented:
{
"id" : null,
"allRenditions" : false
}
```
when undocumented fields that are in request in this case should be ignored (we have some defaults in the input beans that we don't care about and want omitted in this case).
The same happens for other factories like
```
org.springframework.restdocs.hypermedia.HypermediaDocumentation#relaxedLinks(org.springframework.restdocs.hypermedia.LinkDescriptor...)
org.springframework.restdocs.payload.PayloadDocumentation#relaxedResponseFields(org.springframework.restdocs.payload.FieldDescriptor...)
```
etc
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.