Skip to content

OpenApi doesn't convert query params to snake_case #60936

Open
@eskild-th

Description

@eskild-th

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

OpenApi doesn't pickup on ValueProvider changes.
I've replaced the default QueryStringValueProviderFactory with my own SnakeCaseQueryValueProviderFactory. The controller works as expected. But the generated OpenApi spec is still using camelCasing for query params.

Expected Behavior

I expect the OpenApi to pickup on the ValueProvider change and show the correct spec

"parameters": [
  {
      "name": "hello_world", // <----- snake case
      "in": "query",
      "schema": {
          "type": "integer",
          "format": "int32"
      }
  }
],

Steps To Reproduce

// startup

builder
    .Services.AddControllers(options =>
    {
        var index = options.ValueProviderFactories.IndexOf(
            options.ValueProviderFactories.OfType<QueryStringValueProviderFactory>().Single()
        );

        options.ValueProviderFactories[index] = new SnakeCaseQueryValueProviderFactory();
    })

builder.Services.AddOpenApi();

// controller

[HttpGet]
public IResult Get([FromQuery] int helloWorld)

Exceptions (if any)

No response

.NET Version

9.0.201

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesfeature-openapi

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions