Spring REST Docs takes a test-driven approach to documenting RESTful APIs. It uses Spring MVC Test, Spring WebFlux’s WebTestClient or REST Assured to generate accurate, tested documentation snippets that can then be included in documentation written in Asciidoctor or Markdown. Use this tag for questions about Spring REST Docs and its interaction with one of the test frameworks and markup languages.
Questions tagged [spring-restdocs]
274 questions
4
votes
2 answers
Auto generate REST api documentation into RAML from Spring MVC controllers
I am new to Spring-Boot. I want to auto generate my REST api documentation into RAML from my Spring MVC controllers. Is there anything to do that? or any guide that I could use it for generating my rest api into RAML?
user6941415
4
votes
1 answer
Document each element of an array using spring-restdocs
I'm having a response which is an json array. Each element has it's meaning and I would be able to describe it.
My array:
["1525032694","300","true"]
I've found an example in the documentation that describes an array and each element which is the…

pixel
- 24,905
- 36
- 149
- 251
4
votes
1 answer
How to generate Java REST client from Spring REST Docs like it is generated from swagger.json?
My team used swagger for documenting REST API.
As a QA engineer I was able to generate rest client from swagger.json that was published on remote server upon deploy and use the client for REST API integration testing.
Now we are about to switch from…

ludenus
- 1,161
- 17
- 30
4
votes
1 answer
SpringRestDoc SnippetException: Fields with the following paths were not found in the payload:
I have following problem with SpringRestDoc spring-restdocs-mockmvc version 2.0.0.RELEASE
org.springframework.restdocs.snippet.SnippetException: Fields with the following paths were not found in the payload: [listName[].k1]
The result is
Body =…

user2877911
- 43
- 1
- 4
4
votes
1 answer
How could i document java.util.Map using spring docs
Imagine I have next class
public class MyDTO implements Serializable {
private static final long serialVersionUID = 1L;
private String id;
private Map names;
// public Getters and Setters
}
When I use the next…

mibrahim.iti
- 1,928
- 5
- 22
- 50
4
votes
2 answers
conditional include in asciidoc
I am using Spring RestDoc together with AsciiDoc to describe my rest api. RestDoc generates different files depending if there are request parameters described / response fields etc. I would like to have one template conditionally including whatever…

wrm
- 1,898
- 13
- 24
4
votes
1 answer
How can I document the cookie using spring-restdoc?
I use the current version spring-restdoc: 1.1.2.RELEASE.
I created an API that needs a cookie in the header. Here is my controller:
@RequestMapping(value = "/{username}/userInfo", produces = {APPLICATION_JSON_UTF8_VALUE}, method =…

Pascale Borscia
- 51
- 1
4
votes
1 answer
spring-rest-docs application is not generating snippets when run or integration tested
My test class is
package com.htc.spring.rest.docs;
-------
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes=CrudRestDemoApplication.class)
@WebAppConfiguration
@IntegrationTest
public class…

raja
- 61
- 1
- 4
4
votes
2 answers
how to write spring-restdocs snippets with MockMultipartFile
I use spring unit test with spring-restdocs.
this is my mockmvc code:
mockMvc.perform(fileUpload("/api/enterprise/uploadImage")
.file(imageFile)
.with(csrf().asHeader())
…

Joseph Wang
- 41
- 1
- 2
4
votes
1 answer
HttpRequestMethodNotSupportedException: Request method 'POST' not supported
Creating a unit test with MockMvc I am running into:
HttpRequestMethodNotSupportedException: Request method 'POST' not supported
Which causes the test case to fail expecting a '200' but getting a '405'. Some of the additional things you may see in…

mstelz
- 610
- 4
- 9
- 19
4
votes
1 answer
Asciidoctor 'snippets' attribute not found from gradle
I'm following the directions in the Spring Rest Docs reference doc with regards to the build configuration. But the 'snippets' attribute doesn't appear to be exposed to Asciidoctor when I try to do
include::{snippets}/....
but I get an asciidoctor…

Les
- 487
- 1
- 10
- 22
4
votes
1 answer
Custom Jackson module not used in Spring REST docs test
I have written a small test on Spring REST docs with custom Jackson module (using Spring Boot 1.3). In my application main class, I only have @SpringBootApplication. I then have another class JacksonCustomizations that looks like…

Wim Deblauwe
- 25,113
- 20
- 133
- 211
4
votes
1 answer
How to make a request parameter optional in Spring REST Docs
I know fieldWithPath() has optional() but didn't find how to make parameterWithName() optional.

Johnny Lim
- 5,623
- 8
- 38
- 53
4
votes
2 answers
document hierarchical JSON payload with Spring REST Docs
I started to use Spring REST Docs to document a simple REST API. I have a payload that has some hierarchical structure, for example like this (company with employees).
{
"companyName": "FooBar",
"employee":
[
{
…

FrVaBe
- 47,963
- 16
- 124
- 157
3
votes
2 answers
Docker Image created by Google JIB did not include asciidoc of spring rest docs
I use Spring Rest Docs and JIB
When i do ./gradlew build and java -jar /some/build/libs/app.jar. I can get api documents generated by spring rest docs at example.com/docs/asciidocname.html.
but docker image with ./gradlew jib does not contain this…

labyu
- 43
- 5