0

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(RestDocumentationRequestBuilders.get("/accounts/{userId}",123)
.
.
.
.andDo(document("{methodName}",
                    preprocessRequest(prettyPrint()),
                    preprocessResponse(prettyPrint()),
                    pathParameters(
                            parameterWithName("userId").description("userId of the requested user.")

In my index.html, the path params are documented like I expect. What I found was that the table header of my path parameter docs is just the way I want it:

enter image description here

So had a look at the default snippets. Here I found the following:

Docs

So it seems that there is/was a problem with the curly brackets. I tried to copy that +{{path}}+ in a custom http-request.snippet. No success. I also tried to remove the nowrap option but again, the in the path the value shown insted of the variable name. Can someone tell me what might be the problem here? I hope I geave enough details.

FishingIsLife
  • 1,972
  • 3
  • 28
  • 51
  • To avoid anyone wasting time trying to answer this question, it was also cross-posted to GitHub issues: https://github.com/spring-projects/spring-restdocs/issues/706 – Andy Wilkinson Jan 11 '21 at 12:20
  • thanks for the hint @AndyWilkinson . I've implemented a solution so far but how can I make spring boot use my CustomHttpRequestSnippet class instead of the one provided by rest docs? – FishingIsLife Jan 11 '21 at 19:51
  • I've updated my comment on the GitHub issue. You can configure the default snippets as described in the references documentation: https://docs.spring.io/spring-restdocs/docs/current/reference/html5/#configuration-default-snippets – Andy Wilkinson Jan 12 '21 at 11:38
  • Thanks. I've created a new Question https://stackoverflow.com/questions/65680019/spring-rest-docs-error-when-creating-custom-templatesnippet It'll be kind if you may have a look at it. It's basically about the implementation and the including process – FishingIsLife Jan 12 '21 at 13:14
  • @AndyWilkinson I tried the solution but now all my Mockito Mocks are null. I updated my question – FishingIsLife Jan 12 '21 at 14:08
  • Repeatedly editing your question so that it's a moving target isn't a good way of getting help. Please ask separate questions that are as small and as focussed as possible, including a [minimal, reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) each time. – Andy Wilkinson Jan 12 '21 at 14:26
  • Ok, sorry I thought it is the same context and still not solved. I create another – FishingIsLife Jan 12 '21 at 14:27

0 Answers0