Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/246.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在Swagger/Zircote/Nelmio api文档中使用外部定义_Php_Symfony_Swagger_Nelmioapidocbundle - Fatal编程技术网

Php 在Swagger/Zircote/Nelmio api文档中使用外部定义

Php 在Swagger/Zircote/Nelmio api文档中使用外部定义,php,symfony,swagger,nelmioapidocbundle,Php,Symfony,Swagger,Nelmioapidocbundle,我使用以下版本: zircote/swagger-php in version 2.0.10 nelmio/api-doc-bundle in version v3.0.0-BETA4 我的控制器只需一个动作 /** * @Operation( * tags={"DeliverySlip"}, * summary="Send information after deliveryItems are processed and delivery

我使用以下版本:

zircote/swagger-php in version 2.0.10
nelmio/api-doc-bundle in version v3.0.0-BETA4
我的控制器只需一个动作

    /**
     * @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/product")
     *     )
     * )
     *
     * @Put("/deliveryslip/update/{slipIdentifier}", requirements={"slipIdentifier" = "\w+"})
     *
     * @param string $slipIdentifier
     * @param Request $request
     * @return JsonResponse
     */
    public function updateDeliverySlipAction($slipIdentifier, Request $request)
这是我想在控制器操作中使用的模型/定义:

<?php

namespace Sendis\Presentation\RestBundle\Model;

use Swagger\Annotations as SWG;

/**
 * @SWG\Definition(
 *     definition="product",
 *     type="object",
 *     required={"name"}
 * )
 */
class Product
{
    /**
     * @SWG\Property(example="doggie")
     * @var string
     */
    public $name;
}
接下来我意识到: 我的product.php似乎根本不被
swagger
阅读。我可以在这里写任何我想写的东西。没有错误,即使我拼错了什么。这让我得出结论,
swagger
根本没有找到我的product.php

我对每一个提示都很有帮助

亲切问候,,
Max

我找到了这个问题的解决方案。我需要加载外部定义及其完整名称空间,如下所示:

/**
     * @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)
/**
     * @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)