Skip to content

This command-line tool generates Swagger documentation for API endpoints using OpenAI's GPT model. It takes a description, framework, request payload, and response payload as input and returns Swagger documentation based on the provided details.

License

Notifications You must be signed in to change notification settings

reinaldoperes/gpt-api-doc-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GPT-based API Documentation Generator

Swagger Doc Generator Banner

This command-line tool generates Swagger documentation for API endpoints using OpenAI's GPT model. It takes a description, request payload, response payload and output format as input and returns Swagger documentation based on the provided details.

Table of Contents

Requirements

Installation

  1. Clone the repository to your local machine:
git clone https://github.com/yourusername/gpt-api-doc-generator.git
  1. Navigate to the project folder and install the dependencies:
cd gpt-api-doc-generator
npm install
  1. Set up your OpenAI API key. Create a .env file in the root directory of the project and add your OpenAI API key:
OPENAI_API_KEY=your_openai_api_key

Usage

  1. In the terminal, navigate to the project directory.

  2. Run the command:

node index.js

The application will prompt you for the following information:

  • Enter the description of the API endpoint.
  • Enter the request payload (JSON) in a one-line format.
  • Enter the response payload (JSON) in a one-line format.
  • Enter the desired output format (JSON or YAML).

After providing the required information, the application will generate Swagger documentation for the given API endpoint and display it in the console.

  1. The tool will generate and output the Swagger documentation based on the provided details.

Example Input

  1. Description: Retrieve a list of users
  2. Request payload (JSON, one-line format): {"page": 1, "pageSize": 10}
  3. Response payload (JSON, one-line format): {"data": [{"id": 1, "name": "John Doe", "email": "john.doe@example.com"}, {"id": 2, "name": "Jane Doe", "email": "jane.doe@example.com"}], "total": 100, "page": 1, "pageSize": 10}
  4. Desired output format (JSON or YAML): JSON

Use this test input to run the command line application and generate Swagger documentation with descriptions for each field in the request and response payloads.

How to Contribute

  1. Fork the repository on GitHub.

  2. Clone your fork to your local machine:

git clone https://github.com/reinaldoperes/gpt-api-doc-generator.git
  1. Create a new branch for your changes:
git checkout -b my-feature-branch
  1. Make your changes and improvements to the code.

  2. Add and commit your changes:

git add .
git commit -m "My new feature or improvement"
  1. Push your changes to your fork:
git push origin my-feature-branch
  1. Create a pull request from your fork to the original repository.

License

This project is licensed under the MIT License.

About

This command-line tool generates Swagger documentation for API endpoints using OpenAI's GPT model. It takes a description, framework, request payload, and response payload as input and returns Swagger documentation based on the provided details.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published