JDK 17
or higher is requiredSpring Boot 3.X
is required
testImplementation("io.github.hejow:easy-restdocs-generator:1.0.0")
<dependency>
<groupId>io.github.hejow</groupId>
<artifactId>easy-restdocs-generator</artifactId>
<version>1.0.0</version>
<scope>test</scope>
</dependency>
Only you have to do is Customize tags and Use builder.
To specify your api, easy-restdoc use ApiTag
to generate documents.
// example
public enum MyTag implements ApiTag {
USER("user api");
private final String content;
// ... constructor
@Override
public String getName() {
return this.content;
}
}
After test with mockMvc
just use builder to generate as like below.
Planning to support RestAssured
.
To generate documents you MUST put
tag
,result
onBuilder
.If you don’t put
identifier
onBuilder
, Method name of the test you wrote will be used asidentifier
Tests MUST run with rest-docs settings such as
@ExtendWith(RestDocumentationExtension.class)
(see here)
// example
@Test
void myTest() throws Exception {
// given
// when
var result = mockMvc.perform(...);
// then
result.andExpectAll(
status().isOk(),
...
);
// docs
result.andDo(
Document.builder()
.identifier("identifier of your API") // Can skip
.tag(MyTag.USER) // Custom tags
.summary("this will be name of API")
.description("write description about your API")
.result(result) // Test result
.buildAndGenerate()
);
}