Autorest错误-swagger.json'不是有效的OpenAPI 2.0定义(预期为'swagger:2.0') [英] Autorest error - swagger.json' is not a valid OpenAPI 2.0 definition (expected 'swagger: 2.0')
问题描述
我的api使用Swashbuckle.AspNetCore 5.0.0-rc5运行Net Core 3.0
My api is running net core 3.0 with Swashbuckle.AspNetCore 5.0.0-rc5
当我对生成的swagger.json文件运行autorest时,我得到:
When I run autorest on my generated swagger.json file I get:
swagger.json is not a valid OpenAPI 2.0 definition (expected 'swagger: 2.0')
我的swagger.json文件确实说"openapi":"3.0.1". 它曾经是v2.0,但是自从我升级到net core 3.0之后,我不得不升级Swashbuckle,现在Swashbuckle使用v3.0.1创建了json文件
My swagger.json file does indeed say "openapi": "3.0.1". It used to be v2.0 but since I upgraded to net core 3.0 I had to upgrade Swashbuckle which now creates the json file with v3.0.1
我运行了"choco install autorest",所以我应该运行最新版本
I ran "choco install autorest" so I should be running the latest version
如果autorest不支持openapi3.0,那么肯定还必须有一种生成openapi2.0 json文件的方法吗?
If autorest doesn't support openapi3.0 there must still surely be a way to generate an openapi2.0 json file?
推荐答案
此线程之后,自动休息功能尚不支持最新的开放式api,但有解决方法
Followed this thread, auto rest doesn’t support latest open api yet but there are workarounds
https://github.com/Azure/autorest/issues/2680
您可以执行以下操作:
app.UseSwagger(o => o.SerializeAsV2 = true);
这篇关于Autorest错误-swagger.json'不是有效的OpenAPI 2.0定义(预期为'swagger:2.0')的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!