https://github.com/0x-jerry/openapi-ts
Openapi schema to client typescript code
https://github.com/0x-jerry/openapi-ts
generate-code openapi swagger typescript
Last synced: about 2 months ago
JSON representation
Openapi schema to client typescript code
- Host: GitHub
- URL: https://github.com/0x-jerry/openapi-ts
- Owner: 0x-jerry
- Created: 2023-12-19T14:49:52.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-08-18T12:50:43.000Z (10 months ago)
- Last Synced: 2025-08-18T13:29:38.230Z (10 months ago)
- Topics: generate-code, openapi, swagger, typescript
- Language: TypeScript
- Homepage:
- Size: 378 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# OpenAPI Code Generator
This package provide a quick way to transform OpenAPI schema or Swagger schema to client typescript code.
## Usage
1. Generate client typescript code
```ts
import { generate } from '@0x-jerry/openapi-ts'
const apiUrl = 'http://doc-url/api-docs'
const swaggerSchema = await (await fetch(apiUrl)).json()
await generate({
schema: swaggerSchema,
output: 'api',
format: true,
clean: true,
adapter: 'axios'
})
```
2. Change adapter file `api/_adapter.ts` to suit your needs.
3. Use generated code
```ts
import * as api from './api/generated'
const resp = await api.segment.to.path.$get({...})
```