- ABP Framework version: 4.0.2
- UI type: MVC
- DB provider: EF Core
- Tiered (MVC) or Identity Server Seperated (Angular): no
- Exception message and stack trace:
API are not automatically generated
- Steps to reproduce the issue:
- Run abp add-module Acme.Software.SimpleTask --new --add-to-solution-file
- Create a ITaskAppService with a simple method GetAll as follows under the folder call Tasks in the Application.Contract Project in the modules folder
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
namespace Acme.Software.SimpleTask.Tasks
{
public interface ITaskAppService : IApplicationService
{
Task<ListResultDto<TaskDto>> GetAllAsync(GetAllTasksInput input);
}
}
- Create the TaskAppService as follows under the folder called Tasks in the Application.Contract Project in the Modules Folder
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;
namespace Acme.Software.SimpleTask.Tasks
{
public class TaskAppService : SimpleTaskAppService, ITaskAppService
{
private readonly IRepository<Task, Guid> _taskRepository;
public TaskAppService(IRepository<Task, Guid> taskRepository)
{
_taskRepository = taskRepository;
}
public async Task<ListResultDto<TaskDto>> GetAllAsync(GetAllTasksInput input)
{
var tasks = await AsyncExecuter.ToListAsync(_taskRepository
.WhereIf(input.State.HasValue, t => t.State == input.State.Value)
.OrderByDescending(t => t.CreationTime)
);
return new ListResultDto<TaskDto>(ObjectMapper.Map<List<Task>, List<TaskDto>>(tasks));
}
}
}
- Run the project and navigate to Swager can't see the GetAll API
Solution Structure is as follws
8 Answer(s)
-
0
Hi,
You need create an
ApiController
, just likeSampleController
-
0
Why, ABP create them automatically right?? if i follow the BookStore Tutorial then it is all automatic no need to create API Controller
If i have to create a APIController in what project ?
-
0
Why, ABP create them automatically right?? if i follow the BookStore Tutorial then it is all automatic no need to create API Controller
Because the module template is different from the app template. It is microservice compatible
If i have to create a APIController in what project ?
In
*.HttpApi
project. -
0
hmmmm thats not good .... it would be good if that was documented somewhere
-
0
module is a sub application and it shouldn't be decided to expose all appservices in the module.
-
0
can you please explain this a little bit more, having explored the samples like the Blogging modules.
I can't see a reason why the API have to be implemented in
*.HTTPApi
as they are all being implemented, so wouldn't it be better to just automagiclly create them ? -
0
Explained here https://docs.abp.io/en/abp/latest/Best-Practices/Module-Architecture
-
0