Model Driven APIs – Swagger & Node.js
Posted by cfaurer on July 23rd, 2015 filed in Frameworx Consulting, Frameworx Training, REST APIsThanks to Apigee and their contribution to Swagger to create the new swagger-node project! Enabling model driven APIs – Swagger & Node.js
Swagger-node provides a platform that supports an API design-first development approach. Support exists for popular node.js frameworks – express, hapi, restify, sails and any connect-based middleware.
Our previous work with Swagger has supported a model-driven approach using NoMagic MagicDraw and E2E Builder & E2E Bridge along with Nomos RuleX.
Based on that experience, we’ve been able to quickly leverage the new swagger-node project to apply our model-driven approach quickly and effectively.
We took the existing model we have for the TM Forum Ticket Management REST API and made one primary change to support the ‘x-swagger-router-controller’ extension required by swagger-node to route incoming requests to the specified controller. You can learn more here by reading the controllers.md doc.
From the Ticket Management model we generate the swagger.json specification with support for the ‘x-swagger-router-controller’ extension.
The generated swagger.json is imported into Swagger Editor and provides the basis for driving the auto-code-generation feature of the swagger-node project.
Once the swagger.json API specification is verified and validated it’s time to write the controller code to drive the Swagger UI behavior (you can use the mock feature if desired) .
Shown below is the GET results retrieved from the Mongoose MongoDB middleware being used to provide persistence for the TicketManagement REST API reference implementation.
Again, thanks to the Apigee and Swagger teams for creating and sharing their new swagger-node project. It provides an outstanding design-driven platform that supports a model-driven approach to API design, development & implementation.
Leave a Comment
You must be logged in to post a comment.