Hello, We have a module with HttpApi.Host in it. When add some methods into module's HttpApi library's default controller , we couldn't see these methods in httpApi.Host swagger. We checked all implementations which needs to be done but we couldn't figure out the problem. We checked HttpApiModule and HttpApiHostModule implementations, the other modules integration and their methods are shown in swagger but in own module controller methods can't seen. What do you think we missed ?
Thank you .
- ABP Framework version: v.4.1.2
- UI type:MVC
- DB provider: EF Core
- **Tiered (MVC) : yes
- Exception message and stack trace:
- Steps to reproduce the issue:
3 Answer(s)
-
0
Hello again , we found the solution I want to share : Actually there is already a warning which we ignored "Inherit your controllers from this class" : We basically write methods into this base controller so we couldn't see in swagger.
/* **Inherit your controllers from this class.** */ public abstract class EasyCrmController : AbpController { protected EasyCrmController() { LocalizationResource = typeof(EasyCrmResource); } }
But when inherit from this controller class like below and create another controller, issue resolved automatically.
[Route("api/test")] public class TestController : EasyCrmController { [HttpGet] [Route("")] public Task<List<TestModel>> GetAsync() { return Task.FromResult(new List<TestModel> { new TestModel {Name = "John", BirthDate = new DateTime(1942, 11, 18)}, new TestModel {Name = "Adams", BirthDate = new DateTime(1997, 05, 24)} }); } }
Solution is ok but why do we need to inherit from base controller to see methods in swagger ? Is is about dependency injection in HttpApiHost application or something else ? Could you explain the reason ?
Thank you .
-
0
hi
I think
Controller
can't beabstract
.https://docs.abp.io/en/abp/latest/Customizing-Application-Modules-Overriding-Services#example-overriding-a-controller
-
0
This question has been automatically marked as stale because it has not had recent activity.