From 4a9e2e6ffddec9ce42da8c8b7b54aa4bf4268509 Mon Sep 17 00:00:00 2001 From: Lubos Date: Mon, 16 Jun 2025 02:02:21 +0900 Subject: [PATCH] Update generate-clients.md Reference the latest `@hey-api/openapi-ts` release --- docs/en/docs/advanced/generate-clients.md | 24 +++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/en/docs/advanced/generate-clients.md b/docs/en/docs/advanced/generate-clients.md index b2aef5037..c9e01870b 100644 --- a/docs/en/docs/advanced/generate-clients.md +++ b/docs/en/docs/advanced/generate-clients.md @@ -10,7 +10,7 @@ There are many tools to generate clients from **OpenAPI**. A common tool is OpenAPI Generator. -If you are building a **frontend**, a very interesting alternative is openapi-ts. +If you are building a **TypeScript client**, another open-source alternative is @hey-api/openapi-ts. ## Client and SDK Generators - Sponsor @@ -23,7 +23,7 @@ And it shows their true commitment to FastAPI and its **community** (you), as th For example, you might want to try: * Speakeasy -* Stainless +* Stainless * liblab There are also several other companies offering similar services that you can search and find online. 🤓 @@ -50,11 +50,11 @@ And that same information from the models that is included in OpenAPI is what ca ### Generate a TypeScript Client -Now that we have the app with the models, we can generate the client code for the frontend. +Now that we have the app with the models, we can generate a TypeScript client. -#### Install `openapi-ts` +#### Install `@hey-api/openapi-ts` -You can install `openapi-ts` in your frontend code with: +You can install `@hey-api/openapi-ts` in your TypeScript project with:
@@ -81,18 +81,18 @@ It could look like this: "description": "", "main": "index.js", "scripts": { - "generate-client": "openapi-ts --input http://localhost:8000/openapi.json --output ./src/client --client axios" + "generate-client": "openapi-ts -i http://localhost:8000/openapi.json -o ./src/client" }, "author": "", "license": "", "devDependencies": { - "@hey-api/openapi-ts": "^0.27.38", - "typescript": "^4.6.2" + "@hey-api/openapi-ts": "^0.73.0", + "typescript": "^5.8.3" } } ``` -After having that NPM `generate-client` script there, you can run it with: +After having that npm `generate-client` script there, you can run it with:
@@ -100,12 +100,12 @@ After having that NPM `generate-client` script there, you can run it with: $ npm run generate-client frontend-app@1.0.0 generate-client /home/user/code/frontend-app -> openapi-ts --input http://localhost:8000/openapi.json --output ./src/client --client axios +> openapi-ts -i http://localhost:8000/openapi.json -o ./src/client ```
-That command will generate code in `./src/client` and will use `axios` (the frontend HTTP library) internally. +That command will generate code in `./src/client` and will use [`Fetch API`](https://developer.mozilla.org/docs/Web/API/Fetch_API) internally. ### Try Out the Client Code @@ -229,7 +229,7 @@ Now as the end result is in a file `openapi.json`, you would modify the `package "description": "", "main": "index.js", "scripts": { - "generate-client": "openapi-ts --input ./openapi.json --output ./src/client --client axios" + "generate-client": "openapi-ts -i ./openapi.json -o ./src/client" }, "author": "", "license": "",