Forum Discussion
How to import an existing REST API from a Swagger
I have been looking at this tutorial for Azure API Manager https://learn.microsoft.com/en-us/azure/api-management/import-and-publish, which tells you how to create an API from the JSON stored at https://conferenceapi.azurewebsites.net/?format=json.
I have a number of REST APIs built in Visual Studio using the WEB API 2.0 Template, which I'd like to import, but I cant find a way to render my API as JSON in the same way as the conference API.
My API returns a functioning swagger at https://MyAPi:1234/swagger/ui/index
I have tried rendering it as JSON by adding /?format=json to various parts of the url with varying errors
https://MyAPi:1234/swagger/ui/index/?format=json returns
{"Message":"An error has occurred.","ExceptionMessage":"Mapping not found - index/","ExceptionType":"Swashbuckle.SwaggerUi.AssetNotFound","StackTrace":" at Swashbuckle.SwaggerUi.EmbeddedAssetProvider.GetAsset(String rootUrl, String path)\r\n at Swashbuckle.Application.SwaggerUiHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)"}
https://MyAPi:1234/swagger/ui/?format=json returns a 404 not found
https://MyAPi:1234/swagger/?format=json redirects me to the https://MyAPi:1234/swagger/ui/index page
https://MyAPi:1234/?format=json returns a 404 not found
Does anyone have any suggestions
Many Thanks
Richard