Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 396
levis84 Avatar asked Jan 04 '20 22:01

levis84


1 Answers

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);
like image 163
levis84 Avatar answered Oct 18 '22 00:10

levis84