The ability to reply to discussions is limited to PRO members. Want to join in the discussion? Click here to subscribe now.

Create an API with Swagger

Create an API with Swagger

3:56
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.
Watch this lesson now
Avatar
egghead.io

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.

Avatar
Marcel

Hi, first I want to say that I like Egg-head. In many cases, you are ahead, and all your teachers are very smart. You guys put me on the right track in deciding what matters and whats good. Reasons enough to be very happy that you guys are around. Following the lessons is something else. Egg-head style lessons are famous to me because in most cases they leave me dazzeled after the first 3 minutes in lesson 1.

I, as a simple student, am lost again after the first 3 minutes Swagger. because there is no context. In this case: where can I find what is required in Swagger so that when I see the lesson, I can put things in context.
Example: at 1:45 in lesson 1, you say: I want to get rid of the licence stuff. Why would you want to do get rid of the licence stuff. Where can I find the Swagger documentation so that I understand this decison. At 2:06, it turns out property 'path' is missing. But first you want to add the 'host' element. Why would you first want to add the 'host' element. And how would I know a 'host' element is required in the first place.
If I, as a simple student, want to get to know Swagger, I will need to find a course (like I did for Angular2) that goes 1 step at a time. But thanks for drawing my attention to Swagger.

Marcel

In reply to egghead.io
Avatar
David

I think there is something wrong with this lesson: there is no instructions on how to install the command line, neither an introduction to Swagger. However, in the RSS appeared a different lesson with the same title that shows you how to install the command line and give a better introduction than this lesson.

Avatar
Will

Hey David,
You're absolutely right! That's not the correct lesson. We're getting the correct one uploaded now. I'll update here when it's fixed. Thanks for pointing it out!

In reply to David
Avatar
Will

Hey Marcel,
Thanks for your feedback. It's really important for us to hear what is working and what is not working for you. I completely understand your frustration, it sounds very familiar to what I experienced when first introduced to swagger.
There are a couple of things at work here:
First: this is the wrong lesson. It's an earlier version of this course I created, but wasn't happy with so I scrapped it and started over from scratch. The corrected version is getting uploaded as I type this.
Second: The swagger documentation can be found at http://swagger.io/specification/ but I think you'll find the same frustration there, I know I did, and that's what led me to creating this course. There are a lot of interdependencies in a swagger spec, including some that don't seem to make sense until much later. To deal with this, I tried to create a course that shows the 'how-to' steps so that you can use swagger immediately and be successful, then return to the finer points later as needed.
Thanks again for your feedback, it's extremely helpful in delivering the courses and lessons that you want!

In reply to Marcel
Avatar
Will

Hi David,
The correct lesson has been uploaded. Thanks again for pointing it out!

In reply to David
Avatar
Will

Marcel,
The correct lesson has been uploaded. Thanks for your feedback and support!

In reply to Marcel
Avatar
Marcel

Hi Will,
Thanks for taking my comment as I meant it: feedback that might help improve. I look forward to your new course, diving into swagger.

In reply to Will
Avatar
Samir

And this time it's great: clear and easy to follow lesson :) I used swagger at work on existing projects (so just consuming APIs) and didn't know it was that easy to create an API with it. Great news :)

In reply to Will
Avatar
Will

That's great to hear!
Thanks!

In reply to Samir
Avatar
Olivers De Abreu

Hi great tutorial, but I have the following question. When you are deploying to production how do you set the host and port variables?

For example in development you have in your yaml file http and localhost:10010 as your protocol, host and port, how do I change this to https and myapi.com ?

Do I have to use a nginx proxy server? It's there a way to do this with NODE_ENV variables?

Thank you

Avatar
Will

Hey Olivers,
For production: always use a proxy, either nginx as you mentioned or an ELB if you are using AWS.
This allows you to load balance across multiple node.js instances, the SSL overhead can be handled by the proxy so you don't have to do it inside your node application, and you don't have to figure out how to get node to run as root so it can bind to the ports 80 and 443.

In reply to Olivers De Abreu
Avatar
Olivers De Abreu

Great thank you

In reply to Will
HEY, QUICK QUESTION!
Joel's Head
Why are we asking?