Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Absolute path calculated not correctly in swagger.js #84

Closed
Novarg opened this issue Mar 5, 2014 · 3 comments
Closed

Absolute path calculated not correctly in swagger.js #84

Novarg opened this issue Mar 5, 2014 · 3 comments

Comments

@Novarg
Copy link

Novarg commented Mar 5, 2014

Moved this issue into right place.

Abs path in getAbsoluteBasePath from swagger.js calculated not correctly in case when relativeBasePath is /. Currently it returns whole url except slash itself. When the basePath is / then we should treat url as <proto>://<domain> (root of the domain path). Check the patch to see what i mean.

--- dist/lib/swagger.js (revision c92e9a14b98a99064a6256a71706b6b586271a98)
+++ dist/lib/swagger.js (revision )
@@ -381,7 +381,9 @@
       return url + "/" + relativeBasePath;
     }
   } else if (relativeBasePath === "/") {
-    return url.substring(0, pos);
+    parts = url.split("/");
+    url = parts[0] + "//" + parts[2];
+    return url;
   } else {
     return url.substring(0, pos) + relativeBasePath;
   }
@fehguy
Copy link
Contributor

fehguy commented Mar 5, 2014

I'm a tiny bit lost (probably not enough sleep)--do you have a server up and running with a relative base path that I can look at?

@Novarg
Copy link
Author

Novarg commented Mar 5, 2014

I haven't but i can provide some output, maybe that will help.
https://gist.github.com/Novarg/9378218
This resources.json gist desctibe my resources, it sets "basePath": "http://localdomain.local:8001/api/v1/doc/schema"

Next gist https://gist.github.com/Novarg/9378144 contain entity resource description:
resource path set from the root:
"path": "/api/v1/entity/"
...
"basePath": "/",

With current implementation if i try to get some data from that entity resource (by clickint 'try it out!' button) swagger ui try to fetch the following url http://localdomain.local:8001/api/v1/doc/api/v1/entity/
You see that it doesn't build url from the domain root as requested by "basePath": "/"

Such url build function is SwaggerResource.prototype.getAbsoluteBasePath and on my view it build wrong url in my case when if i get relativeBasePath === "/" (that is actually basePath from entity.json) and this.api.basePath points to http://localdomain.local:8001/api/v1/doc/schema.

Or i just wrongly interpreting basePath meaning.

@fehguy
Copy link
Contributor

fehguy commented Jul 11, 2014

closing as #92 was merged.

@fehguy fehguy closed this as completed Jul 11, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants