Nelmioapidocbundle: Issue with @SWG\Parameter() and using ref=@Model(type=Foobar::class))

Created on 7 Apr 2020  路  2Comments  路  Source: nelmio/NelmioApiDocBundle

I get the following error when trying to use this in my controller.

The issue causing this error is ref=@Model(type=Form::class).

Any ideas why that is? Using the latest "nelmio/api-doc-bundle": "^3.6".

request.CRITICAL: Uncaught PHP Exception ErrorException: "Notice: Undefined variable: class" at /data/foobar-api/develop/vendor/nelmio/api-doc-bundle/PropertyDescriber/ArrayPropertyDescriber.php line 35 {"exception":"[object] (ErrorException(code: 0): Notice: Undefined variable: class at /data/foobar-api/develop/vendor/nelmio/api-doc-bundle/PropertyDescriber/ArrayPropertyDescriber.php:35)"} []

<?php

declare(strict_types=1);

namespace App\Controller\V1\Submission\Create;

use App\Service\Submission\Create\FormF2ShortService;
use App\Model\Submission\Create\Form;
use Nelmio\ApiDocBundle\Annotation\Model;
use Nelmio\ApiDocBundle\Annotation\Security;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Swagger\Annotations as SWG;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Annotation\Route;

final class IndexController extends AbstractController
{
    /**
     * @Route("/api/v1/submission/f2s/create", name="api_submission_f2s_create", methods={"POST"})
     * @SWG\Response(
     *     response=200,
     *     description="Create F2s form"
     * )
     *  @SWG\Parameter(
     *     name="body",
     *     in="body",
     *     @SWG\Schema(
     *         type="object",
     *         @SWG\Property(property="form", ref=@Model(type=Form::class))
     *     )
     * )
     * @SWG\Tag(name="CreateSubmission")
     * @Security(name="Bearer")
     * @IsGranted("ROLE_RP")
     */

Most helpful comment

All 2 comments

I also got this issue. It occurs because of the wrong implementation here #1612.

Can you try with replacing
@SWG\Property(property="form", ref=@Model(type=Form::class))
by
@SWG\Property(property="form", ref=@Model(type=Form::class, groups={}))
as a temporary fix.

Was this page helpful?
0 / 5 - 0 ratings