【发布时间】:2019-04-10 21:44:32
【问题描述】:
使用 RAML,我正在尝试创建多个 API 可以用来包装响应的信封。也就是说,一个通用的响应信封。
我想出了这个:
title: Response Envelop
version: 1.0
uses:
another: ./another.raml
traits:
responseEnvelope:
usage: This trait should be used to wrap any response object
body:
application/json:
type: object
properties:
metadata:
type: another.AType
responseObjectToWrap:
type: any
message:
type: another.BType
我很难定义上面的responseObjectToWrap 部分。那就是将被响应信封包装的类型。 type: any 有效吗?
另外,我如何在 API 中使用这个特性?例如,如果我想用这个信封包装一个类型NewType。
【问题讨论】:
标签: rest api api-design raml