Open Closed

Configure naming policy for named parameters on API controllers #7469


User avatar
0
phil@travelengine.com.au created
  • ABP Framework version: v8.1.3
  • UI Type: Blazor Server
  • Database System: EF Core (SQL Server)
  • Tiered (for MVC) or Auth Server Separated (for Angular): no
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

When creating auto API controllers, the properties of complex types that are populated from the query string default to PascalCase. How can I change this to camelCase or kebab-case?


5 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Do you mean localhost/api/users?skip-count=10&max-result-count=10?

  • User Avatar
    0
    phil@travelengine.com.au created

    Yes.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You can try to replace the ConventionalRouteBuilder service

    https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/ConventionalRouteBuilder.cs#L13

    https://docs.abp.io/en/abp/latest/API/Auto-API-Controllers#version-3-x-style-route-calculation

  • User Avatar
    0
    phil@travelengine.com.au created

    Ok thanks. Did a bit more investigating. It looks like the default ASP.NET Core model binding works for any casing of query string parameters. So you just need to tell Swagger to use camel casing: SwaggerGenOptions.DescribeAllParametersInCamelCase() so they appear correctly in the generated API docs.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Great

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