spring-projects / spring-restdocs

Test-driven documentation for RESTful services
https://spring.io/projects/spring-restdocs
Apache License 2.0
1.16k stars 734 forks source link

Support for Messaging controllers #373

Open Polve opened 7 years ago

Polve commented 7 years ago

Controllers using MessageMapping(s) instead of rest endpoint have very similar requirements for documentation. Could spring-restdocs be used for those controllers too?

wilkinsona commented 7 years ago

There's nothing available out-of-the box for this, but I'm not against adding something. The name REST Docs is already stretched as you can document any HTTP-based API not just those that are RESTful. Stretching things further to include @MessageMapping-based controller doesn't seem unreasonable to me.

It would be interesting to see how far things could get by writing a ChannelInterceptorAdapter subclass and turning the messages it intercepts into a REST Docs Operation. It'll break down quite quickly in some areas (pub-sub vs request-response, for example), but I think it may still be a useful exercise.

dsyer commented 7 years ago

A ChannelInterceptorAdapter could cover Spring Integration as well, which would be neat. Spring Cloud Contract already has support for "stubs" on messages, but not the documentation part, so a generic messaging adapter (perhaps something that can cover Spring AMQP and Spring Kafka as well) would be awesome.

dsyer commented 6 years ago

I made some sample apps and got them working with Spring Cloud Stream (and Contracts): https://github.com/dsyer/spring-restdocs-messaging