Automatic Swagger Configuration for Node.js API Routes
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.
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
To install this package, simply clone this repository and install the required dependencies:
git clone https://github.com/Ranork/Swagger-GPT.git
cd Swagger-GPT
npm install
-
Before running the "generate-swagger" command, make sure you have cloned this repository and installed the required dependencies following the steps in the Installation section.
-
Copy the
.env.example
file to a new file named.env
in the root directory of the project:
cp .env.example .env
- Open the
.env
file using a text editor of your choice and modify the values according to your project requirements:
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.
- Once you have configured the
.env
file, you can now run the "generate-swagger" command to automatically generate Swagger configurations for your API routes:
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.
-
Go to docs/ folder and open your files in order
-
Copy all lines and send to chat.openai.com bot
-
There is your swagger configuration!
/**
* @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
*/
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:
// 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
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.
This project is licensed under the MIT License - see the LICENSE file for details.
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!