我需要设计一个 REST API 来导入一个包含 30 列的员工 CSV 文件。文件中的记录数可能因业务规模而异,可能是 10,可能是 5000。
这是我的设计方法
在前两个选项的情况下,用户应该在发送之前读取 CSV 并转换为 JSON。
问题
我正在尝试使用 swagger 在线编辑器http://editor.swagger.io/#/
有一个名为 Authorize 的按钮可打开一个对话框,您可以在其中提供授权方法。有两种选择
第一个用于 OAuth2,第二个用于 API-Key。
我无法弄清楚如何使用这些。
我有一个 JSON
{
"key": "processId-29231",
"fields": {
"attachment": [
{
"id": "79572",
"filename": "File1.png"
},
{
"id": "74620",
"filename": "File2.docx"
},
{
"id": "79072",
"filename": "File3.xlsx"
}
]
}
}
Run Code Online (Sandbox Code Playgroud)
我需要将其重组为这个
{
"processId": "processId-29231",
"attachments": [
"https://example.com/files/79572/File1.png",
"https://example.com/files/79572/File2.docx",
"https://example.com/files/79572/File1.xlsx",
]
}
Run Code Online (Sandbox Code Playgroud)
我可以使用特定的数组索引来完成这项工作
{processID:key,attachments:join('',['https://example.com/files/',fields.attachment[1].id,'/',fields.attachment[1].filename])}
Run Code Online (Sandbox Code Playgroud)
这产生了这个结果
{
"processID": "processId-29231",
"attachments": "https://example.com/files/74620/File2.docx"
}
Run Code Online (Sandbox Code Playgroud)
我以两种方式在没有数组索引的情况下尝试了这个
这个
{processID:key,attachments:join('',['https://example.com/',fields.attachment[].id,'/',fields.attachment[].filename])}
Run Code Online (Sandbox Code Playgroud)
和这个
{processID:key,attachments:join('', ['https://example.com/',fields.attachment[*].id,'/',fields.attachment[*].filename])}
Run Code Online (Sandbox Code Playgroud)
但这没有帮助。
有关如何解决此问题的任何提示?
我想访问https://editor.swagger.io/但需要根据 URL 参数预加载 YAML 文件。
因此,如果我想查看 https://github.com/OAI/OpenAPI-Specification/blob/master/examples/v3.0/petstore.yaml,我应该能够将其作为输入提供给可通过互联网。
这可能吗?