Skip to content

API version can be lost when using media type parameters #37619

Open

Description

@noojung

MediaTypeParamApiVersionResolver supports extracting an API version from Accept or Content-Type.

With the resolver configured for application/json and parameter version, this request resolves to null instead of "3":

Accept: */*
Content-Type: application/json;version=3

Removing Accept resolves the version correctly.

The resolver returns the parameter value from the first compatible Accept media type, even when that value is null. This prevents checking Content-Type. Both MVC and WebFlux are affected.

On the client side, ApiVersionInserter.useMediaTypeParam() adds the version only to an existing Content-Type. The default WebClient connector, Reactor Netty, adds Accept: */*, which triggers the server-side behavior above.

If Content-Type is absent, e.g. for a GET or DELETE request sent without that header, the inserter adds no version and does not write to Accept.

Expected behavior:

  • Fall back to Content-Type when no version is found in Accept.
  • Support client-side media type version insertion for requests without Content-Type.

Related Issue:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions