-
Notifications
You must be signed in to change notification settings - Fork 47
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
Cannot set property 'doc' of undefined #3
Comments
I experienced the same issue. The hook was loaded successfully but was not added to sails.hooks. |
Sorry, updating documentation. This hooks currently works only with sails |
Will this make its way into v0.11? I'm not really sure on the timetable for v0.12 and happy to start on 0.12 if it's a relatively mature beta. |
0.12 is in "release candidate" stage at the moment. I'm running it in production in a couple of places. |
I'm running into problems getting it running with handlebars templates so for now I've reverted to |
The upgrade path to 0.12 should be pretty painless. Can you file a more specific issue in the Sails repo? |
@tjwebb, sure will do. thanks for your feedback here. |
Is there migration from v0.11.x to v0.12.x instructions? I am really excited to use sails-swagger however it is erroring with this issue. |
Following. Just got the same thing on 0.11.2 and 0.12.0-rc3. |
Works on master for me, but not 0.12.0-rc3 |
sails is now on 0.11.2 as master, and i have te same error |
Got the same error here:
|
This hook currently works only with sails 0.12 |
Any update on this ? I get the same error using 0.11.2 and 0.12. |
The problem seems to be about the name of the hook. The hook itself assume it is You can change the way sails loads an installable hook to load the hook correctly with // config/installedHooks.js
module.exports.installedHooks = {
"sails-swagger": {
// load the hook into sails.hooks.swagger instead of sails.hooks['sails-swagger']
"name": "swagger"
}
}; Then you can load the swagger document at http://127.0.0.1:1337/swagger/doc/ Edit // api/controllers/SwaggerController.js
var _ = require('lodash');
var _super = require('sails-swagger/dist/api/controllers/SwaggerController');
_.merge(exports, _super);
_.merge(exports, {
// Extend with custom logic here by adding additional fields, methods, etc.
}); |
I had to create both files in my project directory. |
@AlexisNo I have added both files you described (and also installed lodash). Swagger spec is available form http://localhost:1337/swagger/doc but how do you use swagger-ui then ? |
Swagger UI is not part of From the Swagger UI README file:
You can quickly have a Swagger UI app running on your local environment using docker
This will start Swagger UI at
Also, use
|
Thanks a lot for the details answer ! Got it working :) |
I got a problem with the CORS, even after doing what you said : the Access-Control-Allow-Origin header coming from my sailsjs app is empty, i can't find anything online. |
@adrien-candiotti I also have this problem so I copied the swagger-ui elements in an assets/docs folder instead, so ui is on the same machine/port. It seems I did not manage to setup the CORS correctly. |
@adrien-candiotti @lucj the problem with CORS is the config is hard coded #13. I believe the issue has been fixed in further commits in master, but a new released version has not been added to npm to publish the fix |
@moisesrodriguez Hi, thanks a lot for the update. |
So i read all the thread and was wondering if there was a fix for Sails v0.11.3. ? Thanks. |
I merged #18, I just need to publish to npm. You can use master for now |
Thanks a lot Travis ! On Mon, Dec 21, 2015 at 11:40 PM, Travis Webb [email protected]
Luc Juggery - https://about.me/lucjuggery |
@tjwebb would you mind publishing to npm. I'm getting this error on sails 0.12.0-rc4 and when I try to use master by doing this on my package.json |
Thanks @AlexisNo and @lucj - I was able to get it all running with your instructions! Now I need to figure out how to have the swagger-ui allow me to edit the post/put directly in swagger-ui like the demo. @tjwebb I look forward to the npm push as well. Let me know if I can help. Since I am not running off master for either project. I combined comments from this thread and hope it helps others:
|
@ralberts thanks for your summary, the only thing I did not get is how to navigate to /assets/docs to actually open the swagger.io on local server. |
@ralberts Thanks for your explination it helped me get the ui up and running. @talamaska you will go to http://localhost:1337/docs |
does anyone knows how to enable POST/PUT requests from the local swaggerUI? |
Please let me know how can I send data in query string? |
When i use sails-swagger it says :- error: The bootstrap function threw an error after its callback was called :: Ty peError: Cannot set property 'doc' of undefined. Do you have any documentation about how to implement.
I dig more into code and found
this.sails.hooks.swagger get undefined
in node_modules\sails-swagger\dist\api\hooks\swagger\index.js
The text was updated successfully, but these errors were encountered: