You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have cloned the latest version of this project, v2.1.4-M1(75ca50f), and added an index file using the example from your readme:
<!DOCTYPE html>
<html>
<head>
<script src='lib/shred.bundle.js' type='text/javascript'></script>
<script src='lib/swagger-client.js' type='text/javascript'></script>
<script type="text/javascript">
// initialize swagger, point to a resource listing
window.swagger = new SwaggerClient({
url: "http://petstore.swagger.wordnik.com/api/api-docs",
success: function() {
if(swagger.ready === true) {
// upon connect, fetch a pet and set contents to element "mydata"
swagger.apis.pet.getPetById({petId:1}, function(data) {
document.getElementById("mydata").innerHTML = data.content.data;
});
}
}
});
</script>
</head>
<body>
<div id="mydata"> </div>
</body>
</html>
First, I get the following warnings/errors in the console:
shred.bundle.js:1726 no zlib library
shred.bundle.js:1734 no iconv library
index.html:1 XMLHttpRequest cannot load http://petstore.swagger.wordnik.com/api/api-docs. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
swagger-client.js:548 Uncaught Can't read from server. It may not have the appropriate access-control-origin settings.
So I change the url to http://petstore.swagger.io/v2/swagger.json, and I only get the warnings from shred (which can safely be ignored). But swagger.ready is never set and no data is output to the div.
Personally, I want to use jQuery anyway, so I added the flag useJQuery: true (as well as replacing the reference to shred with jQuery), but I still get no results.
<!DOCTYPE html>
<html>
<head>
<script src='lib/jquery-1.8.0.min.js' type='text/javascript'></script>
<script src='lib/swagger-client.js' type='text/javascript'></script>
<script type="text/javascript">
// initialize swagger, point to a resource listing
window.swagger = new SwaggerClient({
url: "http://petstore.swagger.io/v2/swagger.json",
useJQuery: true,
progress: function(message) {
console.log(message)
},
success: function() {
if(swagger.ready === true) {
// upon connect, fetch a pet and set contents to element "mydata"
swagger.apis.pet.getPetById({petId:1}, function(data) {
document.getElementById("mydata").innerHTML = data.content.data;
});
}
}
});
</script>
</head>
<body>
<div id="mydata"> </div>
</body>
</html>
I believe this was last working with version v2.1.1-M1 (f29b091).
The text was updated successfully, but these errors were encountered:
alycda
changed the title
Can't run from the browser
swagger.ready is not set when running from browser
Feb 12, 2015
Hi,
I have cloned the latest version of this project, v2.1.4-M1(75ca50f), and added an index file using the example from your readme:
First, I get the following warnings/errors in the console:
So I change the url to
http://petstore.swagger.io/v2/swagger.json
, and I only get the warnings from shred (which can safely be ignored). Butswagger.ready
is never set and no data is output to the div.Personally, I want to use jQuery anyway, so I added the flag
useJQuery: true
(as well as replacing the reference to shred with jQuery), but I still get no results.I believe this was last working with version v2.1.1-M1 (f29b091).
The text was updated successfully, but these errors were encountered: