Sails.js API documentation - node.js

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)

Related

Node Express API - Object Mapper

We have created a new Node JS API using Express Framework (Typescript as scripting language). This API internally calls an external API. In order to call the external API from within our API, we need to do a translation of the API models to External API Models. Are there any NPM Packages that are available which does the Object to Object mapper?
As i understood your problem i recommend this package which i really find usefull for typescript backends: class-transformer
the github link : https://github.com/typestack/class-transformer#classtoclass
Also automapper-ts is a good choice too: https://github.com/loedeman/AutoMapper
i don't need to explain more than that i think. they have a good docs there. I hope it helps.

Swagger API Documentation in NodeJS

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.

Undestanding the flow of swagger UI

I am trying to mock the REST API using swagger.. I currently created nodejs project in which the default js appreas which is hello_world.js in ./api/controllers/hello_world.js.
Now I want to create a new controller and want to refer that to my YAML, that is from swaggerUI.. How can I do it? Any link would be much useful.
I am only mocking APIS, not developing.
Many thanks in advance.
Checkout the swagger codegen project, which generates server stubs based on the api specification. Node.js is among the supported languages: https://github.com/swagger-api/swagger-codegen

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

How do Swagger, Express/Nodejs, Sequelize fit all together in a App

I have some experience in Nodejs/Express, Sequelize and jwt apps.
Recently I started looking at API Designing tools/Specs like RAML -- API Designer, Swagger -- Swagger Tools
I am wondering and I found no article linking or pointing out that how can I use swagger to create/design APIs and then use it in my nodejs/express app which uses Sequelize as an ORM.
JWT functionality is added on to middleware for authentication & authorization.
As I tested so far, I can export nodejs scaffolded app structure from Swagger-Editor using Server Code. On inspection, it actually routes the calls to swagger/YAML files.
How can I use sequelize alongside it?
Also, how do you guys go around from API Spec/Design to App (tools or workflow).
Please point where I am going wrong.
You can take a look at the official documentation here. The docs might be written for v1.7.0 but I can tell you it's still relevant for usage in the latest Sequelize version (I have an actual server running with this design approach).
While your actual app's folder structure might be different due to Swagger's structure, but the way you use Sequelize within your app remains the same.

Resources