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
xopenapi-ts
in the FastAPI docs - For configuration and more of
openapi-ts
, see their website
Project details
Release history Release notifications | RSS feed
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)
Built Distribution
Close
Hashes for openapi_ts-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f24fc2a3a22a220ba4a3b4e936b131f7bb3dd507820da4d4f90e48ed726a10b |
|
MD5 | c31ab8e7cbd9415c1fbc460bcdedfaab |
|
BLAKE2b-256 | 628a5c4368042de9a540f0f6ffb38cb6886128af92ef545e67ee9305c8094816 |