ePages-de / ePages-de/restdocs-api-spec

ascii doc response-fields.adoc missing when using only ResourceDocumentation.resource

Open
#169 2 comments 0 reactions 0 assignees View on GitHub
bug help wanted question
Dominant language
Kotlin
Stars
427
Forks
116
Avg merge
23h 54m
Merged PRs (30d)
1

Description

Hi,

Initially, I was using classes from spring-restdocs to document an api and the generated snippets used to include every type of asciidoc needed, including the files response-fields.adoc. Then, I switched to ResourceDocumentation to be able to specify the schema.
Here is an example :

```java

@Test
public void getDriver() throws Exception {
WebTestClient.BodySpec driverBodySpec = webClient.get().
uri("/drivers/{id}", 1).
accept(MediaType.APPLICATION_JSON).
header("HEADER", "value").
exchange().
expectStatus().isOk().
expectBody(Driver.class).
consumeWith(
WebTestClientRestDocumentationWrapper.document(DOCUMENT_IDENTIFIER, "get a driver by its id",
ResourceDocumentation.resource(
ResourceSnippetParameters.
builder().
requestHeaders(
HeaderDocumentation.
headerWithName("HEADER").
optional().
description("optional header when retrieving a driver")
).
pathParameters(
ResourceDocumentation.
parameterWithName("id").
description("the id of a driver").
type(SimpleType.INTEGER)
).
responseFields(this.driverFieldDescriptors).
responseSchema(Schema.schema("Driver")).
build()
)
// todo : find a way to avoid duplication : if not there, no response-fields.adoc generated
, PayloadDocumentation.responseFields(this.driverFieldDescriptors)
));
driverBodySpec.consumeWith(body -> Assertions.assertEquals(driverJohnDOE, body.getResponseBody()));
}
```

I realized that I have to duplicate the responseFields in order for the response-fields.adoc to be generated.

Is there another way to do the same without duplicating this part?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.