https://github.com/ztrehagem/oats
Generate TypeScript code from OpenAPI documents.
https://github.com/ztrehagem/oats
codegen npm-package openapi typescript
Last synced: 3 months ago
JSON representation
Generate TypeScript code from OpenAPI documents.
- Host: GitHub
- URL: https://github.com/ztrehagem/oats
- Owner: ztrehagem
- License: unlicense
- Created: 2022-04-22T15:40:29.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-09-11T08:53:44.000Z (almost 4 years ago)
- Last Synced: 2025-10-07T01:19:07.264Z (9 months ago)
- Topics: codegen, npm-package, openapi, typescript
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@ztrehagem/oats
- Size: 237 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @ztrehagem/oats
[](https://www.npmjs.com/package/@ztrehagem/oats)
[]()
[]()
[](./LICENSE)
Generate TypeScript code from OpenAPI documents.
## Installation
```
npm install @ztrehagem/oats
```
## Example
```js
import { Parser, TypeStringGenerator } from "@ztrehagem/oats";
const parser = new Parser();
const { operations, schemas } = await parser.parse("./path/to/openapidoc.yaml");
const generator = new TypeStringGenerator();
for (const [url, { name, schema }] of schemas.entries()) {
const schemaType = generator.generate(schema, { schemas });
}
// ...
```
[Full script](./example/run.js)
code generation examples:
- [schema types](./example/out/schemas.generated.ts)
- [operation types](./example/out/operations.generated.ts)