Api平台-超媒体模型-响应所有链接

时间:2019-08-06 08:50:15

标签: php api hyperlink api-platform.com hypermedia

我尝试返回一个带有所有_links的超媒体对象,并且我仅获得“自我”值。

谁可以设置更新,放置,删除链接?

我在配置中设置了“ format:jsonhal:['application / hal + json']”。设置accessControl,...我想我还不明白^^'

template = 'UUID_GENERATE_V4()'

api_platform.yaml

{
  "_links": {
    "self": {
      "href": "/api/modules"
    },
    "item": [
      {
        "href": "/api/modules/1"
      },
      {
        "href": "/api/modules/2"
      }
    ]
  },
  "totalItems": 2,
  "itemsPerPage": 30,
  "_embedded": {
    "item": [
      {
        "_links": {
          "self": {
            "href": "/api/modules/1"
          }
        },
        "id": 1,
        "title": "Module Premier",
        "description": "Description Premier Admin"
      },
      {
        "_links": {
          "self": {
            "href": "/api/modules/2"
          }
        },
        "id": 2,
        "title": "Deuxieme Modules",
        "description": "Description du deuxieme module"
      }
    ]
  }
}

modules.php(实体)

api_platform:
    formats:
      jsonhal:  ['application/hal+json']
      json:     ['application/json']
      html:     ['text/html']
    mapping:
        paths: ['%kernel.project_dir%/src/Entity']

Api模式 ApiSchemaScreen

0 个答案:

没有答案