As a part of my development activity involving the creation of a REST API using Spring Integration, I am trying to explore the possibility of documenting the API. Upon reading online, I had a couple of questions as follows: 1) Can the Spring REST Docs module be used to document Spring Integration components like HTTP inbound gateways? 2) If yes, can this be accomplished without Spring Boot? My team's general direction is to use pure Spring (without Boot) and hence the 2nd part of the question.
Thanks in advance!
Sincerely, Bharath
Since Spring Integration HTTP module is fully based on the Spring MVC, the mechanism for docs generation remains the same: you write tests based on the MockMVC and enhance it with the JUnitRestDocumentation
:
@Rule
public JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation();
@Autowired
private WebApplicationContext context;
@Before
public void setUp() {
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
.apply(documentationConfiguration(this.restDocumentation))
.build();
}
Yes, it can be done with Spring Boot. There is no Spring Boot requirement to write MockMVC tests: https://github.com/spring-projects/spring-integration/blob/master/spring-integration-http/src/test/java/org/springframework/integration/http/dsl/HttpDslTests.java