Skip to content

Content-Type */* generates error when format restriction configured #1532

@Nek-

Description

@Nek-

Given you use the following configuration:

    formats:
        jsonld:
            mime_types: ['application/ld+json']
        html:
            mime_types: ['text/html']
            # The fact I need to have HTML just to get the documentation is another story...

And you query api platform with the following header:

Content-Type: */*; charset=utf-8

This is the default one in some tools like PhpStorm for example.

Observation

Apiplatform fails with error on "wrong format requested" instead of taking the first format specified in configuration.

Expected behavior

As documented, it should take the first format (here jsonld) as format for the current query.

How to fix

The issue is located inside the class ApiPlatform\Core\EventListener\DeserializeListener.

It's a quick win. It may be tricky finally.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions