Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mgerasika/swagger-to-typescript
https://github.com/mgerasika/swagger-to-typescript
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/mgerasika/swagger-to-typescript
- Owner: mgerasika
- Created: 2023-04-04T11:32:19.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-09-21T09:28:59.000Z (over 1 year ago)
- Last Synced: 2024-11-25T15:24:41.349Z (about 2 months ago)
- Language: TypeScript
- Size: 1.37 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Generate typescript code from swagger spec.
![image](https://user-images.githubusercontent.com/10614750/230363977-89f3c28b-d8b8-4628-be68-f006762b1ebc.png)### Example
```
const res = fs.readFileSync("../spec.json").toString();
const doc = getDoc(JSON.parse(res));
if (!doc) {
throw "Document cannot be null";
}
const tsCode = swaggerToTypescript(doc);
writeTsToFile(`src/api.generated.ts`, tsCode);
```