Raml网站声明我可以将RAML 1.0数据类型转换为XML Schema:
可以使用数据类型代替模式和示例,让您定义一个数据类型,然后可以动态转换为XML或JSON模式 - 让您只需定义数据模型,并让RAML处理REST。
我该怎么做?具有继承和字符串模式的复杂类型的支持级别是什么?
答案 0 :(得分:1)
该语句暗示您可以使用XML数据类型来定义复杂的结构。此定义是合乎逻辑的,并未指定XML或JSON等物理格式。
这是专辑类型的定义:
#%RAML 1.0 DataType
type: AlbumSimple
displayName: Full Album Object
properties:
artists: ArtistSimple[] # would pull in ArtistSimple DataType
copyrights: Copyright[] # would pull in Copyright DataType
external_ids: ExternalId # would pull in ExternalId DataType
genres:
type: string[]
description: |
A list of the genres used to classify the album. If not yet classified,
the array is empty.
example: ["Prog Rock", "Post-Grunge"]
popularity:
type: integer
description: |
The popularity of the album. The value will be between 0 and 100,
with 100 being the most popular. The popularity is calculated from
the popularity of the album's individual tracks.
tracks:
type: Page # would pull in Page DataType
(pagedObject): TrackSimple
description: The tracks of the album.
该定义并不意味着物理格式。您必须在正文内容类型中定义:
get:
is: [ drm ]
responses:
201:
body:
application/json:
type: AlbumSimple