Build Node.js APIs with OpenAPI Spec (Swagger)

56 minutes

In this course we will build a ToDo API that stores notes using the OpenAPI Specification (Swagger). We will start with a blank API definition using the Swagger Online Editor. The Swagger definition file will be used to create a Node.js API. Along the way, we will discover how to implement additional details required for a fully functional API such as authorization, authentication, requests and responses. We will also learn about the powerful capabilities of Swagger to generate server side code and client libraries.

pro-course-rss-logo

PRO RSS Feed

Create an API with Swagger

Create An API Schema Definition Using Swagger

P

Define an HTTP GET Endpoint for a Node.js API Server with Swagger

P

Define an HTTP POST Endpoint for a Node.js Server with Swagger

P

Define an HTTP GET Endpoint with URL Parameters for a Node.js Server with Swagger

P

Define an HTTP DELETE Endpoint for a Node.js API Server with Swagger

P

Define an HTTP PUT Endpoint for a Node.js API Server with Swagger

P

Mock API Responses with Swagger

P

Create a Node.js function for an HTTP GET request for a Swagger API

P

Create a Node.js function for an HTTP POST request for a Swagger API

P

Create a Node.js function for an HTTP GET request with URL parameters

P

Create a Node.js function for an HTTP DELETE request for a Swagger API

P

Create a Node.js function for an HTTP PUT request for a Swagger API

P

Connect an existing React application to an API server created with Swagger

P

Build Monitoring into your API Server

P

Perform Load Tests on an API Server using Apache jmeter

P
node tutorial about Create an API with Swagger

Create an API with Swagger

3:56 node

Swagger is a project used to describe restful APIs using the OpenAPI Specification. It allows you to document your API so consumers understand the endpoints, parameters, and responses. In this lesson, I'll show you how to install the swagger command line tool, create a new API project using swagger, and introduce you to the swagger API editor.

node tutorial about Create An API Schema Definition Using Swagger

Create An API Schema Definition Using Swagger

2:13 node PRO

Schema definitions allow you to define the format and types of data sent and received by your API. This allows consumers of your API to be confident in using your API. In this lesson, you will learn how to create a schema definition for the Todo API server.

node tutorial about Define an HTTP GET Endpoint for a Node.js API Server with Swagger

Define an HTTP GET Endpoint for a Node.js API Server with Swagger

1:28 node PRO

In this lesson, you will learn how to create an HTTP GET endpoint for a node.js server using Swagger. This endpoint will be used to return all of the Todo items from Elasticsearch to the client.

node tutorial about Define an HTTP POST Endpoint for a Node.js Server with Swagger

Define an HTTP POST Endpoint for a Node.js Server with Swagger

1:23 node PRO

In this lesson, you will learn how to define HTTP POST operations for your Todo API server using Swagger. Creating the endpoint, passing the todo in the request body, and parsing the todo are all demonstrated.

node tutorial about Define an HTTP GET Endpoint with URL Parameters for a Node.js Server with Swagger

Define an HTTP GET Endpoint with URL Parameters for a Node.js Server with Swagger

1:35 node PRO

In this lesson, you will learn how to define an HTTP GET endpoint using Swagger with URL parameters to identify the ID of the Todo item being requested.

node tutorial about Define an HTTP DELETE Endpoint for a Node.js API Server with Swagger

Define an HTTP DELETE Endpoint for a Node.js API Server with Swagger

1:02 node PRO

This lesson demonstrates how to access the ID of a Todo item being deleted from the URL parameters when used with an HTTP DELETE method.

node tutorial about Define an HTTP PUT Endpoint for a Node.js API Server with Swagger

Define an HTTP PUT Endpoint for a Node.js API Server with Swagger

0:57 node PRO

In this lesson, you will learn how to define multiple parameters in the API specification to identify the ID of the Todo item being updated in the URL, as well as the contents for the updated Todo item in the body of the request.

node tutorial about Mock API Responses with Swagger

Mock API Responses with Swagger

2:51 node PRO

APIs created with Swagger have a built-in mock function, allowing you to mock responses from your API prior to writing the backend code to make it functional. In addition to learning how to enable this feature, I will show you how to write your own functions to enhance the mock responses returned when using the Swagger mock feature.

node tutorial about Create a Node.js function for an HTTP GET request for a Swagger API

Create a Node.js function for an HTTP GET request for a Swagger API

5:42 node PRO

This lesson will teach you how to create the javascript functions defined by the Swagger specification to return all Todo items to the client when requested with an HTTP GET method.

node tutorial about Create a Node.js function for an HTTP POST request for a Swagger API

Create a Node.js function for an HTTP POST request for a Swagger API

4:41 node PRO

This lesson shows you how to create the functions defined in the Todo API specification to create new Todo items when received in HTTP POST methods. You will also see the errors you will get when CORS is not properly configured and how to resolve them by installing the NPM CORS package.

node tutorial about Create a Node.js function for an HTTP GET request with URL parameters

Create a Node.js function for an HTTP GET request with URL parameters

3:33 node PRO

In this lesson, you will learn how to create a function in your Node.js Todo API server that gets the ID of the Todo item being requested from the URL and retrieve the Todo item from Elasticsearch.

node tutorial about Create a Node.js function for an HTTP DELETE request for a Swagger API

Create a Node.js function for an HTTP DELETE request for a Swagger API

2:45 node PRO

This lesson shows you how to delete a Todo item from Elasticsearch using the Todo ID from the URL parameters according to the specifications defined in your Swagger API docs.

node tutorial about Create a Node.js function for an HTTP PUT request for a Swagger API

Create a Node.js function for an HTTP PUT request for a Swagger API

2:52 node PRO

This lesson will teach you how to update a Todo item in Elasticsearch when received from an HTTP PUT method in your API server built with Swagger.

node tutorial about Connect an existing React application to an API server created with Swagger

Connect an existing React application to an API server created with Swagger

6:01 node PRO

In this lesson, I will show you how to update a simple, skeleton React application to work with the Todo API server built with Swagger. Using existing components, you will learn how to display all Todo items, update an existing Todo item, and add a new Todo item.

node tutorial about Build Monitoring into your API Server

Build Monitoring into your API Server

7:06 node PRO

There are a lot of great monitoring tools available for Node.js. It is also incredibly easy to build monitoring into your application. In this lesson, we will add precision monitoring to the function calls in the Todo API server, log it to the console, and persist those results to Elasticsearch where they can later be reviewed, graphed, and analyzed.

node tutorial about Perform Load Tests on an API Server using Apache jmeter

Perform Load Tests on an API Server using Apache jmeter

8:25 node PRO

The last step before deploying your new API server into production is to load test it. Load testing allows you to better understand the performance characteristics as well as forecast load and capacity. Fortunately, load testing is incredibly easy and I'll show you exactly how to create a load test plan, test the response from the API server to ensure it is responding correctly, and scale your test up to simulate as many users as needed.

Presented by:

Will Button

Will Button is a DevOps Engineer for Trax Technologies (http://www.traxtech.com) focused on delivering scalable, supportable and cost effective solutions to customers. He is a big fan of all things javascript, fitness, and crazy challenges of all types.

HEY, QUICK QUESTION!
Joel's Head
Why are we asking?