Closed michel19 closed 7 years ago
@michel19 can you show us the code where you are providing your url? It worked for me, only when the url is in string format in controller scope. when I tried to assign url directly to attribute, it did not work.
@anil2 I haven't changed a thing in the code i am just trying the website and locally if i provide a different url in the text field that is different than the petstore url i won't get any response. Maybe the format of the url isn't right. Check the format of the url below and give me your opinion please: https://raw.githubusercontent.com/michel-el-hajj/testSwagger/master/default.json
@michel19 Your file is served with a content-type text/plain
it must be application/json
If you use the demo app http://orange-opensource.github.io/angular-swagger-ui/ you can see an error is thrown
If you're not able to serve your files with a valid content-type
you can force angular-swagger-ui
using the JSON parser using parser="json"
as directive parameter as described here : https://github.com/Orange-OpenSource/angular-swagger-ui#parser-type
yes i saw the error but i am surprised why the compiler doesn't understand it as a JSON file. Even if i upload the same JSON file on Github of the petstore example and i give it the url that the raw button will give, it returns the same error.
can you tell me how to have the documentation for a given local path(that is a JSON file for sure) in case i have lunched the angular-swagger-ui locally??
i have solved my problem by changing in swagger-ui.js just the following in line 104:
$scope.parser = $scope.parser || 'auto';
To
$scope.parser = $scope.parser || 'json';
As said before, you don't need to modify the source code, you just need to add directive parameter parser
Example: <div swagger-ui parser="json" ...>
i tried it and it didn't work maybe because i didn't use it in a div.
i added it in the index.html $scope.parser = "json";
Now i understand what i did wrong!! Thanks for the clarification.
I don't understand how you can use it outside an HTML element (a div or whatever) ...
i added it first in the angular controller where you set the default url in $scope.url = ..... So i wrote $scope.parser="json";
Ok so if you use my sample there is a div in index.html to init the component where you can set the parser parameter Setting parser parameter in the controller is not the best way to do it
yes i have edited my code since your first comment 35 minutes ago and it's working!! Thanks again
why can't i generate the documentation if i put a valid url for a valid JSON caught from github for example? the only valid URL is the petStore URL, could you make it possible to generate the documentation for any valid JSON?