Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call to undefined method App\Api\Resource\Address::getInfo() when using custom controller without json accept header #6809

Open
ThomasBerends opened this issue Nov 19, 2024 · 1 comment

Comments

@ThomasBerends
Copy link

ThomasBerends commented Nov 19, 2024

API Platform version(s) affected: 3.4.6

Description
Call to undefined method App\Api\Resource\Address::getInfo()
in vendor/api-platform/core/src/Symfony/Bundle/SwaggerUi/SwaggerUiProcessor.php (line 50)

How to reproduce
When calling an API endpoint without Accept: application/json, we get the error above. This happens when using custom controllers, for example in an object like this:

#[ApiResource(
    operations:[
        new Api\Get(
            uriTemplate: "/address/{postalCode}/{houseNumber}",
            controller: AddressGetController::class,
            description: "Retrieves Address",
            normalizationContext: [
                'groups' => [
                    'address'
                ],
                'skip_null_values' => false,
            ],
            read: false,
        ),
    ],
)]
class Address
{
    #[Groups([
        'address',
    ])]
    public ?string $street = null;

   // few other properties
}

The controller in question returns an Address object.

Possible Solution
Unfortunately unclear. My guess is it tries to get additional data to show SwaggerUI, but it's fetching it from the class directly.

Additional Context
I've tried in 4.x, but unfortunately there returning an Address object in the controller does did not work instantly. I have not yet reviewed the 4.0 documentation regarding upgrades yet, so it's likely this has nothing to do with this issue.

@soyuka
Copy link
Member

soyuka commented Nov 22, 2024

set extraProperties: ['_api_disable_swagger_provider' => true ] see #6449 and related. Doc entry welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants