Autorest error - swagger.json' is not a valid OpenAPI 2.0 definition (expected 'swagger: 2.0')

时光总嘲笑我的痴心妄想 提交于 2020-05-23 13:54:25

问题


My api is running net core 3.0 with Swashbuckle.AspNetCore 5.0.0-rc5

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')

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

I ran "choco install autorest" so I should be running the latest version

If autorest doesn't support openapi3.0 there must still surely be a way to generate an openapi2.0 json file?


回答1:


Followed this thread, auto rest doesn’t support latest open api yet but there are workarounds

https://github.com/Azure/autorest/issues/2680

You can do this:

app.UseSwagger(o => o.SerializeAsV2 = true);


来源:https://stackoverflow.com/questions/59595335/autorest-error-swagger-json-is-not-a-valid-openapi-2-0-definition-expected

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!