Starts in:
1 DAY
0 HR
7 MIN
17 SEC
Starts in:
1 D
0 H
7 M
17 S
Open Closed

AutoApi Controller and Versioning #8154


User avatar
0
castcrewit created

I am using AutoAPI Controller and trying to implement versioning in Module. No changes in Host/micrsosrvice

The issue I am facing now is I created 2 App Service with the same name however different namespace.

namespace xxxx.Payroll.Project.v1
{
    //[Authorize(ProjectPermissions.Projects.Default)]
    public class xxAppService : ApplicationService, IProjectV1AppService
    
namespace xxxx.Payroll.Project.v2
{
    //[Authorize(ProjectPermissions.Projects.Default)]
    public class xxAppService : ApplicationService, IProjectV2AppService
    {

My Preconfigure in.httpapi project looks like this :

 public override void PreConfigureServices(ServiceConfigurationContext context)
 {
     PreConfigure<IMvcBuilder>(mvcBuilder =>
     {
         mvcBuilder.AddApplicationPartIfNotExists(typeof(ProjectHttpApiModule).Assembly);
     });

     PreConfigure<AbpAspNetCoreMvcOptions>(options =>
     {
         //2.0 Version
         options.ConventionalControllers.Create(typeof(ProjectApplicationModule).Assembly, opts =>
         {
             opts.TypePredicate = t => t.Namespace == typeof(v2.xxAppService).Namespace;
             opts.ApiVersions.Add(new ApiVersion(2, 0));
         });

         //1.0 Compatibility version
         options.ConventionalControllers.Create(typeof(ProjectApplicationModule).Assembly, opts =>
         {
             opts.TypePredicate = t => t.Namespace == typeof(v1.xxAppService ).Namespace;
             opts.ApiVersions.Add(new ApiVersion(1, 0));
         });

         
     });
 }

I get the below error duplicate key in th below code :

public void Configure(SwaggerGenOptions options)
{
    // add a swagger document for each discovered API version
    // note: you might choose to skip or document deprecated API versions differently
    
    foreach (var description in provider.ApiVersionDescriptions)
    {
        options.SwaggerDoc(description.GroupName, CreateInfoForApiVersion(description));
    }
}

If i use different Class name everything works fine.

My understanding of the versioning was in Swagger we will be able to see the same endpoints but with an extra property as Version. Am I missing something here ?

I have scouted all articles in versioning from support but couldn't find any answers


1 Answer(s)
  • User Avatar
    0
    Anjali_Musmade created
    Support Team Support Team Member

    Hello ,

    Can you please check once with this document https://abp.io/docs/latest/framework/api-development/versioning#swagger-versionedapiexplorer Are you following the same approach. Thanks,

Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06