Skip to content

Commit

Permalink
add Swagger (#662)
Browse files Browse the repository at this point in the history
  • Loading branch information
thiennn authored Nov 19, 2018
1 parent 939f855 commit afe0ab2
Show file tree
Hide file tree
Showing 52 changed files with 67 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public BrandApiController(IRepository<Brand> brandRepository, IBrandService bran
_brandService = brandService;
}

[HttpGet]
public async Task<IActionResult> Get()
{
var brandList = await _brandRepository.Query().Where(x => !x.IsDeleted).ToListAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
namespace SimplCommerce.Module.Catalog.Areas.Catalog.Controllers
{
[Area("Catalog")]
[ApiExplorerSettings(IgnoreApi = true)]
public class BrandController : Controller
{
private int _pageSize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public CategoryApiController(IRepository<Category> categoryRepository, IReposito
_mediaService = mediaService;
}

[HttpGet]
public async Task<IActionResult> Get()
{
var gridData = await _categoryService.GetAll();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
namespace SimplCommerce.Module.Catalog.Areas.Catalog.Controllers
{
[Area("Catalog")]
[ApiExplorerSettings(IgnoreApi = true)]
public class CategoryController : Controller
{
private int _pageSize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public ProductAttributeApiController(IRepository<ProductAttribute> productAttrRe
_productAttrRepository = productAttrRepository;
}

[HttpGet]
public IActionResult List()
{
var attributes = _productAttrRepository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public ProductAttributeGroupApiController(IRepository<ProductAttributeGroup> pro
_productAttrGroupRepository = productAttrGroupRepository;
}

[HttpGet]
public IActionResult Get()
{
var attributeGroups = _productAttrGroupRepository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
namespace SimplCommerce.Module.Catalog.Areas.Catalog.Controllers
{
[Area("Catalog")]
[ApiExplorerSettings(IgnoreApi = true)]
public class ProductController : Controller
{
private readonly IMediaService _mediaService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public ProductOptionApiController(IRepository<ProductOption> productOptionReposi
_productOptionRepository = productOptionRepository;
}

[HttpGet]
public IActionResult Get()
{
var options = _productOptionRepository.Query();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public async Task<IActionResult> List([FromBody] SmartTableParam param)
return Ok(products);
}

[HttpPut]
public async Task<IActionResult> Put([FromBody] IList<ProductPriceItemForm> productPriceItemForms)
{
var currentUser = await _workContext.GetCurrentUser();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public ProductTemplateApiController(IRepository<ProductTemplate> productTemplate
_productTemplateProductAttributeRepository = productTemplateProductAttributeRepository;
}

[HttpGet]
public IActionResult Get()
{
var productTemplates = _productTemplateRepository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
namespace SimplCommerce.Module.Cms.Areas.Cms.Controllers
{
[Area("Cms")]
[ApiExplorerSettings(IgnoreApi = true)]
public class PageController : Controller
{
private readonly IRepository<Page> _pageRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace SimplCommerce.Module.Comments.Areas.Comments.Controllers
{
[Area("Comments")]
[ApiExplorerSettings(IgnoreApi = true)]
public class CommentController : Controller
{
private const int DefaultPageSize = 25;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public ContactAreaApiController(IRepository<ContactArea> categoryRepository)
_contactRepository = categoryRepository;
}

[HttpGet]
public IActionResult Get()
{
var categoryList = _contactRepository.Query().Where(x => !x.IsDeleted).ToList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace SimplCommerce.Module.Contacts.Areas.Contacts.Controllers
{
[Area("Contacts")]
[ApiExplorerSettings(IgnoreApi = true)]
public class ContactController : Controller
{
private readonly IRepository<Contact> _contactRepository;
Expand All @@ -23,7 +24,7 @@ public ContactController(IRepository<Contact> contactRepository, IRepository<Con
_workContext = workContext;
}

[Route("contact")]
[HttpGet("contact")]
public async Task<IActionResult> Index()
{
var model = new ContactVm()
Expand All @@ -43,8 +44,7 @@ public async Task<IActionResult> Index()
return View(model);
}

[Route("contact")]
[HttpPost]
[HttpPost("contact")]
public IActionResult SubmitContact(ContactVm model)
{
if (ModelState.IsValid)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace SimplCommerce.Module.Core.Areas.Core.Controllers
{
[Area("Core")]
[Authorize]
[ApiExplorerSettings(IgnoreApi = true)]
public class AccountController : Controller
{
private readonly UserManager<User> _userManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public AppSettingApiController(IRepositoryWithTypedId<AppSetting, string> appSet
_configurationRoot = (IConfigurationRoot)configuration;
}

[HttpGet]
public async Task<IActionResult> Get()
{
var settings = await _appSettingRepository.Query().Where(x => x.IsVisibleInCommonSettingPage).ToListAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public CountryApiController(IRepositoryWithTypedId<Country, string> countryRepos
_countryRepository = countryRepository;
}

[HttpGet]
public async Task<IActionResult> Get([FromQuery]bool? shippingEnabled)
{
var query = _countryRepository.Query();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public ActionResult List([FromBody] SmartTableParam param)
return Json(customerGroups);
}

[HttpGet]
public async Task<IActionResult> Get()
{
var customerGroups = await _customerGroupRepository.Query().Select(x => new
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace SimplCommerce.Module.Core.Areas.Core.Controllers
{
[Area("Core")]
[Authorize(Roles = "admin, vendor")]
[ApiExplorerSettings(IgnoreApi = true)]
public class DashboardController : Controller
{
[Route("admin/dashboard-tpl")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public DistrictApiController(IRepository<District> districtRepository)
_districtRepository = districtRepository;
}

[Route("/api/states-provinces/{stateOrProvinceId}/districts")]
[HttpGet("/api/states-provinces/{stateOrProvinceId}/districts")]
public async Task<IActionResult> GetDistricts(long stateOrProvinceId)
{
var districts = await _districtRepository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public EntityApiController(IRepository<Entity> entityRepository)
_entityRepository = entityRepository;
}

[HttpGet]
public IActionResult Get(string entityTypeId, string name)
{
var query = _entityRepository.Query().Where(x => x.EntityType.IsMenuable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace SimplCommerce.Module.Core.Areas.Core.Controllers
{
[Area("Core")]
[Authorize(Roles = "admin, vendor")]
[ApiExplorerSettings(IgnoreApi = true)]
public class HomeAdminController : Controller
{
private readonly IAntiforgery _antiforgery;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace SimplCommerce.Module.Core.Areas.Core.Controllers
{
[Area("Core")]
[ApiExplorerSettings(IgnoreApi = true)]
public class HomeController : Controller
{
private readonly ILogger _logger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace SimplCommerce.Module.Core.Areas.Core.Controllers
{
[Area("Core")]
[Authorize]
[ApiExplorerSettings(IgnoreApi = true)]
public class ManageController : Controller
{
private readonly UserManager<User> _userManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public RoleApiController(IRepository<Role> roleRepository)
_roleRepository = roleRepository;
}

[HttpGet]
public async Task<IActionResult> Get()
{
var roles = await _roleRepository.Query().Select(x => new
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public StateOrProvinceApiController(IRepository<StateOrProvince> stateOrProvince
_countryRepository = countryRepository;
}

[Route("/api/countries/{countryId}/states-provinces")]
[HttpGet("/api/countries/{countryId}/states-provinces")]
public async Task<IActionResult> GetStatesOrProvinces(string countryId)
{
var statesOrProvinces = await _stateOrProvinceRepository.Query()
Expand All @@ -39,6 +39,7 @@ public async Task<IActionResult> GetStatesOrProvinces(string countryId)
return Ok(statesOrProvinces);
}

[HttpGet]
public async Task<IActionResult> Get()
{
var statesOrProvinces = await _stateOrProvinceRepository.Query()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public ThemeApiController(IThemeService themeService, IHttpClientFactory httpCli
_httpClientFactory = httpClientFactory;
}

[HttpGet]
public async Task<IActionResult> Get()
{
var themes = await _themeService.GetInstalledThemes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace SimplCommerce.Module.Core.Areas.Core.Controllers
{
[Area("Core")]
[Authorize]
[ApiExplorerSettings(IgnoreApi = true)]
public class UserAddressController : Controller
{
private readonly IRepository<UserAddress> _userAddressRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ public async Task<IActionResult> List(long warehouseId, [FromBody] SmartTablePar
return Ok(products);
}

[HttpPut]
public async Task<IActionResult> Put(long warehouseId, [FromBody] IList<StockVm> stockVms)
{
var currentUser = await _workContext.GetCurrentUser();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public WarehouseApiController(IRepository<Warehouse> warehouseRepository, IWorkC
_workContext = workContext;
}

[HttpGet]
public async Task<IActionResult> Get()
{
var query = _warehouseRepository.Query();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
namespace SimplCommerce.Module.Localization.Areas.Localization.Controllers
{
[Area("Localization")]
[ApiExplorerSettings(IgnoreApi = true)]
public class LocalizationController : Controller
{
private readonly IRepositoryWithTypedId<User, long> _userRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public NewsCategoryApiController(IRepository<NewsCategory> categoryRepository, I
_categoryService = categoryService;
}

[HttpGet]
public async Task<IActionResult> Get()
{
var categoryList = await _categoryRepository.Query().Where(x => !x.IsDeleted).ToListAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace SimplCommerce.Module.News.Areas.News.Controllers
{
[Area("News")]
[ApiExplorerSettings(IgnoreApi = true)]
public class NewsItemController : Controller
{
private readonly IRepository<NewsItem> _newsItemRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
namespace SimplCommerce.Module.Orders.Areas.Orders.Controllers
{
[Area("Orders")]
[Authorize]
[Route("checkout")]
[Authorize]
[ApiExplorerSettings(IgnoreApi = true)]
public class CheckoutController : Controller
{
private readonly IOrderService _orderService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
namespace SimplCommerce.Module.PaymentCoD.Areas.PaymentCoD.Controllers
{
[Authorize]
[ApiExplorerSettings(IgnoreApi = true)]
public class CoDController : Controller
{
private readonly IOrderService _orderService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
namespace SimplCommerce.Module.PaymentPaypalExpress.Areas.PaymentPaypalExpress.Controllers
{
[Area("PaymentPaypalExpress")]
[ApiExplorerSettings(IgnoreApi = true)]
public class PaypalExpressController : Controller
{
private readonly ICartService _cartService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
namespace SimplCommerce.Module.PaymentStripe.Areas.PaymentStripe.Controllers
{
[Area("PaymentStripe")]
[ApiExplorerSettings(IgnoreApi = true)]
public class StripeController : Controller
{
private readonly ICartService _cartService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace SimplCommerce.Module.Payments.Areas.Payments.Controllers
[Area("Payments")]
[Route("checkout")]
[Authorize]
[ApiExplorerSettings(IgnoreApi = true)]
public class CheckoutController : Controller
{
private readonly IRepositoryWithTypedId<PaymentProvider, string> _paymentProviderRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
namespace SimplCommerce.Module.ProductComparison.Areas.ProductComparison.Controllers
{
[Area("ProductComparison")]
[ApiExplorerSettings(IgnoreApi = true)]
public class ComparingProductController : Controller
{
private readonly IRepository<ComparingProduct> _comparingProductRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public RecentlyViewedWidgetApiController(IRepository<WidgetInstance> widgetInsta
_widgetInstanceRepository = widgetInstanceRepository;
_mediaService = mediaService;
}

[HttpGet("{id}")]
public async Task<IActionResult> Get(long id)
{
Expand All @@ -38,7 +39,6 @@ public async Task<IActionResult> Get(long id)
ItemCount = JsonConvert.DeserializeObject<int>(widgetInstance.Data)
};


return Json(model);
}

Expand All @@ -61,7 +61,6 @@ public async Task<IActionResult> Post([FromBody] RecentlyViewedWidgetForm model)
_widgetInstanceRepository.Add(widgetInstance);
await _widgetInstanceRepository.SaveChangesAsync();
return CreatedAtAction(nameof(Get), new {id = widgetInstance.Id}, null);

}
}

Expand All @@ -84,7 +83,6 @@ public async Task<IActionResult> Put(long id, [FromBody] RecentlyViewedWidgetFor

await _widgetInstanceRepository.SaveChangesAsync();
return Accepted();

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace SimplCommerce.Module.Reviews.Areas.Reviews.Controllers
{
[Area("Reviews")]
[ApiExplorerSettings(IgnoreApi = true)]
public class ReplyController : Controller
{
private readonly IRepository<Models.Reply> _replyRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace SimplCommerce.Module.Reviews.Areas.Reviews.Controllers
{
[Area("Reviews")]
[ApiExplorerSettings(IgnoreApi = true)]
public class ReviewController : Controller
{
private const int DefaultPageSize = 25;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
namespace SimplCommerce.Module.SampleData.Areas.SampleData.Controllers
{
[Area("SampleData")]
[ApiExplorerSettings(IgnoreApi = true)]
public class SampleDataController : Controller
{
private readonly ISampleDataService _sampleDataService;
Expand Down
Loading

0 comments on commit afe0ab2

Please sign in to comment.