Reputation: 14678
I am getting a weird exception with a trouble on non-existing field either on my response or request. I have configuration setup to generate snippets for response/requests on my endpoints with documentation on the fields of those beans. Except I am getting the following exception from org.springframework.restdocs.mustache
package;
MustacheException$Context: No method or field with name 'required' on line 6
I have no 'required'
field declared anywhere on my descriptor snippets, or within my request/response beans, and what is the deal with line 6
? What a mysterious exception! What is the issue here?
Upvotes: 2
Views: 2019
Reputation: 11
I had the same issue and for 2 hours couldn't findout! until didn't inspect attentively my "template.mustache" and found an extra usage of "required" field (actually, my field had another name, but I adapted it for your case). The thing was happended because I've changed the type of providing data: before I used a simple fields, but later started to use a "section" to iterate over list, but in another place in my template (it was a in the webpage header) I forgot to change it's output.
I think, it's very common cause of such an errors, especially if you don't use hightlighting a html code of your mustache templates.
Upvotes: 0
Reputation: 14678
The trouble stemmed from a custom request-parameters
template, in src/test/resources/org/springframework/restdocs/templates/
resource folder. Due to the addition of a custom field within the template of request descriptor, the lack of this field was causing the issue. List 6
was where the 'request'
field was being used within this file, thus the error.
Removing the custom template to let REST Docs use its default template resolved the issue.
Upvotes: 1