我正在寻找现有正文解析器的扩展。我需要使用 loopback4 节点解析 xml 数据。我尝试将 content-type 设置为 application/xml,但它给了我一个不受支持的内容类型错误。不支持xml。我在 loopback4 文档中没有找到任何示例。
我试过下面的代码:
@post('/dashboard/parseXmlRequest/', {
responses: {
'200': {
description: 'parses the xml and sends the response',
content: {
'application/xml': {
schema: {
type: 'any'
}
}
},
},
},
})
async parseXmlRequest(
@requestBody({
content: {
'application/xml': {
schema: {type: 'object'},
},
},
})
data: object) {
try {
console.log("request : ", data);
return await this.myService.deviceResponse(body);
}
catch (err) {
console.log(err);
return err;
}
}
你能帮忙吗。。谢谢。