为了在以应用程序为中心的情况下描述REST,我尝试使用ALPS描述符及其工具。
假设我有一个对象" artwork ",一个artwork具有以下属性: headline、artform、authors等。
我应该如何描述“作者”属性?在OpenAPI规范中,这很简单,只需说“类型:数组”,然后在“项”下指定引用。在阿尔卑斯山描述集合的等效方式是什么?
我使用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"发布于 2021-01-31 03:21:19
ALPS的描述不会区分单个项目和集合。从模型POV来看,任何东西都可以是一个集合,从实现POV来看,实现该ALPS描述的每个服务都会做出自己的决定。
作为一种常见的实践,我通常在非常重要的情况下使用IANA link-rel值
rel: item and rel: collection有一个小工具(ALPS UNIFIED)展示了如何将ALPS描述转换为OpenAPI定义:https://github.com/mamund/alps-unified
https://stackoverflow.com/questions/65970901
复制相似问题