Hi, I am very interested by this hook and would be pleased to give an help.
I installed it on Sails master branch. Dealing with the configuration, I thought I could propose some evolution:
Use the the sails hook defaults instead of config/routes.js and add defaults values for sails.config.swagger.pkg and sails.config.swagger.ui.
Do not make sails.config.swagger.pkg mandatory. I initialized it with a default name, and a description that invites to use require('../package'). That way, the hook can be quickly experimented.
sails.config.swagger.ui is initialized to http://localhost:8080/. This value is also used for the configuration of CORS (Previously, http://swagger.balderdash.io was hard coded). I choose this default value because it is what you get using the docker build mentioned on swagger-ui's README.
I also added http://online.swagger.io to the CORS configuration to be able to display the validator badge that is included in swagger-ui. It will obviously not work on a local environment, but it can give a useful information for the user and be used later. Since the validator uses a browserless back-end to fetch the contents and schema, it's not subject to the terrible world of CORS.
If these proposals are OK for you, I could update the README too.
As a second step, do you think that it would make sense (or is possible) to generate the routes config in the hook's default() function?
It would allow to generate the CORS rule based on sails.config.swagger.ui instead or configuring this address twice.
Adding some configuration keys in sails.config.swagger could allow the user to easily choose other paths (if he wants to use something else than /swagger/api and/or /swagger/ui).
Hi, I am very interested by this hook and would be pleased to give an help.
I installed it on Sails master branch. Dealing with the configuration, I thought I could propose some evolution:
config/routes.js
and add defaults values forsails.config.swagger.pkg
andsails.config.swagger.ui
.sails.config.swagger.pkg
mandatory. I initialized it with a default name, and a description that invites to userequire('../package')
. That way, the hook can be quickly experimented.sails.config.swagger.ui
is initialized tohttp://localhost:8080/
. This value is also used for the configuration of CORS (Previously,http://swagger.balderdash.io
was hard coded). I choose this default value because it is what you get using the docker build mentioned on swagger-ui's README.I also addedSince the validator uses a browserless back-end to fetch the contents and schema, it's not subject to the terrible world of CORS.http://online.swagger.io
to the CORS configuration to be able to display the validator badge that is included in swagger-ui. It will obviously not work on a local environment, but it can give a useful information for the user and be used later.If these proposals are OK for you, I could update the README too.
As a second step, do you think that it would make sense (or is possible) to generate the
routes
config in the hook'sdefault()
function?sails.config.swagger.ui
instead or configuring this address twice.sails.config.swagger
could allow the user to easily choose other paths (if he wants to use something else than/swagger/api
and/or/swagger/ui
).