Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 9 days 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 1 year ago)
- Default Branch: main
- Last Pushed: 2023-09-15T20:58:06.000Z (over 1 year ago)
- Last Synced: 2024-12-02T23:13:10.207Z (2 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](https://img.shields.io/badge/-Leia%20em%20Portugu%C3%AAs-brightgreen?style=for-the-badge)](./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:
![image](https://github.com/victorbadaro/node-swagger-example/assets/9096344/a1602e7a-e0be-4ba0-b383-02b7230d3eae)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": "[email protected]"
}
```
![image](https://github.com/victorbadaro/node-swagger-example/assets/9096344/47694078-8ba2-4d7d-a488-714b35bde713)
---This project was created and developed with β€ by Victor BadarΓ³