Can the base URL change dynamically?

947 views
Skip to first unread message

mkbry...@gmail.com

unread,
Sep 12, 2014, 2:47:16 PM9/12/14
to swagger-sw...@googlegroups.com
Is it possible for the user to change the base url where the swagger UI is pulling from per verb in the UI? Right now they'd have to individually edit each json file per resource.  Ideally the user would be able to select in the interface, per put get etc. method where to pull the data from

tony tam

unread,
Sep 12, 2014, 4:50:49 PM9/12/14
to swagger-sw...@googlegroups.com
You would need to modify the Swagger UI to do this at the moment.

mkbry...@gmail.com

unread,
Sep 12, 2014, 8:28:36 PM9/12/14
to swagger-sw...@googlegroups.com
Any idea how I would go about doing that?

tony tam

unread,
Sep 12, 2014, 9:46:34 PM9/12/14
to swagger-sw...@googlegroups.com
Sure, you can make a UI component to set a field in the UI.  Then you can intercept the URL for any request made like such:

// create a function to intercept each request and modify the URL
var RequestIntercept = function() {};
RequestIntercept.prototype.apply = function(obj, authorizations) {
  console
.log("modify your URL here");
  obj
.url = obj.url; // <= this is mutable
 
return true;
};


// when loading swagger ui, add the interceptor
window
.authorizations.add("intercept", new RequestIntercept());

mkbry...@gmail.com

unread,
Sep 16, 2014, 5:01:18 PM9/16/14
to swagger-sw...@googlegroups.com
Thank you! I will try this
Reply all
Reply to author
Forward
0 new messages