java-camel-server.routesImpl.mustache Maven / Gradle / Ivy
/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) ({{{generatorVersion}}}).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package {{apiPackage}};
import org.apache.camel.builder.RouteBuilder;
import org.springframework.stereotype.Component;
import org.apache.camel.LoggingLevel;
import {{modelPackage}}.*;
import org.apache.camel.model.dataformat.JsonLibrary;
@Component
public class {{classname}}RoutesImpl extends RouteBuilder {
@Override
public void configure() throws Exception {
{{#operations}}{{#operation}}
/**
{{httpMethod}} {{{path}}}{{#summary}} : {{.}}{{/summary}}
**/
from("direct:{{operationId}}")
.id("{{operationId}}")
.choice()
.when(simple("${body} != null"))
.log(LoggingLevel.INFO, "BODY TYPE: ${body.getClass().getName()}")
.end()
.log(LoggingLevel.INFO, "HEADERS: ${headers}"){{#hasProduces}}{{#examples}}{{#-first}}{{^isArray}}{{^isMap}}{{^isPrimitiveType}}
.setBody(constant({{>exampleString}}))
.unmarshal().json(JsonLibrary.Jackson, {{returnType}}.class){{/isPrimitiveType}}{{/isMap}}{{/isArray}}{{#isArray}}
.setBody(constant({{>exampleString}}))
.unmarshal().json(JsonLibrary.Jackson, {{returnBaseType}}[].class){{/isArray}}{{/-first}}{{/examples}}{{/hasProduces}};{{/operation}}{{/operations}}
}
}