← All Project Ideas

OpenAPI Spec Generator from Code

intermediate

A tool that generates OpenAPI specifications from API route code, JSDoc annotations, or runtime request/response capture. Supports schema inference, example generation, and spec validation with dif...

Target user

API developers who maintain OpenAPI specifications

Problem

API developers need to keep OpenAPI specs in sync with code but manual spec maintenance is error-prone and tedious without a generator that extracts specs from code.

Requirements

  • Extract OpenAPI spec from route definitions
  • Parse JSDoc annotations for documentation
  • Infer schemas from TypeScript types
  • Generate request/response examples
  • Validate generated spec against schema

Core technologies

TypeScript, AST, OpenAPI

Completion criteria

Developers can generate valid OpenAPI specs from code with schema inference, examples, and validation.

Optional extensions

  • Add runtime capture mode
  • Implement spec diff
  • Add Swagger UI integration
  • Support GraphQL to OpenAPI

Project phases

Phase 1: Phase 1: Code Analysis

Tasks: Set up TypeScript project with AST parser, Extract route definitions from code, Parse JSDoc annotations, Infer schemas from types

Phase 2: Phase 2: Spec Generation

Tasks: Build OpenAPI spec data model, Generate paths and components, Create examples from schemas, Add response status codes

Phase 3: Phase 3: Validation and Output

Tasks: Validate spec against OpenAPI schema, Add spec diff comparison, Create output formats, Build CLI interface