Create an API with Swagger

Share this video with your friends

Send Tweet

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.

David
David
~ 8 years ago

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.

Will Button
Will Button(instructor)
~ 8 years ago

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!

Will Button
Will Button(instructor)
~ 8 years ago

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

Olivers De Abreu
Olivers De Abreu
~ 8 years ago

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

Will Button
Will Button(instructor)
~ 8 years ago

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.

Olivers De Abreu
Olivers De Abreu
~ 8 years ago

Great thank you

Alexandr
Alexandr
~ 7 years ago

Hello, Will. Where is information about authorization and authentication? I not found it in lessons.But in course about section you say: "...Along the way, we will discover how to implement additional details required for a fully functional API such as authorization, authentication,..."

Alexandr
Alexandr
~ 7 years ago

Hello Will, where is information about authorization and authentication?

Alexandr
Alexandr
~ 7 years ago

Hello Will, where is information about "...authorization, authentication..."?

Jonathan Palma
Jonathan Palma
~ 5 years ago

If someone is receiving an "Error: Cannot find module swagger_router" using node 12, check https://github.com/swagger-api/swagger-node/issues/586 The user s-kalaus share this answer as a workaround

Problem is that in Node 12 Module Not Found error differs from Node 10. bagpipes relies on error message text. This can tepmorary be fixed in this file: node_modules/bagpipes/lib/fittingTypes/user.js file: var split = err.message.split(path.sep); should be var split = err.message.split('\n')[0].split(path.sep);

Jonathan Palma
Jonathan Palma
~ 5 years ago

If someone in Windows is receiving a " SyntaxError: Invalid regular expression: /.{1,0}/: " Try to use the CMD instead of another console, I received that error in git bash

sinewave440hz
sinewave440hz
~ 5 years ago

Little thing but may get you started quicker; some shells (zsh) currently require you to put quotes around the url in curl http://127.0.0.1:10010/hello?name=Scott

Amani
Amani
~ 4 years ago

For anyone who might be running WSL and run into issues with xdg-open - swagger project edit will crash, meaning the editor server doesn't start. You can run the editor without the swagger command attempting to open it in the browser with the --silent option. E.g. swagger project edit --silent. You should then be able to reach the editor by navigating to the host:port output by the command in your browser.

Jean-Michel
Jean-Michel
~ 3 years ago

Is there a way to use ES6 modules other than transpiling (with Webpack for example) ?