Dynamic Url value for Swagger UI's index.html page

1,284 views
Skip to first unread message

afjal jaha

unread,
Jan 9, 2015, 12:45:05 AM1/9/15
to swagger-sw...@googlegroups.com
Hi 

I want to make the swagger-ui 'url'  to dynamic one. the url which was currently mentioned in the index.html file of Swagger-UI.

currently i was doing like below :

index.html of swagger-ui:

  $(function () {
      var url = window.location.search.match(/url=([^&]+)/);
      alert(url);
      if (url && url.length > 1) {
        url = url[1];
      } else {
      }
      window.swaggerUi = new SwaggerUi({
      .....

But i dont want to hardcode it..!

because my url will changes from http://www1.devenv.com 
                                                  http://www2.qaenv.com
                                                  http://www3.prodenv.com

Looking for :
url = dynamicPath + "/services/api-docs"

what changes i need to there in index.html or any other file changes are required?






Message has been deleted

afjal jaha

unread,
Jan 9, 2015, 2:33:11 AM1/9/15
to swagger-sw...@googlegroups.com
Answer :
 
var myurl = window.location.protocol + "//" + window.location.host;           
     
window.swaggerUi = new SwaggerUi({
        url: myurl + "/myservices/api-docs",
      .....

Reply all
Reply to author
Forward
0 new messages