https://github.com/alan2207/rest-to-ts
A proof of concept of generating TypeScript types from REST API endpoints.
https://github.com/alan2207/rest-to-ts
rest-api typescript
Last synced: 9 months ago
JSON representation
A proof of concept of generating TypeScript types from REST API endpoints.
- Host: GitHub
- URL: https://github.com/alan2207/rest-to-ts
- Owner: alan2207
- License: mit
- Created: 2024-11-20T20:29:26.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-25T20:46:40.000Z (over 1 year ago)
- Last Synced: 2025-04-05T23:11:10.587Z (about 1 year ago)
- Topics: rest-api, typescript
- Language: TypeScript
- Homepage:
- Size: 277 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# REST to TS
A proof of concept of generating TypeScript types from REST API endpoints.
## Why?
Sometimes you have a REST API that doesn't have OpenAPI spec or it is difficult to get one, but you still want to generate types for it. This is a quick way to do it.
## How it works?

1. A configuration is provided with the endpoints you want to generate types for.
2. API calls are made to each endpoint with the provided variations.
3. The responses are extracted and used to generate the types with the help of [quicktype](https://github.com/glideapps/quicktype).
## Usage:
```bash
# Install dependencies
npm install
# Start the API
npm run start-api
# Generate the types
npm run generate-types
```
## Configuration
Configuration is defined in the `src/config.ts` file.
## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.