Open Closed

ABP Api Versioning #2716


User avatar
0
shobhit created
  • ABP Framework version: v4.2.2
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes
  • Exception message and stack trace:
  • Steps to reproduce the issue:"
  • How i can version api in ABP

12 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    You can check this: https://github.com/abpframework/abp/blob/dev/docs/en/API/API-Versioning.md

  • User Avatar
    0
    shobhit created

    Hello liangshiwei, few points:

    1- https://github.com/abpframework/abp/blob/dev/docs/en/API/API-Versioning.md#enable-api-versioning which project --> file i have to make change i.e. Host, API, identity or all 2- do i have to follow all sections?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    which project

    Usually is HttpAPI.Host

    No, you don't need to follow all sections.

    If you are using the Auto API Controller, you just need to follow this section: https://github.com/abpframework/abp/blob/dev/docs/en/API/API-Versioning.md#auto-api-controller

    You can also check the unit tests: https://github.com/abpframework/abp/tree/dev/framework/test/Volo.Abp.AspNetCore.Mvc.Versioning.Tests

  • User Avatar
    0
    shobhit created

    i am using default ABP application so assuming it is using Auto API Controller. Now question is which project --> class file i need to make these changes

  • User Avatar
    0
    shobhit created

    Hello liangshiwei, if i am following https://github.com/abpframework/abp/blob/dev/docs/en/API/API-Versioning.md#enable-api-versioning then swagger is not able to load due to error:

    2022-03-14 14:09:08.056 +05:30 [ERR] An unhandled exception has occurred while executing the request. Swashbuckle.AspNetCore.SwaggerGen.SwaggerGeneratorException: Conflicting method/path combination "GET api/app/user-extensions" for actions - EzpandCC.Domain.Controllers.UserExtensions.UserExtensionController.GetListAsync (EzpandCC.HttpApi),EzpandCC.Domain.Controllers.UserExtensions.UserExtensionV2Controller.GetListAsync (EzpandCC.HttpApi). Actions require a unique method/path combination for Swagger/OpenAPI 3.0. Use ConflictingActionsResolver as a workaround at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GenerateOperations(IEnumerable1 apiDescriptions, SchemaRepository schemaRepository) at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GeneratePaths(IEnumerable1 apiDescriptions, SchemaRepository schemaRepository) at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GetSwagger(String documentName, String host, String basePath) at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider) at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext()

    but if i change path like "[Route("api/v1/app/user-extensions")]" and "[Route("api/v2/app/user-extensions")]" then dynamic api working fine but i am looking for querystring version parameters?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    but i am looking for querystring version parameters?

    Angular service proxies does not support API versioning yet, see : https://github.com/abpframework/abp/issues/11969 You need to use RestService to send http requests manually

  • User Avatar
    0
    shobhit created

    Hi liangshiwei, i have looked the api sample code and api version document also. it is cofusing and i am not sure what exactly i have to change. can you help me:

    ABP: 4.2.2 Angular Auto controller

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Because we improved the feature of the API version in 5.2, your project needs some manual changes.

    I made an example for you: https://github.com/realLiangshiwei/Qa2716

    1.0

    2.0

  • User Avatar
    0
    shobhit created

    Hello liangshiwei, Thanks for sample. i observerd that in in host project we have preConfigure method to define version for every interface. Now i have 2 understanding challenges:

    1. do i have to rename all my classes namespace
    2. do i have to specify all interfaces (i have 100) classes in preConfigure method as higlited below.
    3. What is the other best alternate without impacting current project. current api should be considered as V1 by default and next we can specify as required.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    HI,

    1. No, you don't need it, the TypePredicate is a selector, you can use any method

    2. No, you don't need it, but you need to write an appropriate TypePredicate selector, it will process all application services that match the current selector.

    3. I recommend using namespaces as we did so your solution structure will be very clear, by default all application services are v1 unless you configure selectors for them.

  • User Avatar
    0
    shobhit created

    Hello @liangshiwei, Thanks. can you share 1 application sample with me. for all above points, so that we can follow in our project.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    The example already includes all points.

    https://github.com/realLiangshiwei/Qa2716

Made with ❤️ on ABP v9.1.0-preview. Updated on December 12, 2024, 07:15