fjc0k / yapi-to-typescript

根据 YApi 或 Swagger 的接口定义生成 TypeScript 或 JavaScript 的接口类型及其请求函数代码。
https://fjc0k.github.io/yapi-to-typescript/handbook/
MIT License
443 stars 81 forks source link

能否增加配置项:在RequestDataType和ResponseDataType的注释中增加title #72

Open YujiaCheng1996 opened 2 years ago

YujiaCheng1996 commented 2 years ago

高版本的yapi支持title和desc,希望在请求响应的类型注释中增加每一项的title。 如JsonSchema:

requestDataJsonSchema: {
        title: '测试注册表单',
        description: 'A simple form example.',
        type: 'object',
        required: ['firstName', 'lastName'],
        'ui:order': ['lastName', 'firstName', '*', 'password'],
        properties: {
            firstName: { type: 'string', title: 'First name', default: 'Jun' },
            lastName: { type: 'string', title: 'Last name', 'ui:options': { description: '请输入你的姓' }, 'err:required': '必须输入Last Name' },
            price: { type: 'string', description: '最多输入两位小数点,最大值 999999.99', title: '价格', format: 'price' },
            age: { type: 'integer', title: 'Age', maximum: 80, minimum: 16 },
            bio: { type: 'string', title: 'Bio', minLength: 10 },
            password: { type: 'string', title: 'Password', minLength: 3 },
            telephone: { type: 'string', title: 'Telephone', minLength: 10 },
        },
    },

生成的接口为:

export interface PostApiTestTestRequest {
    firstName: string;
    lastName: string;
    /**
     * 最多输入两位小数点,最大值 999999.99
     */
    price?: string;
    age?: number;
    bio?: string;
    password?: string;
    telephone?: string;
}

希望增加title的注释为:

    /**
     * First name
     */
    firstName: string;
    /**
     * 价格
     * 最多输入两位小数点,最大值 999999.99
     */
    price?: string;