-
Notifications
You must be signed in to change notification settings - Fork 9k
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
Swagger using base path for resource definition #490
Comments
Hi, are you using grape-swagger by chance? |
I'm using swagger-docs. |
While there may still be a bug in swagger-ui, your api-docs.json is wrong as it shouldn't include the basePath property in it (it's not in accordance to the spec). Can you try removing it and test again? |
It's somehow better, but still not fully correct:
Works with this modification:
|
"apis": [ The path should be
On 11 July 2014 13:02, Maciej Kruk [email protected] wrote:
|
Changing {format} to json doesn't change anything. |
right, you're missing a leading slash to the value -
On 11 July 2014 13:08, Maciej Kruk [email protected] wrote:
|
Hi, I'm going to close this out, please reopen if still an issue. |
on hitting https://api.company.com/api/doc, it gives me:
on using swagger-codegen for ruby, it gives me: however api's(calls to https://api.company.com/v1/users etc) are working correctly as expected. |
@kakadiya91 - The output: {
"apiVersion": "v1",
"swaggerVersion": "1.2",
"produces": [
"application/json"
],
"operations": [],
"apis": [
{
"path": "/api/doc/users.{format}"
}
],
"info": {},
"basePath": "https://api.company.com"
} is incorrect - this is an invalid swagger specification file. The ui may work properly, but the codegen may be a bit more sensitive to malformed structures. |
@kakadiya91 are you using grape swagger by chance? If so there's a fork that addresses these issues, see this sample: |
Thank you @fehguy, @webron. I pointed my app to that gem (https://github.com/CraigCottingham/grape-swagger), made some code changes to my api repo to work with this gem, now it works like a charm. |
basePath is not a valid element in the resource list, and it causes swagger-ui to load the wrong paths from the backend, in effect breaking the entire service. See this for a related issue: swagger-api/swagger-ui#490
basePath is not a valid element in the resource list, and it causes swagger-ui to load the wrong paths from the backend, in effect breaking the entire service. See this for a related issue: swagger-api/swagger-ui#490
I'm serving my API from
localhost:3000/api/
. I keep swagger resources' definition atlocalhost:3000/docs/swagger/
and I want to serve the documentation fromlocalhost:3000/docs
.I pointed swagger to the root resource definition file (
http://localhost:3000/docs/swagger/api-docs.json
). File content:Swagger correctly reads the file and displays
registrations
resource, however when it tries to fetch the resource specification, instead of using relative path and going tohttp://localhost:3000/docs/swagger/api/v2/registrations.json
it uses api base path, which results in the error:I traced the error to this line.
What am I doing wrong here?
I fixed it temporarily by changing the basePath in
swagger.js
:The text was updated successfully, but these errors were encountered: