英文:
How to write a swagger file to capture the information within the <> block?
问题
我正在建立用于API调用的数据管道,其响应遵循以下格式:
<drivers>
<driver id="103721">
<reported_driver_id>5555</reported_driver_id>
<display_ref>5555</display_ref>
<name>Toronto Training 1</name>
</driver>
<drivers>
总共有数千名司机在响应中。
我现在编写的Swagger文件如下所示:
"definitions" : {
"sg_response##drivers##driver" : {
"properties" : {
"id" : {
"type" : "number"
},
"reported_driver_id" : {
"type" : "number"
},
"display_ref" : {
"type" : "number"
},
"name" : {
"type" : "string"
}
}
}
当我检查结果数据时,我发现无法捕获第一个 'id' 列,以下是我从ETL获取的示例:
"id","reported_driver_id","display_ref","name"
,"5555","5555","Toronto Training 1"
,"6666","6666","Toronto Training 2"
,"6161","6161","Billings Demo 4"
,"169168","169168","Dharminder Grewal"
我真的希望这个API可以以以下格式返回结果:
<drivers>
<driver>
<id>123<id>
<reported_driver_id>5555</reported_driver_id>
<display_ref>5555</display_ref>
<name>Toronto Training 1</name>
</driver>
<drivers>
但它没有,id位于driver对象的块内。请问你是否可以帮助我修改我的Swagger文件以捕获id信息?
如果由于API的编写方式而无法捕获id信息,也请告诉我,这样我可以推动后端团队更改API结构。
感谢您帮助数据工程行业的新手
英文:
I am working on building data pipeline for an API call whose response follows the below format:
<drivers>
<driver id="103721">
<reported_driver_id>5555</reported_driver_id>
<display_ref>5555</display_ref>
<name>Toronto Training 1</name>
</driver>
<drivers>
And there are in total thousands of drivers within the response.
Right now the swagger file I wrote looks like this:
"definitions" : {
"sg_response##drivers##driver" : {
"properties" : {
"id" : {
"type" : "number"
},
"reported_driver_id" : {
"type" : "number"
},
"display_ref" : {
"type" : "number"
},
"name" : {
"type" : "string"
}
}
}
And when I check the result data, I found that I cannot capture the first 'id' column, below is a sample of what I got from my ETL:
"id","reported_driver_id","display_ref","name"
,"5555","5555","Toronto Training 1"
,"6666","6666","Toronto Training 2"
,"6161","6161","Billings Demo 4"
,"169168","169168","Dharminder Grewal"
I really hope that this API can return the result in this format:
<drivers>
<driver>
<id>123<id>
<reported_driver_id>5555</reported_driver_id>
<display_ref>5555</display_ref>
<name>Toronto Training 1</name>
</driver>
<drivers>
But it's not, the id is within the driver object's block. Could you please help me to modify my swagger file to capture the id information?
If it is not possible to capture the id information due to the nature of how the API is wrote, please also let me know so I can push the backend team to change the API structure.
Thank you for helping a newbee in data engineering industry
答案1
得分: 2
问题已解决,在Swagger文件中添加以下内容:
"sg_response##drivers##driver" : {
"properties" : {
"id" : {
"type" : "number",
"xml":{
"attribute" : "true"
}
}
}
}
基本上添加:
"xml":{
"attribute" : "true"
}
英文:
the question is solved, in the swagger file, add this:
"sg_response##drivers##driver" : {
"properties" : {
"id" : {
"type" : "number",
"xml":{
"attribute" : "true"
}
},
basically add :
"xml":{
"attribute" : "true"
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论