提问人:Harsh Boricha 提问时间:9/21/2023 更新时间:9/22/2023 访问量:68
我正在使用 OpenAPI (Swagger) 来生成我的 node-express 代码。我收到此文件的重复导入(模态)(invites.ts)
I'm using OpenAPI (Swagger) to generate my node-express code. I'm getting duplicate imports (modal) for this file (invites.ts)
问:
这是 swagger ui /schema/config.yaml 的配置
Invite:
type: object
x-mongo-schema: true
properties:
uid:
type: string
description: The unique identifier of the invite.
sequence:
type: number
description: The sequence number of the cal invite.
Invites:
type: object
x-mongo-schema: true
properties:
participant:
$ref: "#/components/schemas/Invite"
researcher:
$ref: "#/components/schemas/Invite"
用于生成样板代码的 mustache 配置 /cgen/generator_custom_templates/config.yaml
templateDir: ./cgen/generator_custom_templates/templates
files:
.env.example: {}
authz.mustache:
folder: controllers
destinationFilename: authz.ts
templateType: SupportingFiles
这是我运行的脚本,用于生成样板代码 脚本:
java -jar ./cgen/openapi-generator-cli.jar generate -g nodejs-express-server -i ./schemas/index.yaml -c ./cgen/generator_custom_templates/config.yaml -o ./generated_code --skip-operation-example
生成的文件:invites.ts
import mongoose from 'mongoose';
import { inviteSchema, IInvite } from '#models/invite'; // Need to fix this Duplicate import
import { inviteSchema, IInvite } from '#models/invite'; // Need to fix this Duplicate import
export interface IInvites {
participant?: IInvite,
researcher?: IInvite,
};
export const invitesSchema = new mongoose.Schema<IInvites>(
{
participant: { type: inviteSchema, },
researcher: { type: inviteSchema, },
},
{ _id: false }
);
答:
0赞
Harsh Boricha
9/22/2023
#1
我解决了它,虽然这是一个黑客。嘿,目前有一个关于这个重复导入问题的公开讨论。我所做的是在生成的代码文件中运行 eslint,即invites.ts文件以使用“eslint --fix”命令删除重复的导入
评论