protected Set < ResponseMessage > read ( OperationContext context ) { Set < ResponseMessage > ret ; try { PathMatchingResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver ( ) ; Resource [ ] resources = resourceResolver . getResources ( "classpath*:" + context . getName ( ) + "*/http-response.springfox" ) ; // TODO: restdocs in safe package name, not directly under restdocs ret = Arrays . stream ( resources ) . map ( toRawHttpResponse ( ) ) . filter ( Objects :: nonNull ) . collect ( Collectors . collectingAndThen ( toMap ( RawHttpResponse :: getStatusCode , mappingResponseToResponseMessageBuilder ( ) , mergingExamples ( ) ) , responseMessagesMap -> responseMessagesMap . values ( ) . stream ( ) . map ( ResponseMessageBuilder :: build ) . collect ( Collectors . toSet ( ) ) ) ) ; } catch ( Exception e ) { LOG . warn ( "Failed to read restdocs example for {} " + context . getName ( ) + " caused by: " + e . toString ( ) ) ; ret = Collections . emptySet ( ) ; } return ret ; }
Provides response messages with examples for given single operation context .