creatify/swagger-builder

此包最新版本(2.0.0)没有提供许可证信息。

基于PHP数组生成Swagger Yaml和Json文件

2.0.0 2023-05-01 20:11 UTC

This package is auto-updated.

Last update: 2024-09-26 15:39:59 UTC


README

pacakge

Swagger Builder

从PHP数组生成API的出色Swagger文档

安装

使用包管理器 composer 安装foobar。

composer require creatify/swagger-builder

用法

# register the package service provider in config/app.php in providers array
Creatify\SwaggerBuilder\Providers\SwaggerBuilderServiceProvider::class,
# publish the needed files
php artisan vendor:publish --provider="Creatify\SwaggerBuilder\Providers\SwaggerBuilderServiceProvider"
php artisan vendor:publish --tag=swagger-builder
运行以下命令开始构建文档并选择文件格式
php artisan swagger:build
# make new directory to save the php array which contain the structure of your endpoints
 by default the path in public/swagger/endpoints
# make new php file which represents your endpoints with the below structure
<?php

return [

    'schema' => [
        'id' => 'integer',
        'name' => 'string',
        'description' => 'string'
    ],

    'store' => [
        'name' => 'string',
        'description' => 'string'
    ],

    'update' => [
        'name' => 'string',
        'description' => 'string'
    ]
];

#schema represent the single response object of your model
#store contains the needed data to store new model (store method request body)
#update contains the needed data to update existing model (update method request body)
#start generating 
php artisan swagger:generate
  1. 管理最常用的端点,如
  • 页面
  • 索引
  • 商店
  • 显示
  • 删除
  • 更新
  • 恢复
  • 强制删除
  1. 安全性是可选的
  2. 对预期路由路径的建议或可以直接输入
  3. 从给定的路由路径检测参数
  4. 处理排序、分页长度、搜索
  5. 为上述操作生成给定模型的单独文件
  6. 支持json和yaml
  7. 可以扩展上述操作并添加其他操作
  8. 拥有 /documentation 路由以查看生成的文档
  9. 支持从配置文件 swagger-builder.php 中配置多个服务器URL

pacakge

pacakge

pacakge

贡献

欢迎拉取请求。对于重大更改,请首先打开一个问题来讨论您想更改的内容。

许可证

MIT