You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在RAML的datatype2.raml中为!引入的类型追加必填id属性?

解决方案

要在datatype2.raml中给contactList的items追加必填的id属性,RAML不支持在!include语句后直接追加属性,需通过类型继承+内联扩展的方式实现,具体修改如下:

修改datatype2.raml内容

把原文件中items下的!include替换为以下结构:

type: object
properties:
   company: string
   contactList: 
     type: array
     items:
       # 继承datatype1的所有属性
       type: !include /datatype1.raml
       # 追加id属性
       properties:
         id: integer
       # 标记id为必填项
       required: [id]

效果说明

  • 继承自datatype1.raml的name、email、phone属性会被保留
  • 新增的id: integer会合并到items的属性列表中
  • required: [id]确保该属性为必填项

datatype3.raml保持原有内容不变即可。

内容的提问来源于stack exchange,提问作者Roy Hu

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.13 00:37:04