JSON-LD与Hydra:如何定义自定义操作并指定其URL



我在某个baseurl/myResource/id123下有一个资源该资源当然具有某些属性,有些链接指向其他资源,但也有一些支持的操作。到目前为止,一切都很好。只要这些操作对应于在somebaseurl/myResource/id123上在资源URL上执行的HTTP动词,一切都可以。但是,如果我定义了某些特殊措施,可以通过在某些baseurl/myResource/id123/someScialaction上发布帖子来访问该怎么办?我如何在资源中代表这一点?JSON-LD HYDA不支持动作,Hydra对操作有支持,但是我无法为资源中的操作指定"端点"或" URL"属性。因此,我只能通过某种Baseurl/MyResource/ID123(所有HTTP动词,什么都没有)访问操作如何将这些边界留在资源表示中?

{
  "@context":"https://contexts.dictionary.mycompany-group.com/person.jsonld",
  "@id":"https://myapi.mycompany.com/persons/BE14A7269802498F992813885546D058",
  "@type":"https://schema.org/Person",
  "name": "Mustermann",
  "operation"
    : [
      {"@type": "DeleteResourceOperation","method": "DELETE"},
      {"@type": "ReplaceResourceOperation","method": "PUT"}
      ],
    // now how would one specify this with JSON-LD augmented by HYDRA?
    {"@type": "some_special_operation","method": "POST", URL:"https://myapi.mycompany.com/persons/BE14A7269802498F992813885546D058/some_special_operation"}
}

i M,正在寻找一种在特定资源上指定操作的方法 实例:操作的URL和HTTP方法应指定。 示例(请检查最后3行):

{

" @context":" https://contexts.dictionary.mycompany-group.com/person.jsonld",

" @id":" https://myapi.mycompany.com/persons/be14a7269802498f992813885546d058" ,,,, " @Type":" https://schema.org/person", "名称":" Mustermann", "手术": [ {" @type":" deleteresourceoperation","方法":" delete"}, {" @Type":"替换式库术","方法":" pot"} ],

//现在如何使用Hydra增强JSON-LD?

来指定此问题

您需要从节点引用其他" some_special_operation"在上方或使用该操作创建一个新的顶级节点

{ " @Type":" some_special_operation", "方法":" post",

url:" https://myapi.mycompany.com/persons/be14a7269802498f99281388546d058/so me_special_operation" } }

所以

  BE14A7269802498F992813885546D058
    - operation: delete + put
  5546D058/some_special_operation
    - operation: post

  BE14A7269802498F992813885546D058
    - operation: delete + put
    - relationshipProperty:
      ... 5546D058/some_special_operation
         - operation: post

您将在哪里选择一些描述的"关系杂物"的财产两个资源之间的关系。

话虽如此,我们目前正在尝试简化这一点,请参见https://github.com/hydracg/specifications/issues/3

相关内容

  • 没有找到相关文章

最新更新