api-clients / resource-generator
由 YAML 生成工具生成的资源
1.0.2
2018-01-19 07:18 UTC
Requires
- php: ^7.0
- api-clients/foundation: ^1.0
- api-clients/hydrator: ^1.0
- api-clients/resource: ^3.0
- api-clients/resource-test-utilities: ^1.0
- doctrine/inflector: ^1.1
- friendsofphp/php-cs-fixer: ^2.3
- nikic/php-parser: ^3.0 || ^2.1
- symfony/yaml: ^2.8||^3.0
Requires (Dev)
- dev-master
- 1.0.2
- 1.0.1
- 1.0.0
- 0.9.0
- dev-renovate/configure
- dev-dependabot/add-v2-config-file
- dev-dependabot/composer/friendsofphp/php-cs-fixer-2.17.1
- dev-improvement-chop-down-code-x-mass-three
- dev-var.ci
- dev-feature-wrap-data-into-classes
- dev-feature-handle-renames
- dev-ci-appveyor-lesstrict-filecomparison
- dev-feature-collection-annotation
- dev-feature-tested-objects-annotations
- dev-php-strict-type-fix
This package is auto-updated.
Last update: 2024-09-15 07:35:49 UTC
README
目标
- 用于轻松创建基于
wyrihaximus/api-client
的 API 客户端资源线框的工具
安装
要使用 Composer 安装,请使用以下命令,它将自动检测最新版本并将其绑定到 ^
。
composer require api-clients/resource-generator
使用方法
传递一个 definition
YAML
文件。
./vendor/bin/api-client-resource-generator [definition]
例如
./vendor/bin/api-client-resource-generator ./yaml/project.yml
YAML
YAML 格式允许快速轻松地生成资源、空资源以及资源测试。规范由两个或更多文件组成。
resource.yaml
首先是包含所有资源元数据的 resource.yml
文件
yaml_location: yaml # The location where the YAML files for the Resources are api_settings: Example\Client\ApiSettings # API Settings file location src: # SRC path: src/Resources # Path where the resources should be placed namespace: Example\Client\Resource # The namespace for the resources tests: # TESTS path: tests/Resources # Path where the resources tests should be placed namespace: Example\Tests\Client\Resource # The namespace for the tests
yaml/project.yaml
以下 YAML 是一个示例资源文件
class: Project # Resource classname properties: # The resource's properties id: int # Simple id field with type int name: string # Any scalar types or classes work plugins: SplObjectStorage # builds: # But differet types `special` properties are supported. type: array # For example the collection expects the type to be an array annotations: # and it uses an annotation name `collection` to collection: Project\Build # transform all items in the array to the specified resource. latestBuild: # Another supported annotation is `nested`, `nested` allows you to type: Project\Build # turn a properties that would otherwise be an array into a annotations: # resource. With it's own properties and methods nested: Project\Build # updated: # Normally all methods are generated to their camelCase property name method: updatedAt # but with `method` you can specify a custom method type: DateTimeInterface # When for example dealing with time, you can specify to return an interface wrap: DateTimeImmutable # while wrapping the value in a concrete class
许可证
MIT 许可证 (MIT)
版权所有 © 2016 Cees-Jan Kiewiet
特此授予任何获得此软件及其相关文档副本(“软件”)的人免费使用权,不受限制地处理该软件,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或出售软件的副本,并允许向提供该软件的人提供这样做,前提是遵守以下条件
上述版权声明和本许可声明应包含在软件的所有副本或主要部分中。
软件按“原样”提供,不提供任何明示或暗示的保证,包括但不限于适销性、针对特定目的的适用性和非侵权性。在任何情况下,作者或版权所有者均不对任何索赔、损害或其他责任承担责任,无论该责任是基于合同、侵权或其他原因,无论该责任是否与软件或软件的使用或其他方式有关。