core icon indicating copy to clipboard operation
core copied to clipboard

3.3.0-alpha1 regression - Can't override formats for a single endpoint

Open paullallier opened this issue 2 years ago • 0 comments

API Platform version(s) affected: 3.3.0-alpha1

Description
Almost everything in my project seems to just work in the alpha version - nice!

I have one issue with endpoints which override the project default format types - this worked in 3.2.x.

How to reproduce
I have an endpoint with this definition:

        new Post(
            controller: DocumentUploadController::class,
            openapi: new Operation(
                summary: 'Upload a new document',
                description: 'Upload a new document',
                requestBody: new RequestBody(
                    content: new ArrayObject([
                        'multipart/form-data' => [
                            'schema' => [
                                'type' => 'object',
                                'properties' => [
                                    'file' => [
                                        'type' => 'string',
                                        'format' => 'binary'
                                    ]
                                ]
                            ]
                        ]
                    ])
                )
            ),
            normalizationContext: ['groups' => ['document:id_only']],
            validationContext: ['groups' => ['document:write_new', 'media_object_create']],
            deserialize: false,
        ),

And project-wide, this in my config:

api_platform:
    formats:
        jsonld: ['application/ld+json']

This is throwing an error now:

The content-type multipart/form-data is not supported. Supported MIME types are application/ld+json.

Additional Context
I suspect this is being missed by the test cases because they run with all the possible types in the format config - not sure if we can run one test with a different list, but I'm happy to try to create one if you can give me a few pointers?

paullallier avatar Feb 01 '24 11:02 paullallier