An open API service indexing awesome lists of open source software.

https://github.com/jenderenco/inkifyai-doc-generator

AI-powered tool that generates comprehensive, human-readable documentation from OpenAPI/Swagger specifications using large language models.
https://github.com/jenderenco/inkifyai-doc-generator

ai api-documentation developer-tools documentation gitbook java llm markdown ollama openapi spring-boot swagger

Last synced: 3 months ago
JSON representation

AI-powered tool that generates comprehensive, human-readable documentation from OpenAPI/Swagger specifications using large language models.

Awesome Lists containing this project

README

          

# InkifyAI - AI-powered OpenAPI Documentation Generator

InkifyAI is a web application that uses AI to automatically generate clear, human-friendly
documentation from OpenAPI specifications (Swagger v2 and v3). By leveraging large language models,
it transforms technical API definitions into well-structured, easy-to-read documentation — making it
more accessible for developers and stakeholders alike.

> **Name Origin**: InkifyAI comes from the phrase "Let AI ink your APIs" - reflecting our mission to
> use artificial intelligence to document your API specifications elegantly and efficiently.


📸 InkifyAI Preview

Screenshot of InkifyAI interface

Generate beautiful API documentation with ease

## Features

- **Simple Web Interface**: Upload your OpenAPI specification URL and get documentation in seconds
- **AI-Powered Documentation**: Uses LLMs to generate high-quality, human-readable documentation
- **GitBook-Ready Markdown**: Documentation is generated in Markdown format optimized for GitBook
- **Spring AI Integration**: Leverages Spring AI for seamless LLM integration
- **Multiple LLM Support**: Designed to work with various LLM providers, currently supporting Ollama
- **OpenAPI Compatibility**: Supports both OpenAPI v3 and Swagger v2 specifications
- **Caching**: Caches OpenAPI specifications for improved performance
- **Streaming Responses**: Processes LLM responses as they arrive for efficient generation

## Prerequisites

- Java 21 or higher
- Maven 3.6 or higher
- [Ollama](https://ollama.ai/) installed and running locally with the `llama3.2` model
- You can install Ollama from [ollama.ai](https://ollama.ai/)
- Pull the llama3.2 model with: `ollama pull llama3.2`

## Installation

1. Clone the repository:
```bash
git clone https://github.com/jenderenco/inkifyai-doc-generator.git
cd inkifyai-doc-generator
```

2. Build the application:
```bash
./mvnw clean package
```

3. Run the application:
```bash
./mvnw spring-boot:run
```

4. Access the application at [http://localhost:8080](http://localhost:8080)

## Usage

1. Ensure Ollama is running with the llama3.2 model (if using the default Ollama provider):
```bash
ollama serve
```

2. Open your browser and navigate to [http://localhost:8080](http://localhost:8080)

3. Enter the URL of your OpenAPI specification. You can use these example URLs for testing:
- Swagger v2: `https://petstore.swagger.io/v2/swagger.json`
- OpenAPI v3: `https://petstore3.swagger.io/api/v3/openapi.json`

4. Select your preferred AI provider from the dropdown (default: Ollama)

5. Click "Generate Docs" and wait for the AI to process your specification

6. The generated documentation will be displayed in Markdown format, which you can copy and use in
your documentation platform

## Configuration

The application can be configured through the `application.yml` file:

```yaml
spring:
application:
name: "inkifyai-doc-generator"
ai:
ollama:
base-url: http://localhost:11434 # URL of your Ollama instance
chat:
options:
model: llama3.2 # LLM model to use
temperature: 0.7 # Temperature setting for generation
top-k: 50 # Top-k sampling parameter
top-p: 0.9 # Top-p sampling parameter
num-predict: 2000 # Maximum number of tokens to generate

openapi:
fetcher:
connect-timeout: 5000 # Connect timeout in milliseconds
read-timeout: 10000 # Read timeout in milliseconds
max-retries: 3 # Maximum number of retry attempts
retry-delay: 1000 # Delay between retries in milliseconds
validate-url: true # Whether to validate URLs before fetching
cache-size: 100 # Number of OpenAPI specs to cache (0 to disable)
cache-ttl: 3600000 # Cache TTL in milliseconds (1 hour)

api:
generate-docs:
timeout: 1m # Timeout for document generation API endpoint
```

You can add additional LLM providers by implementing the `LlmClient` interface and registering them
as Spring beans. The application leverages Spring AI for LLM integration, making it easy to add
support for
additional LLM providers supported by Spring AI.

### Request Timeout

The application has a timeout configuration for the document generation API endpoint:

**API Endpoint Timeout**: Configured in `application.yml` with a default of 2 minutes:

```yaml
api:
generate-docs:
timeout: 2m
```

This timeout configuration prevents requests from hanging indefinitely and ensures that LLM
responses are processed within a reasonable time frame.

## How It Works

1. The application fetches the OpenAPI specification from the provided URL (with caching for
improved performance)
2. It parses the specification (supporting both OpenAPI v3 and Swagger v2 formats) to extract
relevant information
3. It constructs a detailed prompt using a GitBook-optimized template based on the parsed
specification
4. It sends the prompt to the selected LLM provider (using Spring AI integration) and processes the
streaming
response
5. It returns the generated documentation in GitBook-ready Markdown format, ready for use in
documentation
platforms

## Contributing

Contributions are welcome! Here's how you can contribute:

1. Fork the repository
2. Create a feature branch: `git checkout -b feature/my-new-feature`
3. Commit your changes: `git commit -am 'Add some feature'`
4. Push to the branch: `git push origin feature/my-new-feature`
5. Submit a pull request

### Code Style

This project follows
the [Google Java Style Guide](https://google.github.io/styleguide/javaguide.html). Please ensure
your code adheres to these guidelines when submitting contributions.

## License

This project is licensed under the MIT License - see the LICENSE file for details.

## Acknowledgements

- [Spring Boot](https://spring.io/projects/spring-boot) for the web framework
- [Spring AI](https://spring.io/projects/spring-ai) for LLM integration
- [Ollama](https://ollama.ai/) for local LLM inference
- [Swagger Parser](https://github.com/swagger-api/swagger-parser) for OpenAPI specification parsing