承接 eru123/swagger 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

eru123/swagger

最新稳定版本:1.0.1

Composer 安装命令:

composer require eru123/swagger

包简介

Swagger Plugin for eru123/router

README 文档

README

Swagger Plugin for eru123/router

Basic Usage

<?php

// Include the vendor/autoload.php file.
require_once __DIR__ . '/vendor/autoload.php';

// Import the required classes.
use eru123\swagger\Swagger;
use eru123\router\Router;

// Define Swagger path and it's json file path.
$swagger = Swagger::build([
    '/docs' => [
        '/v1' => __DIR__ . '/swaggerv1.json',
        '/v2' => __DIR__ . '/swaggerv2.json',
        '/v3' => [
            '-dev' => __DIR__ . '/swaggerv3-dev.json',
            '-prod' => __DIR__ . '/swaggerv3-prod.json',
        ]
    ]
]);

// Create a new Router instance for the API path and add the Swagger instance as a child.
$api = new Router();
$api->base('/api');
$api->child($swagger);

// Create the main Router instance
$router = new Router();

// Add a fallback route to return a 404 json response.
$router->fallback('/', function () {
    return [
        'error' => '404 Not Found'
    ];
});

// Add the API router as a child of the main router.
$router->child($api);

// Run the router.
$router->run();

Produced Routes

The example code above will produce the following routes:

  • /api/docs/v1
  • /api/docs/v2
  • /api/docs/v3-dev
  • /api/docs/v3-prod

For each of these routes, the file specified in the Swagger::build() method will be served as a json file in these paths as /swagger.json (e.g. /api/docs/v1/swagger.json).

统计信息

  • 总下载量: 8
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: HTML

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2023-03-31