Agent skill

generate-api-client

Generate typed API client from OpenAPI/Swagger specification

Stars 163
Forks 31

Install this agent skill to your Project

npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/generate-api-client-erp-core-dev-eagles-claude-config

SKILL.md

Generate Typed API Client from OpenAPI

Generate a fully typed HTTP client from an OpenAPI/Swagger specification.

For .NET (NSwag)

bash
dotnet tool install -g NSwag.ConsoleCore
nswag openapi2csclient /input:swagger.json /output:ApiClient.cs /namespace:MyApp.ApiClients /className:SourcingApiClient /generateClientInterfaces:true /injectHttpClient:true

Register in DI:

csharp
builder.Services.AddHttpClient<ISourcingApiClient, SourcingApiClient>(client =>
    client.BaseAddress = new Uri(config["ApiBaseUrl"]));

For TypeScript (openapi-typescript + openapi-fetch)

bash
npm install openapi-typescript openapi-fetch
npx openapi-typescript ./openapi.yaml -o ./src/api/schema.d.ts

Usage:

typescript
import createClient from "openapi-fetch";
import type { paths } from "./api/schema";
const client = createClient<paths>({ baseUrl: "http://localhost:5000" });
const { data } = await client.GET("/api/candidates/{id}", { params: { path: { id: "c-001" } } });

For .NET (Microsoft Kiota)

bash
dotnet tool install -g Microsoft.OpenApi.Kiota
kiota generate -l CSharp -d openapi.yaml -c SourcingClient -n MyApp.ApiClients -o ./Generated

Arguments

  • <openapi-url-or-path>: URL or path to OpenAPI spec
  • --lang=<typescript|csharp>: Target language (default: csharp)

Expand your agent's capabilities with these related and highly-rated skills.

Didn't find tool you were looking for?

Be as detailed as possible for better results