spring-restdocs

[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 reference of the same map I used to construct the object but it didn't help:

final Map<VirtualFaxMachineId, Set<VirtualFaxMachinePermission>> virtualFaxPermissionsSetMap = new HashMap<>();
virtualFaxPermissionsSetMap.put(VirtualFaxMachineId.valueOf(SOME_RANDOM_UUID), Set.of(SOME_SPECIFIC_PERMISSION));
user.setVirtualFaxPersmission(virtualFaxPermissionsSetMap);
.....
fieldWithPath("virtualFaxPermissions").description(virtualFaxPermissionsSetMap)

Error i get is that the part above is not documented in the payload.

org.springframework.restdocs.snippet.SnippetException: The following parts of the payload were not documented:
{
  "virtualFaxPermissions" : {
    "RANDOM_UUID_GENERATED" : [ "REQUESTED_PERMISSION" ]
  }
}

at org.springframework.restdocs.payload.AbstractFieldsSnippet.validateFieldDocumentation(AbstractFieldsSnippet.java:218)

I have tried to document using a wildcard for the UUDI, but that didn't help either

Thanks for any pointers


Solution

  • as per: https://github.com/spring-projects/spring-restdocs/issues/793

    using subsectionWithPath("virtualFaxPermissions")

    did the trick