Skip to content

OpenAPI Integration with Swift-DocC: Automated API Documentation Generation

License

Notifications You must be signed in to change notification settings

ayushshrivastv/OpenAPI-integration-with-DocC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenAPI Integration with DocC

This project aims to create a tool that automatically converts OpenAPI specifications into Swift-DocC compatible documentation. By bridging OpenAPI and Swift-DocC through SymbolGraph files, we'll enable seamless documentation generation for REST APIs within the Swift ecosystem.

The project is still in its very early stage, and I’m actively working on improving it.

Google Summer of Code @Swift project to integrate OpenAPI Integration with Swift-DocC: Automated API Documentation Generation.

Technical Details

Problem Statement

Currently, Swift developers maintaining REST APIs need to manually document their APIs in DocC while separately maintaining OpenAPI specifications. This creates duplicate work and potential inconsistencies between API specifications and documentation.

Proposed Solution

Command line tool to simplify API documentation for Swift developers. It parses OpenAPI JSON/YAML files using OpenAPIKit Swift Library, transforms schemas and endpoints into DocC ready SymbolGraph files with createSymbolGraph, and outputs “symbolgraph.json.” Users then execute docc convert symbolgraph.json --output-path docs to create HTML docs, enhanced by a static “API.docc/” catalog for custom pages. For GSoC, I’ll extend support for complex schemas like nested objects and arrays, automate DocC conversion, and add live previews, ensuring effortless, consistent API documentation from OpenAPI specs.

swift run openapi-to-symbolgraph <path-to-openapi.json>: Runs your tool to parse and generate “symbolgraph.json.”

docc convert symbolgraph.json --output-path docs: Converts the SymbolGraph into HTML documentation.

Parses OpenAPI specifications (JSON/YAML) Converts API endpoints and schemas into DocC-compatible SymbolGraph files Generates comprehensive API documentation using Swift-DocC

Architecture

OpenAPI Spec → Parser → Intermediate Representation → SymbolGraph Generator → DocC Integration

Features

  • Parses OpenAPI JSON/YAML specifications
  • Generates DocC-compatible SymbolGraph files
  • Creates documentation structure for API endpoints and schemas

Installation

Prerequisites

  • Xcode 14.0 or later
  • Swift 5.7+
  • macOS 11.0+

Steps

  1. Clone the repository:
git clone https://github.com/yourusername/OpenAPI-integration-with-DocC.git
  1. Navigate to the project directory:
cd OpenAPI-integration-with-DocC
  1. Build the project:
swift build
  1. (Optional) Run tests:
swift test

Converting to DocC

  1. Generate the SymbolGraph file:
swift run openapi-to-symbolgraph test/sample-api.json --output
  1. Convert to DocC documentation:
swift run docc convert symbols/symbolgraph.json --output-path ./docs

2e8f1a628c69dcaafc08ad6f8bad785ceae2cc02_2_1380x300

Examples

Basic Usage

# Convert a simple API specification
swift run openapi-to-symbolgraph api.json --output ./symbols

Screenshot 2025-03-17 at 1 57 27 PM

Project Structure

  • Sources/: Contains the main Swift source code
  • test/: Contains test files and sample OpenAPI specifications
  • API.docc/: Contains DocC documentation catalog

Requirements

  • Swift 5.7+
  • macOS 11.0+

Dependencies

License

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

About

OpenAPI Integration with Swift-DocC: Automated API Documentation Generation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages