https://github.com/victorbadaro/node-swagger-example
An example node/express app that uses swagger
https://github.com/victorbadaro/node-swagger-example
node node-js nodejs swagger swagger-ui ts ts-node-dev typescript
Last synced: 8 months ago
JSON representation
An example node/express app that uses swagger
- Host: GitHub
- URL: https://github.com/victorbadaro/node-swagger-example
- Owner: victorbadaro
- Created: 2023-09-15T11:20:34.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-09-15T20:58:06.000Z (over 2 years ago)
- Last Synced: 2025-01-30T07:13:49.201Z (12 months ago)
- Topics: node, node-js, nodejs, swagger, swagger-ui, ts, ts-node-dev, typescript
- Language: TypeScript
- Homepage:
- Size: 43.9 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# node-swagger-example
[](./LEIAME.md)
## Summary
- [π§Ύ About](#-about)
- [π Main technologies](#-main-technologies)
- [π» Usage](#-usage)
- [π Requests](#-requests)
## π§Ύ About
This is an example of how to use swagger in a Node/Express application
## π Main technologies
- [Node.js](https://nodejs.org/)
- [Express](https://expressjs.com/)
- [Typescript](https://www.typescriptlang.org/)
- [Swagger](https://swagger.io/) (_using the [swagger-ui-express](https://github.com/scottie1984/swagger-ui-express) dependency_)
_(You can see all the dependencies in the [package.json](./package.json) file)_
## π» Usage
1. Clone the project (you'll need a [personal access token](https://docs.github.com/pt/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls)):
```bash
$ git clone https://github.com/victorbadaro/node-swagger-example
```
2. Access its directory:
```bash
$ cd node-swagger-example
```
3. Install its dependencies:
```bash
$ yarn
# feel free to use another package manager, but you might want use yarn once there's already a yarn.lock file in the root directory
```
4. Create a `.env` file in the root directory with the same content that is in the [.env.example](./.env.example) file and fill the `SERVER_PORT` variable with your own data (don't forget to change the `port` variable in the [requests](./requests.http) file if you're going to use it):
For example:

5. Start the server by running the `dev` script:
```bash
$ yarn dev
```
## π Requests
Now the server is ready to receive your requests. The **Swagger docs** are available on http://localhost:3333/api-docs (or localhost:{AnyOtherServerPortYouAreGoingToUse}/api-docs)! There's a [requests](./requests.http) file in the root directory so you can use (you might want to use the [Rest Client](https://marketplace.visualstudio.com/items?itemName=humao.rest-client) extension).
Here are the requests you can make:
- GET /users
- POST /users
```json
{
"name": "Shauna Farrell",
"email": "shauna.farrell@email.com"
}
```

---
This project was created and developed with β€ by Victor BadarΓ³