Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Adding new module and service proxies/nswag #9363


User avatar
0
jaycee26 created

Hi,

Asp.net core + Angular

I have added a new module (project) to my aspnet zero application, e.g. MyCompanyName.NewModule, where I want to have most of my specific code to keep it seperate from asp.net zero code base for various reasons including ease of updating the template versions etc.

Now I can access all the functions in that module from other parts of the aspnet zero application by including that as a project reference in the other modules (such as .Application .Core etc).

But what I am struggling with is having that new module (the Dto's and the functions etc) picked up when running refresh.bat so that they are included in the service proxies on hte angular side. When I run the application and look at swagger, the API's and DTO's are not included.

It may be that I am not fully underestanding how swagger knows where to look for API's. Does the new module need defining somehwere in swagger config?

Any advice to point me in the right direction would be appreciated.

Thanks


11 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team

    hi

    You can try adding modules to ApplicationPartManager.

    public override void PostInitialize()
    {
    	IocManager.Resolve<ApplicationPartManager>()
    		.AddApplicationPartsIfNotAddedBefore(typeof(YourModule).Assembly);
    }
    
  • User Avatar
    0
    jaycee26 created

    I tried to add this to my MyCompanyName.CustomServiceModule.cs PostInitialize() but I get an error:

    'ApplicationPartManager' does not contain contain a definition for 'AddApplicationPartsIfNotAddedBefore' and no accessible extension method 'AddApplicationPartsIfNotAddedBefore' accepting a first argument of type 'ApplicationPartManager' could be found (are you missing a using directive or an assembly reference).

    I ahve added

    using Microsoft.AspNetCore.Mvc.ApplicationParts;

    Thanks,

    Jason

  • User Avatar
    0
    maliming created
    Support Team

    hi

    https://github.com/aspnetboilerplate/aspnetboilerplate/blob/a49362fad71deafe1aad7a9566cd6a61676e8e0b/src/Abp.AspNetCore/AspNetCore/ApplicationPartManagerExtensions.cs#L9

  • User Avatar
    0
    jaycee26 created

    Hi, sorry, but how/where do I need to add this to my project? Im not sure what you mean as that code is part of the ABP source.

  • User Avatar
    0
    jaycee26 created

    There is a similar entry in WebCoreModule.cs and that does not display the error.

  • User Avatar
    0
    maliming created
    Support Team

    hi

    If your module does not depend on the Abp.AspNetCore package, you cannot call this method.

    Can you use the zero demo project to create a simple example? I can download and check it

  • User Avatar
    0
    jaycee26 created

    OK, that was my oversight, I had not added Abp.AspNetCore dependency, which I have now done and therefore inserting

    public override void PostInitialize() { IocManager.Resolve<ApplicationPartManager>() .AddApplicationPartsIfNotAddedBefore(typeof(YourModule).Assembly); }

    In CustomServicesModule.cs compiles fine now.

    But I still cannot see the module through Swagger.

  • User Avatar
    0
    maliming created
    Support Team

    Can you use the zero demo project to create a simple example? I can download and check it

  • User Avatar
    0
    jaycee26 created

    @maliming where should I email the zip of the demo project to for you to look at?

  • User Avatar
    0
    maliming created
    Support Team

    hi @jaycee26 [email protected]

  • User Avatar
    1
    jaycee26 created

    Finally I found the problem! I had not implemented IApplicationService on the interface - schoolboy error :)

    Thanks.