Skip to main content

Generate typescript clients for OpenAPI (e.g. FastAPI) apps, using openapi-ts

Project description

Openapi Ts

Generate typescript clients for OpenAPI (e.g. FastAPI) apps, using openapi-ts

Usage

Make sure you have openapi-ts installed:

npm -g i @hey-api/openapi-ts
from fastapi import FastAPI
from pydantic import BaseModel
from openapi_ts import generate_client

# define your app
app = FastAPI(generate_unique_id_function=lambda route: route.name)

class User(BaseModel):
  name: str
  email: str

@app.get('/users')
def get_users(how_many: int | None = None) -> list[User]:
  ...

# generate client
generate_client(app.openapi(), 'path/to/client')

Read more

  • See a full walkthrough of fastapi x openapi-ts in the FastAPI docs
  • For configuration and more of openapi-ts, see their website

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openapi-ts-0.1.1.tar.gz (2.1 kB view hashes)

Uploaded Source

Built Distribution

openapi_ts-0.1.1-py3-none-any.whl (2.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page