apigateway2openapi

package module
v0.0.0-...-aae411a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 22, 2025 License: MIT Imports: 7 Imported by: 0

README ΒΆ

AWS API Gateway to OpenAPI 3.0 Converter

Code lines Comments

A comprehensive Go tool that converts AWS API Gateway documentation parts to valid OpenAPI 3.0 specifications with complete coverage of all AWS documentation part types.

🎯 Why Use This Tool

Transform your AWS API Gateway exports into industry-standard OpenAPI specifications for:

  • API Documentation: Generate comprehensive API documentation for development teams
  • Code Generation: Use with OpenAPI generators to create client SDKs and server stubs
  • API Testing: Integrate with testing frameworks that support OpenAPI specifications
  • DevOps Integration: Automate API documentation as part of your CI/CD pipeline

✨ Features

  • Complete AWS API Gateway Support: Supports all AWS documentation part types for comprehensive API documentation
  • Professional CLI: Intuitive command-line interface with configurable options and detailed help
  • Flexible Output: Custom output filenames, verbose logging, and configurable processing options
  • Production Ready: Enterprise-grade reliability with robust error handling and input validation
  • Well Tested: Comprehensive test suite ensuring consistent and accurate conversions

πŸ“‹ Supported Documentation Parts

  • βœ… API: General API information and metadata
  • βœ… METHOD: Complete HTTP method definitions (GET, POST, PUT, DELETE, PATCH, etc.)
  • βœ… MODEL: Schema definitions converted to OpenAPI components
  • βœ… PATH_PARAMETER: Path parameter documentation (e.g., /pets/{petId})
  • βœ… QUERY_PARAMETER: Query parameter documentation
  • βœ… REQUEST_BODY: Request body schemas and examples
  • βœ… RESOURCE: Resource-level documentation
  • βœ… RESPONSE: Response definitions with proper error handling

πŸš€ Installation

Build from source
git clone https://github.com/mauriciocm9/apigateway2openapi.git
cd apigateway2openapi
go build -o apigateway2openapi cmd/apigateway2openapi/main.go
Using go install
go install github.com/mauriciocm9/apigateway2openapi/cmd/apigateway2openapi@latest

πŸ’» Usage

Basic Usage
# Convert with default output (out.yaml)
./apigateway2openapi input-file.json

# Custom output file
./apigateway2openapi input-file.json -o my-api-spec.yaml

# Verbose mode for detailed logging
./apigateway2openapi input-file.json -v
CLI Options
# Show help and all available options
./apigateway2openapi --help

# All options example
./apigateway2openapi samples/PetStore-staging-oas30-apigateway.json \
  --output custom-spec.yaml \
  --verbose
Using go run
# Run directly with go
go run cmd/apigateway2openapi/main.go samples/PetStore-staging-oas30-apigateway.json

πŸ“– Examples

Convert Pet Store API
# Using the included sample
./apigateway2openapi samples/PetStore-staging-oas30-apigateway.json -o petstore-openapi.yaml -v

Expected output:

Processing API Gateway file: samples/PetStore-staging-oas30-apigateway.json
Output will be written to: petstore-openapi.yaml
Successfully converted API Gateway documentation to OpenAPI spec: petstore-openapi.yaml

πŸ§ͺ Testing

# Run all tests
go test -v

# Run specific test
go test -run TestSpecHandler_processMethodPart -v

# Run tests with coverage
go test -v -cover

πŸ›  Development

Project Structure
β”œβ”€β”€ cmd/apigateway2openapi/    # CLI application entry point
β”œβ”€β”€ samples/                   # Sample API Gateway exports for testing
β”œβ”€β”€ models.go                  # Data structures for AWS and OpenAPI formats
β”œβ”€β”€ execute.go                 # Main conversion engine with input validation
β”œβ”€β”€ documentation_part.go      # Type-specific processors for all documentation parts
β”œβ”€β”€ *_test.go                 # Comprehensive test suite
Build and Test
# Install dependencies
go get .

# Build
go build -v ./...

# Test
go test -v

# Build CLI binary
go build -o apigateway2openapi cmd/apigateway2openapi/main.go

🎯 Key Features

Production Ready
  • Enterprise Grade: Robust error handling and input validation
  • Performance Optimized: Efficient processing of large API Gateway exports
  • Reliable: Comprehensive test suite ensuring consistent output quality
Developer Experience
  • Modern CLI: Intuitive command-line interface with helpful flags and options
  • Flexible Output: Configurable output files and detailed logging options
  • Easy Integration: Simple to incorporate into CI/CD pipelines and automation workflows

πŸ“„ License

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

🀝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“ž Support

  • πŸ“« Create an issue for bug reports or feature requests
  • πŸ“š Check CLAUDE.md for detailed architecture documentation
  • πŸ” Review the test files for usage examples

Documentation ΒΆ

Index ΒΆ

Constants ΒΆ

This section is empty.

Variables ΒΆ

This section is empty.

Functions ΒΆ

func Execute ΒΆ

func Execute(path string) ([]byte, error)

Types ΒΆ

type AmazonApigatewayDocumentation ΒΆ

type AmazonApigatewayDocumentation struct {
	Version            string
	DocumentationParts []DocumentationPart `json:"documentationParts"`
}

type DocumentationPart ΒΆ

type DocumentationPart struct {
	Location   Location
	Properties json.RawMessage
}

type Example ΒΆ

type Example struct {
	Value string `json:"value"`
}

type Location ΒΆ

type Location struct {
	Type       string
	Path       string
	Method     string
	Name       string
	StatusCode string `json:"statusCode"`
}

type Method ΒΆ

type Method struct {
	Description string   `json:"description"`
	Summary     string   `json:"summary"`
	Tags        []string `json:"tags"`
}

type OpenapiGateway ΒΆ

type OpenapiGateway struct {
	AmazonApigatewayDocumentation AmazonApigatewayDocumentation `json:"x-amazon-apigateway-documentation"`
}

type RequestBody ΒΆ

type RequestBody struct {
	Content     string `json:"content"`
	Description string `json:"description"`
}

type Response ΒΆ

type Response struct {
	Description      string                        `json:"description"`
	ResponseExamples map[string]map[string]Example `json:"responseExamples"`
	ResponseModels   map[string]string             `json:"responseModels"`
}

type SpecHandler ΒΆ

type SpecHandler struct {
	// contains filtered or unexported fields
}

func NewSpecHandler ΒΆ

func NewSpecHandler(path string) (SpecHandler, error)

Directories ΒΆ

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL