微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何在 ALPS 描述符中将事物集合描述为词汇属性?

如何解决如何在 ALPS 描述符中将事物集合描述为词汇属性?

为了以应用程序为中心来描述 REST API,我正在尝试使用 ALPS 描述符及其工具。

假设我有一个对象“艺术品”,艺术品具有以下属性标题、艺术形式、作者等

我应该如何描述属性“authors”?在 OpenAPI 规范中很简单,只需说“类型:数组”,然后在“项目”下指定引用。在 ALPS 中描述集合的等效方式是什么?

我使用 YAML 格式来描述 API。

我当前的描述符如下所示:

descriptors:
# vocabulary properties
- id: "identifier"
  type: "semantic"
  text: "Unique identifier within Alpha Org. This is not the serial number of the item. This identifier is automatically generated when a new artwork item is created in the system."
  ref: "https://schema.org/identifier"

- id: "headline"
  type: "semantic"
  text: "Title of the artwork"
  ref: "https://schema.org/headline"

- id: "artform"
  type: "semantic"
  text: "Form of the artwork: painting? photograph? sculpture? others?"
  ref: "https://schema.org/artform"

- id: "authors"
  type: "semantic"
  text: "Authors of this artwork"
  ref: "https://schema.org/author"

- id: "serialNumber"
  type: "semantic"
  text: "Serial number of the artwork. If the artwork does not have a serial number,such as an original painting from an artist,then this number is simply the examplar number,usually 1."
  ref: "https://schema.org/serialNumber"

- id: "description"
  type: "semantic"
  text: "Description of the artwork"
  ref: "https://schema.org/description"

- id: "obtainDate"
  type: "semantic"
  text: "Date on which Alpha Org obtained the ownership of this artwork."
  ref: "https://schema.org/Date"

- id: "itemLocation"
  type: "semantic"
  text: "Location of the storage of the artwork item"
  ref: "https://schema.org/itemLocation"

- id: "images"
  type: "semantic"
  text: "Images of the artwork"
  ref: "https://schema.org/image"

解决方法

ALPS 描述不区分单个项目和集合。从模型 POV 来看,任何东西都可以是一个集合,从实现 POV 来看,实现该 ALPS 描述的每个服务都做出自己的决定。

作为一种常见做法,我通常在重要时使用 IANA 链接相关值

rel: item and rel: collection

有一个小实用程序 (ALPS UNIFIED) 展示了如何将 ALPS 描述转换为 OpenAPI 定义: https://github.com/mamund/alps-unified

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。