I have made api documention with the help of swagger-editor. Now I want see it graphically with the help of swagger-ui. I have deployed my json here https://powerful-escarpment-92284.herokuapp.com/swagger.json
Now When I am trying to access it then I am getting an error
Failed to load spec.
I solved this by setting this header in the response of swagger.json file.
app.get('/:file(*)', function(req, res, next){
var file = req.params.file, path = __dirname + '/' + file;
console.log('.');
res.header('Access-Control-Allow-Origin', '*');
res.download(path);
});
I was getting this error in a c# project, due to a problem with a controller I added. I could get more information by trying to browse to the swagger.json It turned out I was missing the routing attribute on a controller action.
After many exercises for me apparently, it helped just to serve a file with flask server [How to serve static files in Flask. and (important) add "?" to the end of the url, i.e. http://127.0.0.1/js/swagger.json?