<dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-openapi-java</artifactId> <version>3.14.0</version> <!-- Same as Camel Core --> </dependency>
Java
@Component public class RestDsl extends RouteBuilder { @Override public void configure() throws Exception { restConfiguration() .component("servlet") .bindingMode(RestBindingMode.json) .dataFormatProperty("prettyPrint", "true") .apiContextPath("/api-doc") .apiProperty("api.title", "Saggu.UK Camel Rest APIs") .apiProperty("api.version", "1.0") .apiContextListing(true) ;
rest() .consumes("application/json").produces("application/json") .get("/weather/{city}") .responseMessage("200", "On good request") .responseMessage("404", "For invalid city name") .description("Get weather data for a given city") .param() .name("city").type(path).description("The name of the city e.g. London").dataType("string") .endParam() .outType(WeatherDto.class).to("direct:get-weather-data") } }