我正在尝试记录查询数据库的函数的返回类型。我的尝试是这样的:
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new Info { Title = "My API", Version = "v1" });
});
...
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseSwagger();
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
});
...
}
但是我真的不确定“ rtype”。 这是此类对象的示例:
"""
Execute the query, append a report to the file (start & end time, duration, n rows and result file) and copy results
next to the original file with the same file name but the extension being csv.
:param file_path: file containing a single SQL query
:type file_path: str
:return: data queried from the database
:rtype: {'headers': list<str>, 'rows': list<tuple<any>>}
"""
因此,使用键“ headers”托管str的列表和使用键“ rows”托管不确定类型的元组的列表是dict。 我想这里有两个问题:
{
"headers": ["id", "name"],
"rows": [
(1, "Adrien"),
(2, "Simon")
]
}
可以吗?GenericType<SubType>
可以吗?我正在寻找是否存在约定。