C# 使用Halcyon.net生成居里曲线
使用Halcyon.NET库(),我可以生成原型API所需的HAL()输出 然而,我想在文档中添加curies,以记录我的一些rel类型的附加语义。我看不到使用提供的API添加居里点作为链接的方法 我试过:C# 使用Halcyon.net生成居里曲线,c#,json,semantic-web,hal,curie,C#,Json,Semantic Web,Hal,Curie,使用Halcyon.NET库(),我可以生成原型API所需的HAL()输出 然而,我想在文档中添加curies,以记录我的一些rel类型的附加语义。我看不到使用提供的API添加居里点作为链接的方法 我试过: public class LinkBuilder { public static readonly Link[] Curies = { new Link("curies", "http://test.com/api/docs/rels/{rel}", repl
public class LinkBuilder
{
public static readonly Link[] Curies =
{
new Link("curies", "http://test.com/api/docs/rels/{rel}", replaceParameters: false, isRelArray: true)
};
public static Link AsProductFamilyLink(int familyId)
{
return new Link("tns:product-family", $"/product-family/{familyId}");
}
/* snip */
}
但这会导致输出缺少居里的关键name
属性:
{
"id": 2,
"name": "Chips",
"unitPrice": 0,
"_links": {
"delete-product": {
"href": "/product/2",
"method": "DELETE",
"title": "Delete product"
},
"tns:product-family": {
"href": "/product-family/1"
},
"self": {
"href": "/product/2",
"method": "GET"
},
"curies": [
{
"href": "http://test.com/api/docs/rels/{rel}",
"templated": true
}
]
}
}
如何正确生成居里曲线?(可能是另一个库?)
[
{
"name": "tns",
"href": "http://test.com/api/docs/rels/{rel}",
"templated": true
}
]
设置居里链接的Name属性:
new Link("curies", "http://test.com/api/docs/rels/{rel}", replaceParameters: false, isRelArray: true)
{
Name = "tns"
};