UNPKG

openapi-ts-mock-generator

Version:
685 lines (673 loc) 25.6 kB
var __defProp = Object.defineProperty; var __defProps = Object.defineProperties; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropDescs = Object.getOwnPropertyDescriptors; var __getOwnPropNames = Object.getOwnPropertyNames; var __getOwnPropSymbols = Object.getOwnPropertySymbols; var __hasOwnProp = Object.prototype.hasOwnProperty; var __propIsEnum = Object.prototype.propertyIsEnumerable; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __spreadValues = (a, b) => { for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]); if (__getOwnPropSymbols) for (var prop of __getOwnPropSymbols(b)) { if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]); } return a; }; var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); var __esm = (fn, res) => function __init() { return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res; }; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var __async = (__this, __arguments, generator) => { return new Promise((resolve, reject) => { var fulfilled = (value) => { try { step(generator.next(value)); } catch (e) { reject(e); } }; var rejected = (value) => { try { step(generator.throw(value)); } catch (e) { reject(e); } }; var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); step((generator = generator.apply(__this, __arguments)).next()); }); }; // src/core/types.ts var HttpMethods, isNotNullish; var init_types = __esm({ "src/core/types.ts"() { "use strict"; HttpMethods = /* @__PURE__ */ ((HttpMethods2) => { HttpMethods2["GET"] = "get"; HttpMethods2["PUT"] = "put"; HttpMethods2["POST"] = "post"; HttpMethods2["DELETE"] = "delete"; HttpMethods2["OPTIONS"] = "options"; HttpMethods2["HEAD"] = "head"; HttpMethods2["PATCH"] = "patch"; HttpMethods2["TRACE"] = "trace"; return HttpMethods2; })(HttpMethods || {}); isNotNullish = (value) => { return value !== null && value !== void 0; }; } }); // src/core/config.ts import { Faker, ko } from "@faker-js/faker"; var defaultOptions, ARRAY_MIN_LENGTH, ARRAY_MAX_LENGTH, MIN_STRING_LENGTH, MAX_STRING_LENGTH, MIN_INTEGER, MAX_INTEGER, MIN_NUMBER, MAX_NUMBER, MIN_WORD_LENGTH, MAX_WORD_LENGTH, FAKER_SEED, faker, GEN_COMMENT; var init_config = __esm({ "src/core/config.ts"() { "use strict"; defaultOptions = { path: "", arrayMinLength: 1, arrayMaxLength: 3, includeCodes: void 0, baseDir: "./", specialPath: void 0, handlerUrl: "*", fakerLocale: "ko", generateTarget: "api,schema", clear: false, // TypeScriptCodeOptions isStatic: false, isOptional: false }; ARRAY_MIN_LENGTH = 1; ARRAY_MAX_LENGTH = 3; MIN_STRING_LENGTH = 3; MAX_STRING_LENGTH = 20; MIN_INTEGER = 1; MAX_INTEGER = 1e5; MIN_NUMBER = 0; MAX_NUMBER = 100; MIN_WORD_LENGTH = 0; MAX_WORD_LENGTH = 3; FAKER_SEED = 1; faker = new Faker({ locale: [ko] }); faker.seed(FAKER_SEED); GEN_COMMENT = "/* Do not edit this file. */\n/* This file generated by openapi-ts-mock-generator. */\n\n"; } }); // src/core/options.ts var mergeOptions, transformCliOptions, validateOptions; var init_options = __esm({ "src/core/options.ts"() { "use strict"; init_config(); mergeOptions = (userOptions) => { return __spreadValues(__spreadValues({}, defaultOptions), userOptions); }; transformCliOptions = (rawOptions) => { return { path: rawOptions.path || defaultOptions.path, baseDir: rawOptions.baseDir || defaultOptions.baseDir, arrayMinLength: parseInt(rawOptions.arrayMinLength) || defaultOptions.arrayMinLength, arrayMaxLength: parseInt(rawOptions.arrayMaxLength) || defaultOptions.arrayMaxLength, handlerUrl: rawOptions.handlerUrl || defaultOptions.handlerUrl, fakerLocale: rawOptions.locales || defaultOptions.fakerLocale, generateTarget: rawOptions.generateTarget || defaultOptions.generateTarget, specialPath: rawOptions.specialPath || defaultOptions.specialPath, clear: rawOptions.clear || defaultOptions.clear, includeCodes: rawOptions.includeCodes ? rawOptions.includeCodes.toString().split(",").map((code) => parseInt(code)) : void 0, // TypeScriptCodeOptions isStatic: rawOptions.static || defaultOptions.isStatic, isOptional: rawOptions.optional || defaultOptions.isOptional }; }; validateOptions = (options) => { const errors = []; if (!options.path) { errors.push("path is required"); } if (options.arrayMinLength && options.arrayMaxLength && options.arrayMinLength > options.arrayMaxLength) { errors.push("arrayMinLength should not be greater than arrayMaxLength"); } if (options.generateTarget && !options.generateTarget.split(",").every((target) => ["api", "schema"].includes(target.trim()))) { errors.push("generateTarget should contain only 'api' and/or 'schema'"); } return errors; }; } }); // src/core/index.ts var core_exports = {}; __export(core_exports, { ARRAY_MAX_LENGTH: () => ARRAY_MAX_LENGTH, ARRAY_MIN_LENGTH: () => ARRAY_MIN_LENGTH, GEN_COMMENT: () => GEN_COMMENT, HttpMethods: () => HttpMethods, MAX_INTEGER: () => MAX_INTEGER, MAX_NUMBER: () => MAX_NUMBER, MAX_STRING_LENGTH: () => MAX_STRING_LENGTH, MAX_WORD_LENGTH: () => MAX_WORD_LENGTH, MIN_INTEGER: () => MIN_INTEGER, MIN_NUMBER: () => MIN_NUMBER, MIN_STRING_LENGTH: () => MIN_STRING_LENGTH, MIN_WORD_LENGTH: () => MIN_WORD_LENGTH, defaultOptions: () => defaultOptions, faker: () => faker, isNotNullish: () => isNotNullish, mergeOptions: () => mergeOptions, transformCliOptions: () => transformCliOptions, validateOptions: () => validateOptions }); var init_core = __esm({ "src/core/index.ts"() { "use strict"; init_types(); init_config(); init_options(); } }); // src/utils/string-utils.ts var uuidToB64 = (uuid) => { const uuidBuffer = Buffer.from(uuid.replace(/-/g, ""), "hex"); const base64Uuid = uuidBuffer.toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, ""); return base64Uuid; }; // src/utils/code-utils.ts var toTypeScriptCode = (param, options) => { const { depth = 0, isStatic } = options; const prefixSpace = " ".repeat(depth * 2); if (param === null) { return "null"; } if (Array.isArray(param)) { const results = param.map((elem) => toTypeScriptCode(elem, __spreadProps(__spreadValues({}, options), { depth: depth + 1 }))).join(",\n" + prefixSpace); return ["[", results, "]"].join("\n" + prefixSpace); } if (typeof param === "object") { const results = Object.entries(param).map(([key, value]) => { return generateObjectProperty(key, value, options, prefixSpace); }).join("\n" + prefixSpace); return ["{", `${results}`, "}"].join("\n" + prefixSpace); } if (typeof param === "string") { if (isStatic === false && (param.startsWith("faker") || param.startsWith("Buffer.from(faker"))) { return param; } if (param.endsWith(" as const")) { return `"${param.slice(0, -" as const".length)}" as const`; } } return JSON.stringify(param); }; var shouldApplyNullableExtension = (value, isOptional) => { if (!isOptional) return false; if (value === null) return true; if (typeof value === "string" && value.includes(",null")) { return true; } return false; }; var generateObjectProperty = (key, value, options, prefixSpace) => { const { isOptional, depth = 0 } = options; const shouldApplyNullable = shouldApplyNullableExtension(value, isOptional); const nullableTypeExtensionStart = shouldApplyNullable ? `...(faker.datatype.boolean() ? { ${prefixSpace}` : ""; const nullableTypeExtensionEnd = shouldApplyNullable ? ` ${prefixSpace}} : {})` : ""; const propertyValue = toTypeScriptCode(value, __spreadProps(__spreadValues({}, options), { depth: depth + 1 })); return `${nullableTypeExtensionStart}${prefixSpace}${key}: ${propertyValue}${nullableTypeExtensionEnd},`; }; var compressCode = (code) => { return code.replace(/\n/g, " ").replace(/\s+/g, " ").replace(/\s\./g, ".").trim(); }; // src/utils/array-utils.ts init_core(); var getRandomLengthArray = (min = 1, max = 3) => { const length = faker.number.int({ min, max }); return Array.from({ length }, (_, i) => i); }; // src/utils/file-utils.ts import { existsSync, mkdirSync, writeFileSync, rmSync, readdirSync, readFileSync } from "fs"; import * as path from "path"; var ensureDir = (dirPath) => { if (!existsSync(dirPath)) { mkdirSync(dirPath, { recursive: true }); } }; var clearDirectory = (dirPath) => { if (existsSync(dirPath)) { readdirSync(dirPath).forEach((file) => { rmSync(path.join(dirPath, file)); }); } }; var safeWriteFile = (filePath, content) => { const dir = path.dirname(filePath); ensureDir(dir); writeFileSync(filePath, content); }; var readJsonFile = (filePath, defaultValue) => { if (!existsSync(filePath)) { return defaultValue; } try { const content = readFileSync(filePath, "utf-8"); return JSON.parse(content); } catch (error) { console.warn(`Failed to read JSON file ${filePath}:`, error); return defaultValue; } }; var resolveFilePath = (inputPath, baseDir) => { if (inputPath.startsWith("http")) { return inputPath; } if (baseDir) { return path.join(baseDir, inputPath); } return inputPath; }; // src/parsers/openapi-parser.ts import SwaggerParser from "@apidevtools/swagger-parser"; // src/parsers/schema-parser.ts init_core(); import { pascalCase } from "change-case-all"; import { isReference } from "oazapfts/generate"; var parseSchema = (schemaValue, specialSchema, options, outputSchema = {}) => { if (isReference(schemaValue)) { console.warn("can't parse reference schema", schemaValue, schemaValue.$ref); return; } if (schemaValue.type === "object") { if (schemaValue.properties === void 0) return {}; return Object.entries(schemaValue.properties).reduce((acc, [key, field]) => { acc[key] = parseSchema(field, specialSchema, options, outputSchema); return acc; }, {}); } else if (schemaValue.enum !== void 0) { const enumValue = options.isStatic ? faker.helpers.arrayElement(schemaValue.enum) : `faker.helpers.arrayElement<${schemaValue.enum.map((item) => `"${item}"`).join(" | ")}>(${toTypeScriptCode(schemaValue.enum, __spreadValues({ depth: 0 }, options))})`; if (options.isStatic && typeof enumValue === "string") return enumValue + " as const"; return enumValue; } else if (schemaValue.allOf !== void 0) { const allOfValue = schemaValue.allOf; return faker.helpers.arrayElement( allOfValue.map((field) => { return parseSchema(field, specialSchema, options, outputSchema); }) ); } else if (schemaValue.anyOf !== void 0) { const anyOfValue = schemaValue.anyOf; return options.isStatic ? faker.helpers.arrayElement( anyOfValue.map((field) => { return parseSchema(field, specialSchema, options, outputSchema); }) ) : compressCode( ` faker.helpers.arrayElement([ ${anyOfValue.map( (field) => toTypeScriptCode(parseSchema(field, specialSchema, options, {}), __spreadValues({ depth: 0 }, options)) )} ]) ` ); } else if (schemaValue.oneOf !== void 0) { const oneOfValue = schemaValue.oneOf; return options.isStatic ? faker.helpers.arrayElement( oneOfValue.map((field) => { return parseSchema(field, specialSchema, options, outputSchema); }) ) : compressCode( ` faker.helpers.arrayElement([ ${oneOfValue.map( (field) => toTypeScriptCode(parseSchema(field, specialSchema, options, {}), __spreadValues({ depth: 0 }, options)) )} ]) ` ); } else if (schemaValue.type === "array") { if ("prefixItems" in schemaValue) { const length = faker.number.int({ min: schemaValue.minItems, max: schemaValue.maxItems }); return schemaValue.prefixItems.slice(0, length).map((field) => parseSchema(field, specialSchema, options, outputSchema)); } const arrayValue = schemaValue.items; return getRandomLengthArray(options.arrayMinLength, options.arrayMaxLength).map( () => parseSchema(arrayValue, specialSchema, options, outputSchema) ); } return valueGenerator(schemaValue, specialSchema, options); }; var refSchemaParser = (ref, refs) => { const schemaName = pascalCase(ref.replace("#/components/schemas/", "")); const schemaValue = refs.get(ref); return { name: schemaName, value: schemaValue }; }; var valueGenerator = (schemaValue, specialSchema, options) => { var _a, _b, _c, _d, _e, _f, _g, _h, _i; const { isStatic } = options; const { titleSpecial, descriptionSpecial } = specialSchema; if (schemaValue.title && titleSpecial[schemaValue.title]) { return titleSpecial[schemaValue.title]; } else if (schemaValue.description && descriptionSpecial[schemaValue.description]) { return descriptionSpecial[schemaValue.description]; } if (schemaValue.type === "string" && schemaValue.format === "date-time") { return isStatic ? faker.date.between({ from: "2020-01-01T00:00:00.000Z", to: "2030-12-31T23:59:59.999Z" }).toISOString() : compressCode( ` faker.date.between({ from: "2020-01-01T00:00:00.000Z", to: "2030-12-31T23:59:59.999Z", }) .toISOString() ` ); } else if (schemaValue.type === "string" && schemaValue.format === "date") { return isStatic ? faker.date.between({ from: "2020-01-01T00:00:00.000Z", to: "2030-12-31T23:59:59.999Z" }).toISOString().split("T")[0] : compressCode( ` faker.date.between({ from: "2020-01-01T00:00:00.000Z", to: "2030-12-31T23:59:59.999Z", }) .toISOString() .split("T")[0] ` ); } else if (schemaValue.type === "string" && schemaValue.pattern) { return isStatic ? faker.helpers.fromRegExp(schemaValue.pattern) : `faker.helpers.fromRegExp(/${schemaValue.pattern}/)`; } else if (schemaValue.type === "string" && ((_a = schemaValue.title) == null ? void 0 : _a.toLowerCase()) === "b64uuid") { const baseUuid = faker.string.uuid(); return isStatic ? uuidToB64(baseUuid) : compressCode( ` Buffer.from(faker.string.uuid().replace(/-/g, ""), "hex") .toString("base64") .replace(/\\+/g, "-") .replace(/\\//g, "_") .replace(/=/g, "") ` ); } else if (schemaValue.type === "string") { const minLength = (_c = schemaValue.minLength) != null ? _c : Math.min(MIN_STRING_LENGTH, (_b = schemaValue.maxLength) != null ? _b : MAX_STRING_LENGTH); const maxLength = (_e = schemaValue.maxLength) != null ? _e : Math.max(MAX_STRING_LENGTH, (_d = schemaValue.minLength) != null ? _d : MIN_STRING_LENGTH); return isStatic ? faker.string.alphanumeric({ length: { min: minLength, max: maxLength } }) : compressCode( ` faker.string.alphanumeric({ length: { min: ${minLength}, max: ${maxLength} }, }) ` ); } else if (schemaValue.type === "integer") { return isStatic ? faker.number.int({ min: MIN_INTEGER, max: MAX_INTEGER }) : compressCode( ` faker.number.int({ min: ${MIN_INTEGER}, max: ${MAX_INTEGER} }) ` ); } else if (schemaValue.type === "number") { const minNumber = (_g = schemaValue.minimum) != null ? _g : Math.min(MIN_NUMBER, (_f = schemaValue.maximum) != null ? _f : MAX_NUMBER); const maxNumber = (_i = schemaValue.maximum) != null ? _i : Math.max(MAX_NUMBER, (_h = schemaValue.minimum) != null ? _h : MIN_NUMBER); return isStatic ? faker.number.float({ min: minNumber, max: maxNumber, fractionDigits: 2 }) : compressCode( ` faker.number.float({ min: ${minNumber}, max: ${maxNumber}, fractionDigits: 2, }) ` ); } else if (schemaValue.type === "boolean") { return isStatic ? faker.datatype.boolean() : "faker.datatype.boolean()"; } else if (schemaValue.type === "null") { return null; } else if (Object.keys(schemaValue).length === 0) { return isStatic ? faker.word.words({ count: { min: MIN_WORD_LENGTH, max: MAX_WORD_LENGTH } }) : compressCode( ` faker.word.words({ count: { min: ${MIN_WORD_LENGTH}, max: ${MAX_WORD_LENGTH}, }, }) ` ); } return isStatic ? faker.word.adjective() : "faker.word.adjective()"; }; // src/parsers/faker-parser.ts init_core(); import { join as join2 } from "path"; var specialFakerParser = (options) => { var _a, _b; if (options.specialPath === void 0) return { titleSpecial: {}, descriptionSpecial: {} }; const titlePath = join2((_a = options.baseDir) != null ? _a : "", options.specialPath, "titles.json"); const descPath = join2((_b = options.baseDir) != null ? _b : "", options.specialPath, "descriptions.json"); const titleSpecialKey = readJsonFile(titlePath, {}); const descriptionSpecialKey = readJsonFile(descPath, {}); const titleSpecial = Object.entries(titleSpecialKey).reduce((acc, [key, value]) => { const fakerValue = getFakerValue(value, options); acc[key] = fakerValue; return acc; }, {}); const descriptionSpecial = Object.entries(descriptionSpecialKey).reduce((acc, [key, value]) => { const fakerValue = getFakerValue(value, options); acc[key] = fakerValue; return acc; }, {}); return { titleSpecial, descriptionSpecial }; }; var getFakerValue = (value, options) => { if ("value" in value) { return value.value; } if ("module" in value && "type" in value) { if (options.isStatic === false) { const fakerOption = "options" in value ? toTypeScriptCode(value.options, __spreadValues({ depth: 0 }, options)) : ""; return `faker.${value.module}.${value.type}(${fakerOption})`; } const fakerModule = faker[value.module]; if (fakerModule === void 0) { console.warn("can't find faker module", fakerModule); return void 0; } const fakerFunc = fakerModule[value.type]; if (fakerFunc === void 0 || typeof fakerFunc !== "function") { console.warn("can't find faker function", fakerFunc); return void 0; } return "options" in value ? fakerFunc(value.options) : fakerFunc(); } return void 0; }; // src/generators/response-generator.ts import SwaggerParser2 from "@apidevtools/swagger-parser"; import { pascalCase as pascalCase2 } from "change-case-all"; import * as path2 from "path"; import { isReference as isReference2 } from "oazapfts/generate"; var generateResponses = (paths, options) => __async(void 0, null, function* () { const parser = new SwaggerParser2(); const openapiPath = resolveFilePath(options.path, options.baseDir); yield parser.dereference(openapiPath); const refs = parser.$refs; const firstTags = Array.from(new Set(paths.map((path3) => path3.tags[0]))); const codeBasePerTag = firstTags.reduce((acc, tag) => { acc[tag] = []; return acc; }, {}); const specialFakers = specialFakerParser(options); paths.forEach((path3) => { const pathResponses = path3.responses.map((res) => { return generateSingleResponse(path3, res, refs, specialFakers, options); }); const pathResponsesWithComment = `// ${path3.operationId} ` + pathResponses.join("\n\n"); codeBasePerTag[path3.tags[0]].push(pathResponsesWithComment); }); yield writeResponseFiles(codeBasePerTag, options); }); var generateSingleResponse = (path3, res, refs, specialFakers, options) => { var _a, _b, _c, _d, _e; const codeBaseArray = [ `export const get${pascalCase2(path3.operationId)}${res.statusCode} = () => {` ]; if (((_a = res.schema) == null ? void 0 : _a.type) === "ref") { const { name, value } = refSchemaParser(res.schema.value.$ref, refs); const outputSchema = parseSchema(value, specialFakers, options); codeBaseArray.push(` // Schema is ${name}`); codeBaseArray.push( ` return ${toTypeScriptCode(outputSchema, __spreadValues({ depth: 1 }, options))}` ); } else if (((_b = res.schema) == null ? void 0 : _b.type) === "array") { if (isReference2(res.schema.value)) { const { name, value } = refSchemaParser(res.schema.value.$ref, refs); const outputSchema = getRandomLengthArray(options.arrayMinLength, options.arrayMaxLength).map( () => parseSchema(value, specialFakers, options) ); codeBaseArray.push(` // Schema is ${name} array`); codeBaseArray.push( ` return ${toTypeScriptCode(outputSchema, __spreadValues({ depth: 1 }, options))}` ); } else { const outputSchema = getRandomLengthArray(options.arrayMinLength, options.arrayMaxLength).map( () => res.schema && parseSchema(res.schema.value, specialFakers, options) ); codeBaseArray.push( ` return ${toTypeScriptCode(outputSchema, __spreadValues({ depth: 1 }, options))}` ); } } else if (((_c = res.schema) == null ? void 0 : _c.type) === "anyOf") { const firstSchema = (_d = res.schema.value.anyOf) == null ? void 0 : _d[0]; if (isReference2(firstSchema)) { const { name, value } = refSchemaParser(firstSchema.$ref, refs); const outputSchema = parseSchema(value, specialFakers, options); codeBaseArray.push(` // Schema is ${name}`); codeBaseArray.push( ` return ${toTypeScriptCode(outputSchema, __spreadValues({ depth: 1 }, options))}` ); } else { codeBaseArray.push(` return ${res.schema.value}`); } } else { codeBaseArray.push(` return ${(_e = res.schema) == null ? void 0 : _e.value}`); } return [...codeBaseArray, `}`].join("\n"); }; var writeResponseFiles = (codeBasePerTag, options) => __async(void 0, null, function* () { const directory = path2.join(options.baseDir, "response"); ensureDir(directory); if (options.clear) { clearDirectory(directory); } Object.entries(codeBasePerTag).forEach(([tag, responses]) => { const needImportFaker = responses.some((res) => res.includes("faker.")); const importFaker = options.isStatic || !needImportFaker ? "" : 'import { faker } from "../fakers"\n\n'; const fileName = `${directory}/${tag}.ts`; const content = generateResponseFileContent(importFaker, responses); safeWriteFile(fileName, content); console.log(`Generated ${fileName}`); }); const indexContent = generateResponseIndexFile(codeBasePerTag); const indexFileName = `${directory}/index.ts`; safeWriteFile(indexFileName, indexContent); console.log(`Generated ${indexFileName}`); }); var generateResponseFileContent = (importFaker, responses) => { const { GEN_COMMENT: GEN_COMMENT2 } = (init_core(), __toCommonJS(core_exports)); return GEN_COMMENT2 + importFaker + responses.join("\n\n"); }; var generateResponseIndexFile = (codeBasePerTag) => { const { GEN_COMMENT: GEN_COMMENT2 } = (init_core(), __toCommonJS(core_exports)); const importResponses = Object.entries(codeBasePerTag).map(([tag, responses]) => { const responseNames = responses.reduce((acc, handler) => { const matched = handler.match(/get[A-Z]\w+/g); if (matched === null) return acc; return [...acc, ...matched]; }, []).join(",\n "); return ["export {", " " + responseNames, '} from "./' + tag + '"'].join("\n"); }); return GEN_COMMENT2 + importResponses.join("\n"); }; var generateResponseFunctionName = (operationId, statusCode) => { return `get${pascalCase2(operationId)}${statusCode}`; }; var generateResponsesForTag = (paths, tag, options) => __async(void 0, null, function* () { const filteredPaths = paths.filter((path3) => path3.tags.includes(tag)); const parser = new SwaggerParser2(); const openapiPath = resolveFilePath(options.path, options.baseDir); yield parser.dereference(openapiPath); const refs = parser.$refs; const specialFakers = specialFakerParser(options); return filteredPaths.flatMap( (path3) => path3.responses.map((res) => generateSingleResponse(path3, res, refs, specialFakers, options)) ); }); export { generateResponseFunctionName, generateResponses, generateResponsesForTag }; //# sourceMappingURL=response-generator.mjs.map