{"id":27163928,"url":"https://github.com/zxypro1/openapi-example-code-generator","last_synced_at":"2026-02-24T06:04:40.836Z","repository":{"id":285046193,"uuid":"956924535","full_name":"zxypro1/openapi-example-code-generator","owner":"zxypro1","description":"Generate cUrl, Python, Java, JavaScript (and more...) code examples from one OpenAPI spec","archived":false,"fork":false,"pushed_at":"2025-03-29T06:16:30.000Z","size":101,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-29T07:20:55.120Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zxypro1.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2025-03-29T06:08:24.000Z","updated_at":"2025-03-29T06:17:05.000Z","dependencies_parsed_at":"2025-03-29T06:21:35.523Z","dependency_job_id":"25dbe935-2796-4660-b72e-260112535b2e","html_url":"https://github.com/zxypro1/openapi-example-code-generator","commit_stats":null,"previous_names":["zxypro1/openapi-example-code-generator","zxypro1/openapi-code-generator"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zxypro1%2Fopenapi-example-code-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zxypro1%2Fopenapi-example-code-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zxypro1%2Fopenapi-example-code-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zxypro1%2Fopenapi-example-code-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zxypro1","download_url":"https://codeload.github.com/zxypro1/openapi-example-code-generator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247959798,"owners_count":21024842,"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","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-04-09T01:52:55.494Z","updated_at":"2026-02-24T06:04:40.802Z","avatar_url":"https://github.com/zxypro1.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenAPI Example Code Generator\n\n[![npm version](https://img.shields.io/npm/v/openapi-example-code-generator.svg)](https://www.npmjs.com/package/openapi-example-code-generator)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nGenerate executable code examples from OpenAPI specifications for multiple languages.\n\n## Features\n\n- **Multi-language Support**: Generate code for cURL, Python, Java, JavaScript (Fetch API), and Axios\n- **Smart Example Generation**: Automatically handles path/query parameters and request bodies\n- **Type Safe**: Built with TypeScript and official OpenAPI types\n- **Framework Agnostic**: Works with any OpenAPI 3.0+ specification\n\n## Installation\n\n```bash\nnpm install openapi-example-code-generator\n# or\nyarn add openapi-example-code-generator\n```\n\n## Usage\n\n### Basic Example\n\n```typescript\nimport { OpenAPICodeGenerator } from \"openapi-example-code-generator\";\nimport type { OpenAPIObject } from \"openapi-types\";\n\nconst openApiSpec: OpenAPIObject = {\n  // Your OpenAPI specification\n};\n\nconst generator = new OpenAPICodeGenerator(\n  openApiSpec,\n  \"https://api.example.com\"\n);\n\n// Get examples for specific language\nconst curlExamples = generator.getCurlExamples();\nconst pythonExamples = generator.getPythonExamples();\nconst axiosExamples = generator.getAxiosExamples();\n\n// Get all examples\nconst allExamples = generator.getAllExamples();\n```\n\n### Advanced Usage\n\n#### Custom Server URL\n\n```typescript\n// Override server URL from specification\nconst generator = new OpenAPICodeGenerator(\n  openApiSpec,\n  \"https://custom-api.example.com\"\n);\n```\n\n#### Generate Specific Examples\n\n```typescript\n// Generate only Python examples\nconst pythonCode = generator.getPythonExamples();\n\n// Generate Axios examples with TypeScript types\nconst axiosCode = generator.getAxiosExamples();\n```\n\n## Supported Languages\n\n| Language   | Method                      | Example Output                         |\n| ---------- | --------------------------- | -------------------------------------- |\n| cURL       | `getCurlExamples()`       | `curl -X GET https://api.example...` |\n| Python     | `getPythonExamples()`     | `import requests...`                 |\n| Java       | `getJavaExamples()`       | `HttpURLConnection conn = ...`       |\n| JavaScript | `getJavaScriptExamples()` | `fetch(...)`                         |\n| Axios      | `getAxiosExamples()`      | `axios.get(...)`                     |\n\n## API Reference\n\n### `new OpenAPICodeGenerator(spec: OpenAPIObject, serverUrl?: string)`\n\nCreate a new generator instance.\n\n**Parameters:**\n\n- `spec`: OpenAPI 3.0+ specification object\n- `serverUrl`: Optional base URL override\n\n### Methods\n\n- `getCurlExamples(): string[]`\n- `getPythonExamples(): string[]`\n- `getJavaExamples(): string[]`\n- `getJavaScriptExamples(): string[]`\n- `getAxiosExamples(): string[]`\n- `getAllExamples(): string[]`\n\n## Contributing\n\nContributions are welcome! Please follow these steps:\n\n1. Fork the repository\n2. Create a feature branch (`git checkout -b feature/your-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin feature/your-feature`)\n5. Create a new Pull Request\n\n## License\n\nMIT © [zxypro1](https://github.com/zxypro1)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzxypro1%2Fopenapi-example-code-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzxypro1%2Fopenapi-example-code-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzxypro1%2Fopenapi-example-code-generator/lists"}