https://github.com/mgerasika/swagger-to-typescript
https://github.com/mgerasika/swagger-to-typescript
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/mgerasika/swagger-to-typescript
- Owner: mgerasika
- Created: 2023-04-04T11:32:19.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-09-21T09:28:59.000Z (almost 2 years ago)
- Last Synced: 2025-03-13T11:39:32.584Z (4 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.
### 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);
```