chenshuai2144 / openapi2typescript

一个被大范围使用的小工具
307 stars 136 forks source link

在 getSchema 方法中对本地文件使用 require 加载会在文件更新后,无法获取新的文件内容 #103

Open kuangshu opened 1 year ago

kuangshu commented 1 year ago
export const getSchema = async (schemaPath: string) => {
  if (schemaPath.startsWith('http')) {
    ...
  }
  const schema = require(schemaPath);
  return schema;
};

https://github.com/chenshuai2144/openapi2typescript/blob/b035170d8c5a6bea14616a87e1d7ce7b1390440a/src/index.ts#LL114C18-L114C25

如题,我在使用 getSchema 对本地文件的 json 进行加载时,由于存在轮询刷新该文件的逻辑,但是一直获取的都是第一次的内容。