Swagger数据显示为纯文本

时间:2019-11-26 13:08:16

标签: laravel swagger laravel-6

从中加载的数据以纯文本显示。 控制器代码:

public static function home()
{
    $openapi = \OpenApi\scan(public_path()."/data.php");
    header('Content-Type: application/x-yaml');
    echo "<pre>";
    echo $openapi->toYaml();
    echo "</pre>";
}

data.php包含此

<?php
use OpenApi\Annotations as OA;
/**
 * @OA\Info(
 *     version="1.0",
 *     title="Example for response examples value"
 * )
 */
/**
 * @OA\Post(
 *     path="/users",
 *     summary="Adds a new user",
 *     @OA\RequestBody(
 *         @OA\MediaType(
 *             mediaType="application/json",
 *             @OA\Schema(
 *                 @OA\Property(
 *                     property="id",
 *                     type="string"
 *                 ),
 *                 @OA\Property(
 *                     property="name",
 *                     type="string"
 *                 ),
 *                 example={"id": 10, "name": "Jessica Smith"}
 *             )
 *         )
 *     ),
 *     @OA\Response(
 *         response=200,
 *         description="OK"
 *     )
 * )
 */

0 个答案:

没有答案