Ein gängiges Tool ist <a href="https://openapi-generator.tech/" class="external-link" target="_blank">OpenAPI Generator</a>.
-Wenn Sie ein **Frontend** erstellen, ist <a href="https://github.com/ferdikoomen/openapi-typescript-codegen" class="external-link" target="_blank">openapi-typescript-codegen</a> eine sehr interessante Alternative.
+Wenn Sie ein **Frontend** erstellen, ist <a href="https://github.com/hey-api/openapi-ts" class="external-link" target="_blank">openapi-ts</a> eine sehr interessante Alternative.
## Client- und SDK-Generatoren – Sponsor
Nachdem wir nun die Anwendung mit den Modellen haben, können wir den Client-Code für das Frontend generieren.
-#### `openapi-typescript-codegen` installieren
+#### `openapi-ts` installieren
-Sie können `openapi-typescript-codegen` in Ihrem Frontend-Code installieren mit:
+Sie können `openapi-ts` in Ihrem Frontend-Code installieren mit:
<div class="termy">
```console
-$ npm install openapi-typescript-codegen --save-dev
+$ npm install @hey-api/openapi-ts --save-dev
---> 100%
```
#### Client-Code generieren
-Um den Client-Code zu generieren, können Sie das Kommandozeilentool `openapi` verwenden, das soeben installiert wurde.
+Um den Client-Code zu generieren, können Sie das Kommandozeilentool `openapi-ts` verwenden, das soeben installiert wurde.
Da es im lokalen Projekt installiert ist, könnten Sie diesen Befehl wahrscheinlich nicht direkt aufrufen, sondern würden ihn in Ihre Datei `package.json` einfügen.
"description": "",
"main": "index.js",
"scripts": {
- "generate-client": "openapi --input http://localhost:8000/openapi.json --output ./src/client --client axios --useOptions --useUnionTypes"
+ "generate-client": "openapi-ts --input http://localhost:8000/openapi.json --output ./src/client --client axios"
},
"author": "",
"license": "",
"devDependencies": {
- "openapi-typescript-codegen": "^0.20.1",
+ "@hey-api/openapi-ts": "^0.27.38",
"typescript": "^4.6.2"
}
}
$ npm run generate-client
frontend-app@1.0.0 generate-client /home/user/code/frontend-app
-> openapi --input http://localhost:8000/openapi.json --output ./src/client --client axios --useOptions --useUnionTypes
+> openapi-ts --input http://localhost:8000/openapi.json --output ./src/client --client axios
```
</div>
"description": "",
"main": "index.js",
"scripts": {
- "generate-client": "openapi --input ./openapi.json --output ./src/client --client axios --useOptions --useUnionTypes"
+ "generate-client": "openapi-ts --input ./openapi.json --output ./src/client --client axios"
},
"author": "",
"license": "",
"devDependencies": {
- "openapi-typescript-codegen": "^0.20.1",
+ "@hey-api/openapi-ts": "^0.27.38",
"typescript": "^4.6.2"
}
}
⚠ 🧰 <a href="https://openapi-generator.tech/" class="external-link" target="_blank">🗄 🚂</a>.
-🚥 👆 🏗 **🕸**, 📶 😌 🎛 <a href="https://github.com/ferdikoomen/openapi-typescript-codegen" class="external-link" target="_blank">🗄-📕-🇦🇪</a>.
+🚥 👆 🏗 **🕸**, 📶 😌 🎛 <a href="https://github.com/hey-api/openapi-ts" class="external-link" target="_blank">🗄-📕-🇦🇪</a>.
## 🏗 📕 🕸 👩💻
🔜 👈 👥 ✔️ 📱 ⏮️ 🏷, 👥 💪 🏗 👩💻 📟 🕸.
-#### ❎ `openapi-typescript-codegen`
+#### ❎ `openapi-ts`
-👆 💪 ❎ `openapi-typescript-codegen` 👆 🕸 📟 ⏮️:
+👆 💪 ❎ `openapi-ts` 👆 🕸 📟 ⏮️:
<div class="termy">
```console
-$ npm install openapi-typescript-codegen --save-dev
+$ npm install @hey-api/openapi-ts --save-dev
---> 100%
```
#### 🏗 👩💻 📟
-🏗 👩💻 📟 👆 💪 ⚙️ 📋 ⏸ 🈸 `openapi` 👈 🔜 🔜 ❎.
+🏗 👩💻 📟 👆 💪 ⚙️ 📋 ⏸ 🈸 `openapi-ts` 👈 🔜 🔜 ❎.
↩️ ⚫️ ❎ 🇧🇿 🏗, 👆 🎲 🚫🔜 💪 🤙 👈 📋 🔗, ✋️ 👆 🔜 🚮 ⚫️ 🔛 👆 `package.json` 📁.
"description": "",
"main": "index.js",
"scripts": {
- "generate-client": "openapi --input http://localhost:8000/openapi.json --output ./src/client --client axios"
+ "generate-client": "openapi-ts --input http://localhost:8000/openapi.json --output ./src/client --client axios"
},
"author": "",
"license": "",
"devDependencies": {
- "openapi-typescript-codegen": "^0.20.1",
+ "@hey-api/openapi-ts": "^0.27.38",
"typescript": "^4.6.2"
}
}
$ npm run generate-client
frontend-app@1.0.0 generate-client /home/user/code/frontend-app
-> openapi --input http://localhost:8000/openapi.json --output ./src/client --client axios
+> openapi-ts --input http://localhost:8000/openapi.json --output ./src/client --client axios
```
</div>
"description": "",
"main": "index.js",
"scripts": {
- "generate-client": "openapi --input ./openapi.json --output ./src/client --client axios"
+ "generate-client": "openapi-ts --input ./openapi.json --output ./src/client --client axios"
},
"author": "",
"license": "",
"devDependencies": {
- "openapi-typescript-codegen": "^0.20.1",
+ "@hey-api/openapi-ts": "^0.27.38",
"typescript": "^4.6.2"
}
}
A common tool is <a href="https://openapi-generator.tech/" class="external-link" target="_blank">OpenAPI Generator</a>.
-If you are building a **frontend**, a very interesting alternative is <a href="https://github.com/ferdikoomen/openapi-typescript-codegen" class="external-link" target="_blank">openapi-typescript-codegen</a>.
+If you are building a **frontend**, a very interesting alternative is <a href="https://github.com/hey-api/openapi-ts" class="external-link" target="_blank">openapi-ts</a>.
## Client and SDK Generators - Sponsor
Now that we have the app with the models, we can generate the client code for the frontend.
-#### Install `openapi-typescript-codegen`
+#### Install `openapi-ts`
-You can install `openapi-typescript-codegen` in your frontend code with:
+You can install `openapi-ts` in your frontend code with:
<div class="termy">
```console
-$ npm install openapi-typescript-codegen --save-dev
+$ npm install @hey-api/openapi-ts --save-dev
---> 100%
```
#### Generate Client Code
-To generate the client code you can use the command line application `openapi` that would now be installed.
+To generate the client code you can use the command line application `openapi-ts` that would now be installed.
Because it is installed in the local project, you probably wouldn't be able to call that command directly, but you would put it on your `package.json` file.
"description": "",
"main": "index.js",
"scripts": {
- "generate-client": "openapi --input http://localhost:8000/openapi.json --output ./src/client --client axios --useOptions --useUnionTypes"
+ "generate-client": "openapi-ts --input http://localhost:8000/openapi.json --output ./src/client --client axios"
},
"author": "",
"license": "",
"devDependencies": {
- "openapi-typescript-codegen": "^0.20.1",
+ "@hey-api/openapi-ts": "^0.27.38",
"typescript": "^4.6.2"
}
}
$ npm run generate-client
frontend-app@1.0.0 generate-client /home/user/code/frontend-app
-> openapi --input http://localhost:8000/openapi.json --output ./src/client --client axios --useOptions --useUnionTypes
+> openapi-ts --input http://localhost:8000/openapi.json --output ./src/client --client axios
```
</div>
"description": "",
"main": "index.js",
"scripts": {
- "generate-client": "openapi --input ./openapi.json --output ./src/client --client axios --useOptions --useUnionTypes"
+ "generate-client": "openapi-ts --input ./openapi.json --output ./src/client --client axios"
},
"author": "",
"license": "",
"devDependencies": {
- "openapi-typescript-codegen": "^0.20.1",
+ "@hey-api/openapi-ts": "^0.27.38",
"typescript": "^4.6.2"
}
}
一个常见的工具是 <a href="https://openapi-generator.tech/" class="external-link" target="_blank">OpenAPI Generator</a>。
-如果您正在开发**前端**,一个非常有趣的替代方案是 <a href="https://github.com/ferdikoomen/openapi-typescript-codegen" class="external-link" target="_blank">openapi-typescript-codegen</a>。
+如果您正在开发**前端**,一个非常有趣的替代方案是 <a href="https://github.com/hey-api/openapi-ts" class="external-link" target="_blank">openapi-ts</a>。
## 生成一个 TypeScript 前端客户端
现在我们有了带有模型的应用,我们可以为前端生成客户端代码。
-#### 安装 `openapi-typescript-codegen`
+#### 安装 `openapi-ts`
-您可以使用以下工具在前端代码中安装 `openapi-typescript-codegen`:
+您可以使用以下工具在前端代码中安装 `openapi-ts`:
<div class="termy">
```console
-$ npm install openapi-typescript-codegen --save-dev
+$ npm install @hey-api/openapi-ts --save-dev
---> 100%
```
#### 生成客户端代码
-要生成客户端代码,您可以使用现在将要安装的命令行应用程序 `openapi`。
+要生成客户端代码,您可以使用现在将要安装的命令行应用程序 `openapi-ts`。
因为它安装在本地项目中,所以您可能无法直接使用此命令,但您可以将其放在 `package.json` 文件中。
"description": "",
"main": "index.js",
"scripts": {
- "generate-client": "openapi --input http://localhost:8000/openapi.json --output ./src/client --client axios"
+ "generate-client": "openapi-ts --input http://localhost:8000/openapi.json --output ./src/client --client axios"
},
"author": "",
"license": "",
"devDependencies": {
- "openapi-typescript-codegen": "^0.20.1",
+ "@hey-api/openapi-ts": "^0.27.38",
"typescript": "^4.6.2"
}
}
$ npm run generate-client
frontend-app@1.0.0 generate-client /home/user/code/frontend-app
-> openapi --input http://localhost:8000/openapi.json --output ./src/client --client axios
+> openapi-ts --input http://localhost:8000/openapi.json --output ./src/client --client axios
```
</div>
"description": "",
"main": "index.js",
"scripts": {
- "generate-client": "openapi --input ./openapi.json --output ./src/client --client axios"
+ "generate-client": "openapi-ts --input ./openapi.json --output ./src/client --client axios"
},
"author": "",
"license": "",
"devDependencies": {
- "openapi-typescript-codegen": "^0.20.1",
+ "@hey-api/openapi-ts": "^0.27.38",
"typescript": "^4.6.2"
}
}