invoicing-client
v1.0.1
Published
Invoicing client application generator using Plop.
Downloads
115
Readme
Net9 代码生成器
代码生成器
初始化项目
mkdir code-gen cd code-gen npm init -y
安装 Plop
pnpm install --save-dev plop
创建 Plopfile.js
Openapi-ts 生成 client (swagger 文档)
安装 openapi-ts
pnpm install --save-dev openapi-ts
创建 openapi-ts 配置文件
文档地址: https://heyapi.dev/
// https://heyapi.dev/ import { defineConfig } from "@hey-api/openapi-ts"; export default defineConfig({ client: "@hey-api/client-axios", input: "http://localhost:3000/swagger.json", output: { format: "prettier", path: "src/client", // lint: 'eslint' lint: false } // plugins: [ // "@hey-api/schemas", // "@hey-api/services", // { // serviceNameBuilder: "{{name}}Service", // name: "@hey-api/services" // }, // { // dates: true, // name: "@hey-api/transformers" // }, // { // enums: "typescript", // name: "@hey-api/types" // } // ] // services: { // asClass: false, // name: "{{name}}Service", // methodNameBuilder(operation) { // console.log("operation", operation); // const parts = operation.name.split("Controller"); // // return formatName(parts[1], false); // return parts.join(""); // } // // operationId: true // // response: 'response' // }, // types: { // enums: "typescript" // }, // schemas: { // type: "form" // } });
安装依赖 @hey-api/client-axios
pnpm install @hey-api/client-axios
Usage 使用
CURD生成器
npx plop order
Clent生成
pnpm openapi-ts