What is OpenAPI to TypeScript Axios Client Generator?
This tool converts OpenAPI 3.0/3.1 and Swagger 2.0 specifications into a fully typed TypeScript Axios HTTP client. It generates TypeScript interfaces for all schemas and request/response types, plus an API client class with typed methods for each endpoint.
How to Use
- Set the API client class name (default: ApiClient)
- Paste your OpenAPI or Swagger specification (JSON or YAML format)
- Click "Generate Client" to create the TypeScript code
- Copy the generated files (types.ts, api.ts, index.ts) to your project
Why Use This Tool?
Tips & Best Practices
- Use the operationId field in your spec for cleaner method names
- The generated client uses AxiosRequestConfig for additional options
- You can extend the generated class to add interceptors or custom logic
- For large APIs, consider splitting into multiple clients by tag
Frequently Asked Questions
What OpenAPI versions are supported?
OpenAPI 3.0.x, 3.1.x, and Swagger 2.0 specifications are all supported. The tool automatically detects the version and handles the differences.
How are $ref references handled?
All $ref references are resolved and converted to TypeScript type references. Schemas from components/schemas (OpenAPI 3.x) or definitions (Swagger 2.x) are generated as interfaces.
Can I use YAML format?
Yes, the tool accepts both JSON and YAML formats. Simply paste your YAML OpenAPI spec and it will be parsed automatically.
How do I use the generated client?
Import the client class, create an instance with your base URL, and call the typed methods. Example: const api = new ApiClient("https://api.example.com"); const pets = await api.listPets();