swagger中ISO时间戳改为另一种格式
我正在使用 Plumber 包制作 R API。我创建了一条路由,用户将在其中发送公司名称、开始和结束时间戳。在我的水管工文件中,路线看起来像这样。
#* @param company is the name of the company
#* @param start is a timestamp
#* @param end is a timestamp
#* @get /info_box/<company>/<start>/<end>
function(company,start,end){
future_result <- future(info_box(company,start,end))
return(future_result)
}
开始时间和结束时间的参数将传递到存储在字符串变量中的 SQL 查询中。这将被发送给雅典娜执行。该字符串如下所示:
"SELECT *
FROM the_table
WHERE completed = true
AND end_time >= CAST(from_iso8601_timestamp('replacement_start') AS TIMESTAMP)
AND end_time <= CAST(from_iso8601_timestamp('replacement_end') AS TIMESTAMP);"
replacement_start 和 replacement_end 替换为用户将在 API 中发送的参数。
在 R 中,当我运行 API 时,会出现 swagger 页面,我可以在其中使用参数测试 API。我输入以下参数
我得到这个结果
{
"error": "500 - Internal server error",
"message": "Error: INVALID_FUNCTION_ARGUMENT: Invalid format: \"2022-01-01T01%3A00%3A00.000Z\" is malformed at \"%3A00%3A00.000Z\"\n"
}
我不知道为什么 swagger 添加 %3A00%3A00。我知道这是问题所在,但为什么 swagger 会这样做。这与我输入的 ISO8601 格式不同吗?
I am making an R API using the package Plumber. I have created a route where a user will send a company name, start and end timestamp. The route looks like this in my plumber file.
#* @param company is the name of the company
#* @param start is a timestamp
#* @param end is a timestamp
#* @get /info_box/<company>/<start>/<end>
function(company,start,end){
future_result <- future(info_box(company,start,end))
return(future_result)
}
The parameters for start and end time will be passed into a SQL query that is stored in a string variable. This is sent to Athena to be executed. The string looks like this:
"SELECT *
FROM the_table
WHERE completed = true
AND end_time >= CAST(from_iso8601_timestamp('replacement_start') AS TIMESTAMP)
AND end_time <= CAST(from_iso8601_timestamp('replacement_end') AS TIMESTAMP);"
replacement_start and replacement_end are replaced with the parameters that the user will send in the API.
In R when I run the API the swagger page appears where I can test the API out with parameters. I enter the following parameters
and I get this result
{
"error": "500 - Internal server error",
"message": "Error: INVALID_FUNCTION_ARGUMENT: Invalid format: \"2022-01-01T01%3A00%3A00.000Z\" is malformed at \"%3A00%3A00.000Z\"\n"
}
I don't know why swagger is adding %3A00%3A00. I know this is the problem but why is swagger doing this. Is this a different Format than ISO8601 which I am entering?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论