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,它现在使用 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?
推荐答案
关注了这个帖子,auto rest 还不支持最新的open 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屋!