Questions tagged [spring-restdocs]

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.

Filter by
Sorted by
Tagged with
0 votes
0 answers
81 views

I don't know if MockMvc is not autowired when writing test code using spring rest docs

I tried to write a test code using 'rest docs' in Spring Boot with kotlin. I am having an issue with injecting MockMvc to my test class. No qualifying bean of type Shouldn't @AutoConfigureMockMvc, @...
rwabe213's user avatar
1 vote
1 answer
196 views

Spring Boot 3 with RESTDOCS

I was using spring-restdocs with SB2.7.9 Now we migrated to SB3.0.6. I am using gradle plugin (kotlin DSL) id("org.asciidoctor.jvm.convert") version "3.3.2" Libraries are versions: ...
Gondri's user avatar
  • 173
0 votes
1 answer
89 views

mockMVC test code I wrote call other controller's api (maybe)

First I ask for your understanding of my poor eng. I'm writing test code for make api specification by Spring Rest Docs library. plugins { id 'java' id 'org.springframework.boot' version '2.7....
Chanmi's user avatar
  • 1
0 votes
1 answer
275 views

Spring REST Docs: how to documentation multipart form list parameter?

How to documentation form list parameter? Controller @PostMapping("/sample") public void post(@ModelAttribute PostRequest request) { // ... } @Data public static class PostRequest { ...
LuxusIo's user avatar
2 votes
1 answer
112 views

Adding extra information in Spring Rest-Docs using Attributes failing

I'm generating documentation for APIs that are written in Python. I am using Spring Rest-Docs for this which works flawless. Now I must add a list of roles that are authorized to call the API to each ...
Arc-E-Tect's user avatar
1 vote
1 answer
1k views

How to load openapi local files into swagger on localhost? (Files generated by restdocs)

I have my api documentation generated by restdocs through unit tests. Although it works fine for most of my needs, I'm still lacking a bit of the nice swagger features, so I was trying to have the ...
Francislainy Campos's user avatar
0 votes
0 answers
23 views

How to check a json response contains a text using RestDocs

I'm using Spring RestDocs to validate my APIs against their specification. All works well and for some of the APIs I am verifying that some of the fields have specific values. An example would be: @...
Arc-E-Tect's user avatar
0 votes
0 answers
273 views

gradle bootjar task does not update the jar file

plugins { id 'org.springframework.boot' version '2.7.3' id 'io.spring.dependency-management' version '1.0.13.RELEASE' id "org.asciidoctor.jvm.convert" version "3.3.2" ...
coconut's user avatar
0 votes
1 answer
111 views

Spring REST Docs - Add p12 certificate in Curl Snippet

I am using MockMVC and Spring REST docs and am trying to generate a curl snippet that has the certificate in it. I imagine the certificate portion of the curl statement should look something like: --...
rr_nm's user avatar
  • 26
0 votes
0 answers
53 views

NoSuchBeanDefinitionException `HttpSecurity` after adding `spring-restdocs-mockmvc` dependency

I have a spring boot application which have different folders for repository, service and api controller. The DB is Postgress and we are using Gradle as our build tool. The test cases for repository ...
priyanka garg's user avatar
1 vote
1 answer
125 views

Best practice to send the input request to POST endpoint

Iam creating a POST endpoint named /transactions which should accept the below input. What is the best practice to send the input request like the below? Should i use a request body or a input stream ...
chetan's user avatar
  • 55
0 votes
1 answer
131 views

Is there any solution for converting openapi3 to Restdocs(adoc)?

I could convert openapi2 to adoc with Swagger2Markup, but it support only openapi2, not 3. https://github.com/Swagger2Markup/swagger2markup/issues and I read some issues on it, and i guess it still ...
tofan's user avatar
  • 17
2 votes
2 answers
383 views

Spring boot document configuration properties

I'm trying to automatically document my configuration properties in order to create a html like the one on spring boot appendix for it's configuration. I see that I can enable configuration metadata ...
Luca's user avatar
  • 331
0 votes
1 answer
96 views

How to authenticate with a bearer token when using Spring Rest Docs

Can I use Spring RestDocs to document APIs when the authorization mode is bearer? A pointer to a simple example would be appreciated, it doesn't seem the be available on the Spring RestDocs pages. ...
Arc-E-Tect's user avatar
0 votes
0 answers
221 views

Is there any way to mask body content in Spring Rest Docs?

I am using JWT authentication with Spring Security, where authentication requests have to contain the username and password in their body. I do not want the credentials I use in the test to be ...
Drason's user avatar
  • 41
0 votes
0 answers
63 views

how can I specify that an input parameter depends on another parameter

In my Rest Service i could have request country parameter by two way On in subOject from main User Object and an other way friendly is country code in String Could i in Spring RestsDocs says if ...
phil pcs's user avatar
1 vote
1 answer
185 views

[spring-rest-docs]: Problem documenting a Map<Object, Set<Object>>

I have a hard time trying to document the following: { "virtualFaxPermissions" : { "SOME_RANDOM_UUID" : [ "SOME_SPECIFIC_PERMISSION" ] } } I have tried to put a ...
Dave's user avatar
  • 95
0 votes
0 answers
120 views

Open webpages generated by restdocs

I want to display static pages using Spring Boot. I tried this configuration: plugins { id "java" id "org.asciidoctor.jvm.convert" version "3.3.2" } repositories ...
Peter Penzov's user avatar
1 vote
1 answer
3k views

Springdoc with a generic return type

I have a custom Page to return when the user does a query with a Pageable. This Page has a generic parameter and I want to specify it in my Swagger documentation. Here is the current result: Where ...
Oromis's user avatar
  • 196
0 votes
1 answer
329 views

How to document a Map with Enum as key entry?

I am doing documentation for a REST service that returns this kind of JSON: { "CKM_RSA_PKCS_OAEP" : { "keyType" : "RSA", "canGenerateKey" : false, ...
3ric-T's user avatar
  • 31
0 votes
1 answer
927 views

How to document path parameters both in the uri and in the query string?

In a JUnit 5 test, I'm trying to document my Spring Boot application API with the following: (...) this.webTestClient = WebTestClient.bindToApplicationContext(applicationContext) ....
3ric-T's user avatar
  • 31
0 votes
1 answer
530 views

Rest doc for PUT request with request param but without request body setting content type as form url encoded

I have noticed that rest doc (HttpRequestSnippet.java) is setting APPLICATION_FORM_URLENCODED_VALUE as content type for PUT with request parameter and without request body. This should be corrected, ...
Venkat Bontha's user avatar
1 vote
2 answers
418 views

Specify custom snippet directory for spring-restdocs-asciidoctor?

I have configured a custom snippet directory with RestDocumentationExtension. How can I specify this snippet directory for the spring-restdocs-asciidoctor?
Harold L. Brown's user avatar
0 votes
1 answer
129 views

Creating snippet for shared model

Is it possible to generate snippet for a nested bean shared between different response structures ? Address model class Address { String state; Integer postcode; } Response from endpoint 1 (R1) { ...
Hasnain's user avatar
  • 1,909
7 votes
1 answer
2k views

Configuring asciidoctor when using Spring Restdoc

I'm adopting Spring Rest Docs and the test successfully created *.adoc files. I made api-guide.doc file in src/docs/asciidoc directory to create html, but when I run asciidoc as a gradle task, it ...
pepsi's user avatar
  • 191
0 votes
1 answer
216 views

Can we Document Model/entity with using Spring rest docs

Writing all fields with the snippets description is not reliable solution is there any way to implement Model/Entity as a table with the fields and description, constraints, Type seprately. ...
Saurabh Kohade's user avatar
0 votes
1 answer
351 views

How to convert generated-snippets .adoc files to html in src/docs/asciidoc using gradle project

I am facing the issue while working with the asciidoc for my spring rest docs implemetation my adoc files as per my test cases is created in build/generated-snippets. I am having issue with creating ...
Saurabh Kohade's user avatar
0 votes
2 answers
462 views

How to Disable Spring Rest Docs

PROBLEM I use Spring Rest Docs in my project. It is useful at development stage, but i don't want it to be available for ordinary users and search engines in production. RESEARCH I see no robot meta ...
Zon's user avatar
  • 18.7k
0 votes
1 answer
85 views

How i can document inner collection constraints in spring auto restdocs

I'm trying to document inner constraint for Collections (NotBlank and Size) like: @Valid private List<@NotBlank @Size(min = 1, max = 100) String> someAnotherUsefulInformationList; Can I do ...
Grigorii Riabov's user avatar
0 votes
1 answer
1k views

Spring AutoConfigureRestDocs additional configuration

I am generating documentation using Spring REST docs and I am using the new annotation @AutoConfigureRestDocs instead of explicitly defining in the @BeforeEach method. The below test is currently ...
ashley's user avatar
  • 1,008
2 votes
1 answer
1k views

How to collapse TOC(table of contents) in spring RestDoc (asciidoc)?

I had used SpringRestDoc and want to collapse Table of Contents. Below my index.adoc = Service Rest Docs API Document :doctype: book :icons: font :source-highlighter: highlightjs :toc2: left :theme: ...
bbuljj's user avatar
  • 93
0 votes
1 answer
765 views

When using spring rest docs, how do I make a newline in the description?

I tried \n or br tag to make a newline, but it doesn't work. requestParameters( parameterWithName("name").description("This is the description <br/> in the table.&...
Nick's user avatar
  • 235
0 votes
1 answer
917 views

Optional on response FieldDescriptor not working as expected

I'm having trouble documenting optional response fields with Spring Docs. My test code: mockMvc.perform(get("/foo").accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) ...
user871611's user avatar
  • 3,319
1 vote
2 answers
2k views

Spring webflux testing

I have a Spring webflux application with the service below. @Configuration public class RouterConfiguration { @Autowired private RegistrationHandler regHandler; @Bean public ...
user1578872's user avatar
  • 7,988
0 votes
1 answer
580 views

Spring webflux restdocs - By passing security for test cases

I am using Spring webflux security for my application and trying to write Spring webflux restdocs. Getting unauthorized error for test cases. Is there anyway to by pass security for rest doc test ...
user1578872's user avatar
  • 7,988
0 votes
1 answer
805 views

Spring Rest Doc (Gradle) Snippets disappear upon build

Recently switch to Gradle from Maven. Following this tutorial for continuous REST Doc build with Gradle. https://www.youtube.com/watch?v=k5ncCJBarRI&t=1490s Snippets are generating just fine when ...
Eric Huang's user avatar
  • 1,114
0 votes
1 answer
449 views

Spring REST Docs + RequestBody + Prevent deep-level documentation of fields

i have problems with Spring REST Docs and preventing deep-level documentation of fields within a request body: @Transactional @RequestMapping(path = "/edit", method = RequestMethod.POST) ...
alex_steward's user avatar
0 votes
0 answers
915 views

Spring rest docs request url shows value for path parameter instead of the parameter name

I use spring rest docs to document my api. Now I want to document my document my path in the form of .../accounts/{userId} but I get .../accounts/123 The test part look as follows: mockMvc.perform(...
FishingIsLife's user avatar
2 votes
1 answer
213 views

Integration tests create files for the packaged jar

I'm generating spring-restdocs snippets with rest assured in my integration tests. With maven and the failsafe plugin that defaults to the integration-test and verify phase. Problem is, that ...
Simon Lenz's user avatar
  • 2,762
0 votes
0 answers
443 views

Spring Rest docs ignore request body fields in documentation

I have the followin situation: My Endpoint consumes an Object A that results in the backend depending on the requesting user to Object B or C. So the problem is, that Object A has all the fields of ...
FishingIsLife's user avatar
0 votes
0 answers
524 views

Spring Rest docs custom snippets are ignored

Setup: Intellij IDE community Spring Boot 2.4.0 Spring rest docs Hi, I use spring rest docs in all my services. The problem is that in one of them, the custom snippets are ignored and I just don't ...
FishingIsLife's user avatar
0 votes
1 answer
505 views

Springdoc OpenAPI displays class relationships under schemas and examples

I am using springdoc-openapi for REST API documentation. I have two classes which has One to One relationship between them. After I create the API, When I use the API. It returns exactly the way it ...
pavan sai's user avatar
0 votes
1 answer
122 views

Why do Spring ResDocs FieldDescriptor don't gather constraint on inner objects?

currently I'm struggling with a FieldDescriptor which seem not to "see" all validation constraints. Following scenario: I have an Dto similar to: @Data @AllArgsConstructor @NoArgsConstructor ...
hilbert's user avatar
  • 266
1 vote
1 answer
570 views

How to parse a string array with Mustache Template Lambda in java

I am currently working on implementing a Mustache Lambda to parse this object: [{name=Content-Type, value=application/hal+json;charset=UTF-8}, {name=Content-Length, value=906}] My template lambda ...
Evan Gertis's user avatar
  • 1,846
1 vote
3 answers
1k views

Asciidoc numbered sections, but only part of document

I'm using Ascii doc to make rest documentation with Spring Restdocs. I have an overview section and then a section with operations. I want the operations to have numbered sections, but I don't want ...
Jeff Walker's user avatar
  • 1,658
3 votes
2 answers
787 views

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 ...
labyu's user avatar
  • 43
1 vote
1 answer
695 views

Spring rest docs failing to document pathParameters using WebTestClient

After upgrading to Spring-test-5.3.0-SNAPSHOT, spring rest docs is failing to document path parameters complaining it can't find urlTemplate. webTestClient.mutateWith(csrf()).get() .uri("/...
wn.ab's user avatar
  • 21
2 votes
1 answer
1k views

Asciidoctor "Snippets" is missing in Maven

When I run the test case then requests and responses of adoc type will be created and displayed in JSON format under the generated-snippets directory. when I run this mvn command mvn clean package to ...
Nafaz M N M's user avatar
  • 1,568
0 votes
1 answer
319 views

Test Case Fail in Junit with Spring Rest Docs

I have implemented a sample application and test it by using JUnit with spring rest docs. When I make a Rest API call through postman the result is retrieved successfully and when I do the same thing ...
Nafaz M N M's user avatar
  • 1,568
0 votes
1 answer
333 views

in spring boot + rest docs, how to set '.html' suffix

this is example repository. https://github.com/JYK0128/Debug-Projects/tree/master/Spring_RestDocs_Example I try to Make resolver bean OR Set Profiles. I did mapping resource. just in cases. try first....
Jinyong Kim's user avatar

1
2 3 4 5 6