/* */ package service; import dao.ShoppingDAO; import domain.ShoppingItem; import org.jooby.Jooby; import org.jooby.apitool.ApiTool; import org.jooby.json.Gzon; import resources.ShoppingItemResource; import resources.ShoppingListResource; /** * Shopping List Service. */ public class Server extends Jooby { public Server() { super("Server"); ShoppingDAO dao = new ShoppingDAO(); // add support for JSON use(new Gzon()); use(new ShoppingListResource(dao)); use(new ShoppingItemResource(dao)); // add Swagger documentation use(new ApiTool().modify(r -> r.pattern().equals("/api/items"), route -> { // Fix response type since Swagger couldn't guess route.response().type(new ShoppingItem[0].getClass()); }).swagger()); } public static void main(String[] args) { new Server().start(); } }