Open wonderer007 opened 8 years ago
Try manually adding a "/" to basePath in api-docs.json
{
"apiVersion": "1.0",
"swaggerVersion": "1.2",
"basePath": "/",
"apis": [
{
"path": "some path",
"description": "some description"
}
],
"authorizations": null
}
This did fix it for me but I am still trying to figure out how to solve the problem permanently because it will refresh once you run rake swagger:docs
As a temporary fix i did .sh script
set -o nounset # Treat unset variables as an error
sed 's/"basePath": "",/"basePath": "\/ipa-swagger",/' public/ipa-swagger/api-docs.json > public/ipa-swagger/api-docs-tmp.json; mv public/ipa-swagger/api-docs-tmp.json public/ipa-swagger/api-docs.json;
FILES=public/ipa-swagger/api/v1/* for i in $FILES do sed 's/"basePath": "",/"basePath": "\/",/' $i > $i-tmp; mv $i-tmp $i; done
FILES=public/ipa-swagger/employee_api/v1/* for i in $FILES do sed 's/"basePath": "",/"basePath": "\/",/' $i > $i-tmp; mv $i-tmp $i; done
Every time you want to refresh your swagger docs you'll have to run
rake swagger:docs && ./script.sh
Hopefully it helps :)
I am generating swagger docs using rails 5 API, below is my swagger.rb
I have able to run
rake swagger:docs
successfully and it generated .json file inside public/api folder but I cannot be able to access swagger docs UI through my base path which is http://localhost:3000/api I think I am doing something wrong hereThanks for reading