线虫/性感字段API

此包为部分添加API功能。

dev-master 2021-02-24 12:42 UTC

README

Build Status

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的属性。字段nameamountunit是成分的属性。

/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来控制返回数据的深度级别。