core icon indicating copy to clipboard operation
core copied to clipboard

Error in XmlResourceExtractor when building request body content values

Open fraynaud1330 opened this issue 3 years ago • 5 comments

API Platform version(s) affected: 3.1.2

Description
When creating a custom operation with a specific request body in a resource in a XML file we have the following error : In ResourceExtractorTrait.php line 91: Warning: foreach() argument must be of type array|object, null given

How to reproduce
Create a resource in a XML file with an operation with a specific request body

Possible Solution
Modification in the file src/Metadata/Extractor/XmlResourceExtractor.php line 218 change $this->buildValues($openapi->requestBody->values) to $this->buildValues($openapi->requestBody->content->values) : https://github.com/api-platform/core/blob/3.1/src/Metadata/Extractor/XmlResourceExtractor.php#L218

fraynaud1330 avatar Feb 10 '23 17:02 fraynaud1330

Feel free to patch this, thanks!

soyuka avatar Feb 11 '23 00:02 soyuka

@soyuka I am not allowed to push on the project : Permission to api-platform/core.git denied to fraynaud1330

fraynaud1330 avatar Feb 13 '23 07:02 fraynaud1330

@soyuka Hello, I can't do the fix, I don't have the permission to push a new branch on the project

fraynaud1330 avatar Feb 27 '23 07:02 fraynaud1330

You need to make a PR: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request

alanpoulain avatar Feb 27 '23 08:02 alanpoulain

Ok thanks, here is the pull request : https://github.com/api-platform/core/pull/5419

fraynaud1330 avatar Feb 27 '23 10:02 fraynaud1330