Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ranork/swagger-gpt
Swagger auto configuration with Chat GPT (NodeJS)
https://github.com/ranork/swagger-gpt
api automatic-documentation chatgpt code-generation codegeneration developer-tools documentation javascript json nodejs opensource rest-api swagger web-api webapi webdevelopment
Last synced: about 1 month ago
JSON representation
Swagger auto configuration with Chat GPT (NodeJS)
- Host: GitHub
- URL: https://github.com/ranork/swagger-gpt
- Owner: Ranork
- License: mit
- Created: 2023-07-24T13:39:25.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-07-12T09:58:11.000Z (6 months ago)
- Last Synced: 2024-07-12T11:25:23.900Z (6 months ago)
- Topics: api, automatic-documentation, chatgpt, code-generation, codegeneration, developer-tools, documentation, javascript, json, nodejs, opensource, rest-api, swagger, web-api, webapi, webdevelopment
- Language: JavaScript
- Homepage:
- Size: 58.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Swagger-GPT
Automatic Swagger Configuration for Node.js API Routes[![License](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![GitHub stars](https://img.shields.io/github/stars/Ranork/Swagger-GPT.svg)](https://github.com/Ranork/Swagger-GPT/stargazers)Welcome to the **Automatic Swagger Configuration** project! This Node.js-based repository aims to simplify the process of generating Swagger documentation for your API routes. Swagger is a powerful tool for describing and visualizing APIs, making it easier for developers to understand and interact with your endpoints.
This project gives you a flatten javascript file and necessery prompts to make a swagger configuration with chat gpt.
## Table of Contents
- [Getting Started](#getting-started)
- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [Usage](#usage)
- [Examples](#examples)
- [Configuration](#configuration)
- [Contributing](#contributing)
- [License](#license)
- [Contact](#contact)## Getting Started
### Prerequisites
Before you start using this tool, ensure you have the following prerequisites installed:
- Node.js (v12.0.0 or higher)
- NPM (v6.0.0 or higher)
- Your Node.js API project with defined routes### Installation
To install this package, simply clone this repository and install the required dependencies:
```bash
git clone https://github.com/Ranork/Swagger-GPT.git
cd Swagger-GPT
npm install
```## Usage
1. Before running the "generate-swagger" command, make sure you have cloned this repository and installed the required dependencies following the steps in the [Installation](#installation) section.
2. Copy the `.env.example` file to a new file named `.env` in the root directory of the project:
```bash
cp .env.example .env
```3. Open the `.env` file using a text editor of your choice and modify the values according to your project requirements:
```plaintext
target_path=".../API/src/routes"
file_suffix=".js"
```- `target_path`: Specify the path where your Node.js API routes are located. This tool will scan the provided path for route files and generate Swagger documentation accordingly.
- `file_suffix`: If your route files have a specific file extension other than ".js", you can specify it here.4. Once you have configured the `.env` file, you can now run the "generate-swagger" command to automatically generate Swagger configurations for your API routes:
```bash
npm run start
```This command will utilize the configurations from the `.env` file, scan your Node.js API project, identify the defined routes, and generate Swagger documentation in JSON format.
5. Go to docs/ folder and open your files in order
6. Copy all lines and send to chat.openai.com bot
7. There is your swagger configuration!
## Examples
```javascript
/**
* @swagger
* /login:
* delete:
* summary: Kullanıcı Çıkışı
* description: Kullanıcıyı çıkış yapar ve tokenı geçersiz kılar.
* tags: [Auth]
* parameters:
* - name: Token
* in: header
* required: true
* schema:
* type: string
* description: Kullanıcı tokenı.
* responses:
* '200':
* description: Çıkış başarılı.
* content:
* application/json:
* schema:
* type: object
* properties:
* Success:
* type: boolean
* example: true
*//**
* @swagger
* tags:
* name: Auth
* description: Kullanıcı girişi ve çıkışı için API yönlendirmesi
*/
```## Configuration
You can customize the Swagger documentation generated by this tool using the base.txt file. The base.txt file allows you to provide additional comments and instructions that will be added to the generated Swagger documentation for each API route. This way, you can provide more context, descriptions, and notes specific to your API endpoints. The tool will look for the base.txt file and include its content for each route in the Swagger documentation.
The base.txt file in default:
```plaintext
// Create a swagger description for the route file given at the top, considering the following files
// Create this specification to be added with @swagger inside the route javascript file
// Create a tag that defines the route and add it to it
// Show only rows to be added as attachments
// Pay attention to the details of the body parameters
// Make Language: Turkish
```## Contributing
We welcome contributions from the community to improve this project and make it even more robust. If you have any bug fixes, enhancements, or new features to propose, please follow the standard GitHub fork and pull request workflow.For more details, please read our Contribution Guidelines.
## License
This project is licensed under the MIT License - see the LICENSE file for details.## Contact
If you have any questions or suggestions regarding this project, please feel free to reach out to us:Email: [email protected]
GitHub: @Ranork
Thank you for using Automatic Swagger Configuration for Node.js API Routes! Happy documenting your APIs!