java-camel-server.api.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.apache.camel.model.rest.RestParamType;
import org.springframework.stereotype.Component;
import {{modelPackage}}.*;
import org.apache.camel.model.rest.RestBindingMode;
import org.apache.camel.LoggingLevel;
@Component
public class {{classname}} extends RouteBuilder {
@Override
public void configure() throws Exception {
{{#performBeanValidation}}
onException(Exception.class)
.log(LoggingLevel.ERROR, "${exception.message}: ${exception.stacktrace}")
.handled(true)
.process("{{camelValidationErrorProcessor}}");
{{/performBeanValidation}}
{{#operations}}{{#operation}}
/**
{{httpMethod}} {{{path}}}{{#summary}} : {{.}}{{/summary}}
**/
rest(){{#camelSecurityDefinitions}}{{#hasAuthMethods}}
.securityDefinitions(){{#authMethods}}{{#isOAuth}}
.oauth2("{{name}}"){{#flow}}
.flow("{{flow}}"){{/flow}}{{#tokenUrl}}
.tokenUrl("{{tokenUrl}}"){{/tokenUrl}}{{#authorizationUrl}}
.authorizationUrl("{{authorizationUrl}}"){{/authorizationUrl}}{{#refreshUrl}}
.refreshUrl("{{refreshUrl}}"){{/refreshUrl}}{{#scopes}}
.withScope("{{scope}}"{{#description}},"{{{.}}}"{{/description}}){{/scopes}}
{{^-last}}.end(){{/-last}}{{#-last}}
.endSecurityDefinition(){{/-last}}{{/isOAuth}}{{#isApiKey}}
.apiKey("{{name}}"){{#isKeyInHeader}}
.withHeader("{{name}}"){{/isKeyInHeader}}{{#isKeyInQuery}}
.withQuery("{{name}}").{{/isKeyInQuery}}{{#isKeyInCookie}}
.withCookie("{{name}}").{{/isKeyInCookie}}
{{^-last}}.end(){{/-last}}{{#-last}}
.endSecurityDefinition(){{/-last}}{{/isApiKey}}{{#isBasic}}{{#isBasicBasic}}
.basicAuth("{{name}}"){{#-last}}.end(){{/-last}}{{/isBasicBasic}}{{#isBasicBearer}}
.bearerToken("{{name}}"{{#bearerFormat}}, "{{bearerFormat}}"{{/bearerFormat}}){{#-last}}.end(){{/-last}}{{/isBasicBearer}}{{/isBasic}}{{/authMethods}}{{/hasAuthMethods}}{{/camelSecurityDefinitions}}
.{{#lambda.lowercase}}{{httpMethod}}{{/lambda.lowercase}}("{{path}}")
.description("{{#summary}}{{{.}}}{{/summary}}")
.id("{{operationId}}Api"){{#vendorExtensions}}{{#camelRestBindingMode}}
.clientRequestValidation(false)
.bindingMode(RestBindingMode.off){{/camelRestBindingMode}}{{/vendorExtensions}}{{#hasProduces}}
.produces("{{#produces}}{{{mediaType}}}{{^-last}}, {{/-last}}{{/produces}}"){{^isArray}}{{^isMap}}{{^isPrimitiveType}}
.outType({{returnType}}.class){{/isPrimitiveType}}{{/isMap}}{{/isArray}}{{#isArray}}
.outType({{returnBaseType}}[].class){{/isArray}}{{/hasProduces}}{{#hasConsumes}}
.consumes("{{#consumes}}{{{mediaType}}}{{^-last}}, {{/-last}}{{/consumes}}"){{#bodyParams}}{{^isArray}}{{^isMap}}{{^isPrimitiveType}}
.type({{baseType}}.class){{/isPrimitiveType}}{{/isMap}}{{/isArray}}{{#isArray}}
.type({{baseType}}[].class){{/isArray}}{{/bodyParams}}
{{/hasConsumes}}{{#pathParams}}
.param()
.name("{{paramName}}")
.type(RestParamType.path)
.required({{required}}){{#description}}
.description("{{{.}}}"){{/description}}
.endParam(){{/pathParams}}{{#queryParams}}
.param()
.name("{{paramName}}")
.type(RestParamType.query)
.required({{required}}){{#description}}
.description("{{{.}}}"){{/description}}
.endParam(){{/queryParams}}{{#headerParams}}
.param()
.name("{{paramName}}")
.type(RestParamType.header)
.required({{required}}){{#description}}
.description("{{{.}}}"){{/description}}
.endParam(){{/headerParams}}{{#implicitHeadersParams}}
.param()
.name("{{baseName}}")
.type(RestParamType.header)
.required({{required}}){{#description}}
.description("{{{.}}}"){{/description}}
.endParam(){{/implicitHeadersParams}}{{#bodyParams}}
.param()
.name("{{paramName}}")
.type(RestParamType.body)
.required({{required}}){{#description}}
.description("{{{.}}}"){{/description}}
.endParam(){{/bodyParams}}{{#formParams}}
.param()
.name("{{paramName}}")
.type(RestParamType.formData)
.required({{required}}){{#description}}
.description("{{{.}}}"){{/description}}
.endParam(){{/formParams}}{{#performBeanValidation}}
.to("direct:validate-{{operationId}}");{{/performBeanValidation}}{{^performBeanValidation}}
.to("direct:{{operationId}}");{{/performBeanValidation}}
{{/operation}}{{/operations}}
}
}