Hello,
nelmio/api-doc-bundle v3.0.0-BETA4
zircote/swagger-php 2.0.11
trying such annotations:
use AppBundle\Entity\User;
...
/**
* @Rest\Post("/users/register")
*
* @SWG\Parameter(
* name="version",
* in="path",
* required=true,
* type="string",
* description="API version, example: v1",
* )
* @SWG\Response(
* response=201,
* description="Succesfully registered user",
* @SWG\Schema(
* type="array",
* @Model(type=User::class, groups={"registration"})
* )
* )
* @SWG\Response(
* response=400,
* description="There was a validation error",
* )
* @SWG\Tag(name="Users API")
*
* @return Response
*/
getting:
User Notice: $ref "#/definitions/User" not found for @SWG\Items() in \Nelmio\ApiDocBundle\SwaggerPhp\ModelRegister->__invoke() in .....vendor/nelmio/api-doc-bundle/SwaggerPhp/ModelRegister.php
am I doing something wrong here ?
@crashev read prev issues. Solution:
"zircote/swagger-php": "2.0.10"
You can also use dev-master which contains a fix :)
I still get this error, though i have zircote in version 2.0.11
This is my controller-action definition
/**
* @Operation(
* tags={"DeliverySlip"},
* summary="Send information after deliveryItems are processed and deliverySlip was scanned",
* @SWG\Response(
* response="200",
* description="Returned when successful"
* ),
* @SWG\Response(
* response="400",
* description="Returned on a missing request parameter"
* ),
* @SWG\Response(
* response="500",
* description="Returned on any other error"
* ),
* @SWG\Parameter(
* name="JSON update body",
* in="body",
* description="json login request object",
* required=true,
* @SWG\Schema(
* type="array",
* @Model(type=DeliverySlipUpdateRequest::class)
* )
* )
* )
*
* @Put("/deliveryslip/update/{slipIdentifier}", requirements={"slipIdentifier" = "\w+"})
*
* @param string $slipIdentifier
* @param Request $request
* @return JsonResponse
*/
And this is the model i want to use:
<?php
namespace Sendis\Presentation\RestBundle\Model;
/**
* @SWG\Definition(
* type="object",
* definition="DeliverySlipUpdateRequest"
* )
*/
class DeliverySlipUpdateRequest
{
/**
* @var DeliveryItem[]
* @SWG\Property(@SWG\Xml(name="delivery_items", wrapped=true))
*/
public $deliveryItems = [];
}
that results in this message
User Notice: $ref "#/definitions/DeliverySlipUpdateRequest" not found for @SWG\Items() in \Nelmio\ApiDocBundle\SwaggerPhp\ModelRegister->__invoke() in /app/vendor/nelmio/api-doc-bundle/SwaggerPhp/ModelRegister.php on line 74
@chucky2305 2.0.11 version contains a BC, try to use another version. 2.0.10 is ok or dev-master
Okay.But now i get new problems.
With this ControllerAnnotation
/**
* @Operation(
* tags={"DeliverySlip"},
* summary="Send information after deliveryItems are processed and deliverySlip was scanned",
* @SWG\Response(
* response="200",
* description="Returned when successful"
* ),
* @SWG\Response(
* response="400",
* description="Returned on a missing request parameter"
* ),
* @SWG\Response(
* response="500",
* description="Returned on any other error"
* ),
* @SWG\Parameter(
* name="slipIdentifier",
* description="identifier of delivery slip",
* type="string",
* format="string",
* in="path"
* ),
* @SWG\Parameter(
* name="JSON update body",
* in="body",
* description="json login request object",
* required=true,
* @SWG\Schema(ref="#/definitions/DeliverySlipUpdateRequest")
* )
* )
*
* @Put("/deliveryslip/update/{slipIdentifier}", requirements={"slipIdentifier" = "\w+"})
*
* @param string $slipIdentifier
* @param Request $request
* @return JsonResponse
*/
public function updateDeliverySlipAction($slipIdentifier, Request $request)
and this Model-Definition:
<?php
namespace Sendis\Presentation\RestBundle\Model;
/**
* @SWG\Definition(required={"name", "photoUrls"}, type="object", @SWG\Xml(name="DeliverySlipUpdateRequest"))
*/
class DeliverySlipUpdateRequest
{
/**
* @SWG\Property(example="doggie")
* @var string
*/
public $name;
/**
* @var string[]
* @SWG\Property(@SWG\Xml(name="photoUrl", wrapped=true))
*/
public $photoUrls;
}
i get the following message. It not an error. I can see the swagger ui, but this message appears on top
Errors
Hide
Resolver error at paths./api/deliveryslip/update/{slipIdentifier}.put.parameters.1.schema.$ref
Could not resolve reference: #/definitions/DeliverySlipUpdateRequest
When i try to link to my Model via
...
@SWG\Parameter(
* name="JSON update body",
* in="body",
* description="json login request object",
* required=true,
* @SWG\Schema(
* type="array",
* @Model(type=DeliverySlipUpdateRequest::class)
* )
* )
...
i can see a ModelDefiniton for DeliverySlipUpdateRequest on the bottom of the page, but it is empty, although i try to configure two fields in it
@konradpodgorski Any help on this?
Nevermind. I found the solution. I just needed to define the loaded model with its complete namespace like so:
/**
* @SWG\Put(
* path="/deliveryslip/update/{slipIdentifier}",
* tags={"DeliverySlip"},
* summary="Send information after deliveryItems are processed and deliverySlip was scanned",
* @SWG\Definition(
* definition="product",
* type="object",
* required={"name"}
* ),
* @SWG\Response(
* response="200",
* description="Returned when successful"
* ),
* @SWG\Response(
* response="400",
* description="Returned on a missing request parameter"
* ),
* @SWG\Response(
* response="500",
* description="Returned on any other error"
* ),
* @SWG\Parameter(
* name="slipIdentifier",
* description="identifier of delivery slip",
* type="string",
* format="string",
* in="path"
* ),
* @SWG\Parameter(
* name="JSON update body",
* in="body",
* description="json login request object",
* required=true,
* @SWG\Schema(
* type="array",
* @Model(type=Sendis\Presentation\RestBundle\Model\Product::class)
* )
* )
* )
*
* @param string $slipIdentifier
* @param Request $request
* @return JsonResponse
*/
public function updateDeliverySlipAction($slipIdentifier, Request $request)
Most helpful comment
You can also use
dev-masterwhich contains a fix :)