超全模态模型 × Harness 升级,升级解锁 ArkClaw,最新支持 DeepSeek-V4 系列与 GLM-5.1
不用修改整个装饰器,只需要调整message.payload部分的配置,就能让文档呈现array的形式。修改方案1(简洁版) #直接通过数组包裹类型的方式,告诉装饰器这是一个Feature对象数组:@AsyncApiSub({ channel: 'myChannel', description: 'Read all features - result', message: { name: 'getFeaturesResponse', payload: { type: () => [Feature], // 用数组包裹Feature类型,标识数组结构 }, headers: AsyncApiHeaders.subHeaders(), }, }) 修改方案2(自定义schema版) #如果你需要和AsyncAPI Studio里手动编写的结构完全对应,可以直接指定schema:@AsyncApiSub({ channel: 'myChannel', description: 'Read all features - result', message: { name: 'getFeaturesResponse', payload: { schema: { type: 'array', items: { $ref: '#/components/schemas/Feature' // 引用已定义的Feature schema } } }, headers: AsyncApiHeaders.subHeaders(), }, }) 说明 #方案1依赖你已经通过@Schema()装饰器给Feature类定义了对应的属性结构,装饰器会自动关联生成数组的文档结构。方案2更灵活,可以完全自定义数组和item的结构,和你在AsyncAPI Studio中编写的结构一致。两种方案都能解决文档只显示单个对象的问题,根据你的需求选一种就行。不需要额外提供更多信息,只要确保Feature类的schema定义正确即可。内容的提问来源于stack exchange,提问作者Martin54
message.payload
直接通过数组包裹类型的方式,告诉装饰器这是一个Feature对象数组:
@AsyncApiSub({ channel: 'myChannel', description: 'Read all features - result', message: { name: 'getFeaturesResponse', payload: { type: () => [Feature], // 用数组包裹Feature类型,标识数组结构 }, headers: AsyncApiHeaders.subHeaders(), }, })
如果你需要和AsyncAPI Studio里手动编写的结构完全对应,可以直接指定schema:
@AsyncApiSub({ channel: 'myChannel', description: 'Read all features - result', message: { name: 'getFeaturesResponse', payload: { schema: { type: 'array', items: { $ref: '#/components/schemas/Feature' // 引用已定义的Feature schema } } }, headers: AsyncApiHeaders.subHeaders(), }, })
@Schema()
两种方案都能解决文档只显示单个对象的问题,根据你的需求选一种就行。不需要额外提供更多信息,只要确保Feature类的schema定义正确即可。
内容的提问来源于stack exchange,提问作者Martin54
超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起
模型再升级,30秒超长叙事, 模态参考扩容
模型自由,工具不限,最新支持 Deepseek-V4 系列、GLM-5.3 系列
超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列
大模型19元起,Al应用9.9元畅享,新人首购爆款尽享优惠