Base solution for your next web application
Open Closed

API with same names and input/output in Swagger?! #4095


User avatar
0
zokho created

Hi, I have got a situation where I have to have 2 API with a same name and signatures as below:

namespace HomeStart.HomeStart.**AMS**
{
    public interface IAMSAppService : IApplicationService
    {
        Task<SearchLoanOutput> SearchLoan(SearchLoanInput input);
    }
}
namespace HomeStart.HomeStart.**Broker**
{
    public interface IBrokerAppService : IApplicationService
    {
        Task<SearchLoanOutput> SearchLoan(SearchLoanInput input);
    }
}

As you can see they are in 2 different namespaces. The problem seems around the SearchLoanInput and SearchLoanOutput though. I have created 2 sets of input and output for each within different namespaces (Dto). For some reason when I run the app the swagger does not get loaded and shows an error as: 500 : <a class="postlink" href="http://localhost:22742/swagger/v1/swagger.json">http://localhost:22742/swagger/v1/swagger.json</a>

Any thought?!


2 Answer(s)
  • User Avatar
    0
    aaron created
    Support Team

    Use full type name in schema ids:

    services.AddSwaggerGen(options =>
    {
        // ...
        options.CustomSchemaIds(x => x.FullName);
    });
    
  • User Avatar
    0
    zokho created

    Thanks! that was it! :D