public CafeModule(ISwaggerModelCatalog modelCatalog) : base("/cafe") { modelCatalog.AddModel <CafeMenu>(); modelCatalog.AddModel <MenuItem>(); Get( "/menu", parameter => { var cafeMenuQuery = new CafeMenuQuery { Page = Request.Query.page ?? 1, PageCount = Request.Query.pagecount ?? 10, Sort = Request.Query.sort ?? null, SortDirection = Request.Query.sortdirection ?? null, MinumumPrice = Request.Query.minimumprice ?? Double.MinValue, MaximumPrice = Request.Query.maximumprice ?? Double.MaxValue, VeganOnly = Request.Query.veganonly ?? null, Category = string.IsNullOrEmpty(Request.Query.category) ? MenuCategory.All : Enum.Parse(typeof(MenuCategory), Request.Query.category), }; return(GetMenu(cafeMenuQuery)); }, null, "GetMenu"); }
private CafeMenu GetMenu([RouteParam(ParameterIn.Query, Name = "GetMenu")] CafeMenuQuery cafeMenuQuery) { return(new CafeMenu { Items = new List <MenuItem> { new MenuItem { Name = "Pesto Pasta", Price = 9.99, Category = MenuCategory.Food, IsVegan = false, }, new MenuItem { Name = "Avocado Toast", Price = 8.99, Category = MenuCategory.Food, IsVegan = true, }, new MenuItem { Name = "Tiramisu", Price = 5.99, Category = MenuCategory.Dessert, IsVegan = false, }, new MenuItem { Name = "Flat white", Price = 3.99, Category = MenuCategory.Beverage, IsVegan = false, }, } }); }