I have a DTO like this:
# AppBundle\DTO
/**
* @OA\Schema(
* schema="ProductDto",
* type="object",
* required={
* "foo",
* "bar",
* "baz",
* },
* )
*/
class ProductDto
{
/**
* @OA\Property(description="foo bar baz")
* @var string|null
*/
private $foo;
...
}
I am trying to reference this DTO in my controller, but it seems that this is file is not being parsed.
# AppBundle\Controller\Api\v1
class ProductController {
...
/**
* @OA\Post(
* @OA\RequestBody(
* required=true,
* content={
* @OA\MediaType(
* mediaType="application/json",
* @OA\Schema(
* type="object",
* ref="#/components/schemas/ProductDto",
* ),
* ),
* }
* ),
* )
*/
public function create(Request $request): ApiResponse
...
}
This results in:
User Notice: $ref "#/components/schemas/ProductDto" not found for @OA\Schema() in \Doctrine\Common\Annotations\DocParser->Annotation() in /srv/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php on line 827
It seems if I put my DTO into the Controller namespace, the file is being found and parsed, but the referencing still does not work. It works with the pure swagger-php package though.
I am using the current Beta (v4.0.0, NelmioApiDocBundle), since I want to use OpenAPI 3. Do I need to reference it differently? Is that a bug in the package, or am I doing it wrong?