线虫/ 性感字段API
此包为部分添加API功能。
dev-master
2021-02-24 12:42 UTC
Requires
- php: ^7.2
- ext-json: *
- jms/serializer: ^3.4
- symfony/config: ^4
- symfony/dependency-injection: ^4
- symfony/form: ^4
- symfony/http-foundation: ^4
Requires (Dev)
- mikey179/vfsstream: ^1.6
- mockery/mockery: ^1.0
- phpunit/phpunit: ^7.0
- squizlabs/php_codesniffer: ^3.2
- tardigrades/sexy-field: dev-master
- tardigrades/sexy-field-doctrine: dev-master
- tardigrades/sexy-field-entity: dev-master
- tardigrades/sexy-field-field-types-base: dev-master
- tardigrades/sexy-field-form: dev-master
Suggests
- tardigrades/sexy-field: Without the base package this api is nothing
- tardigrades/sexy-field-doctrine: You might want to use doctrine for persisting data
- tardigrades/sexy-field-form: The api requires you to use form
- tardigrated/sexy-field-entity: You need entities, yes you do
This package is auto-updated.
Last update: 2024-09-29 05:07:56 UTC
README
SexyFieldApi
此包为SexyField添加部分端点。
GET请求
当需要检索数据时,Sexy-field-api功能非常强大。默认情况下,您可以得到您实体的所有信息,包括父实体和子实体。
以下是如何构建GET请求的示例。
一个菜谱
/v1/section/{sectionHandle}/id/{id}
/v1/section/recipe/id/15?fields=id,title,description,recipeType,created,updated
所有菜谱
/v1/section/{sectionHandle}
/v1/section/recipe?fields=id,title,description,recipeType,created,updated
按字段值过滤的菜谱
/v1/section/fieldvalue/{sectionHandle}/{fieldHandle}
/v1/section/fieldvalue/recipe/recipeType?value=vegan&fields=id,title,description
通过slug查找的菜谱
/v1/section/{sectionHandle}/slug/{slug}
/v1/section/recipe/slug/recipe-20180325?fields=title
包含成分的菜谱(显示子实体的字段)
子实体由父实体中属性的名称指示。在这种情况下,recipe
实体有一个名为ingredients
的属性。字段name
、amount
、unit
是成分的属性。
/v1/section/recipe/id/3?fields=id,title,description,recipeType,created,updated,ingredients,name,amount,unit
POST请求
要创建一个新的菜谱,您需要使用POST请求到
/v1/section/recipe
内容类型:application/x-www-form-urlencoded
表单数据
form[title]: Black bean soup
form[description]: A delicious soup
form[recipeType]: vegan
PUT、DELETE和OPTIONS请求
请参阅 src/config/routing/api.yml
返回条目请求的深度控制
除了?fields=id,field之外,您还可以添加&depth=3来控制返回数据的深度级别。