Skip to content

Microsoft.AspNetCore.OpenApi Handling Of Mvc Json Options #60145

@RyanThomas73

Description

@RyanThomas73

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

Related issue: #57891

Problem:
For an AspNetCore.Mvc api, the request and response json serializer settings are configured using an options specific to the AspNetCore.Mvc packages.

In the Microsoft.AspNetCore.OpenApi packages, the open api document services rely solely on the Microsoft.AspNetCore.Http.Json.JsonOptions value to control json serializer settings. As mentioned in the related issue, this was done to avoid the need to reference the .Mvc packages from the OpenApi packages.

However, requiring consumers to always change their Microsoft.AspNetCore.Http.Json.JsonOptions to match their Mvc ones in order for the open api spec doc generation to work is not viable in many situations. Changing the Microsoft.AspNetCore.Http.Json.JsonOptions has additional ramifications as it would also change behavior of outbound http calls from an aspnet core mvc api to other services.

Describe the solution you'd like

  • The Microsoft.AspNetCore.OpenApi packages should support json options configuration independently of the overall Microsoft.AspNetCore.Http.Json.JsonOptions configuration.
  • Continuing to default the values to match those of the service container's Http.Json.JsonOptions would be acceptable, but the AddOpenApi() service collection extension methods should support specifying the options to use without requiring a global default change to the behavior of the application

Additional context

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