fix(api): 修复 OpenAPI 生成器识别 title 字段
修改内容: - 修复 generateApiFromOpenAPI.js 同时支持 description 和 title 字段 - 更新 plan/add.md 文档格式(application/json,使用 title 字段) - 重新生成 plan.js 和 user.js API 文件 影响: - API 参数描述现在能正确显示中文名称(从 title 字段提取) - 修正了参数类型(如 customer_age 从 string 改为 integer) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Showing
4 changed files
with
71 additions
and
50 deletions
| ... | @@ -39,63 +39,83 @@ paths: | ... | @@ -39,63 +39,83 @@ paths: |
| 39 | type: string | 39 | type: string |
| 40 | requestBody: | 40 | requestBody: |
| 41 | content: | 41 | content: |
| 42 | - application/x-www-form-urlencoded: | 42 | + application/json: |
| 43 | schema: | 43 | schema: |
| 44 | type: object | 44 | type: object |
| 45 | properties: | 45 | properties: |
| 46 | customer_name: | 46 | customer_name: |
| 47 | - description: 客户姓名 | ||
| 48 | - example: 冬一 | ||
| 49 | type: string | 47 | type: string |
| 48 | + title: 申请人 | ||
| 50 | customer_gender: | 49 | customer_gender: |
| 51 | - description: 客户性别 | ||
| 52 | - example: 男 | ||
| 53 | type: string | 50 | type: string |
| 51 | + title: 性别 | ||
| 54 | customer_age: | 52 | customer_age: |
| 55 | - description: 客户年龄 | 53 | + type: integer |
| 56 | - example: '20' | 54 | + title: 年龄 |
| 55 | + customer_birthday: | ||
| 57 | type: string | 56 | type: string |
| 57 | + title: 出生年月日 | ||
| 58 | annual_premium: | 58 | annual_premium: |
| 59 | - description: 年缴保费 | 59 | + type: integer |
| 60 | - example: '5000' | 60 | + title: 保额 |
| 61 | - type: string | ||
| 62 | payment_years: | 61 | payment_years: |
| 63 | - description: 缴费年限 | ||
| 64 | - example: '10' | ||
| 65 | type: string | 62 | type: string |
| 63 | + title: 繳費年期 | ||
| 66 | currency_type: | 64 | currency_type: |
| 67 | - description: 币种 | ||
| 68 | - example: CNY | ||
| 69 | - type: string | ||
| 70 | - product_id: | ||
| 71 | - description: 产品id | ||
| 72 | - example: '2769884' | ||
| 73 | - type: string | ||
| 74 | - customer_birthday: | ||
| 75 | - description: 出生年月日 | ||
| 76 | - example: '' | ||
| 77 | type: string | 65 | type: string |
| 66 | + title: 币种 | ||
| 78 | allow_reduce_amount: | 67 | allow_reduce_amount: |
| 79 | - description: 是否容许减少名义金额 | ||
| 80 | - example: '' | ||
| 81 | type: string | 68 | type: string |
| 69 | + title: 是否容许减少名义金额 | ||
| 82 | withdrawal_option: | 70 | withdrawal_option: |
| 83 | - description: 提取选项 | ||
| 84 | - example: '' | ||
| 85 | type: string | 71 | type: string |
| 72 | + title: 提取选项 | ||
| 86 | withdrawal_start_age: | 73 | withdrawal_start_age: |
| 87 | - description: 提取开始年龄 | 74 | + type: integer |
| 88 | - example: '' | 75 | + title: 提取开始年龄 |
| 89 | - type: string | ||
| 90 | withdrawal_period: | 76 | withdrawal_period: |
| 91 | - description: 提取期(年) | 77 | + type: integer |
| 92 | - example: '' | 78 | + title: 提取期(年) |
| 79 | + smoking_status: | ||
| 93 | type: string | 80 | type: string |
| 81 | + title: 是否吸烟 | ||
| 94 | total_premium: | 82 | total_premium: |
| 95 | - description: 总保费金额 | 83 | + type: integer |
| 96 | - example: '' | 84 | + title: 总保费金额 |
| 97 | - type: string | 85 | + product_id: |
| 98 | - examples: {} | 86 | + type: integer |
| 87 | + title: 产品id | ||
| 88 | + required: | ||
| 89 | + - customer_name | ||
| 90 | + - customer_gender | ||
| 91 | + - customer_age | ||
| 92 | + - customer_birthday | ||
| 93 | + - annual_premium | ||
| 94 | + - payment_years | ||
| 95 | + - currency_type | ||
| 96 | + - allow_reduce_amount | ||
| 97 | + - withdrawal_option | ||
| 98 | + - withdrawal_start_age | ||
| 99 | + - withdrawal_period | ||
| 100 | + - smoking_status | ||
| 101 | + - total_premium | ||
| 102 | + - product_id | ||
| 103 | + x-apifox-orders: | ||
| 104 | + - customer_name | ||
| 105 | + - customer_gender | ||
| 106 | + - customer_age | ||
| 107 | + - annual_premium | ||
| 108 | + - payment_years | ||
| 109 | + - currency_type | ||
| 110 | + - product_id | ||
| 111 | + - customer_birthday | ||
| 112 | + - allow_reduce_amount | ||
| 113 | + - withdrawal_option | ||
| 114 | + - withdrawal_start_age | ||
| 115 | + - withdrawal_period | ||
| 116 | + - smoking_status | ||
| 117 | + - total_premium | ||
| 118 | + example: "{\r\n customer_name: '张三',\r\n customer_gender: 'male',\r\n customer_age: 30,\r\n annual_premium: 5000,\r\n payment_years: '10年',\r\n currency_type: 'CNY',\r\n product_id: 1\r\n }" | ||
| 99 | responses: | 119 | responses: |
| 100 | '200': | 120 | '200': |
| 101 | description: '' | 121 | description: '' | ... | ... |
| ... | @@ -313,7 +313,7 @@ function extractRequestParams(requestBody) { | ... | @@ -313,7 +313,7 @@ function extractRequestParams(requestBody) { |
| 313 | params.push({ | 313 | params.push({ |
| 314 | name: key, | 314 | name: key, |
| 315 | type: value.type || 'any', | 315 | type: value.type || 'any', |
| 316 | - description: value.description || '', | 316 | + description: value.description || value.title || '', // 同时支持 title 和 description |
| 317 | example: value.example || '', | 317 | example: value.example || '', |
| 318 | required: content.schema.required?.includes(key) || false, | 318 | required: content.schema.required?.includes(key) || false, |
| 319 | }); | 319 | }); | ... | ... |
| ... | @@ -9,19 +9,20 @@ const Api = { | ... | @@ -9,19 +9,20 @@ const Api = { |
| 9 | * @description 新增计划书 | 9 | * @description 新增计划书 |
| 10 | * @remark | 10 | * @remark |
| 11 | * @param {Object} params 请求参数 | 11 | * @param {Object} params 请求参数 |
| 12 | - * @param {string} params.customer_name (可选) 客户姓名 | 12 | + * @param {string} params.customer_name 申请人 |
| 13 | - * @param {string} params.customer_gender (可选) 客户性别 | 13 | + * @param {string} params.customer_gender 性别 |
| 14 | - * @param {string} params.customer_age (可选) 客户年龄 | 14 | + * @param {integer} params.customer_age 年龄 |
| 15 | - * @param {string} params.annual_premium (可选) 年缴保费 | 15 | + * @param {string} params.customer_birthday 出生年月日 |
| 16 | - * @param {string} params.payment_years (可选) 缴费年限 | 16 | + * @param {integer} params.annual_premium 保额 |
| 17 | - * @param {string} params.currency_type (可选) 币种 | 17 | + * @param {string} params.payment_years 繳費年期 |
| 18 | - * @param {string} params.product_id (可选) 产品id | 18 | + * @param {string} params.currency_type 币种 |
| 19 | - * @param {string} params.customer_birthday (可选) 出生年月日 | 19 | + * @param {string} params.allow_reduce_amount 是否容许减少名义金额 |
| 20 | - * @param {string} params.allow_reduce_amount (可选) 是否容许减少名义金额 | 20 | + * @param {string} params.withdrawal_option 提取选项 |
| 21 | - * @param {string} params.withdrawal_option (可选) 提取选项 | 21 | + * @param {integer} params.withdrawal_start_age 提取开始年龄 |
| 22 | - * @param {string} params.withdrawal_start_age (可选) 提取开始年龄 | 22 | + * @param {integer} params.withdrawal_period 提取期(年) |
| 23 | - * @param {string} params.withdrawal_period (可选) 提取期(年) | 23 | + * @param {string} params.smoking_status 是否吸烟 |
| 24 | - * @param {string} params.total_premium (可选) 总保费金额 | 24 | + * @param {integer} params.total_premium 总保费金额 |
| 25 | + * @param {integer} params.product_id 产品id | ||
| 25 | * @returns {Promise<{ | 26 | * @returns {Promise<{ |
| 26 | * code: number; // 状态码 | 27 | * code: number; // 状态码 |
| 27 | * msg: string; // 消息 | 28 | * msg: string; // 消息 | ... | ... |
| ... | @@ -79,7 +79,7 @@ export const logoutAPI = (params) => fn(fetch.post(Api.Logout, params)); | ... | @@ -79,7 +79,7 @@ export const logoutAPI = (params) => fn(fetch.post(Api.Logout, params)); |
| 79 | * @description 更新个人资料 | 79 | * @description 更新个人资料 |
| 80 | * @remark | 80 | * @remark |
| 81 | * @param {Object} params 请求参数 | 81 | * @param {Object} params 请求参数 |
| 82 | - * @param {object} params.avatar | 82 | + * @param {object} params.avatar 头像 |
| 83 | * @returns {Promise<{ | 83 | * @returns {Promise<{ |
| 84 | * code: number; // 状态码 | 84 | * code: number; // 状态码 |
| 85 | * msg: string; // 消息 | 85 | * msg: string; // 消息 | ... | ... |
-
Please register or login to post a comment