One function per operation
Generated modules group operations by tag and export the request and response types alongside each function.
OpenApiGen is a .NET tool that turns your API definition into functions you can call with fetch or Axios.
GET /greetings/{name}
import { getGreetingsName } from "./generated";
const [status, body] = await getGreetingsName(
fetch,
"Ada",
);
if (status === 200) {
console.log(body.message);
}
Start with an OpenAPI JSON file from your API and run the tool with the .NET 10 or .NET 11 SDK. OpenApiGen is tested with documents from ASP.NET Core 10 and 11. Documents from other tools can work when they use supported OpenAPI features.
See the ASP.NET Core exampledotnet tool install --global MagnusOpera.OpenApiGen
openapigen --transport fetch openapi.json ./generated
Generated modules group operations by tag and export the request and response types alongside each function.
Check the returned HTTP status to narrow the response type before reading the body.
Pass a fetch implementation or a configured Axios instance to control how requests reach your API.