typewags
v0.2.2
Published
A typescript web API generator script.
Downloads
18
Readme
typewags
A typescript web API generator script.
Usage
To generate the TypeScript definitions, you need a type definition and web API information JSON.
Here is a NuGet package for ASP.NET Core
projects to generate the JSON:
Here is an example of usage if you followed the example of typewags-aspnetcore.
import axios from "axios";
import path from "path";
import fs from "fs/promises";
import { WebAPIInspectResult, ApiBundleGenerator } from "typewags";
async function main() {
const response = await axios.get<WebAPIInspectResult>(
// If you follow the example, you can get the definition json by the following request.
"http://localhost:5000/typewags"
);
const json = response.data;
// Generate all of the definitions by a simple API.
const generator = new ApiBundleGenerator(json);
const declarationContent = generator.generateApiInterfaceBundle();
await fs.writeFile(
path.resolve(process.cwd(), "bundle.ts"),
declarationContent
);
}
main();