Swagger API Documentation in NodeJS - node.js

I am facing the problem in setting up Swagger. How can I implement Swagger to in my node-express project to write API Doc for existing APIs?
I have looked swagger, swagger-ui, and swagger-ui-dist npm packages. But not getting the desired output.
I want to use Swagger UI but getting counfused in the confugurations. Can anybody tell me the step by step guide for the configuration?
Need help.

After basic installation:
Here is a STEP-BY-STEP guide.
Adding Swagger To Existing Node.js Project
Using Swagger UI with any codebase
Hope this is what you are looking for.

A good option for beginners is to install the Swagger NPM package https://www.npmjs.com/package/swagger and follow the instructions.
Overview:
// install
npm install -g swagger
// create a new project
swagger project create hello-world
// edit your API using the Swagger UI
swagger project edit
Then follow the rest of the instructions on how to code up your controllers.

Related

Integrate swagger codegen into an existing project

I work into a existing nodeJS project and I would like to use swagger codegen to automate the documentation.
Currently I write the swagger doc after to have code and there is always a time lag between dev and production....
I find two solutions. The first generate the node js projet and after you code inside, but my project have one year and lot of code...
The second solution is to write a syntax in my code and automate the documentation after with command line but this solution don't use yaml and my actual doc is to write is Yaml...
Thanks :)
If your existing node.js project uses Express as its web framework, you could consider using swagger-spec-express which would enable you to simply annotate your existing express api with swagger info.

node.js REST client for JHipster application

I have generated jhipster web-app, it comes with REST APIs.
Now, I would like to integrate an existing node.js application to jhipster web-app.
Is there a way to generate a rest-jhipster-client from existing jhipster app? Instead of manually creating functions and calls? Currently using node-rest-client for this
Thank you!
JHipster exposes your REST API documentation using swagger.
So you should look for swagger codegen to generate your client code from swagger JSON specification file, for your Jhipster app it is available at /v2/api-docs URL.
I'm not a nodejs expert but you could have a look at this one: https://www.npmjs.com/package/swagger-js-codegen

Angular2 and NodeJs

I'm trying to create an Angular2 project with a REST service, using NodeJs. Although I found some tutorials/sample codes doing this kind of applications, the organization of the code/project is different form each other. I'm trying to figure out what's the best way so far to do that.
Basically,
what is the best approach to creating Angular2 project with NodeJs back end?
what should be the folder structure?
where to put the Angular code(with TypeScript)?
how to use Bower/Gulp?
A sample of Angular2 + NodeJS and a few other things: http://thejackalofjavascript.com/developing-a-mean-app-with-angular-2-0/
You can use Angular-Cli to create the initial project structure: https://github.com/angular/angular-cli
Gulp tutorial: https://scotch.io/tutorials/automate-your-tasks-easily-with-gulp-js
I do not recommend using bower. Use npm instead, as it is more stable, and has more support from the tools.

Node Red Bluemix Application

Is there any way to provide front end to the NODE-RED App in BLUEMIX? I mean if there is a way to attach Angular.JS or PHP to the application.
You can embed a Node-RED app into an application based on AngularJS. Node-RED is based on Node.js and there is even official documentation on how to embed it. Take a look here: http://nodered.org/docs/embedding
You need to add the node-red package to the requirements and configure some settings. All is explained in the sample code provided in the above document.
I think the best way to use angularJs in combination with node-red is the template node from the dashboard ui:
npm package dashboard ui:
https://github.com/node-red/node-red-dashboard
detailed description of usage:
http://noderedguide.com/tag/template-node/

Sails.js API documentation

I want to develop an API using the MVC pattern. I found sails framework interesting and I'd like to know if it's possible to configure swagger or something like with sails to generate the documentation of my API (something like swagger-express for express for example).
Thanks!
This feature is in progress. If you'd like to help out, we can all collaborate here: https://github.com/balderdashy/sails/issues/1094
Update (August 2015):
Check out this Sails Hook that offers native Swagger integration. It compiles all of the bound routes in Sails, and generates a Swagger 2.0 document: https://github.com/tjwebb/sails-swagger
Here is what I did to have my documentation work with sails.js : you can download swagger-ui here : https://github.com/swagger-api/swagger-ui or via npm (npm install swagger-ui).
Then in the assets folder of your sails project, create a folder that points to the swagger folder ("docs" for example, so you'll be able to access to your documentation via your_url:port/docs)

Resources