我正在使用NSwag,并试图将OpenAPI JSON文档转换为版本2。
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddOpenApiDocument(config =>
{
config.PostProcess = doc =>
{
doc.SchemaType = NJsonSchema.SchemaType.Swagger2;
}
}
}但是,当我将生成的OpenAPI文件粘贴到Swagger中时,它会显示错误:

如何配置NSwag以生成适当的OpenAPI 2.0文件?
发布于 2020-06-16 14:00:31
要将NSwag配置为输出OpenAPI 2.0定义而不是OpenAPI 3.0,请使用.AddSwaggerDocument(...)而不是.AddOpenAPIDocument(...)。更多信息:
https://github.com/RicoSuter/NSwag/wiki/AspNetCore-Middleware
https://stackoverflow.com/questions/62408517
复制相似问题