Prompt

How do I generate strongly typed API clients?

Technology / Developer Tools5 observationsLast seen Oct 11, 2026

Latest observation

Oct 11, 2026OpenAI APIWeb search: off

To generate strongly typed API clients, the usual approach is:

  1. Describe the API with a machine-readable contract

    • Most commonly:
      • OpenAPI/Swagger for REST APIs
      • gRPC/protobuf for RPC APIs
      • GraphQL schema for GraphQL APIs
  2. Use a code generator

    • The generator reads the contract and emits client code with:
      • typed request/response models
      • typed method signatures
      • enums / discriminated unions where supported
      • validation helpers in some generators

Common options by API style

REST APIs

OpenAPI is the standard.

Popular generators:

  • OpenAPI Generator
  • Swagger Codegen
  • NSwag (.NET, TypeScript)
  • Kiota (Microsoft, multi-language)
  • orval (TypeScript/React Query)
  • openapi-typescript (TS types only)
  • openapi-fetch (typed fetch client for TS)

Example workflow:

  1. Write or export openapi.yaml
  2. Run generator
  3. Import generated client into your app

Example:

openapi-generator-cli generate -i openapi.yaml -g typescript-fetch -o ./client

This can produce code like:

const api = new PetApi();
const pets = await api.listPets();

gRPC APIs

Use protobuf definitions.

Generate strongly typed clients with:

  • protoc
  • language-specific plugins

Example:

protoc --ts_out=./client --plugin=protoc-gen-ts=...

This gives you typed request/response messages and service stubs.


GraphQL APIs

Use the GraphQL schema and operations.

Popular tools:

  • GraphQL Code Generator
  • Apollo codegen

These generate:

  • typed query/mutation result types
  • typed variables
  • typed hooks in frontend frameworks

Example:

graphql-codegen

Best practices for strong typing

  • Keep the API contract as the source of truth
  • Generate models from the contract, rather than hand-writing them
  • Version your API schema
  • Use enums and oneOf/anyOf carefully for better type narrowing
  • Add runtime validation if you need safety beyond compile-time types
  • Regenerate clients in CI when the contract changes

If you’re using TypeScript

The most common choices are:

  • openapi-typescript → generates types from OpenAPI
  • openapi-fetch → lightweight typed HTTP client
  • orval → generates clients + hooks
  • GraphQL Code Generator → for GraphQL

Quick recommendation

  • REST + TypeScript: openapi-typescript or orval
  • REST + many languages: OpenAPI Generator
  • gRPC: protoc
  • GraphQL: GraphQL Code Generator

If you want, I can show you a step-by-step example for your stack, like:

  • TypeScript + REST
  • Python
  • Java/Kotlin
  • C#
  • Go

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (5 observations for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.