kozluoglu/rest-api-bundle

Chameleon System 的 Symfony 扩展包

安装: 5

依赖者: 0

建议者: 0

安全: 0

星级: 0

关注者: 2

分支: 0

开放问题: 0

类型:symfony-bundle

dev-master 2021-04-09 13:27 UTC

This package is auto-updated.

Last update: 2024-09-25 20:22:35 UTC


README

此扩展包为 Chameleon Shop 提供 REST API 接口。所有业务功能(尚未)均可实现。

已完成的功能

  • 登录
  • 带有排序、偏移量和限制的基本产品列表

安装

  • 使用 Composer 安装扩展包
 composer.sh require kzorluoglu/rest-api-bundle:dev-master
  • 在 app/AppKernel.php 中添加扩展包
new \kzorluoglu\RestApiBundle\kzorluogluRestApiBundle(),
  • 在 app/autoload.php 中添加 AnnotationReader::addGlobalIgnoredNamespace("OA")
$loader = require __DIR__.'/../vendor/autoload.php';

// OA (open AI) Annotations adding Doctorine Ingored Namespaces List
\Doctrine\Common\Annotations\AnnotationReader::addGlobalIgnoredNamespace("OA");
  • 在 app/config/routing.yml 中添加 API 路由
api:
    resource: "@kzorluogluRestApiBundle/Resources/config/routing.yml"
    type:     yaml
    prefix:   /api

API 端点文档

所有 URI 都相对于 https://demo.chameleon-system.de/

模型文档

测试

准备

cd /vendor/kzorluoglu/rest-api-bundle
composer install

并运行测试

./vendor/bin/phpunit -c phpunit.xml

开发

更改后创建新的 openapi yaml

./vendor/bin/openapi -o api.yml  /your/root/path/vendor/kzorluoglu/rest-api-bundle/Controller

示例

./vendor/bin/openapi -o api.yml  /usr/local/apache2/htdocs/customer/vendor/kzorluoglu/rest-api-bundle/Controller
  1. 检查 api.yml 是否存在
../customer
..../app
..../web
..../api.yml
  1. 预览;将 api.yml 文件的内容复制并粘贴到 https://editor.swagger.io

文档生成

预览

  1. 复制 api.yml 文件的内容
  2. 粘贴到 https://editor.swagger.io

替代方案 1

  1. 复制 api.yml 文件的内容并粘贴到 https://editor.swagger.io
  2. 点击 生成客户端
  3. 选择一种客户端软件语言
  4. 解压缩生成的 zip 文件
  5. 从 readme.md 中复制 "## API 端点文档" 部分
  6. 从 zip 文件中将 docs 文件夹复制到该扩展包中

替代方案 2

  1. 下载 https://github.com/swagger-api/swagger-ui - 相关文件夹为 "dist"
  2. 将您的 api YAML 复制到 dist 文件夹中
  3. 打开 index.html 并将文件底部标签中的 URL 的值更改为 ./swagger.json(或您的 swagger json 所叫的名称)
  4. 在线托管!(或启动本地服务器以查看输出)。