Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ztrehagem/oats
Generate TypeScript code from OpenAPI documents.
https://github.com/ztrehagem/oats
codegen npm-package openapi typescript
Last synced: 14 days 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 (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-09-11T08:53:44.000Z (over 2 years ago)
- Last Synced: 2024-12-30T00:07:21.311Z (about 1 month 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://img.shields.io/npm/v/@ztrehagem/oats)](https://www.npmjs.com/package/@ztrehagem/oats)
[![](https://img.shields.io/npm/types/@ztrehagem/oats)]()
[![](https://img.shields.io/librariesio/release/npm/@ztrehagem/oats)]()
[![](https://img.shields.io/github/license/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)