damack/ramltosilex

从RAML描述文件生成REST API的Silex Provider

安装: 59

依赖项: 0

建议者: 0

安全: 0

星标: 0

关注者: 2

分支: 0

开放问题: 0

语言:JavaScript

v1.2.6 2017-06-22 11:20 UTC

This package is not auto-updated.

Last update: 2024-09-18 19:42:37 UTC


README

RamlToSilex是一个Silex提供者,用于基于YAML(RAML)配置文件在关系数据库上设置REST API。

什么是RAML?

RESTful API Modeling Language (RAML)是一种简单且充分的描述实际RESTful API的方法。它鼓励重用,启用发现和模式共享,并旨在基于功绩的涌现最佳实践。

安装

要安装RamlToSilex库,运行以下命令,您将获取最新版本

composer require damack/ramltosilex

在您的应用程序中启用ServiceControllerDoctrineRamlToSilex服务提供者

$app = new Application();

$app->register(new \Silex\Provider\ServiceControllerServiceProvider());
$app->register(new \Silex\Provider\DoctrineServiceProvider(), array(
    'dbs.options' => array(
        'test' => array(
            'driver' => 'pdo_sqlite',
            'path' => __DIR__ . '/db.sqlite'
        )
    ),
));
$app->register(new Damack\RamlToSilex\RamlToSilexServiceProvider(), array(
    'ramlToSilex.raml_file' => __DIR__ . '/raml/api.raml',
    'ramlToSilex.config_file' => __DIR__ . '/config.json',
    'ramlToSilex.google-app-id' => 'id',
    'ramlToSilex.google-app-secret' => 'secret',
    'ramlToSilex.google-redirect-uri' => 'https:///',
    'ramlToSilex.redirectUri' => 'https:///login.html',
    'ramlToSilex.customController' => function() use ($app) {
        return new CustomController($app);
    }
));

- You need to give the path to the `RAML` file describing your API. You can find an example into the `tests/raml` directory
- You need to give the path to the config file describing your access to the routs and custom controller
- You need to give the app-id, app-secret and redirect-uri so google auth can work

## Function
- Create table from schema definition
- Goolge OAuth authentication
- API authentication with token
- Role based access to routes
- Hidden fields for get
- Custom controller
- API console

### Missing function
- Input validation

## Tests

Run the tests suite with the following commands:

```bash
composer install
composer test

许可证

MIT许可证下许可