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
3
votes
2 answers
No such snippet is present in configuration warning
I'm doing documentation using Spring rest auto docs and AsciiDoc. Below is my error message
Error Message
Section snippet 'auto-method-path' is configured to be included in the section but no such snippet is present in configuration
Section snippet…

Rui Fernandes
- 51
- 7
3
votes
1 answer
How to create a curl snippet with Spring REST Docs to use double quotes instead of single ones?
Spring REST Docs is a very nice way to create up-to-date API documentation. It also generates code snippets from your test code, that you can insert into your API documentation. When a user of your API reads your documentation they can easily…

Karel
- 33
- 4
3
votes
1 answer
Adding path to base url in Spring Rest Docs?
I have following configuration to use with Rest Docs:
webTestClient = buildWebClient().mutate()
.filter(documentationConfiguration(restDocumentation))
.baseUrl("https://api.my-domain.com/")
.build()
In my case I use path prefix to my service…

pixel
- 24,905
- 36
- 149
- 251
3
votes
4 answers
java.lang.AssertionError: Status expected:<200> but was:<404> in Junit test
I want to create JUnit test for Rest api and generate api doc. I want to test this code:
Rest controller
@RestController
@RequestMapping("/transactions")
public class PaymentTransactionsController {
@Autowired
private PaymentTransactionRepository…

Peter Penzov
- 1,126
- 134
- 430
- 808
3
votes
1 answer
Authorization header not found using Rest Assured and Spring Rest Docs
I am using Rest Assured to set the an authorization header and authenticate with client id and client secret using OAuth2. The Authorization is being sent to my application in my test, but my test fails if I use Spring Rest Docs to check for the…

secondbreakfast
- 4,194
- 5
- 47
- 101
3
votes
1 answer
Maven: How to test that generated documents in target folder are properly generated?
I've got a Java/Maven project that uses RestDocs to generate documentation of our endpoints.
For the uninitiated of RestDocs, what it does is monitor tests during the build and use information from the tests to generate "snippets" that get used to…

TonyRedYellow
- 41
- 4
3
votes
1 answer
Spring Rest Docs snippet template is ignored
I am attempting to be able to create custom snippet template for Spring Rest Docs documentation purposes. I have been following the reference guide
My first problem I ran into was in IntelliJ when creating a .snippet file in…

shirafuno
- 387
- 3
- 9
- 24
3
votes
0 answers
Spring-auto-restdocs have response fields link to objects instead of flattening them
Currently, when using Spring Auto REST Docs to generate response fields, all objects are flattened out into the response. For example consider these two classes:
public class Foo {
private Bar bar;
/** Returns the bar. */
public Bar…

Bram
- 988
- 7
- 10
3
votes
1 answer
Spring Boot Swagger: How to ignore certain API's from swagger based on spring profile?
Currently, there are certain private API's in my controller class which I need to ignore them in my production environment, whereas needed in the QA and Dev environments.
I'm using @ApiIgnore annotation from spring fox to achieve this on a global…

shoaib1992
- 410
- 1
- 8
- 26
3
votes
0 answers
Is it possible to use REST Docs, REST Assured and kotlin ktor together?
Info about technologies available here:
Spring REST Docs link
Rest Assured link
Ktor backend link
Main question is:
Can I generate documentation with json payloads for ktor backend like I did it for Spring backend using Spring Rest Docs
Spring…

nail
- 715
- 7
- 20
3
votes
3 answers
Publish spring-restdocs html documentation with application
I have spring-boot application with spring-restdocs and I want to create endpoint in that application for generated documentation. What is the best approach to expose endpoint with generated html documentation(by asciidoctor)?
I can include…

Игорь Кравченко
- 43
- 5
3
votes
1 answer
Transitive dependency pulling in lower version than declared in POM
I am using version 1.2.2 of spring-restdocs-mockmvc in my Spring Boot application that I am developing with IntelliJ.
Taking a look at its POM, it declares the following dependency of spring-restdocs-core:
But for some reason, the compile version…

secondbreakfast
- 4,194
- 5
- 47
- 101
3
votes
5 answers
Unable to generate the Spring rest docs using Cucumber
I am trying to test spring rest documentation for rest API for our services using spring cucumber jvm but end up with a null pointer exeception when I try to execute the scenario, as the framework is not able to intialize the Junit context.
Error…

ravi
- 81
- 6
3
votes
1 answer
How to document REST services with Spring REST Docs that return a response conditionally?
I've a REST service that has an access limit per resource. Let's say that I've the following service:
GET /record/{recordId}
An access count per record is defined and when the limit is reached, it returns an exception.
I wrote an integration test…

Alper Kanat
- 376
- 1
- 2
- 16
3
votes
1 answer
How to hide section title in Asciidoctor?
I've searched, but I can't find a way to hide the section title on the main page, and to only display in the Table of Contents (:toc:). As seen from this screenshot, Home and Test are external links to the adoc files. I want to only keep it in the…

Tda
- 33
- 7