Closed eigan closed 1 year ago
Have you tried upgrading swagger-php ? I tried creating a testcase and it looks like the latest code should be ok with this.
Sorry, I should have provided better example.
<?php
require "vendor/autoload.php";
use OpenApi\Annotations as OA;
/**
* @Annotation
*/
class CustomAnnotation {}
/**
* @OA\Schema
* @CustomAnnotation
*/
class SomeParent {}
/**
* @OA\Schema
*/
class Child extends SomeParent {}
$generator = new \OpenApi\Generator();
$generator->generate([
__FILE__
]);
Interesting - things change depending on whether there is a namespace used or not :waffle:
Thank you for the quick fix! 🙂
FYI this is also happening in https://github.com/zircote/swagger-php/blob/47922894170ca3c51703230e0d9417e22edcefd4/src/Processors/AugmentSchemas.php#L27 also
Call to undefined method OpenApi\\Attributes\\JsonContent::isRoot()
Using the latest 4.7.1 version.
Adding the same
I take this back, it this does not work, JsonContent is an instance of OA\Schema but still does not have the $schema instanceof OA\Schema
check seems to get rid of the error, but I'm not sure if that is the correct solution.isRoot
function, not sure why in this PR https://github.com/zircote/swagger-php/pull/1417 it works...
I've added localy method_exists($schema, 'isRoot')
just to have it pass
I am not sure what is going on there - JsonContent
definitly shoudl have AbstractAnnotation
as parent somewhere and that has the isRoot
method.
@DerManoMann You are correct, the function should be there but isn't... something went haywire with my vendor folder, re-installed everything and it works.
This can happen if you have a different annotation on an
@OA\Schema
.The line in Analysis seems to just assume that all annotations on the class has the
isRoot
method.Seems to be related to https://github.com/zircote/swagger-php/commit/e449670473d7ecaff75dff744e8e9be68a79a44c https://github.com/zircote/swagger-php/pull/1403