{"id":31009400,"url":"https://github.com/backendarchitect/go-api-gen","last_synced_at":"2025-09-13T04:35:39.228Z","repository":{"id":312978079,"uuid":"1049527061","full_name":"backendArchitect/go-api-gen","owner":"backendArchitect","description":null,"archived":false,"fork":false,"pushed_at":"2025-09-03T07:24:29.000Z","size":22892,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-03T07:26:27.962Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/backendArchitect.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-03T05:41:20.000Z","updated_at":"2025-09-03T06:37:20.000Z","dependencies_parsed_at":"2025-09-03T07:26:37.779Z","dependency_job_id":"f8a45106-c6eb-4255-ab0a-5c80e6d95183","html_url":"https://github.com/backendArchitect/go-api-gen","commit_stats":null,"previous_names":["backendarchitect/go-api-gen"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/backendArchitect/go-api-gen","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/backendArchitect%2Fgo-api-gen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/backendArchitect%2Fgo-api-gen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/backendArchitect%2Fgo-api-gen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/backendArchitect%2Fgo-api-gen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/backendArchitect","download_url":"https://codeload.github.com/backendArchitect/go-api-gen/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/backendArchitect%2Fgo-api-gen/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274919805,"owners_count":25373953,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-13T02:00:10.085Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-09-13T04:35:35.501Z","updated_at":"2025-09-13T04:35:39.212Z","avatar_url":"https://github.com/backendArchitect.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-api-gen\n\nA Go tool that automatically generates complete Go client libraries from OpenAPI/Swagger specifications. This saves developers time and effort when integrating with new APIs by automatically creating all the necessary HTTP client code, request/response models, and error handling.\n\n## Features\n\n- **OpenAPI 3.0 Support**: Parses OpenAPI 3.0 specifications (JSON/YAML)\n- **Complete Client Generation**: Generates HTTP client with methods for all API endpoints\n- **Model Generation**: Creates Go structs for all data models with proper JSON tags\n- **Type Safety**: Converts OpenAPI types to appropriate Go types\n- **Error Handling**: Built-in HTTP error handling and response parsing\n- **Customizable**: Configurable package names, client names, and output directories\n\n## Installation\n\n```bash\ngo install github.com/backendArchitect/go-api-gen/cmd/go-api-gen@latest\n```\n\nOr build from source:\n\n```bash\ngit clone https://github.com/backendArchitect/go-api-gen.git\ncd go-api-gen\ngo build ./cmd/go-api-gen\n```\n\n## Usage\n\n### Basic Usage\n\n```bash\ngo-api-gen --input petstore.yaml --output ./generated\n```\n\n### Advanced Usage\n\n```bash\ngo-api-gen \\\n  --input examples/petstore.yaml \\\n  --output ./clients/petstore \\\n  --package petstore \\\n  --client-name PetStoreClient\n```\n\n### Command Line Options\n\n- `--input`, `-i`: Path to OpenAPI/Swagger specification file (required)\n- `--output`, `-o`: Output directory for generated client code (default: `./generated`)\n- `--package`, `-p`: Go package name for generated code (default: `client`)\n- `--client-name`, `-c`: Name for the generated client struct (default: `APIClient`)\n- `--log-level`: Log level for output (debug, info, warn, error) (default: `info`)\n- `--debug`: Enable debug logging (equivalent to `--log-level=debug`)\n- `--json-log`: Output logs in JSON format for structured logging\n\n### Logging\n\nThe tool provides comprehensive logging for debugging and monitoring:\n\n- **Info Level** (default): Shows major operation progress and completion status\n- **Debug Level**: Detailed tracing of all operations, including parameter extraction, file operations, and template processing\n- **Warn/Error Levels**: Important warnings and error conditions with context\n- **JSON Format**: Structured logging suitable for log aggregation systems\n\n#### Logging Examples\n\n```bash\n# Default info-level logging\ngo-api-gen --input petstore.yaml --output ./generated\n\n# Debug logging for troubleshooting\ngo-api-gen --input petstore.yaml --output ./generated --debug\n\n# JSON structured logging for monitoring\ngo-api-gen --input petstore.yaml --output ./generated --json-log\n\n# Custom log level\ngo-api-gen --input petstore.yaml --output ./generated --log-level warn\n```\n\n#### Log Components\n\nEach component logs with a distinct identifier for easy filtering:\n- `cli`: Command-line interface operations\n- `generator`: Overall code generation orchestration\n- `parser`: OpenAPI specification parsing and validation\n- `client-template`: Client code generation and operation extraction\n- `models-template`: Model and type generation\n\n## Generated Code Structure\n\nThe tool generates two main files:\n\n### client.go\nContains the main HTTP client with:\n- Client struct with configuration\n- Constructor functions\n- HTTP request methods for each API endpoint\n- Error handling and response parsing\n- URL building with path and query parameters\n\n### models.go\nContains data models with:\n- Go structs for all schema definitions\n- Proper JSON tags for serialization\n- Type aliases for array types\n- Time imports only when needed\n\n## Example\n\nGiven this OpenAPI specification:\n\n```yaml\nopenapi: 3.0.0\ninfo:\n  title: Pet Store API\n  version: 1.0.0\nservers:\n  - url: https://petstore.example.com/v1\npaths:\n  /pets:\n    get:\n      operationId: listPets\n      parameters:\n        - name: limit\n          in: query\n          schema:\n            type: integer\n      responses:\n        '200':\n          description: A list of pets\ncomponents:\n  schemas:\n    Pet:\n      type: object\n      properties:\n        id:\n          type: integer\n        name:\n          type: string\n```\n\nThe tool generates a client that can be used like:\n\n```go\npackage main\n\nimport (\n    \"context\"\n    \"log\"\n    \n    \"your-module/generated/client\"\n)\n\nfunc main() {\n    client := client.NewAPIClient()\n    \n    ctx := context.Background()\n    limit := 10\n    \n    if err := client.ListPets(ctx, \u0026limit); err != nil {\n        log.Fatal(err)\n    }\n}\n```\n\n## Development\n\n### Running Tests\n\n```bash\ngo test ./...\n```\n\n### Building\n\n```bash\ngo build ./cmd/go-api-gen\n```\n\n## License\n\nMIT License - see LICENSE file for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbackendarchitect%2Fgo-api-gen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbackendarchitect%2Fgo-api-gen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbackendarchitect%2Fgo-api-gen/lists"}