这是swaggerui的配置文件**/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 }
);
1条答案
按热度按时间oewdyzsn1#
我解决了,虽然这是一个黑客。嘿,目前有一个关于这个重复导入问题的公开讨论。我所做的就是在生成的代码文件中运行eslint。邀请.ts文件使用“eslint --fix”命令删除重复的导入