Open Closed

Can't see API when developing a module using the new command abp add-module Acme.Software.SimpleTask --new --add-to-solution-file #769


User avatar
0
learnabp created
  • 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:
  1. Run abp add-module Acme.Software.SimpleTask --new --add-to-solution-file
  2. 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);

    }
}
  1. 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));
                                
        }
    }
}
  1. Run the project and navigate to Swager can't see the GetAll API

Solution Structure is as follws

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

8 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    Hi,

    You need create an ApiController, just like SampleController

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    learnabp created

    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 ?

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    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.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    learnabp created

    hmmmm thats not good .... it would be good if that was documented somewhere

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    alper created
    Support Team Director

    module is a sub application and it shouldn't be decided to expose all appservices in the module.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    learnabp created

    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 ?

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    alper created
    Support Team Director

    Explained here https://docs.abp.io/en/abp/latest/Best-Practices/Module-Architecture

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    alper created
    Support Team Director

    When you create a monolithic application, then you can use the AppServices as WebAPIs. But in tier layout it's not available. This is a diagram of a sample microservice (tier).

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 16, 2026, 14:50
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.