// Path: camel-rest-swagger/src/main/java/org/wildfly/camel/examples/rest/model/Customer.java
// @Entity
// @Table(name = "customer")
// public class Customer implements Serializable {
// 
//     private static final long serialVersionUID = -2372350530824400584L;
// 
//     @Id
//     @GeneratedValue(strategy= GenerationType.IDENTITY)
//     private Long id;
//     private String firstName;
//     private String lastName;
// 
//     public Long getId() {
//         return id;
//     }
// 
//     public void setId(Long id) {
//         this.id = id;
//     }
// 
//     public String getFirstName() {
//         return firstName;
//     }
// 
//     public void setFirstName(String firstName) {
//         this.firstName = firstName;
//     }
// 
//     public String getLastName() {
//         return lastName;
//     }
// 
//     public void setLastName(String lastName) {
//         this.lastName = lastName;
//     }
// 
//     @Override
//     public String toString() {
//         return "Customer{" + "id=" + id + ", firstName='" + firstName + '\'' + ", lastName='" + lastName + '\'' + '}';
//     }
// }
// 
// Path: camel-rest-swagger/src/main/java/org/wildfly/camel/examples/rest/service/CustomerService.java
// @ApplicationScoped
// @Named
// public class CustomerService {
// 
//     @Inject
//     CustomerRepository customerRepository;
// 
//     public void findAll(Exchange exchange) {
//         List<Customer> customers = customerRepository.findAll();
//         exchange.getOut().setBody(customers);
//     }
// 
//     public void findById(Exchange exchange) {
//         Long id = exchange.getIn().getHeader("id", Long.class);
//         Customer customer = customerRepository.findById(id);
// 
//         if (customer != null) {
//             exchange.getOut().setBody(customer);
//         } else {
//             exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 404);
//         }
//     }
// 
//     public void create(Exchange exchange) {
//         Customer customer = customerRepository.save(exchange.getIn().getBody(Customer.class));
//         exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 201);
// 
//         String URL = exchange.getIn().getHeader(Exchange.HTTP_URL, String.class);
//         exchange.getOut().setHeader("Location", URL + "/" + customer.getId());
// 
//         exchange.getOut().setBody(customer);
//     }
// 
//     public void update(Exchange exchange) {
//         Long id = exchange.getIn().getHeader("id", Long.class);
//         Customer customer = customerRepository.findById(id);
// 
//         if (customer != null) {
//             Customer updatedCustomer = customerRepository.save(exchange.getIn().getBody(Customer.class));
// 
//             String URL = exchange.getIn().getHeader(Exchange.HTTP_URL, String.class);
//             exchange.getOut().setHeader("Location", URL + "/" + updatedCustomer.getId());
//             exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 204);
//             exchange.getOut().setBody(updatedCustomer);
//         } else {
//             exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 404);
//         }
//     }
// 
//     public void delete(Exchange exchange) {
//         Long id = exchange.getIn().getHeader("id", Long.class);
//         Customer customer = customerRepository.findById(id);
// 
//         if (customer != null) {
//             customerRepository.delete(customer);
//             exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 204);
//         } else {
//             exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 404);
//         }
//     }
// }


import javax.enterprise.context.ApplicationScoped;
import javax.ws.rs.core.MediaType;
import com.fasterxml.jackson.core.JsonParseException;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.model.rest.RestBindingMode;
import org.apache.camel.model.rest.RestParamType;
import org.wildfly.camel.examples.rest.model.Customer;
import org.wildfly.camel.examples.rest.service.CustomerService;
            .apiContextPath("swagger");

        /**
         * Configure REST API with a base path of /customers
         */
        rest("/customers").description("Customers REST service")
            .get()
                .description("Retrieves all customers")
                .produces(MediaType.APPLICATION_JSON)
                .route()
                    .bean(CustomerService.class, "findAll")
                .endRest()

            .get("/{id}")
                .description("Retrieves a customer for the specified id")
                .param()
                    .name("id")
                    .description("Customer ID")
                    .type(RestParamType.path)
                    .dataType("int")
                .endParam()
                .produces(MediaType.APPLICATION_JSON)
                .route()
                    .bean(CustomerService.class, "findById")
                .endRest()

            .post()
                .description("Creates a new customer")
                .consumes(MediaType.APPLICATION_JSON)
                .produces(MediaType.APPLICATION_JSON)
// Path: camel-rest-swagger/src/main/java/org/wildfly/camel/examples/rest/model/Customer.java
// @Entity
// @Table(name = "customer")
// public class Customer implements Serializable {
// 
//     private static final long serialVersionUID = -2372350530824400584L;
// 
//     @Id
//     @GeneratedValue(strategy= GenerationType.IDENTITY)
//     private Long id;
//     private String firstName;
//     private String lastName;
// 
//     public Long getId() {
//         return id;
//     }
// 
//     public void setId(Long id) {
//         this.id = id;
//     }
// 
//     public String getFirstName() {
//         return firstName;
//     }
// 
//     public void setFirstName(String firstName) {
//         this.firstName = firstName;
//     }
// 
//     public String getLastName() {
//         return lastName;
//     }
// 
//     public void setLastName(String lastName) {
//         this.lastName = lastName;
//     }
// 
//     @Override
//     public String toString() {
//         return "Customer{" + "id=" + id + ", firstName='" + firstName + '\'' + ", lastName='" + lastName + '\'' + '}';
//     }
// }
// 
// Path: camel-rest-swagger/src/main/java/org/wildfly/camel/examples/rest/service/CustomerService.java
// @ApplicationScoped
// @Named
// public class CustomerService {
// 
//     @Inject
//     CustomerRepository customerRepository;
// 
//     public void findAll(Exchange exchange) {
//         List<Customer> customers = customerRepository.findAll();
//         exchange.getOut().setBody(customers);
//     }
// 
//     public void findById(Exchange exchange) {
//         Long id = exchange.getIn().getHeader("id", Long.class);
//         Customer customer = customerRepository.findById(id);
// 
//         if (customer != null) {
//             exchange.getOut().setBody(customer);
//         } else {
//             exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 404);
//         }
//     }
// 
//     public void create(Exchange exchange) {
//         Customer customer = customerRepository.save(exchange.getIn().getBody(Customer.class));
//         exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 201);
// 
//         String URL = exchange.getIn().getHeader(Exchange.HTTP_URL, String.class);
//         exchange.getOut().setHeader("Location", URL + "/" + customer.getId());
// 
//         exchange.getOut().setBody(customer);
//     }
// 
//     public void update(Exchange exchange) {
//         Long id = exchange.getIn().getHeader("id", Long.class);
//         Customer customer = customerRepository.findById(id);
// 
//         if (customer != null) {
//             Customer updatedCustomer = customerRepository.save(exchange.getIn().getBody(Customer.class));
// 
//             String URL = exchange.getIn().getHeader(Exchange.HTTP_URL, String.class);
//             exchange.getOut().setHeader("Location", URL + "/" + updatedCustomer.getId());
//             exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 204);
//             exchange.getOut().setBody(updatedCustomer);
//         } else {
//             exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 404);
//         }
//     }
// 
//     public void delete(Exchange exchange) {
//         Long id = exchange.getIn().getHeader("id", Long.class);
//         Customer customer = customerRepository.findById(id);
// 
//         if (customer != null) {
//             customerRepository.delete(customer);
//             exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 204);
//         } else {
//             exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 404);
//         }
//     }
// }


// Path: camel-rest-swagger/src/main/java/org/wildfly/camel/examples/rest/RestRouteBuilder.java
import javax.enterprise.context.ApplicationScoped;
import javax.ws.rs.core.MediaType;
import com.fasterxml.jackson.core.JsonParseException;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.model.rest.RestBindingMode;
import org.apache.camel.model.rest.RestParamType;
import org.wildfly.camel.examples.rest.model.Customer;
import org.wildfly.camel.examples.rest.service.CustomerService;

            .apiContextPath("swagger");

        /**
         * Configure REST API with a base path of /customers
         */
        rest("/customers").description("Customers REST service")
            .get()
                .description("Retrieves all customers")
                .produces(MediaType.APPLICATION_JSON)
                .route()
                    .bean(CustomerService.class, "findAll")
                .endRest()

            .get("/{id}")
                .description("Retrieves a customer for the specified id")
                .param()
                    .name("id")
                    .description("Customer ID")
                    .type(RestParamType.path)
                    .dataType("int")
                .endParam()
                .produces(MediaType.APPLICATION_JSON)
                .route()
                    .bean(CustomerService.class, "findById")
                .endRest()

            .post()
                .description("Creates a new customer")
                .consumes(MediaType.APPLICATION_JSON)
                .produces(MediaType.APPLICATION_JSON)
                .type(Customer.class)