diff --git a/.changeset/hip-ravens-teach.md b/.changeset/hip-ravens-teach.md new file mode 100644 index 00000000..37c6b4e0 --- /dev/null +++ b/.changeset/hip-ravens-teach.md @@ -0,0 +1,5 @@ +--- +"counterfact": minor +--- + +turn the proxy on or off for individual paths diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f3fb2673..db255c5f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -22,7 +22,7 @@ jobs: fetch-depth: 0 - uses: actions/setup-node@v4 with: - node-version: 20.x + node-version: 22.x cache: yarn id: setup-node - name: Get Node Version diff --git a/.mise.toml b/.mise.toml index 126f6807..6a0493c6 100644 --- a/.mise.toml +++ b/.mise.toml @@ -1,2 +1,2 @@ [tools] -node = "20" +node = "22" diff --git a/bin/counterfact.js b/bin/counterfact.js index 5a34ae17..65a58af4 100755 --- a/bin/counterfact.js +++ b/bin/counterfact.js @@ -9,7 +9,7 @@ import { program } from "commander"; import createDebug from "debug"; import open from "open"; -import { counterfact } from "../dist/server/app.js"; +import { counterfact } from "../dist/app.js"; const MIN_NODE_VERSION = 17; @@ -151,8 +151,8 @@ async function main(source, destination) { includeSwaggerUi: true, openApiPath: source, port: options.port, - proxyEnabled: Boolean(options.proxyUrl), - proxyUrl: options.proxyUrl, + proxyPaths: new Map([["", Boolean(options.proxyUrl)]]), + proxyUrl: options.proxyUrl ?? "", routePrefix: options.prefix, startRepl: options.repl, startServer: options.serve, diff --git a/docs/usage.md b/docs/usage.md index 4b0f686a..c0fd3681 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -282,11 +282,9 @@ To proxy an individual endpoint, you can use the `$.proxy()` function. }; ``` -To toggle globally between Counterfact and a proxy server, pass `--proxy-url ` in the CLI. +To set up a proxy for the entire API, add `--proxy ` in the CLI. -Then type `.proxy on` / `.proxy off` in the REPL to turn it on and off. When the global proxy is on, all requests will be sent to the proxy URL instead of the mock implementations in Counterfact. - -This feature is hot off the presses and somewhat experimental. We have plans to introduce more granular controls over what gets proxied when, but we want to see how this works first. Please send feedback! +From there, you can switch back and forth between the proxy and mocks by typing `.proxy [on|off] `. Type `.proxy help` for detailed information on using the `.proxy` command. ## No Cap Recap ๐Ÿงข diff --git a/src/server/app.ts b/src/app.ts similarity index 82% rename from src/server/app.ts rename to src/app.ts index 4353bf5a..3ca8ab81 100644 --- a/src/server/app.ts +++ b/src/app.ts @@ -5,17 +5,17 @@ import { createHttpTerminator, type HttpTerminator } from "http-terminator"; import yaml from "js-yaml"; import $RefParser from "json-schema-ref-parser"; -import { CodeGenerator } from "../typescript-generator/code-generator.js"; -import { readFile } from "../util/read-file.js"; -import type { Config } from "./config.js"; -import { ContextRegistry } from "./context-registry.js"; -import { createKoaApp } from "./create-koa-app.js"; -import { Dispatcher, type OpenApiDocument } from "./dispatcher.js"; -import { koaMiddleware } from "./koa-middleware.js"; -import { ModuleLoader } from "./module-loader.js"; -import { Registry } from "./registry.js"; -import { startRepl } from "./repl.js"; -import { Transpiler } from "./transpiler.js"; +import { startRepl } from "./repl/repl.js"; +import type { Config } from "./server/config.js"; +import { ContextRegistry } from "./server/context-registry.js"; +import { createKoaApp } from "./server/create-koa-app.js"; +import { Dispatcher, type OpenApiDocument } from "./server/dispatcher.js"; +import { koaMiddleware } from "./server/koa-middleware.js"; +import { ModuleLoader } from "./server/module-loader.js"; +import { Registry } from "./server/registry.js"; +import { Transpiler } from "./server/transpiler.js"; +import { CodeGenerator } from "./typescript-generator/code-generator.js"; +import { readFile } from "./util/read-file.js"; async function loadOpenApiDocument(source: string) { try { diff --git a/src/repl/repl.ts b/src/repl/repl.ts new file mode 100644 index 00000000..b0bfcc18 --- /dev/null +++ b/src/repl/repl.ts @@ -0,0 +1,130 @@ +import repl from "node:repl"; + +import type { Config } from "../server/config.js"; +import type { ContextRegistry } from "../server/context-registry.js"; + +function printToStdout(line: string) { + process.stdout.write(`${line}\n`); +} + +export function startRepl( + contextRegistry: ContextRegistry, + config: Config, + print = printToStdout, +) { + // eslint-disable-next-line max-statements + function printProxyStatus() { + if (config.proxyUrl === "") { + print("The proxy URL is not set."); + print('To set it, type ".proxy url '); + return; + } + + print("Proxy Configuration:"); + print(""); + print(`The proxy URL is ${config.proxyUrl}`); + print(""); + print("Paths prefixed with [+] will be proxied."); + print("Paths prefixed with [-] will not be proxied."); + print(""); + + // eslint-disable-next-line array-func/prefer-array-from + const entries = [...config.proxyPaths.entries()].sort(([path1], [path2]) => + path1 < path2 ? -1 : 1, + ); + + for (const [path, state] of entries) { + print(`${state ? "[+]" : "[-]"} ${path}/`); + } + } + + function setProxyUrl(url: string | undefined) { + if (url === undefined) { + print("usage: .proxy url "); + return; + } + + config.proxyUrl = url; + print(`proxy URL is set to ${url}`); + } + + function turnProxyOnOrOff(text: string) { + const [command, endpoint] = text.split(" "); + + const printEndpoint = + endpoint === undefined || endpoint === "" ? "/" : endpoint; + + config.proxyPaths.set( + (endpoint ?? "").replace(/\/$/u, ""), + command === "on", + ); + + if (command === "on") { + print( + `Requests to ${printEndpoint} will be proxied to ${ + config.proxyUrl || "" + }${printEndpoint}`, + ); + } + + if (command === "off") { + print(`Requests to ${printEndpoint} will be handled by local code`); + } + } + + const replServer = repl.start({ prompt: "๐Ÿค–> " }); + + replServer.defineCommand("counterfact", { + action() { + print( + "This is a read-eval-print loop (REPL), the same as the one you get when you run node with no arguments.", + ); + print( + "Except that it's connected to the running server, which you can access with the following globals:", + ); + print(""); + print( + "- loadContext('/some/path'): to access the context object for a given path", + ); + print("- context: the root context ( same as loadContext('/') )"); + print(""); + print( + "For more information, see https://counterfact.dev/docs/usage.html", + ); + print(""); + + this.clearBufferedCommand(); + this.displayPrompt(); + }, + + help: "Get help with Counterfact", + }); + + replServer.defineCommand("proxy", { + action(text) { + if (text === "help" || text === "") { + print(".proxy [on|off] - turn the proxy on/off at the root level"); + print(".proxy [on|off] - turn the proxy on for a path"); + print(".proxy status - show the proxy status"); + print(".proxy help - show this message"); + } else if (text.startsWith("url")) { + setProxyUrl(text.split(" ")[1]); + } else if (text === "status") { + printProxyStatus(); + } else { + turnProxyOnOrOff(text); + } + + this.clearBufferedCommand(); + this.displayPrompt(); + }, + + help: 'proxy configuration (".proxy help" for details)', + }); + + replServer.context.loadContext = (path: string) => contextRegistry.find(path); + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call + replServer.context.context = replServer.context.loadContext("/"); + + return replServer; +} diff --git a/src/server/config.ts b/src/server/config.ts index 09695088..7aebf295 100644 --- a/src/server/config.ts +++ b/src/server/config.ts @@ -6,7 +6,7 @@ export interface Config { }; openApiPath: string; port: number; - proxyEnabled: boolean; + proxyPaths: Map; proxyUrl: string; routePrefix: string; startRepl: boolean; diff --git a/src/server/is-proxy-enabled-for-path.ts b/src/server/is-proxy-enabled-for-path.ts new file mode 100644 index 00000000..f75e2ac7 --- /dev/null +++ b/src/server/is-proxy-enabled-for-path.ts @@ -0,0 +1,20 @@ +interface ProxyConfig { + proxyPaths: Map; +} + +export function isProxyEnabledForPath( + path: string, + config: ProxyConfig, +): boolean { + if (config.proxyPaths.has(path)) { + return config.proxyPaths.get(path) ?? false; + } + + if (path === "") { + return false; + } + + const parentPath = path.slice(0, Math.max(0, path.lastIndexOf("/"))); + + return isProxyEnabledForPath(parentPath, config); +} diff --git a/src/server/koa-middleware.ts b/src/server/koa-middleware.ts index 238218d6..d8ffa225 100644 --- a/src/server/koa-middleware.ts +++ b/src/server/koa-middleware.ts @@ -6,6 +6,7 @@ import koaProxy from "koa-proxy"; import type { Config } from "./config.js"; import type { Dispatcher } from "./dispatcher.js"; +import { isProxyEnabledForPath } from "./is-proxy-enabled-for-path.js"; import type { HttpMethods } from "./registry.js"; const debug = createDebug("counterfact:server:create-koa-app"); @@ -59,7 +60,7 @@ export function koaMiddleware( ): Koa.Middleware { // eslint-disable-next-line max-statements return async function middleware(ctx, next) { - const { proxyEnabled, proxyUrl, routePrefix } = config; + const { proxyUrl, routePrefix } = config; debug("middleware running for path: %s", ctx.request.path); debug("routePrefix: %s", routePrefix); @@ -79,7 +80,7 @@ export function koaMiddleware( // eslint-disable-next-line @typescript-eslint/consistent-type-assertions const method = ctx.request.method as HttpMethods; - if (proxyEnabled && proxyUrl) { + if (isProxyEnabledForPath(path, config) && proxyUrl) { /* @ts-expect-error the body comes from koa-bodyparser, not sure how to fix this */ // eslint-disable-next-line @typescript-eslint/no-unsafe-return return proxy({ host: proxyUrl })(ctx, next); diff --git a/src/server/registry.ts b/src/server/registry.ts index 32dc115f..fb2e9c3f 100644 --- a/src/server/registry.ts +++ b/src/server/registry.ts @@ -17,6 +17,10 @@ type HttpMethods = | "TRACE"; interface RequestData { + auth?: { + password?: string; + username?: string; + }; context: unknown; headers: { [key: string]: number | string }; matchedPath?: string; @@ -30,10 +34,6 @@ interface RequestData { query: { [key: string]: number | string }; response: ResponseBuilderFactory; tools: Tools; - user?: { - password?: string; - username?: string; - }; } interface RequestDataWithBody extends RequestData { diff --git a/src/server/repl.ts b/src/server/repl.ts deleted file mode 100644 index 623ab373..00000000 --- a/src/server/repl.ts +++ /dev/null @@ -1,60 +0,0 @@ -import repl from "node:repl"; - -import type { Config } from "./config.js"; -import type { ContextRegistry } from "./context-registry.js"; - -export function startRepl(contextRegistry: ContextRegistry, config: Config) { - const replServer = repl.start("๐Ÿค–> "); - - replServer.defineCommand("counterfact", { - action() { - process.stdout.write( - "This is a read-eval-print loop (REPL), the same as the one you get when you run node with no arguments.\n", - ); - process.stdout.write( - "Except that it's connected to the running server, which you can access with the following globals:\n\n", - ); - process.stdout.write( - "- loadContext('/some/path'): to access the context object for a given path\n", - ); - process.stdout.write( - "- context: the root context ( same as loadContext('/') )\n", - ); - process.stdout.write( - "\nFor more information, see https://counterfact.dev/docs/usage.html\n\n", - ); - - this.clearBufferedCommand(); - this.displayPrompt(); - }, - - help: "Get help with Counterfact", - }); - - replServer.defineCommand("proxy", { - action(state) { - if (state === "on") { - config.proxyEnabled = true; - } - - if (state === "off") { - config.proxyEnabled = false; - } - - process.stdout.write( - `Proxy is ${config.proxyEnabled ? "on" : "off"}: ${config.proxyUrl}\n`, - ); - - this.clearBufferedCommand(); - this.displayPrompt(); - }, - - help: "proxy [on|off] - turn the proxy on or off; proxy - print proxy info", - }); - - replServer.context.loadContext = (path: string) => contextRegistry.find(path); - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call - replServer.context.context = replServer.context.loadContext("/"); - - return replServer; -} diff --git a/src/util/wait-for-event.ts b/src/util/wait-for-event.ts index 4a15be8f..63d81ee1 100644 --- a/src/util/wait-for-event.ts +++ b/src/util/wait-for-event.ts @@ -1,4 +1,4 @@ -import type { EventEmitter } from "koa"; +import { EventEmitter } from "node:events"; /** * Creates a promise that resolves when a specified event is fired on the given EventTarget. @@ -19,10 +19,10 @@ export async function waitForEvent( resolve(event); }; - if (target instanceof EventTarget) { - target.addEventListener(eventName, handler); - } else { + if (target instanceof EventEmitter) { target.once(eventName, handler); + } else { + target.addEventListener(eventName, handler); } }); } diff --git a/test/repl/repl.test.ts b/test/repl/repl.test.ts new file mode 100644 index 00000000..cd1a4f72 --- /dev/null +++ b/test/repl/repl.test.ts @@ -0,0 +1,218 @@ +import type { REPLServer } from "node:repl"; + +import { startRepl } from "../../src/repl/repl.js"; +import type { Config } from "../../src/server/config.js"; +import { ContextRegistry } from "../../src/server/context-registry.js"; + +const CONFIG: Config = { + basePath: "", + + generate: { + routes: true, + types: true, + }, + + openApiPath: "", + port: 9999, + proxyPaths: new Map([]), + proxyUrl: "https://example.com/test", + routePrefix: "", + startRepl: false, + startServer: true, + + watch: { + routes: true, + types: true, + }, +}; + +class MockRepl { + public isBufferCleared = false; + + public isPromptDisplayed = false; + + public commandLog: string[] = []; + + public clearBufferedCommand() { + this.commandLog.push("clearBufferedCommand"); + } + + public displayPrompt() { + this.commandLog.push("displayPrompt"); + } +} + +class ReplHarness { + public server: REPLServer; + + private readonly mock = new MockRepl(); + + public output: string[] = []; + + public constructor(contextRegistry: ContextRegistry, config: Config) { + this.server = startRepl(contextRegistry, config, (line) => + this.output.push(line), + ); + } + + public call(name: string, options: string) { + this.server.commands[name]?.action.call(this.mock, options); + } + + public isReset() { + return ( + this.mock.commandLog[0] === "clearBufferedCommand" && + this.mock.commandLog[1] === "displayPrompt" + ); + } +} + +function createHarness() { + const contextRegistry = new ContextRegistry(); + const config = { ...CONFIG }; + + config.proxyPaths = new Map(); + + const harness = new ReplHarness(contextRegistry, config); + + return { config, contextRegistry, harness }; +} + +describe("REPL", () => { + it("turns on the proxy globally", () => { + const { config, harness } = createHarness(); + harness.call("proxy", "on"); + + expect(config.proxyPaths.get("")).toBe(true); + expect(harness.isReset()).toBe(true); + }); + + it("turns off the proxy globally", () => { + const { config, harness } = createHarness(); + + harness.call("proxy", "off"); + + expect(config.proxyPaths.get("")).toBe(false); + expect(harness.isReset()).toBe(true); + }); + + it("turns on the proxy for the root", () => { + const { config, harness } = createHarness(); + harness.call("proxy", "on /"); + + expect(config.proxyPaths.get("")).toBe(true); + expect(harness.isReset()).toBe(true); + }); + + it("turns off the proxy for the root", () => { + const { config, harness } = createHarness(); + + harness.call("proxy", "off /"); + + expect(config.proxyPaths.get("")).toBe(false); + expect(harness.isReset()).toBe(true); + }); + + it("turns on the proxy for an endpoint", () => { + const { config, harness } = createHarness(); + harness.call("proxy", "on /foo/bar"); + + expect(config.proxyPaths.get("/foo/bar")).toBe(true); + expect(harness.isReset()).toBe(true); + }); + + it("turns off the proxy for an endpoint", () => { + const { config, harness } = createHarness(); + harness.call("proxy", "off /foo/bar"); + + expect(config.proxyPaths.get("/foo/bar")).toBe(false); + expect(harness.isReset()).toBe(true); + }); + + it("shows the proxy status", () => { + const { config, harness } = createHarness(); + + config.proxyPaths.set("/foo", true); + config.proxyPaths.set("/foo/bar", false); + + harness.call("proxy", "status"); + + expect(harness.output).toEqual([ + "Proxy Configuration:", + "", + "The proxy URL is https://example.com/test", + "", + "Paths prefixed with [+] will be proxied.", + "Paths prefixed with [-] will not be proxied.", + "", + "[+] /foo/", + "[-] /foo/bar/", + ]); + expect(harness.isReset()).toBe(true); + }); + + it("shows the proxy status when no URL is set", () => { + const { config, harness } = createHarness(); + + config.proxyUrl = ""; + config.proxyPaths.set("/foo", true); + config.proxyPaths.set("/foo/bar", false); + + harness.call("proxy", "status"); + + expect(harness.output).toEqual([ + "The proxy URL is not set.", + 'To set it, type ".proxy url ', + ]); + expect(harness.isReset()).toBe(true); + }); + + it("displays an explanatory message after turning the proxy on for an endpoint", () => { + const { harness } = createHarness(); + harness.call("proxy", "on /foo/bar"); + + expect(harness.output).toEqual([ + "Requests to /foo/bar will be proxied to https://example.com/test/foo/bar", + ]); + }); + + it("displays an explanatory message after turning the proxy off for an endpoint", () => { + const { harness } = createHarness(); + harness.call("proxy", "off /foo/bar"); + + expect(harness.output).toEqual([ + "Requests to /foo/bar will be handled by local code", + ]); + }); + + it.each(["", "help"])("displays a proxy help message (%s)", () => { + const { harness } = createHarness(); + harness.call("proxy", "help"); + + expect(harness.output).toEqual([ + ".proxy [on|off] - turn the proxy on/off at the root level", + ".proxy [on|off] - turn the proxy on for a path", + ".proxy status - show the proxy status", + ".proxy help - show this message", + ]); + }); + + it("sets the proxy url", () => { + const { config, harness } = createHarness(); + harness.call("proxy", "url https://example.com/new-url"); + + expect(config.proxyUrl).toBe("https://example.com/new-url"); + expect(harness.output).toEqual([ + "proxy URL is set to https://example.com/new-url", + ]); + expect(harness.isReset()).toBe(true); + }); + + it("displays a message if 'proxy url' is entered without a URL", () => { + const { harness } = createHarness(); + harness.call("proxy", "url"); + + expect(harness.output).toEqual(["usage: .proxy url "]); + expect(harness.isReset()).toBe(true); + }); +}); diff --git a/test/server/is-proxy-enabled-for-path.test.ts b/test/server/is-proxy-enabled-for-path.test.ts new file mode 100644 index 00000000..df90fa0b --- /dev/null +++ b/test/server/is-proxy-enabled-for-path.test.ts @@ -0,0 +1,43 @@ +import { isProxyEnabledForPath } from "../../src/server/is-proxy-enabled-for-path.js"; + +describe("isProxyEnabledForPath()", () => { + it.each([ + ["/", true], + ["/enabled", true], + ["/enabled/sub/path", true], + ["/disabled", false], + ["/disabled/sub/path", false], + ["/unset", true], + ["/unset/sub/path", true], + ])("given path '%s', returns %s", (path, expected) => { + expect( + isProxyEnabledForPath(path, { + proxyPaths: new Map([ + ["", true], + ["/disabled", false], + ["/enabled", true], + ]), + }), + ).toBe(expected); + }); + + it.each([ + ["/", false], + ["/enabled", true], + ["/enabled/sub/path", true], + ["/disabled", false], + ["/disabled/sub/path", false], + ["/unset", false], + ["/unset/sub/path", false], + ])("given path '%s', returns %s", (path, expected) => { + expect( + isProxyEnabledForPath(path, { + proxyPaths: new Map([ + ["", false], + ["/disabled", false], + ["/enabled", true], + ]), + }), + ).toBe(expected); + }); +}); diff --git a/test/server/koa-middleware.test.ts b/test/server/koa-middleware.test.ts index 88b34c64..60084205 100644 --- a/test/server/koa-middleware.test.ts +++ b/test/server/koa-middleware.test.ts @@ -1,26 +1,40 @@ /* eslint-disable max-lines */ // eslint-disable-next-line import/no-extraneous-dependencies, n/no-extraneous-import import { jest } from "@jest/globals"; -import type { Context as KoaContext, ParameterizedContext } from "koa"; +import type { ParameterizedContext } from "koa"; import type KoaProxy from "koa-proxy"; +import type { Config } from "../../src/server/config.js"; import { ContextRegistry } from "../../src/server/context-registry.js"; import { Dispatcher } from "../../src/server/dispatcher.js"; import { koaMiddleware } from "../../src/server/koa-middleware.js"; import { Registry } from "../../src/server/registry.js"; -const CONFIG = { +const CONFIG: Config = { basePath: "", + + generate: { + routes: true, + types: true, + }, + openApiPath: "", port: 9999, - proxyEnabled: false, + proxyPaths: new Map([]), proxyUrl: "", routePrefix: "", + startRepl: false, + startServer: true, + + watch: { + routes: true, + types: true, + }, }; -const mockKoaProxy = (options: KoaProxy.Options | undefined) => - function proxy(ctx: KoaContext) { - ctx.mockProxyHost = options?.host; +const mockKoaProxy: typeof KoaProxy = (options) => + function proxy(context) { + context.mockProxyHost = options?.host; }; describe("koa middleware", () => { @@ -102,12 +116,21 @@ describe("koa middleware", () => { const dispatcher = new Dispatcher(registry, new ContextRegistry()); const middleware = koaMiddleware( dispatcher, - { ...CONFIG, proxyEnabled: true, proxyUrl: "https://example.com" }, + { + ...CONFIG, + proxyPaths: new Map([["", true]]), + proxyUrl: "https://example.com", + }, + mockKoaProxy, ); const ctx = { mockProxyHost: undefined, request: { headers: {}, method: "GET", path: "/proxy" }, + + set() { + /* set a header */ + }, }; // @ts-expect-error - not obvious how to make TS happy here, and it's just a unit test @@ -290,7 +313,10 @@ describe("koa middleware", () => { }); const dispatcher = new Dispatcher(registry, new ContextRegistry()); - const middleware = koaMiddleware(dispatcher, { routePrefix: "/api/v1" }); + const middleware = koaMiddleware(dispatcher, { + ...CONFIG, + routePrefix: "/api/v1", + }); // eslint-disable-next-line @typescript-eslint/consistent-type-assertions const ctx = { req: { diff --git a/test/typescript-generator/__snapshots__/generate.test.ts.snap b/test/typescript-generator/__snapshots__/generate.test.ts.snap index 5ae50d75..d9aba8c0 100644 --- a/test/typescript-generator/__snapshots__/generate.test.ts.snap +++ b/test/typescript-generator/__snapshots__/generate.test.ts.snap @@ -1,5476 +1,1175 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`end-to-end test generates the same code for pet store that it did on the last test run 1`] = ` -Map { - "paths/pet.ts" => Script { - "cache": Map { - "OperationCoder@./petstore.yaml#/paths/~1pet/post:false" => "POST", - "OperationTypeCoder@./petstore.yaml#/paths/~1pet/post@path-types/pet.types.ts:true:false" => "HTTP_POST", - "OperationCoder@./petstore.yaml#/paths/~1pet/put:false" => "PUT", - "OperationTypeCoder@./petstore.yaml#/paths/~1pet/put@path-types/pet.types.ts:true:false" => "HTTP_PUT", - }, - "comments": [], - "exports": Map { - "POST" => { - "beforeExport": "", - "code": "($) => { - return $.response[200].random(); - }", - "done": true, - "id": "OperationCoder@./petstore.yaml#/paths/~1pet/post", - "isDefault": false, - "isType": false, - "name": "POST", - "promise": Promise {}, - "typeDeclaration": "HTTP_POST", - }, - "PUT" => { - "beforeExport": "", - "code": "($) => { - return $.response[200].random(); - }", - "done": true, - "id": "OperationCoder@./petstore.yaml#/paths/~1pet/put", - "isDefault": false, - "isType": false, - "name": "PUT", - "promise": Promise {}, - "typeDeclaration": "HTTP_PUT", - }, - }, - "externalImport": Map {}, - "imports": Map { - "HTTP_POST" => { - "isDefault": false, - "isType": true, - "name": "HTTP_POST", - "script": Script { - "cache": Map { - "OperationTypeCoder@./petstore.yaml#/paths/~1pet/post:true" => "HTTP_POST", - "OperationTypeCoder@./petstore.yaml#/paths/~1pet/put:true" => "HTTP_PUT", - "SchemaTypeCoder@undefined@components/Pet.ts:true:false" => "Pet", - }, - "comments": [ - "This code was automatically generated from an OpenAPI description.", - "Do not edit this file. Edit the OpenAPI file instead.", - "For more information, see https://github.com/pmcelhaney/counterfact/blob/main/docs/faq-generated-code.md", - ], - "exports": Map { - "HTTP_POST" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: never, path: never, header: never, body: Pet, context: Context, response: ResponseBuilderFactory<{ -200: { - headers: never; - requiredHeaders: never; - content: { -"application/xml": { - schema: Pet - }, -"application/json": { - schema: Pet - } -}; - }, -405: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: 200, - contentType?: "application/xml", - body?: Pet - } | { - status: 200, - contentType?: "application/json", - body?: Pet - } | { - status: 405 - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1pet/post", - "isDefault": false, - "isType": true, - "name": "HTTP_POST", - "promise": Promise {}, - "typeDeclaration": "", - }, - "HTTP_PUT" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: never, path: never, header: never, body: Pet, context: Context, response: ResponseBuilderFactory<{ -200: { - headers: never; - requiredHeaders: never; - content: { -"application/xml": { - schema: Pet - }, -"application/json": { - schema: Pet - } -}; - }, -400: { - headers: never; - requiredHeaders: never; - content: never; - }, -404: { - headers: never; - requiredHeaders: never; - content: never; - }, -405: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: 200, - contentType?: "application/xml", - body?: Pet - } | { - status: 200, - contentType?: "application/json", - body?: Pet - } | { - status: 400 - } | { - status: 404 - } | { - status: 405 - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1pet/put", - "isDefault": false, - "isType": true, - "name": "HTTP_PUT", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map { - "WideOperationArgument" => { - "isType": true, - "modulePath": "../types.d.ts", - }, - "OmitValueWhenNever" => { - "isType": true, - "modulePath": "../types.d.ts", - }, - "Context" => { - "isType": true, - "modulePath": "@@CONTEXT_FILE_TOKEN@@", - }, - "ResponseBuilderFactory" => { - "isType": true, - "modulePath": "../types.d.ts", - }, - }, - "imports": Map { - "Pet" => { - "isDefault": false, - "isType": true, - "name": "Pet", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "Pet", - "SchemaTypeCoder@undefined@components/Category.ts:true:false" => "Category", - "SchemaTypeCoder@undefined@components/Tag.ts:true:false" => "Tag", - }, - "comments": [], - "exports": Map { - "Pet" => { - "beforeExport": "", - "code": "{"id"?: number,"name": string,"category"?: Category,"photoUrls": Array,"tags"?: Array,"status"?: "available" | "pending" | "sold"}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "Pet", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map { - "Category" => { - "isDefault": false, - "isType": true, - "name": "Category", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "Category", - }, - "comments": [], - "exports": Map { - "Category" => { - "beforeExport": "", - "code": "{"id"?: number,"name"?: string}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "Category", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map {}, - "path": "components/Category.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - "Tag" => { - "isDefault": false, - "isType": true, - "name": "Tag", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "Tag", - }, - "comments": [], - "exports": Map { - "Tag" => { - "beforeExport": "", - "code": "{"id"?: number,"name"?: string}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "Tag", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map {}, - "path": "components/Tag.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "components/Pet.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "path-types/pet.types.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - "HTTP_PUT" => { - "isDefault": false, - "isType": true, - "name": "HTTP_PUT", - "script": Script { - "cache": Map { - "OperationTypeCoder@./petstore.yaml#/paths/~1pet/post:true" => "HTTP_POST", - "OperationTypeCoder@./petstore.yaml#/paths/~1pet/put:true" => "HTTP_PUT", - "SchemaTypeCoder@undefined@components/Pet.ts:true:false" => "Pet", - }, - "comments": [ - "This code was automatically generated from an OpenAPI description.", - "Do not edit this file. Edit the OpenAPI file instead.", - "For more information, see https://github.com/pmcelhaney/counterfact/blob/main/docs/faq-generated-code.md", - ], - "exports": Map { - "HTTP_POST" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: never, path: never, header: never, body: Pet, context: Context, response: ResponseBuilderFactory<{ -200: { - headers: never; - requiredHeaders: never; - content: { -"application/xml": { - schema: Pet - }, -"application/json": { - schema: Pet - } -}; - }, -405: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: 200, - contentType?: "application/xml", - body?: Pet - } | { - status: 200, - contentType?: "application/json", - body?: Pet - } | { - status: 405 - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1pet/post", - "isDefault": false, - "isType": true, - "name": "HTTP_POST", - "promise": Promise {}, - "typeDeclaration": "", - }, - "HTTP_PUT" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: never, path: never, header: never, body: Pet, context: Context, response: ResponseBuilderFactory<{ -200: { - headers: never; - requiredHeaders: never; - content: { -"application/xml": { - schema: Pet - }, -"application/json": { - schema: Pet - } -}; - }, -400: { - headers: never; - requiredHeaders: never; - content: never; - }, -404: { - headers: never; - requiredHeaders: never; - content: never; - }, -405: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: 200, - contentType?: "application/xml", - body?: Pet - } | { - status: 200, - contentType?: "application/json", - body?: Pet - } | { - status: 400 - } | { - status: 404 - } | { - status: 405 - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1pet/put", - "isDefault": false, - "isType": true, - "name": "HTTP_PUT", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map { - "WideOperationArgument" => { - "isType": true, - "modulePath": "../types.d.ts", - }, - "OmitValueWhenNever" => { - "isType": true, - "modulePath": "../types.d.ts", - }, - "Context" => { - "isType": true, - "modulePath": "@@CONTEXT_FILE_TOKEN@@", - }, - "ResponseBuilderFactory" => { - "isType": true, - "modulePath": "../types.d.ts", - }, - }, - "imports": Map { - "Pet" => { - "isDefault": false, - "isType": true, - "name": "Pet", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "Pet", - "SchemaTypeCoder@undefined@components/Category.ts:true:false" => "Category", - "SchemaTypeCoder@undefined@components/Tag.ts:true:false" => "Tag", - }, - "comments": [], - "exports": Map { - "Pet" => { - "beforeExport": "", - "code": "{"id"?: number,"name": string,"category"?: Category,"photoUrls": Array,"tags"?: Array,"status"?: "available" | "pending" | "sold"}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "Pet", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map { - "Category" => { - "isDefault": false, - "isType": true, - "name": "Category", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "Category", - }, - "comments": [], - "exports": Map { - "Category" => { - "beforeExport": "", - "code": "{"id"?: number,"name"?: string}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "Category", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map {}, - "path": "components/Category.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - "Tag" => { - "isDefault": false, - "isType": true, - "name": "Tag", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "Tag", - }, - "comments": [], - "exports": Map { - "Tag" => { - "beforeExport": "", - "code": "{"id"?: number,"name"?: string}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "Tag", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map {}, - "path": "components/Tag.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "components/Pet.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "path-types/pet.types.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "paths/pet.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - "path-types/pet.types.ts" => Script { - "cache": Map { - "OperationTypeCoder@./petstore.yaml#/paths/~1pet/post:true" => "HTTP_POST", - "OperationTypeCoder@./petstore.yaml#/paths/~1pet/put:true" => "HTTP_PUT", - "SchemaTypeCoder@undefined@components/Pet.ts:true:false" => "Pet", - }, - "comments": [ - "This code was automatically generated from an OpenAPI description.", - "Do not edit this file. Edit the OpenAPI file instead.", - "For more information, see https://github.com/pmcelhaney/counterfact/blob/main/docs/faq-generated-code.md", - ], - "exports": Map { - "HTTP_POST" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: never, path: never, header: never, body: Pet, context: Context, response: ResponseBuilderFactory<{ -200: { - headers: never; - requiredHeaders: never; - content: { -"application/xml": { - schema: Pet - }, -"application/json": { - schema: Pet - } -}; - }, -405: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: 200, - contentType?: "application/xml", - body?: Pet - } | { - status: 200, - contentType?: "application/json", - body?: Pet - } | { - status: 405 - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1pet/post", - "isDefault": false, - "isType": true, - "name": "HTTP_POST", - "promise": Promise {}, - "typeDeclaration": "", - }, - "HTTP_PUT" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: never, path: never, header: never, body: Pet, context: Context, response: ResponseBuilderFactory<{ -200: { - headers: never; - requiredHeaders: never; - content: { -"application/xml": { - schema: Pet - }, -"application/json": { - schema: Pet - } -}; - }, -400: { - headers: never; - requiredHeaders: never; - content: never; - }, -404: { - headers: never; - requiredHeaders: never; - content: never; - }, -405: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: 200, - contentType?: "application/xml", - body?: Pet - } | { - status: 200, - contentType?: "application/json", - body?: Pet - } | { - status: 400 - } | { - status: 404 - } | { - status: 405 - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1pet/put", - "isDefault": false, - "isType": true, - "name": "HTTP_PUT", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map { - "WideOperationArgument" => { - "isType": true, - "modulePath": "../types.d.ts", - }, - "OmitValueWhenNever" => { - "isType": true, - "modulePath": "../types.d.ts", - }, - "Context" => { - "isType": true, - "modulePath": "@@CONTEXT_FILE_TOKEN@@", - }, - "ResponseBuilderFactory" => { - "isType": true, - "modulePath": "../types.d.ts", - }, - }, - "imports": Map { - "Pet" => { - "isDefault": false, - "isType": true, - "name": "Pet", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "Pet", - "SchemaTypeCoder@undefined@components/Category.ts:true:false" => "Category", - "SchemaTypeCoder@undefined@components/Tag.ts:true:false" => "Tag", - }, - "comments": [], - "exports": Map { - "Pet" => { - "beforeExport": "", - "code": "{"id"?: number,"name": string,"category"?: Category,"photoUrls": Array,"tags"?: Array,"status"?: "available" | "pending" | "sold"}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "Pet", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map { - "Category" => { - "isDefault": false, - "isType": true, - "name": "Category", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "Category", - }, - "comments": [], - "exports": Map { - "Category" => { - "beforeExport": "", - "code": "{"id"?: number,"name"?: string}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "Category", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map {}, - "path": "components/Category.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - "Tag" => { - "isDefault": false, - "isType": true, - "name": "Tag", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "Tag", - }, - "comments": [], - "exports": Map { - "Tag" => { - "beforeExport": "", - "code": "{"id"?: number,"name"?: string}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "Tag", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map {}, - "path": "components/Tag.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "components/Pet.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "path-types/pet.types.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - "paths/pet/findByStatus.ts" => Script { - "cache": Map { - "OperationCoder@./petstore.yaml#/paths/~1pet~1findByStatus/get:false" => "GET", - "OperationTypeCoder@./petstore.yaml#/paths/~1pet~1findByStatus/get@path-types/pet/findByStatus.types.ts:true:false" => "HTTP_GET", - }, - "comments": [], - "exports": Map { - "GET" => { - "beforeExport": "", - "code": "($) => { - return $.response[200].random(); - }", - "done": true, - "id": "OperationCoder@./petstore.yaml#/paths/~1pet~1findByStatus/get", - "isDefault": false, - "isType": false, - "name": "GET", - "promise": Promise {}, - "typeDeclaration": "HTTP_GET", - }, - }, - "externalImport": Map {}, - "imports": Map { - "HTTP_GET" => { - "isDefault": false, - "isType": true, - "name": "HTTP_GET", - "script": Script { - "cache": Map { - "OperationTypeCoder@./petstore.yaml#/paths/~1pet~1findByStatus/get:true" => "HTTP_GET", - "SchemaTypeCoder@undefined@components/Pet.ts:true:false" => "Pet", - }, - "comments": [ - "This code was automatically generated from an OpenAPI description.", - "Do not edit this file. Edit the OpenAPI file instead.", - "For more information, see https://github.com/pmcelhaney/counterfact/blob/main/docs/faq-generated-code.md", - ], - "exports": Map { - "HTTP_GET" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: {"status"?: "available" | "pending" | "sold"}, path: never, header: never, body: never, context: Context, response: ResponseBuilderFactory<{ -200: { - headers: never; - requiredHeaders: never; - content: { -"application/xml": { - schema: Array - }, -"application/json": { - schema: Array - } -}; - }, -400: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: 200, - contentType?: "application/xml", - body?: Array - } | { - status: 200, - contentType?: "application/json", - body?: Array - } | { - status: 400 - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1pet~1findByStatus/get", - "isDefault": false, - "isType": true, - "name": "HTTP_GET", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map { - "WideOperationArgument" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "OmitValueWhenNever" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "Context" => { - "isType": true, - "modulePath": "@@CONTEXT_FILE_TOKEN@@", - }, - "ResponseBuilderFactory" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - }, - "imports": Map { - "Pet" => { - "isDefault": false, - "isType": true, - "name": "Pet", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "Pet", - "SchemaTypeCoder@undefined@components/Category.ts:true:false" => "Category", - "SchemaTypeCoder@undefined@components/Tag.ts:true:false" => "Tag", - }, - "comments": [], - "exports": Map { - "Pet" => { - "beforeExport": "", - "code": "{"id"?: number,"name": string,"category"?: Category,"photoUrls": Array,"tags"?: Array,"status"?: "available" | "pending" | "sold"}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "Pet", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map { - "Category" => { - "isDefault": false, - "isType": true, - "name": "Category", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "Category", - }, - "comments": [], - "exports": Map { - "Category" => { - "beforeExport": "", - "code": "{"id"?: number,"name"?: string}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "Category", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map {}, - "path": "components/Category.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - "Tag" => { - "isDefault": false, - "isType": true, - "name": "Tag", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "Tag", - }, - "comments": [], - "exports": Map { - "Tag" => { - "beforeExport": "", - "code": "{"id"?: number,"name"?: string}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "Tag", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map {}, - "path": "components/Tag.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "components/Pet.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "path-types/pet/findByStatus.types.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "paths/pet/findByStatus.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - "path-types/pet/findByStatus.types.ts" => Script { - "cache": Map { - "OperationTypeCoder@./petstore.yaml#/paths/~1pet~1findByStatus/get:true" => "HTTP_GET", - "SchemaTypeCoder@undefined@components/Pet.ts:true:false" => "Pet", - }, - "comments": [ - "This code was automatically generated from an OpenAPI description.", - "Do not edit this file. Edit the OpenAPI file instead.", - "For more information, see https://github.com/pmcelhaney/counterfact/blob/main/docs/faq-generated-code.md", - ], - "exports": Map { - "HTTP_GET" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: {"status"?: "available" | "pending" | "sold"}, path: never, header: never, body: never, context: Context, response: ResponseBuilderFactory<{ -200: { - headers: never; - requiredHeaders: never; - content: { -"application/xml": { - schema: Array - }, -"application/json": { - schema: Array - } -}; - }, -400: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: 200, - contentType?: "application/xml", - body?: Array - } | { - status: 200, - contentType?: "application/json", - body?: Array - } | { - status: 400 - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1pet~1findByStatus/get", - "isDefault": false, - "isType": true, - "name": "HTTP_GET", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map { - "WideOperationArgument" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "OmitValueWhenNever" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "Context" => { - "isType": true, - "modulePath": "@@CONTEXT_FILE_TOKEN@@", - }, - "ResponseBuilderFactory" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - }, - "imports": Map { - "Pet" => { - "isDefault": false, - "isType": true, - "name": "Pet", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "Pet", - "SchemaTypeCoder@undefined@components/Category.ts:true:false" => "Category", - "SchemaTypeCoder@undefined@components/Tag.ts:true:false" => "Tag", - }, - "comments": [], - "exports": Map { - "Pet" => { - "beforeExport": "", - "code": "{"id"?: number,"name": string,"category"?: Category,"photoUrls": Array,"tags"?: Array,"status"?: "available" | "pending" | "sold"}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "Pet", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map { - "Category" => { - "isDefault": false, - "isType": true, - "name": "Category", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "Category", - }, - "comments": [], - "exports": Map { - "Category" => { - "beforeExport": "", - "code": "{"id"?: number,"name"?: string}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "Category", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map {}, - "path": "components/Category.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - "Tag" => { - "isDefault": false, - "isType": true, - "name": "Tag", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "Tag", - }, - "comments": [], - "exports": Map { - "Tag" => { - "beforeExport": "", - "code": "{"id"?: number,"name"?: string}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "Tag", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map {}, - "path": "components/Tag.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "components/Pet.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "path-types/pet/findByStatus.types.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - "paths/pet/findByTags.ts" => Script { - "cache": Map { - "OperationCoder@./petstore.yaml#/paths/~1pet~1findByTags/get:false" => "GET", - "OperationTypeCoder@./petstore.yaml#/paths/~1pet~1findByTags/get@path-types/pet/findByTags.types.ts:true:false" => "HTTP_GET", - }, - "comments": [], - "exports": Map { - "GET" => { - "beforeExport": "", - "code": "($) => { - return $.response[200].random(); - }", - "done": true, - "id": "OperationCoder@./petstore.yaml#/paths/~1pet~1findByTags/get", - "isDefault": false, - "isType": false, - "name": "GET", - "promise": Promise {}, - "typeDeclaration": "HTTP_GET", - }, - }, - "externalImport": Map {}, - "imports": Map { - "HTTP_GET" => { - "isDefault": false, - "isType": true, - "name": "HTTP_GET", - "script": Script { - "cache": Map { - "OperationTypeCoder@./petstore.yaml#/paths/~1pet~1findByTags/get:true" => "HTTP_GET", - "SchemaTypeCoder@undefined@components/Pet.ts:true:false" => "Pet", - }, - "comments": [ - "This code was automatically generated from an OpenAPI description.", - "Do not edit this file. Edit the OpenAPI file instead.", - "For more information, see https://github.com/pmcelhaney/counterfact/blob/main/docs/faq-generated-code.md", - ], - "exports": Map { - "HTTP_GET" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: {"tags"?: Array}, path: never, header: never, body: never, context: Context, response: ResponseBuilderFactory<{ -200: { - headers: never; - requiredHeaders: never; - content: { -"application/xml": { - schema: Array - }, -"application/json": { - schema: Array - } -}; - }, -400: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: 200, - contentType?: "application/xml", - body?: Array - } | { - status: 200, - contentType?: "application/json", - body?: Array - } | { - status: 400 - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1pet~1findByTags/get", - "isDefault": false, - "isType": true, - "name": "HTTP_GET", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map { - "WideOperationArgument" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "OmitValueWhenNever" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "Context" => { - "isType": true, - "modulePath": "@@CONTEXT_FILE_TOKEN@@", - }, - "ResponseBuilderFactory" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - }, - "imports": Map { - "Pet" => { - "isDefault": false, - "isType": true, - "name": "Pet", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "Pet", - "SchemaTypeCoder@undefined@components/Category.ts:true:false" => "Category", - "SchemaTypeCoder@undefined@components/Tag.ts:true:false" => "Tag", - }, - "comments": [], - "exports": Map { - "Pet" => { - "beforeExport": "", - "code": "{"id"?: number,"name": string,"category"?: Category,"photoUrls": Array,"tags"?: Array,"status"?: "available" | "pending" | "sold"}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "Pet", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map { - "Category" => { - "isDefault": false, - "isType": true, - "name": "Category", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "Category", - }, - "comments": [], - "exports": Map { - "Category" => { - "beforeExport": "", - "code": "{"id"?: number,"name"?: string}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "Category", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map {}, - "path": "components/Category.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - "Tag" => { - "isDefault": false, - "isType": true, - "name": "Tag", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "Tag", - }, - "comments": [], - "exports": Map { - "Tag" => { - "beforeExport": "", - "code": "{"id"?: number,"name"?: string}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "Tag", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map {}, - "path": "components/Tag.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "components/Pet.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "path-types/pet/findByTags.types.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "paths/pet/findByTags.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - "path-types/pet/findByTags.types.ts" => Script { - "cache": Map { - "OperationTypeCoder@./petstore.yaml#/paths/~1pet~1findByTags/get:true" => "HTTP_GET", - "SchemaTypeCoder@undefined@components/Pet.ts:true:false" => "Pet", - }, - "comments": [ - "This code was automatically generated from an OpenAPI description.", - "Do not edit this file. Edit the OpenAPI file instead.", - "For more information, see https://github.com/pmcelhaney/counterfact/blob/main/docs/faq-generated-code.md", - ], - "exports": Map { - "HTTP_GET" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: {"tags"?: Array}, path: never, header: never, body: never, context: Context, response: ResponseBuilderFactory<{ -200: { - headers: never; - requiredHeaders: never; - content: { -"application/xml": { - schema: Array - }, -"application/json": { - schema: Array - } -}; - }, -400: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: 200, - contentType?: "application/xml", - body?: Array - } | { - status: 200, - contentType?: "application/json", - body?: Array - } | { - status: 400 - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1pet~1findByTags/get", - "isDefault": false, - "isType": true, - "name": "HTTP_GET", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map { - "WideOperationArgument" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "OmitValueWhenNever" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "Context" => { - "isType": true, - "modulePath": "@@CONTEXT_FILE_TOKEN@@", - }, - "ResponseBuilderFactory" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - }, - "imports": Map { - "Pet" => { - "isDefault": false, - "isType": true, - "name": "Pet", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "Pet", - "SchemaTypeCoder@undefined@components/Category.ts:true:false" => "Category", - "SchemaTypeCoder@undefined@components/Tag.ts:true:false" => "Tag", - }, - "comments": [], - "exports": Map { - "Pet" => { - "beforeExport": "", - "code": "{"id"?: number,"name": string,"category"?: Category,"photoUrls": Array,"tags"?: Array,"status"?: "available" | "pending" | "sold"}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "Pet", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map { - "Category" => { - "isDefault": false, - "isType": true, - "name": "Category", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "Category", - }, - "comments": [], - "exports": Map { - "Category" => { - "beforeExport": "", - "code": "{"id"?: number,"name"?: string}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "Category", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map {}, - "path": "components/Category.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - "Tag" => { - "isDefault": false, - "isType": true, - "name": "Tag", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "Tag", - }, - "comments": [], - "exports": Map { - "Tag" => { - "beforeExport": "", - "code": "{"id"?: number,"name"?: string}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "Tag", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map {}, - "path": "components/Tag.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "components/Pet.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "path-types/pet/findByTags.types.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - "paths/pet/{petId}.ts" => Script { - "cache": Map { - "OperationCoder@./petstore.yaml#/paths/~1pet~1{petId}/get:false" => "GET", - "OperationTypeCoder@./petstore.yaml#/paths/~1pet~1{petId}/get@path-types/pet/{petId}.types.ts:true:false" => "HTTP_GET", - "OperationCoder@./petstore.yaml#/paths/~1pet~1{petId}/post:false" => "POST", - "OperationTypeCoder@./petstore.yaml#/paths/~1pet~1{petId}/post@path-types/pet/{petId}.types.ts:true:false" => "HTTP_POST", - "OperationCoder@./petstore.yaml#/paths/~1pet~1{petId}/delete:false" => "DELETE", - "OperationTypeCoder@./petstore.yaml#/paths/~1pet~1{petId}/delete@path-types/pet/{petId}.types.ts:true:false" => "HTTP_DELETE", - }, - "comments": [], - "exports": Map { - "GET" => { - "beforeExport": "", - "code": "($) => { - return $.response[200].random(); - }", - "done": true, - "id": "OperationCoder@./petstore.yaml#/paths/~1pet~1{petId}/get", - "isDefault": false, - "isType": false, - "name": "GET", - "promise": Promise {}, - "typeDeclaration": "HTTP_GET", - }, - "POST" => { - "beforeExport": "", - "code": "($) => { - return $.response[405]; - }", - "done": true, - "id": "OperationCoder@./petstore.yaml#/paths/~1pet~1{petId}/post", - "isDefault": false, - "isType": false, - "name": "POST", - "promise": Promise {}, - "typeDeclaration": "HTTP_POST", - }, - "DELETE" => { - "beforeExport": "", - "code": "($) => { - return $.response[400]; - }", - "done": true, - "id": "OperationCoder@./petstore.yaml#/paths/~1pet~1{petId}/delete", - "isDefault": false, - "isType": false, - "name": "DELETE", - "promise": Promise {}, - "typeDeclaration": "HTTP_DELETE", - }, - }, - "externalImport": Map {}, - "imports": Map { - "HTTP_GET" => { - "isDefault": false, - "isType": true, - "name": "HTTP_GET", - "script": Script { - "cache": Map { - "OperationTypeCoder@./petstore.yaml#/paths/~1pet~1{petId}/get:true" => "HTTP_GET", - "OperationTypeCoder@./petstore.yaml#/paths/~1pet~1{petId}/post:true" => "HTTP_POST", - "OperationTypeCoder@./petstore.yaml#/paths/~1pet~1{petId}/delete:true" => "HTTP_DELETE", - "SchemaTypeCoder@undefined@components/Pet.ts:true:false" => "Pet", - }, - "comments": [ - "This code was automatically generated from an OpenAPI description.", - "Do not edit this file. Edit the OpenAPI file instead.", - "For more information, see https://github.com/pmcelhaney/counterfact/blob/main/docs/faq-generated-code.md", - ], - "exports": Map { - "HTTP_GET" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: never, path: {"petId": number}, header: never, body: never, context: Context, response: ResponseBuilderFactory<{ -200: { - headers: never; - requiredHeaders: never; - content: { -"application/xml": { - schema: Pet - }, -"application/json": { - schema: Pet - } -}; - }, -400: { - headers: never; - requiredHeaders: never; - content: never; - }, -404: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: 200, - contentType?: "application/xml", - body?: Pet - } | { - status: 200, - contentType?: "application/json", - body?: Pet - } | { - status: 400 - } | { - status: 404 - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1pet~1{petId}/get", - "isDefault": false, - "isType": true, - "name": "HTTP_GET", - "promise": Promise {}, - "typeDeclaration": "", - }, - "HTTP_POST" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: {"name"?: number, "status"?: string}, path: {"petId": number}, header: never, body: never, context: Context, response: ResponseBuilderFactory<{ -405: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: 405 - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1pet~1{petId}/post", - "isDefault": false, - "isType": true, - "name": "HTTP_POST", - "promise": Promise {}, - "typeDeclaration": "", - }, - "HTTP_DELETE" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: never, path: {"petId": string}, header: {"api_key"?: string}, body: never, context: Context, response: ResponseBuilderFactory<{ -400: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: 400 - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1pet~1{petId}/delete", - "isDefault": false, - "isType": true, - "name": "HTTP_DELETE", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map { - "WideOperationArgument" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "OmitValueWhenNever" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "Context" => { - "isType": true, - "modulePath": "@@CONTEXT_FILE_TOKEN@@", - }, - "ResponseBuilderFactory" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - }, - "imports": Map { - "Pet" => { - "isDefault": false, - "isType": true, - "name": "Pet", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "Pet", - "SchemaTypeCoder@undefined@components/Category.ts:true:false" => "Category", - "SchemaTypeCoder@undefined@components/Tag.ts:true:false" => "Tag", - }, - "comments": [], - "exports": Map { - "Pet" => { - "beforeExport": "", - "code": "{"id"?: number,"name": string,"category"?: Category,"photoUrls": Array,"tags"?: Array,"status"?: "available" | "pending" | "sold"}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "Pet", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map { - "Category" => { - "isDefault": false, - "isType": true, - "name": "Category", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "Category", - }, - "comments": [], - "exports": Map { - "Category" => { - "beforeExport": "", - "code": "{"id"?: number,"name"?: string}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "Category", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map {}, - "path": "components/Category.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - "Tag" => { - "isDefault": false, - "isType": true, - "name": "Tag", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "Tag", - }, - "comments": [], - "exports": Map { - "Tag" => { - "beforeExport": "", - "code": "{"id"?: number,"name"?: string}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "Tag", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map {}, - "path": "components/Tag.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "components/Pet.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "path-types/pet/{petId}.types.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - "HTTP_POST" => { - "isDefault": false, - "isType": true, - "name": "HTTP_POST", - "script": Script { - "cache": Map { - "OperationTypeCoder@./petstore.yaml#/paths/~1pet~1{petId}/get:true" => "HTTP_GET", - "OperationTypeCoder@./petstore.yaml#/paths/~1pet~1{petId}/post:true" => "HTTP_POST", - "OperationTypeCoder@./petstore.yaml#/paths/~1pet~1{petId}/delete:true" => "HTTP_DELETE", - "SchemaTypeCoder@undefined@components/Pet.ts:true:false" => "Pet", - }, - "comments": [ - "This code was automatically generated from an OpenAPI description.", - "Do not edit this file. Edit the OpenAPI file instead.", - "For more information, see https://github.com/pmcelhaney/counterfact/blob/main/docs/faq-generated-code.md", - ], - "exports": Map { - "HTTP_GET" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: never, path: {"petId": number}, header: never, body: never, context: Context, response: ResponseBuilderFactory<{ -200: { - headers: never; - requiredHeaders: never; - content: { -"application/xml": { - schema: Pet - }, -"application/json": { - schema: Pet - } -}; - }, -400: { - headers: never; - requiredHeaders: never; - content: never; - }, -404: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: 200, - contentType?: "application/xml", - body?: Pet - } | { - status: 200, - contentType?: "application/json", - body?: Pet - } | { - status: 400 - } | { - status: 404 - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1pet~1{petId}/get", - "isDefault": false, - "isType": true, - "name": "HTTP_GET", - "promise": Promise {}, - "typeDeclaration": "", - }, - "HTTP_POST" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: {"name"?: number, "status"?: string}, path: {"petId": number}, header: never, body: never, context: Context, response: ResponseBuilderFactory<{ -405: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: 405 - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1pet~1{petId}/post", - "isDefault": false, - "isType": true, - "name": "HTTP_POST", - "promise": Promise {}, - "typeDeclaration": "", - }, - "HTTP_DELETE" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: never, path: {"petId": string}, header: {"api_key"?: string}, body: never, context: Context, response: ResponseBuilderFactory<{ -400: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: 400 - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1pet~1{petId}/delete", - "isDefault": false, - "isType": true, - "name": "HTTP_DELETE", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map { - "WideOperationArgument" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "OmitValueWhenNever" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "Context" => { - "isType": true, - "modulePath": "@@CONTEXT_FILE_TOKEN@@", - }, - "ResponseBuilderFactory" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - }, - "imports": Map { - "Pet" => { - "isDefault": false, - "isType": true, - "name": "Pet", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "Pet", - "SchemaTypeCoder@undefined@components/Category.ts:true:false" => "Category", - "SchemaTypeCoder@undefined@components/Tag.ts:true:false" => "Tag", - }, - "comments": [], - "exports": Map { - "Pet" => { - "beforeExport": "", - "code": "{"id"?: number,"name": string,"category"?: Category,"photoUrls": Array,"tags"?: Array,"status"?: "available" | "pending" | "sold"}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "Pet", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map { - "Category" => { - "isDefault": false, - "isType": true, - "name": "Category", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "Category", - }, - "comments": [], - "exports": Map { - "Category" => { - "beforeExport": "", - "code": "{"id"?: number,"name"?: string}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "Category", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map {}, - "path": "components/Category.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - "Tag" => { - "isDefault": false, - "isType": true, - "name": "Tag", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "Tag", - }, - "comments": [], - "exports": Map { - "Tag" => { - "beforeExport": "", - "code": "{"id"?: number,"name"?: string}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "Tag", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map {}, - "path": "components/Tag.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "components/Pet.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "path-types/pet/{petId}.types.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - "HTTP_DELETE" => { - "isDefault": false, - "isType": true, - "name": "HTTP_DELETE", - "script": Script { - "cache": Map { - "OperationTypeCoder@./petstore.yaml#/paths/~1pet~1{petId}/get:true" => "HTTP_GET", - "OperationTypeCoder@./petstore.yaml#/paths/~1pet~1{petId}/post:true" => "HTTP_POST", - "OperationTypeCoder@./petstore.yaml#/paths/~1pet~1{petId}/delete:true" => "HTTP_DELETE", - "SchemaTypeCoder@undefined@components/Pet.ts:true:false" => "Pet", - }, - "comments": [ - "This code was automatically generated from an OpenAPI description.", - "Do not edit this file. Edit the OpenAPI file instead.", - "For more information, see https://github.com/pmcelhaney/counterfact/blob/main/docs/faq-generated-code.md", - ], - "exports": Map { - "HTTP_GET" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: never, path: {"petId": number}, header: never, body: never, context: Context, response: ResponseBuilderFactory<{ -200: { - headers: never; - requiredHeaders: never; - content: { -"application/xml": { - schema: Pet - }, -"application/json": { - schema: Pet - } -}; - }, -400: { - headers: never; - requiredHeaders: never; - content: never; - }, -404: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: 200, - contentType?: "application/xml", - body?: Pet - } | { - status: 200, - contentType?: "application/json", - body?: Pet - } | { - status: 400 - } | { - status: 404 - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1pet~1{petId}/get", - "isDefault": false, - "isType": true, - "name": "HTTP_GET", - "promise": Promise {}, - "typeDeclaration": "", - }, - "HTTP_POST" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: {"name"?: number, "status"?: string}, path: {"petId": number}, header: never, body: never, context: Context, response: ResponseBuilderFactory<{ -405: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: 405 - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1pet~1{petId}/post", - "isDefault": false, - "isType": true, - "name": "HTTP_POST", - "promise": Promise {}, - "typeDeclaration": "", - }, - "HTTP_DELETE" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: never, path: {"petId": string}, header: {"api_key"?: string}, body: never, context: Context, response: ResponseBuilderFactory<{ -400: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: 400 - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1pet~1{petId}/delete", - "isDefault": false, - "isType": true, - "name": "HTTP_DELETE", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map { - "WideOperationArgument" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "OmitValueWhenNever" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "Context" => { - "isType": true, - "modulePath": "@@CONTEXT_FILE_TOKEN@@", - }, - "ResponseBuilderFactory" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - }, - "imports": Map { - "Pet" => { - "isDefault": false, - "isType": true, - "name": "Pet", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "Pet", - "SchemaTypeCoder@undefined@components/Category.ts:true:false" => "Category", - "SchemaTypeCoder@undefined@components/Tag.ts:true:false" => "Tag", - }, - "comments": [], - "exports": Map { - "Pet" => { - "beforeExport": "", - "code": "{"id"?: number,"name": string,"category"?: Category,"photoUrls": Array,"tags"?: Array,"status"?: "available" | "pending" | "sold"}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "Pet", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map { - "Category" => { - "isDefault": false, - "isType": true, - "name": "Category", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "Category", - }, - "comments": [], - "exports": Map { - "Category" => { - "beforeExport": "", - "code": "{"id"?: number,"name"?: string}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "Category", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map {}, - "path": "components/Category.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - "Tag" => { - "isDefault": false, - "isType": true, - "name": "Tag", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "Tag", - }, - "comments": [], - "exports": Map { - "Tag" => { - "beforeExport": "", - "code": "{"id"?: number,"name"?: string}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "Tag", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map {}, - "path": "components/Tag.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "components/Pet.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "path-types/pet/{petId}.types.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "paths/pet/{petId}.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - "path-types/pet/{petId}.types.ts" => Script { - "cache": Map { - "OperationTypeCoder@./petstore.yaml#/paths/~1pet~1{petId}/get:true" => "HTTP_GET", - "OperationTypeCoder@./petstore.yaml#/paths/~1pet~1{petId}/post:true" => "HTTP_POST", - "OperationTypeCoder@./petstore.yaml#/paths/~1pet~1{petId}/delete:true" => "HTTP_DELETE", - "SchemaTypeCoder@undefined@components/Pet.ts:true:false" => "Pet", - }, - "comments": [ - "This code was automatically generated from an OpenAPI description.", - "Do not edit this file. Edit the OpenAPI file instead.", - "For more information, see https://github.com/pmcelhaney/counterfact/blob/main/docs/faq-generated-code.md", - ], - "exports": Map { - "HTTP_GET" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: never, path: {"petId": number}, header: never, body: never, context: Context, response: ResponseBuilderFactory<{ -200: { - headers: never; - requiredHeaders: never; - content: { -"application/xml": { - schema: Pet - }, -"application/json": { - schema: Pet - } +"paths/pet.ts:import type { HTTP_POST } from "../path-types/pet.types.js"; +import type { HTTP_PUT } from "../path-types/pet.types.js"; + +export const POST: HTTP_POST = ($) => { + return $.response[200].random(); }; - }, -400: { - headers: never; - requiredHeaders: never; - content: never; - }, -404: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: 200, - contentType?: "application/xml", - body?: Pet - } | { - status: 200, - contentType?: "application/json", - body?: Pet - } | { - status: 400 - } | { - status: 404 - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1pet~1{petId}/get", - "isDefault": false, - "isType": true, - "name": "HTTP_GET", - "promise": Promise {}, - "typeDeclaration": "", - }, - "HTTP_POST" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: {"name"?: number, "status"?: string}, path: {"petId": number}, header: never, body: never, context: Context, response: ResponseBuilderFactory<{ -405: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: 405 - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1pet~1{petId}/post", - "isDefault": false, - "isType": true, - "name": "HTTP_POST", - "promise": Promise {}, - "typeDeclaration": "", - }, - "HTTP_DELETE" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: never, path: {"petId": string}, header: {"api_key"?: string}, body: never, context: Context, response: ResponseBuilderFactory<{ -400: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: 400 - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1pet~1{petId}/delete", - "isDefault": false, - "isType": true, - "name": "HTTP_DELETE", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map { - "WideOperationArgument" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "OmitValueWhenNever" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "Context" => { - "isType": true, - "modulePath": "@@CONTEXT_FILE_TOKEN@@", - }, - "ResponseBuilderFactory" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - }, - "imports": Map { - "Pet" => { - "isDefault": false, - "isType": true, - "name": "Pet", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "Pet", - "SchemaTypeCoder@undefined@components/Category.ts:true:false" => "Category", - "SchemaTypeCoder@undefined@components/Tag.ts:true:false" => "Tag", - }, - "comments": [], - "exports": Map { - "Pet" => { - "beforeExport": "", - "code": "{"id"?: number,"name": string,"category"?: Category,"photoUrls": Array,"tags"?: Array,"status"?: "available" | "pending" | "sold"}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "Pet", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map { - "Category" => { - "isDefault": false, - "isType": true, - "name": "Category", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "Category", - }, - "comments": [], - "exports": Map { - "Category" => { - "beforeExport": "", - "code": "{"id"?: number,"name"?: string}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "Category", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map {}, - "path": "components/Category.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - "Tag" => { - "isDefault": false, - "isType": true, - "name": "Tag", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "Tag", - }, - "comments": [], - "exports": Map { - "Tag" => { - "beforeExport": "", - "code": "{"id"?: number,"name"?: string}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "Tag", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map {}, - "path": "components/Tag.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "components/Pet.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "path-types/pet/{petId}.types.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - "paths/pet/{petId}/uploadImage.ts" => Script { - "cache": Map { - "OperationCoder@./petstore.yaml#/paths/~1pet~1{petId}~1uploadImage/post:false" => "POST", - "OperationTypeCoder@./petstore.yaml#/paths/~1pet~1{petId}~1uploadImage/post@path-types/pet/{petId}/uploadImage.types.ts:true:false" => "HTTP_POST", - }, - "comments": [], - "exports": Map { - "POST" => { - "beforeExport": "", - "code": "($) => { - return $.response[200].random(); - }", - "done": true, - "id": "OperationCoder@./petstore.yaml#/paths/~1pet~1{petId}~1uploadImage/post", - "isDefault": false, - "isType": false, - "name": "POST", - "promise": Promise {}, - "typeDeclaration": "HTTP_POST", - }, - }, - "externalImport": Map {}, - "imports": Map { - "HTTP_POST" => { - "isDefault": false, - "isType": true, - "name": "HTTP_POST", - "script": Script { - "cache": Map { - "OperationTypeCoder@./petstore.yaml#/paths/~1pet~1{petId}~1uploadImage/post:true" => "HTTP_POST", - "SchemaTypeCoder@undefined@components/ApiResponse.ts:true:false" => "ApiResponse", - }, - "comments": [ - "This code was automatically generated from an OpenAPI description.", - "Do not edit this file. Edit the OpenAPI file instead.", - "For more information, see https://github.com/pmcelhaney/counterfact/blob/main/docs/faq-generated-code.md", - ], - "exports": Map { - "HTTP_POST" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: {"additionalMetadata"?: number}, path: {"petId": number}, header: never, body: never, context: Context, response: ResponseBuilderFactory<{ -200: { - headers: never; - requiredHeaders: never; - content: { -"application/json": { - schema: ApiResponse - } + +export const PUT: HTTP_PUT = ($) => { + return $.response[200].random(); }; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: 200, - contentType?: "application/json", - body?: ApiResponse - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1pet~1{petId}~1uploadImage/post", - "isDefault": false, - "isType": true, - "name": "HTTP_POST", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map { - "WideOperationArgument" => { - "isType": true, - "modulePath": "../../../types.d.ts", - }, - "OmitValueWhenNever" => { - "isType": true, - "modulePath": "../../../types.d.ts", - }, - "Context" => { - "isType": true, - "modulePath": "@@CONTEXT_FILE_TOKEN@@", - }, - "ResponseBuilderFactory" => { - "isType": true, - "modulePath": "../../../types.d.ts", - }, - }, - "imports": Map { - "ApiResponse" => { - "isDefault": false, - "isType": true, - "name": "ApiResponse", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "ApiResponse", - }, - "comments": [], - "exports": Map { - "ApiResponse" => { - "beforeExport": "", - "code": "{"code"?: number,"type"?: string,"message"?: string}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "ApiResponse", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map {}, - "path": "components/ApiResponse.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "path-types/pet/{petId}/uploadImage.types.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "paths/pet/{petId}/uploadImage.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - "path-types/pet/{petId}/uploadImage.types.ts" => Script { - "cache": Map { - "OperationTypeCoder@./petstore.yaml#/paths/~1pet~1{petId}~1uploadImage/post:true" => "HTTP_POST", - "SchemaTypeCoder@undefined@components/ApiResponse.ts:true:false" => "ApiResponse", - }, - "comments": [ - "This code was automatically generated from an OpenAPI description.", - "Do not edit this file. Edit the OpenAPI file instead.", - "For more information, see https://github.com/pmcelhaney/counterfact/blob/main/docs/faq-generated-code.md", - ], - "exports": Map { - "HTTP_POST" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: {"additionalMetadata"?: number}, path: {"petId": number}, header: never, body: never, context: Context, response: ResponseBuilderFactory<{ -200: { - headers: never; - requiredHeaders: never; - content: { -"application/json": { - schema: ApiResponse - } +" +`; + +exports[`end-to-end test generates the same code for pet store that it did on the last test run 2`] = ` +"path-types/pet.types.ts:// This code was automatically generated from an OpenAPI description. +// Do not edit this file. Edit the OpenAPI file instead. +// For more information, see https://github.com/pmcelhaney/counterfact/blob/main/docs/faq-generated-code.md + +import type { WideOperationArgument } from "../types.d.ts"; +import type { OmitValueWhenNever } from "../types.d.ts"; +import type { Context } from "@@CONTEXT_FILE_TOKEN@@"; +import type { ResponseBuilderFactory } from "../types.d.ts"; +import type { Pet } from "../components/Pet.js"; + +export type HTTP_POST = ( + $: OmitValueWhenNever<{ + query: never; + path: never; + header: never; + body: Pet; + context: Context; + response: ResponseBuilderFactory<{ + 200: { + headers: never; + requiredHeaders: never; + content: { + "application/xml": { + schema: Pet; + }; + "application/json": { + schema: Pet; + }; + }; + }; + 405: { + headers: never; + requiredHeaders: never; + content: never; + }; + }>; + x: WideOperationArgument; + proxy: (url: string) => "COUNTERFACT_RESPONSE"; + user: never; + }>, +) => + | { + status: 200; + contentType?: "application/xml"; + body?: Pet; + } + | { + status: 200; + contentType?: "application/json"; + body?: Pet; + } + | { + status: 405; + } + | { status: 415; contentType: "text/plain"; body: string } + | "COUNTERFACT_RESPONSE" + | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }; + +export type HTTP_PUT = ( + $: OmitValueWhenNever<{ + query: never; + path: never; + header: never; + body: Pet; + context: Context; + response: ResponseBuilderFactory<{ + 200: { + headers: never; + requiredHeaders: never; + content: { + "application/xml": { + schema: Pet; + }; + "application/json": { + schema: Pet; + }; + }; + }; + 400: { + headers: never; + requiredHeaders: never; + content: never; + }; + 404: { + headers: never; + requiredHeaders: never; + content: never; + }; + 405: { + headers: never; + requiredHeaders: never; + content: never; + }; + }>; + x: WideOperationArgument; + proxy: (url: string) => "COUNTERFACT_RESPONSE"; + user: never; + }>, +) => + | { + status: 200; + contentType?: "application/xml"; + body?: Pet; + } + | { + status: 200; + contentType?: "application/json"; + body?: Pet; + } + | { + status: 400; + } + | { + status: 404; + } + | { + status: 405; + } + | { status: 415; contentType: "text/plain"; body: string } + | "COUNTERFACT_RESPONSE" + | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }; +" +`; + +exports[`end-to-end test generates the same code for pet store that it did on the last test run 3`] = ` +"paths/pet/findByStatus.ts:import type { HTTP_GET } from "../../path-types/pet/findByStatus.types.js"; + +export const GET: HTTP_GET = ($) => { + return $.response[200].random(); }; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: 200, - contentType?: "application/json", - body?: ApiResponse - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1pet~1{petId}~1uploadImage/post", - "isDefault": false, - "isType": true, - "name": "HTTP_POST", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map { - "WideOperationArgument" => { - "isType": true, - "modulePath": "../../../types.d.ts", - }, - "OmitValueWhenNever" => { - "isType": true, - "modulePath": "../../../types.d.ts", - }, - "Context" => { - "isType": true, - "modulePath": "@@CONTEXT_FILE_TOKEN@@", - }, - "ResponseBuilderFactory" => { - "isType": true, - "modulePath": "../../../types.d.ts", - }, - }, - "imports": Map { - "ApiResponse" => { - "isDefault": false, - "isType": true, - "name": "ApiResponse", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "ApiResponse", - }, - "comments": [], - "exports": Map { - "ApiResponse" => { - "beforeExport": "", - "code": "{"code"?: number,"type"?: string,"message"?: string}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "ApiResponse", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map {}, - "path": "components/ApiResponse.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "path-types/pet/{petId}/uploadImage.types.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - "paths/store/inventory.ts" => Script { - "cache": Map { - "OperationCoder@./petstore.yaml#/paths/~1store~1inventory/get:false" => "GET", - "OperationTypeCoder@./petstore.yaml#/paths/~1store~1inventory/get@path-types/store/inventory.types.ts:true:false" => "HTTP_GET", - }, - "comments": [], - "exports": Map { - "GET" => { - "beforeExport": "", - "code": "($) => { - return $.response[200].random(); - }", - "done": true, - "id": "OperationCoder@./petstore.yaml#/paths/~1store~1inventory/get", - "isDefault": false, - "isType": false, - "name": "GET", - "promise": Promise {}, - "typeDeclaration": "HTTP_GET", - }, - }, - "externalImport": Map {}, - "imports": Map { - "HTTP_GET" => { - "isDefault": false, - "isType": true, - "name": "HTTP_GET", - "script": Script { - "cache": Map { - "OperationTypeCoder@./petstore.yaml#/paths/~1store~1inventory/get:true" => "HTTP_GET", - }, - "comments": [ - "This code was automatically generated from an OpenAPI description.", - "Do not edit this file. Edit the OpenAPI file instead.", - "For more information, see https://github.com/pmcelhaney/counterfact/blob/main/docs/faq-generated-code.md", - ], - "exports": Map { - "HTTP_GET" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: never, path: never, header: never, body: never, context: Context, response: ResponseBuilderFactory<{ -200: { - headers: never; - requiredHeaders: never; - content: { -"application/json": { - schema: {[key: string]: number} - } +" +`; + +exports[`end-to-end test generates the same code for pet store that it did on the last test run 4`] = ` +"path-types/pet/findByStatus.types.ts:// This code was automatically generated from an OpenAPI description. +// Do not edit this file. Edit the OpenAPI file instead. +// For more information, see https://github.com/pmcelhaney/counterfact/blob/main/docs/faq-generated-code.md + +import type { WideOperationArgument } from "../../types.d.ts"; +import type { OmitValueWhenNever } from "../../types.d.ts"; +import type { Context } from "@@CONTEXT_FILE_TOKEN@@"; +import type { ResponseBuilderFactory } from "../../types.d.ts"; +import type { Pet } from "../../components/Pet.js"; + +export type HTTP_GET = ( + $: OmitValueWhenNever<{ + query: { status?: "available" | "pending" | "sold" }; + path: never; + header: never; + body: never; + context: Context; + response: ResponseBuilderFactory<{ + 200: { + headers: never; + requiredHeaders: never; + content: { + "application/xml": { + schema: Array; + }; + "application/json": { + schema: Array; + }; + }; + }; + 400: { + headers: never; + requiredHeaders: never; + content: never; + }; + }>; + x: WideOperationArgument; + proxy: (url: string) => "COUNTERFACT_RESPONSE"; + user: never; + }>, +) => + | { + status: 200; + contentType?: "application/xml"; + body?: Array; + } + | { + status: 200; + contentType?: "application/json"; + body?: Array; + } + | { + status: 400; + } + | { status: 415; contentType: "text/plain"; body: string } + | "COUNTERFACT_RESPONSE" + | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }; +" +`; + +exports[`end-to-end test generates the same code for pet store that it did on the last test run 5`] = ` +"paths/pet/findByTags.ts:import type { HTTP_GET } from "../../path-types/pet/findByTags.types.js"; + +export const GET: HTTP_GET = ($) => { + return $.response[200].random(); }; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: 200, - contentType?: "application/json", - body?: {[key: string]: number} - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1store~1inventory/get", - "isDefault": false, - "isType": true, - "name": "HTTP_GET", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map { - "WideOperationArgument" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "OmitValueWhenNever" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "Context" => { - "isType": true, - "modulePath": "@@CONTEXT_FILE_TOKEN@@", - }, - "ResponseBuilderFactory" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - }, - "imports": Map {}, - "path": "path-types/store/inventory.types.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "paths/store/inventory.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - "path-types/store/inventory.types.ts" => Script { - "cache": Map { - "OperationTypeCoder@./petstore.yaml#/paths/~1store~1inventory/get:true" => "HTTP_GET", - }, - "comments": [ - "This code was automatically generated from an OpenAPI description.", - "Do not edit this file. Edit the OpenAPI file instead.", - "For more information, see https://github.com/pmcelhaney/counterfact/blob/main/docs/faq-generated-code.md", - ], - "exports": Map { - "HTTP_GET" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: never, path: never, header: never, body: never, context: Context, response: ResponseBuilderFactory<{ -200: { - headers: never; - requiredHeaders: never; - content: { -"application/json": { - schema: {[key: string]: number} - } +" +`; + +exports[`end-to-end test generates the same code for pet store that it did on the last test run 6`] = ` +"path-types/pet/findByTags.types.ts:// This code was automatically generated from an OpenAPI description. +// Do not edit this file. Edit the OpenAPI file instead. +// For more information, see https://github.com/pmcelhaney/counterfact/blob/main/docs/faq-generated-code.md + +import type { WideOperationArgument } from "../../types.d.ts"; +import type { OmitValueWhenNever } from "../../types.d.ts"; +import type { Context } from "@@CONTEXT_FILE_TOKEN@@"; +import type { ResponseBuilderFactory } from "../../types.d.ts"; +import type { Pet } from "../../components/Pet.js"; + +export type HTTP_GET = ( + $: OmitValueWhenNever<{ + query: { tags?: Array }; + path: never; + header: never; + body: never; + context: Context; + response: ResponseBuilderFactory<{ + 200: { + headers: never; + requiredHeaders: never; + content: { + "application/xml": { + schema: Array; + }; + "application/json": { + schema: Array; + }; + }; + }; + 400: { + headers: never; + requiredHeaders: never; + content: never; + }; + }>; + x: WideOperationArgument; + proxy: (url: string) => "COUNTERFACT_RESPONSE"; + user: never; + }>, +) => + | { + status: 200; + contentType?: "application/xml"; + body?: Array; + } + | { + status: 200; + contentType?: "application/json"; + body?: Array; + } + | { + status: 400; + } + | { status: 415; contentType: "text/plain"; body: string } + | "COUNTERFACT_RESPONSE" + | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }; +" +`; + +exports[`end-to-end test generates the same code for pet store that it did on the last test run 7`] = ` +"paths/pet/{petId}.ts:import type { HTTP_GET } from "../../path-types/pet/{petId}.types.js"; +import type { HTTP_POST } from "../../path-types/pet/{petId}.types.js"; +import type { HTTP_DELETE } from "../../path-types/pet/{petId}.types.js"; + +export const GET: HTTP_GET = ($) => { + return $.response[200].random(); }; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: 200, - contentType?: "application/json", - body?: {[key: string]: number} - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1store~1inventory/get", - "isDefault": false, - "isType": true, - "name": "HTTP_GET", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map { - "WideOperationArgument" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "OmitValueWhenNever" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "Context" => { - "isType": true, - "modulePath": "@@CONTEXT_FILE_TOKEN@@", - }, - "ResponseBuilderFactory" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - }, - "imports": Map {}, - "path": "path-types/store/inventory.types.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - "paths/store/order.ts" => Script { - "cache": Map { - "OperationCoder@./petstore.yaml#/paths/~1store~1order/post:false" => "POST", - "OperationTypeCoder@./petstore.yaml#/paths/~1store~1order/post@path-types/store/order.types.ts:true:false" => "HTTP_POST", - }, - "comments": [], - "exports": Map { - "POST" => { - "beforeExport": "", - "code": "($) => { - return $.response[200].random(); - }", - "done": true, - "id": "OperationCoder@./petstore.yaml#/paths/~1store~1order/post", - "isDefault": false, - "isType": false, - "name": "POST", - "promise": Promise {}, - "typeDeclaration": "HTTP_POST", - }, - }, - "externalImport": Map {}, - "imports": Map { - "HTTP_POST" => { - "isDefault": false, - "isType": true, - "name": "HTTP_POST", - "script": Script { - "cache": Map { - "OperationTypeCoder@./petstore.yaml#/paths/~1store~1order/post:true" => "HTTP_POST", - "SchemaTypeCoder@undefined@components/Order.ts:true:false" => "Order", - }, - "comments": [ - "This code was automatically generated from an OpenAPI description.", - "Do not edit this file. Edit the OpenAPI file instead.", - "For more information, see https://github.com/pmcelhaney/counterfact/blob/main/docs/faq-generated-code.md", - ], - "exports": Map { - "HTTP_POST" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: never, path: never, header: never, body: Order, context: Context, response: ResponseBuilderFactory<{ -200: { - headers: never; - requiredHeaders: never; - content: { -"application/json": { - schema: Order - } + +export const POST: HTTP_POST = ($) => { + return $.response[405]; }; - }, -405: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: 200, - contentType?: "application/json", - body?: Order - } | { - status: 405 - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1store~1order/post", - "isDefault": false, - "isType": true, - "name": "HTTP_POST", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map { - "WideOperationArgument" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "OmitValueWhenNever" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "Context" => { - "isType": true, - "modulePath": "@@CONTEXT_FILE_TOKEN@@", - }, - "ResponseBuilderFactory" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - }, - "imports": Map { - "Order" => { - "isDefault": false, - "isType": true, - "name": "Order", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "Order", - }, - "comments": [], - "exports": Map { - "Order" => { - "beforeExport": "", - "code": "{"id"?: number,"petId"?: number,"quantity"?: number,"shipDate"?: string,"status"?: "placed" | "approved" | "delivered","complete"?: boolean}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "Order", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map {}, - "path": "components/Order.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "path-types/store/order.types.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "paths/store/order.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - "path-types/store/order.types.ts" => Script { - "cache": Map { - "OperationTypeCoder@./petstore.yaml#/paths/~1store~1order/post:true" => "HTTP_POST", - "SchemaTypeCoder@undefined@components/Order.ts:true:false" => "Order", - }, - "comments": [ - "This code was automatically generated from an OpenAPI description.", - "Do not edit this file. Edit the OpenAPI file instead.", - "For more information, see https://github.com/pmcelhaney/counterfact/blob/main/docs/faq-generated-code.md", - ], - "exports": Map { - "HTTP_POST" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: never, path: never, header: never, body: Order, context: Context, response: ResponseBuilderFactory<{ -200: { - headers: never; - requiredHeaders: never; - content: { -"application/json": { - schema: Order - } + +export const DELETE: HTTP_DELETE = ($) => { + return $.response[400]; }; - }, -405: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: 200, - contentType?: "application/json", - body?: Order - } | { - status: 405 - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1store~1order/post", - "isDefault": false, - "isType": true, - "name": "HTTP_POST", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map { - "WideOperationArgument" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "OmitValueWhenNever" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "Context" => { - "isType": true, - "modulePath": "@@CONTEXT_FILE_TOKEN@@", - }, - "ResponseBuilderFactory" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - }, - "imports": Map { - "Order" => { - "isDefault": false, - "isType": true, - "name": "Order", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "Order", - }, - "comments": [], - "exports": Map { - "Order" => { - "beforeExport": "", - "code": "{"id"?: number,"petId"?: number,"quantity"?: number,"shipDate"?: string,"status"?: "placed" | "approved" | "delivered","complete"?: boolean}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "Order", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map {}, - "path": "components/Order.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "path-types/store/order.types.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - "paths/store/order/{orderId}.ts" => Script { - "cache": Map { - "OperationCoder@./petstore.yaml#/paths/~1store~1order~1{orderId}/get:false" => "GET", - "OperationTypeCoder@./petstore.yaml#/paths/~1store~1order~1{orderId}/get@path-types/store/order/{orderId}.types.ts:true:false" => "HTTP_GET", - "OperationCoder@./petstore.yaml#/paths/~1store~1order~1{orderId}/delete:false" => "DELETE", - "OperationTypeCoder@./petstore.yaml#/paths/~1store~1order~1{orderId}/delete@path-types/store/order/{orderId}.types.ts:true:false" => "HTTP_DELETE", - }, - "comments": [], - "exports": Map { - "GET" => { - "beforeExport": "", - "code": "($) => { - return $.response[200].random(); - }", - "done": true, - "id": "OperationCoder@./petstore.yaml#/paths/~1store~1order~1{orderId}/get", - "isDefault": false, - "isType": false, - "name": "GET", - "promise": Promise {}, - "typeDeclaration": "HTTP_GET", - }, - "DELETE" => { - "beforeExport": "", - "code": "($) => { - return $.response[400]; - }", - "done": true, - "id": "OperationCoder@./petstore.yaml#/paths/~1store~1order~1{orderId}/delete", - "isDefault": false, - "isType": false, - "name": "DELETE", - "promise": Promise {}, - "typeDeclaration": "HTTP_DELETE", - }, - }, - "externalImport": Map {}, - "imports": Map { - "HTTP_GET" => { - "isDefault": false, - "isType": true, - "name": "HTTP_GET", - "script": Script { - "cache": Map { - "OperationTypeCoder@./petstore.yaml#/paths/~1store~1order~1{orderId}/get:true" => "HTTP_GET", - "OperationTypeCoder@./petstore.yaml#/paths/~1store~1order~1{orderId}/delete:true" => "HTTP_DELETE", - "SchemaTypeCoder@undefined@components/Order.ts:true:false" => "Order", - }, - "comments": [ - "This code was automatically generated from an OpenAPI description.", - "Do not edit this file. Edit the OpenAPI file instead.", - "For more information, see https://github.com/pmcelhaney/counterfact/blob/main/docs/faq-generated-code.md", - ], - "exports": Map { - "HTTP_GET" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: never, path: {"orderId": number}, header: never, body: never, context: Context, response: ResponseBuilderFactory<{ -200: { - headers: never; - requiredHeaders: never; - content: { -"application/xml": { - schema: Order - }, -"application/json": { - schema: Order - } +" +`; + +exports[`end-to-end test generates the same code for pet store that it did on the last test run 8`] = ` +"path-types/pet/{petId}.types.ts:// This code was automatically generated from an OpenAPI description. +// Do not edit this file. Edit the OpenAPI file instead. +// For more information, see https://github.com/pmcelhaney/counterfact/blob/main/docs/faq-generated-code.md + +import type { WideOperationArgument } from "../../types.d.ts"; +import type { OmitValueWhenNever } from "../../types.d.ts"; +import type { Context } from "@@CONTEXT_FILE_TOKEN@@"; +import type { ResponseBuilderFactory } from "../../types.d.ts"; +import type { Pet } from "../../components/Pet.js"; + +export type HTTP_GET = ( + $: OmitValueWhenNever<{ + query: never; + path: { petId: number }; + header: never; + body: never; + context: Context; + response: ResponseBuilderFactory<{ + 200: { + headers: never; + requiredHeaders: never; + content: { + "application/xml": { + schema: Pet; + }; + "application/json": { + schema: Pet; + }; + }; + }; + 400: { + headers: never; + requiredHeaders: never; + content: never; + }; + 404: { + headers: never; + requiredHeaders: never; + content: never; + }; + }>; + x: WideOperationArgument; + proxy: (url: string) => "COUNTERFACT_RESPONSE"; + user: never; + }>, +) => + | { + status: 200; + contentType?: "application/xml"; + body?: Pet; + } + | { + status: 200; + contentType?: "application/json"; + body?: Pet; + } + | { + status: 400; + } + | { + status: 404; + } + | { status: 415; contentType: "text/plain"; body: string } + | "COUNTERFACT_RESPONSE" + | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }; + +export type HTTP_POST = ( + $: OmitValueWhenNever<{ + query: { name?: number; status?: string }; + path: { petId: number }; + header: never; + body: never; + context: Context; + response: ResponseBuilderFactory<{ + 405: { + headers: never; + requiredHeaders: never; + content: never; + }; + }>; + x: WideOperationArgument; + proxy: (url: string) => "COUNTERFACT_RESPONSE"; + user: never; + }>, +) => + | { + status: 405; + } + | { status: 415; contentType: "text/plain"; body: string } + | "COUNTERFACT_RESPONSE" + | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }; + +export type HTTP_DELETE = ( + $: OmitValueWhenNever<{ + query: never; + path: { petId: string }; + header: { api_key?: string }; + body: never; + context: Context; + response: ResponseBuilderFactory<{ + 400: { + headers: never; + requiredHeaders: never; + content: never; + }; + }>; + x: WideOperationArgument; + proxy: (url: string) => "COUNTERFACT_RESPONSE"; + user: never; + }>, +) => + | { + status: 400; + } + | { status: 415; contentType: "text/plain"; body: string } + | "COUNTERFACT_RESPONSE" + | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }; +" +`; + +exports[`end-to-end test generates the same code for pet store that it did on the last test run 9`] = ` +"paths/pet/{petId}/uploadImage.ts:import type { HTTP_POST } from "../../../path-types/pet/{petId}/uploadImage.types.js"; + +export const POST: HTTP_POST = ($) => { + return $.response[200].random(); }; - }, -400: { - headers: never; - requiredHeaders: never; - content: never; - }, -404: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: 200, - contentType?: "application/xml", - body?: Order - } | { - status: 200, - contentType?: "application/json", - body?: Order - } | { - status: 400 - } | { - status: 404 - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1store~1order~1{orderId}/get", - "isDefault": false, - "isType": true, - "name": "HTTP_GET", - "promise": Promise {}, - "typeDeclaration": "", - }, - "HTTP_DELETE" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: never, path: {"orderId": number}, header: never, body: never, context: Context, response: ResponseBuilderFactory<{ -400: { - headers: never; - requiredHeaders: never; - content: never; - }, -404: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: 400 - } | { - status: 404 - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1store~1order~1{orderId}/delete", - "isDefault": false, - "isType": true, - "name": "HTTP_DELETE", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map { - "WideOperationArgument" => { - "isType": true, - "modulePath": "../../../types.d.ts", - }, - "OmitValueWhenNever" => { - "isType": true, - "modulePath": "../../../types.d.ts", - }, - "Context" => { - "isType": true, - "modulePath": "@@CONTEXT_FILE_TOKEN@@", - }, - "ResponseBuilderFactory" => { - "isType": true, - "modulePath": "../../../types.d.ts", - }, - }, - "imports": Map { - "Order" => { - "isDefault": false, - "isType": true, - "name": "Order", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "Order", - }, - "comments": [], - "exports": Map { - "Order" => { - "beforeExport": "", - "code": "{"id"?: number,"petId"?: number,"quantity"?: number,"shipDate"?: string,"status"?: "placed" | "approved" | "delivered","complete"?: boolean}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "Order", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map {}, - "path": "components/Order.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "path-types/store/order/{orderId}.types.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - "HTTP_DELETE" => { - "isDefault": false, - "isType": true, - "name": "HTTP_DELETE", - "script": Script { - "cache": Map { - "OperationTypeCoder@./petstore.yaml#/paths/~1store~1order~1{orderId}/get:true" => "HTTP_GET", - "OperationTypeCoder@./petstore.yaml#/paths/~1store~1order~1{orderId}/delete:true" => "HTTP_DELETE", - "SchemaTypeCoder@undefined@components/Order.ts:true:false" => "Order", - }, - "comments": [ - "This code was automatically generated from an OpenAPI description.", - "Do not edit this file. Edit the OpenAPI file instead.", - "For more information, see https://github.com/pmcelhaney/counterfact/blob/main/docs/faq-generated-code.md", - ], - "exports": Map { - "HTTP_GET" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: never, path: {"orderId": number}, header: never, body: never, context: Context, response: ResponseBuilderFactory<{ -200: { - headers: never; - requiredHeaders: never; - content: { -"application/xml": { - schema: Order - }, -"application/json": { - schema: Order - } +" +`; + +exports[`end-to-end test generates the same code for pet store that it did on the last test run 10`] = ` +"path-types/pet/{petId}/uploadImage.types.ts:// This code was automatically generated from an OpenAPI description. +// Do not edit this file. Edit the OpenAPI file instead. +// For more information, see https://github.com/pmcelhaney/counterfact/blob/main/docs/faq-generated-code.md + +import type { WideOperationArgument } from "../../../types.d.ts"; +import type { OmitValueWhenNever } from "../../../types.d.ts"; +import type { Context } from "@@CONTEXT_FILE_TOKEN@@"; +import type { ResponseBuilderFactory } from "../../../types.d.ts"; +import type { ApiResponse } from "../../../components/ApiResponse.js"; + +export type HTTP_POST = ( + $: OmitValueWhenNever<{ + query: { additionalMetadata?: number }; + path: { petId: number }; + header: never; + body: never; + context: Context; + response: ResponseBuilderFactory<{ + 200: { + headers: never; + requiredHeaders: never; + content: { + "application/json": { + schema: ApiResponse; + }; + }; + }; + }>; + x: WideOperationArgument; + proxy: (url: string) => "COUNTERFACT_RESPONSE"; + user: never; + }>, +) => + | { + status: 200; + contentType?: "application/json"; + body?: ApiResponse; + } + | { status: 415; contentType: "text/plain"; body: string } + | "COUNTERFACT_RESPONSE" + | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }; +" +`; + +exports[`end-to-end test generates the same code for pet store that it did on the last test run 11`] = ` +"paths/store/inventory.ts:import type { HTTP_GET } from "../../path-types/store/inventory.types.js"; + +export const GET: HTTP_GET = ($) => { + return $.response[200].random(); }; - }, -400: { - headers: never; - requiredHeaders: never; - content: never; - }, -404: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: 200, - contentType?: "application/xml", - body?: Order - } | { - status: 200, - contentType?: "application/json", - body?: Order - } | { - status: 400 - } | { - status: 404 - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1store~1order~1{orderId}/get", - "isDefault": false, - "isType": true, - "name": "HTTP_GET", - "promise": Promise {}, - "typeDeclaration": "", - }, - "HTTP_DELETE" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: never, path: {"orderId": number}, header: never, body: never, context: Context, response: ResponseBuilderFactory<{ -400: { - headers: never; - requiredHeaders: never; - content: never; - }, -404: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: 400 - } | { - status: 404 - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1store~1order~1{orderId}/delete", - "isDefault": false, - "isType": true, - "name": "HTTP_DELETE", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map { - "WideOperationArgument" => { - "isType": true, - "modulePath": "../../../types.d.ts", - }, - "OmitValueWhenNever" => { - "isType": true, - "modulePath": "../../../types.d.ts", - }, - "Context" => { - "isType": true, - "modulePath": "@@CONTEXT_FILE_TOKEN@@", - }, - "ResponseBuilderFactory" => { - "isType": true, - "modulePath": "../../../types.d.ts", - }, - }, - "imports": Map { - "Order" => { - "isDefault": false, - "isType": true, - "name": "Order", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "Order", - }, - "comments": [], - "exports": Map { - "Order" => { - "beforeExport": "", - "code": "{"id"?: number,"petId"?: number,"quantity"?: number,"shipDate"?: string,"status"?: "placed" | "approved" | "delivered","complete"?: boolean}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "Order", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map {}, - "path": "components/Order.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "path-types/store/order/{orderId}.types.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "paths/store/order/{orderId}.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - "path-types/store/order/{orderId}.types.ts" => Script { - "cache": Map { - "OperationTypeCoder@./petstore.yaml#/paths/~1store~1order~1{orderId}/get:true" => "HTTP_GET", - "OperationTypeCoder@./petstore.yaml#/paths/~1store~1order~1{orderId}/delete:true" => "HTTP_DELETE", - "SchemaTypeCoder@undefined@components/Order.ts:true:false" => "Order", - }, - "comments": [ - "This code was automatically generated from an OpenAPI description.", - "Do not edit this file. Edit the OpenAPI file instead.", - "For more information, see https://github.com/pmcelhaney/counterfact/blob/main/docs/faq-generated-code.md", - ], - "exports": Map { - "HTTP_GET" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: never, path: {"orderId": number}, header: never, body: never, context: Context, response: ResponseBuilderFactory<{ -200: { - headers: never; - requiredHeaders: never; - content: { -"application/xml": { - schema: Order - }, -"application/json": { - schema: Order - } +" +`; + +exports[`end-to-end test generates the same code for pet store that it did on the last test run 12`] = ` +"path-types/store/inventory.types.ts:// This code was automatically generated from an OpenAPI description. +// Do not edit this file. Edit the OpenAPI file instead. +// For more information, see https://github.com/pmcelhaney/counterfact/blob/main/docs/faq-generated-code.md + +import type { WideOperationArgument } from "../../types.d.ts"; +import type { OmitValueWhenNever } from "../../types.d.ts"; +import type { Context } from "@@CONTEXT_FILE_TOKEN@@"; +import type { ResponseBuilderFactory } from "../../types.d.ts"; + +export type HTTP_GET = ( + $: OmitValueWhenNever<{ + query: never; + path: never; + header: never; + body: never; + context: Context; + response: ResponseBuilderFactory<{ + 200: { + headers: never; + requiredHeaders: never; + content: { + "application/json": { + schema: { [key: string]: number }; + }; + }; + }; + }>; + x: WideOperationArgument; + proxy: (url: string) => "COUNTERFACT_RESPONSE"; + user: never; + }>, +) => + | { + status: 200; + contentType?: "application/json"; + body?: { [key: string]: number }; + } + | { status: 415; contentType: "text/plain"; body: string } + | "COUNTERFACT_RESPONSE" + | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }; +" +`; + +exports[`end-to-end test generates the same code for pet store that it did on the last test run 13`] = ` +"paths/store/order.ts:import type { HTTP_POST } from "../../path-types/store/order.types.js"; + +export const POST: HTTP_POST = ($) => { + return $.response[200].random(); }; - }, -400: { - headers: never; - requiredHeaders: never; - content: never; - }, -404: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: 200, - contentType?: "application/xml", - body?: Order - } | { - status: 200, - contentType?: "application/json", - body?: Order - } | { - status: 400 - } | { - status: 404 - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1store~1order~1{orderId}/get", - "isDefault": false, - "isType": true, - "name": "HTTP_GET", - "promise": Promise {}, - "typeDeclaration": "", - }, - "HTTP_DELETE" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: never, path: {"orderId": number}, header: never, body: never, context: Context, response: ResponseBuilderFactory<{ -400: { - headers: never; - requiredHeaders: never; - content: never; - }, -404: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: 400 - } | { - status: 404 - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1store~1order~1{orderId}/delete", - "isDefault": false, - "isType": true, - "name": "HTTP_DELETE", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map { - "WideOperationArgument" => { - "isType": true, - "modulePath": "../../../types.d.ts", - }, - "OmitValueWhenNever" => { - "isType": true, - "modulePath": "../../../types.d.ts", - }, - "Context" => { - "isType": true, - "modulePath": "@@CONTEXT_FILE_TOKEN@@", - }, - "ResponseBuilderFactory" => { - "isType": true, - "modulePath": "../../../types.d.ts", - }, - }, - "imports": Map { - "Order" => { - "isDefault": false, - "isType": true, - "name": "Order", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "Order", - }, - "comments": [], - "exports": Map { - "Order" => { - "beforeExport": "", - "code": "{"id"?: number,"petId"?: number,"quantity"?: number,"shipDate"?: string,"status"?: "placed" | "approved" | "delivered","complete"?: boolean}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "Order", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map {}, - "path": "components/Order.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "path-types/store/order/{orderId}.types.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - "paths/user.ts" => Script { - "cache": Map { - "OperationCoder@./petstore.yaml#/paths/~1user/post:false" => "POST", - "OperationTypeCoder@./petstore.yaml#/paths/~1user/post@path-types/user.types.ts:true:false" => "HTTP_POST", - }, - "comments": [], - "exports": Map { - "POST" => { - "beforeExport": "", - "code": "($) => { - return $.response[200].random(); - }", - "done": true, - "id": "OperationCoder@./petstore.yaml#/paths/~1user/post", - "isDefault": false, - "isType": false, - "name": "POST", - "promise": Promise {}, - "typeDeclaration": "HTTP_POST", - }, - }, - "externalImport": Map {}, - "imports": Map { - "HTTP_POST" => { - "isDefault": false, - "isType": true, - "name": "HTTP_POST", - "script": Script { - "cache": Map { - "OperationTypeCoder@./petstore.yaml#/paths/~1user/post:true" => "HTTP_POST", - "SchemaTypeCoder@undefined@components/User.ts:true:false" => "User", - }, - "comments": [ - "This code was automatically generated from an OpenAPI description.", - "Do not edit this file. Edit the OpenAPI file instead.", - "For more information, see https://github.com/pmcelhaney/counterfact/blob/main/docs/faq-generated-code.md", - ], - "exports": Map { - "HTTP_POST" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: never, path: never, header: never, body: User, context: Context, response: ResponseBuilderFactory<{ -[statusCode in HttpStatusCode]: { - headers: never; - requiredHeaders: never; - content: { -"application/json": { - schema: User - }, -"application/xml": { - schema: User - } +" +`; + +exports[`end-to-end test generates the same code for pet store that it did on the last test run 14`] = ` +"path-types/store/order.types.ts:// This code was automatically generated from an OpenAPI description. +// Do not edit this file. Edit the OpenAPI file instead. +// For more information, see https://github.com/pmcelhaney/counterfact/blob/main/docs/faq-generated-code.md + +import type { WideOperationArgument } from "../../types.d.ts"; +import type { OmitValueWhenNever } from "../../types.d.ts"; +import type { Context } from "@@CONTEXT_FILE_TOKEN@@"; +import type { ResponseBuilderFactory } from "../../types.d.ts"; +import type { Order } from "../../components/Order.js"; + +export type HTTP_POST = ( + $: OmitValueWhenNever<{ + query: never; + path: never; + header: never; + body: Order; + context: Context; + response: ResponseBuilderFactory<{ + 200: { + headers: never; + requiredHeaders: never; + content: { + "application/json": { + schema: Order; + }; + }; + }; + 405: { + headers: never; + requiredHeaders: never; + content: never; + }; + }>; + x: WideOperationArgument; + proxy: (url: string) => "COUNTERFACT_RESPONSE"; + user: never; + }>, +) => + | { + status: 200; + contentType?: "application/json"; + body?: Order; + } + | { + status: 405; + } + | { status: 415; contentType: "text/plain"; body: string } + | "COUNTERFACT_RESPONSE" + | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }; +" +`; + +exports[`end-to-end test generates the same code for pet store that it did on the last test run 15`] = ` +"paths/store/order/{orderId}.ts:import type { HTTP_GET } from "../../../path-types/store/order/{orderId}.types.js"; +import type { HTTP_DELETE } from "../../../path-types/store/order/{orderId}.types.js"; + +export const GET: HTTP_GET = ($) => { + return $.response[200].random(); }; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: number | undefined, - contentType?: "application/json", - body?: User - } | { - status: number | undefined, - contentType?: "application/xml", - body?: User - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1user/post", - "isDefault": false, - "isType": true, - "name": "HTTP_POST", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map { - "WideOperationArgument" => { - "isType": true, - "modulePath": "../types.d.ts", - }, - "OmitValueWhenNever" => { - "isType": true, - "modulePath": "../types.d.ts", - }, - "Context" => { - "isType": true, - "modulePath": "@@CONTEXT_FILE_TOKEN@@", - }, - "ResponseBuilderFactory" => { - "isType": true, - "modulePath": "../types.d.ts", - }, - "HttpStatusCode" => { - "isType": true, - "modulePath": "../types.d.ts", - }, - }, - "imports": Map { - "User" => { - "isDefault": false, - "isType": true, - "name": "User", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "User", - }, - "comments": [], - "exports": Map { - "User" => { - "beforeExport": "", - "code": "{"id"?: number,"username"?: string,"firstName"?: string,"lastName"?: string,"email"?: string,"password"?: string,"phone"?: string,"userStatus"?: number}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "User", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map {}, - "path": "components/User.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "path-types/user.types.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "paths/user.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - "path-types/user.types.ts" => Script { - "cache": Map { - "OperationTypeCoder@./petstore.yaml#/paths/~1user/post:true" => "HTTP_POST", - "SchemaTypeCoder@undefined@components/User.ts:true:false" => "User", - }, - "comments": [ - "This code was automatically generated from an OpenAPI description.", - "Do not edit this file. Edit the OpenAPI file instead.", - "For more information, see https://github.com/pmcelhaney/counterfact/blob/main/docs/faq-generated-code.md", - ], - "exports": Map { - "HTTP_POST" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: never, path: never, header: never, body: User, context: Context, response: ResponseBuilderFactory<{ -[statusCode in HttpStatusCode]: { - headers: never; - requiredHeaders: never; - content: { -"application/json": { - schema: User - }, -"application/xml": { - schema: User - } + +export const DELETE: HTTP_DELETE = ($) => { + return $.response[400]; }; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: number | undefined, - contentType?: "application/json", - body?: User - } | { - status: number | undefined, - contentType?: "application/xml", - body?: User - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1user/post", - "isDefault": false, - "isType": true, - "name": "HTTP_POST", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map { - "WideOperationArgument" => { - "isType": true, - "modulePath": "../types.d.ts", - }, - "OmitValueWhenNever" => { - "isType": true, - "modulePath": "../types.d.ts", - }, - "Context" => { - "isType": true, - "modulePath": "@@CONTEXT_FILE_TOKEN@@", - }, - "ResponseBuilderFactory" => { - "isType": true, - "modulePath": "../types.d.ts", - }, - "HttpStatusCode" => { - "isType": true, - "modulePath": "../types.d.ts", - }, - }, - "imports": Map { - "User" => { - "isDefault": false, - "isType": true, - "name": "User", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "User", - }, - "comments": [], - "exports": Map { - "User" => { - "beforeExport": "", - "code": "{"id"?: number,"username"?: string,"firstName"?: string,"lastName"?: string,"email"?: string,"password"?: string,"phone"?: string,"userStatus"?: number}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "User", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map {}, - "path": "components/User.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "path-types/user.types.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - "paths/user/createWithList.ts" => Script { - "cache": Map { - "OperationCoder@./petstore.yaml#/paths/~1user~1createWithList/post:false" => "POST", - "OperationTypeCoder@./petstore.yaml#/paths/~1user~1createWithList/post@path-types/user/createWithList.types.ts:true:false" => "HTTP_POST", - }, - "comments": [], - "exports": Map { - "POST" => { - "beforeExport": "", - "code": "($) => { - return $.response[200].random(); - }", - "done": true, - "id": "OperationCoder@./petstore.yaml#/paths/~1user~1createWithList/post", - "isDefault": false, - "isType": false, - "name": "POST", - "promise": Promise {}, - "typeDeclaration": "HTTP_POST", - }, - }, - "externalImport": Map {}, - "imports": Map { - "HTTP_POST" => { - "isDefault": false, - "isType": true, - "name": "HTTP_POST", - "script": Script { - "cache": Map { - "OperationTypeCoder@./petstore.yaml#/paths/~1user~1createWithList/post:true" => "HTTP_POST", - "SchemaTypeCoder@undefined@components/User.ts:true:false" => "User", - }, - "comments": [ - "This code was automatically generated from an OpenAPI description.", - "Do not edit this file. Edit the OpenAPI file instead.", - "For more information, see https://github.com/pmcelhaney/counterfact/blob/main/docs/faq-generated-code.md", - ], - "exports": Map { - "HTTP_POST" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: never, path: never, header: never, body: Array, context: Context, response: ResponseBuilderFactory<{ -200: { - headers: never; - requiredHeaders: never; - content: { -"application/xml": { - schema: User - }, -"application/json": { - schema: User - } +" +`; + +exports[`end-to-end test generates the same code for pet store that it did on the last test run 16`] = ` +"path-types/store/order/{orderId}.types.ts:// This code was automatically generated from an OpenAPI description. +// Do not edit this file. Edit the OpenAPI file instead. +// For more information, see https://github.com/pmcelhaney/counterfact/blob/main/docs/faq-generated-code.md + +import type { WideOperationArgument } from "../../../types.d.ts"; +import type { OmitValueWhenNever } from "../../../types.d.ts"; +import type { Context } from "@@CONTEXT_FILE_TOKEN@@"; +import type { ResponseBuilderFactory } from "../../../types.d.ts"; +import type { Order } from "../../../components/Order.js"; + +export type HTTP_GET = ( + $: OmitValueWhenNever<{ + query: never; + path: { orderId: number }; + header: never; + body: never; + context: Context; + response: ResponseBuilderFactory<{ + 200: { + headers: never; + requiredHeaders: never; + content: { + "application/xml": { + schema: Order; + }; + "application/json": { + schema: Order; + }; + }; + }; + 400: { + headers: never; + requiredHeaders: never; + content: never; + }; + 404: { + headers: never; + requiredHeaders: never; + content: never; + }; + }>; + x: WideOperationArgument; + proxy: (url: string) => "COUNTERFACT_RESPONSE"; + user: never; + }>, +) => + | { + status: 200; + contentType?: "application/xml"; + body?: Order; + } + | { + status: 200; + contentType?: "application/json"; + body?: Order; + } + | { + status: 400; + } + | { + status: 404; + } + | { status: 415; contentType: "text/plain"; body: string } + | "COUNTERFACT_RESPONSE" + | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }; + +export type HTTP_DELETE = ( + $: OmitValueWhenNever<{ + query: never; + path: { orderId: number }; + header: never; + body: never; + context: Context; + response: ResponseBuilderFactory<{ + 400: { + headers: never; + requiredHeaders: never; + content: never; + }; + 404: { + headers: never; + requiredHeaders: never; + content: never; + }; + }>; + x: WideOperationArgument; + proxy: (url: string) => "COUNTERFACT_RESPONSE"; + user: never; + }>, +) => + | { + status: 400; + } + | { + status: 404; + } + | { status: 415; contentType: "text/plain"; body: string } + | "COUNTERFACT_RESPONSE" + | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }; +" +`; + +exports[`end-to-end test generates the same code for pet store that it did on the last test run 17`] = ` +"paths/user.ts:import type { HTTP_POST } from "../path-types/user.types.js"; + +export const POST: HTTP_POST = ($) => { + return $.response[200].random(); }; - }, -[statusCode in Exclude]: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: 200, - contentType?: "application/xml", - body?: User - } | { - status: 200, - contentType?: "application/json", - body?: User - } | { - status: number | undefined - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1user~1createWithList/post", - "isDefault": false, - "isType": true, - "name": "HTTP_POST", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map { - "WideOperationArgument" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "OmitValueWhenNever" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "Context" => { - "isType": true, - "modulePath": "@@CONTEXT_FILE_TOKEN@@", - }, - "ResponseBuilderFactory" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "HttpStatusCode" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - }, - "imports": Map { - "User" => { - "isDefault": false, - "isType": true, - "name": "User", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "User", - }, - "comments": [], - "exports": Map { - "User" => { - "beforeExport": "", - "code": "{"id"?: number,"username"?: string,"firstName"?: string,"lastName"?: string,"email"?: string,"password"?: string,"phone"?: string,"userStatus"?: number}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "User", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map {}, - "path": "components/User.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "path-types/user/createWithList.types.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "paths/user/createWithList.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - "path-types/user/createWithList.types.ts" => Script { - "cache": Map { - "OperationTypeCoder@./petstore.yaml#/paths/~1user~1createWithList/post:true" => "HTTP_POST", - "SchemaTypeCoder@undefined@components/User.ts:true:false" => "User", - }, - "comments": [ - "This code was automatically generated from an OpenAPI description.", - "Do not edit this file. Edit the OpenAPI file instead.", - "For more information, see https://github.com/pmcelhaney/counterfact/blob/main/docs/faq-generated-code.md", - ], - "exports": Map { - "HTTP_POST" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: never, path: never, header: never, body: Array, context: Context, response: ResponseBuilderFactory<{ -200: { - headers: never; - requiredHeaders: never; - content: { -"application/xml": { - schema: User - }, -"application/json": { - schema: User - } +" +`; + +exports[`end-to-end test generates the same code for pet store that it did on the last test run 18`] = ` +"path-types/user.types.ts:// This code was automatically generated from an OpenAPI description. +// Do not edit this file. Edit the OpenAPI file instead. +// For more information, see https://github.com/pmcelhaney/counterfact/blob/main/docs/faq-generated-code.md + +import type { WideOperationArgument } from "../types.d.ts"; +import type { OmitValueWhenNever } from "../types.d.ts"; +import type { Context } from "@@CONTEXT_FILE_TOKEN@@"; +import type { ResponseBuilderFactory } from "../types.d.ts"; +import type { HttpStatusCode } from "../types.d.ts"; +import type { User } from "../components/User.js"; + +export type HTTP_POST = ( + $: OmitValueWhenNever<{ + query: never; + path: never; + header: never; + body: User; + context: Context; + response: ResponseBuilderFactory<{ + [statusCode in HttpStatusCode]: { + headers: never; + requiredHeaders: never; + content: { + "application/json": { + schema: User; + }; + "application/xml": { + schema: User; + }; + }; + }; + }>; + x: WideOperationArgument; + proxy: (url: string) => "COUNTERFACT_RESPONSE"; + user: never; + }>, +) => + | { + status: number | undefined; + contentType?: "application/json"; + body?: User; + } + | { + status: number | undefined; + contentType?: "application/xml"; + body?: User; + } + | { status: 415; contentType: "text/plain"; body: string } + | "COUNTERFACT_RESPONSE" + | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }; +" +`; + +exports[`end-to-end test generates the same code for pet store that it did on the last test run 19`] = ` +"paths/user/createWithList.ts:import type { HTTP_POST } from "../../path-types/user/createWithList.types.js"; + +export const POST: HTTP_POST = ($) => { + return $.response[200].random(); }; - }, -[statusCode in Exclude]: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: 200, - contentType?: "application/xml", - body?: User - } | { - status: 200, - contentType?: "application/json", - body?: User - } | { - status: number | undefined - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1user~1createWithList/post", - "isDefault": false, - "isType": true, - "name": "HTTP_POST", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map { - "WideOperationArgument" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "OmitValueWhenNever" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "Context" => { - "isType": true, - "modulePath": "@@CONTEXT_FILE_TOKEN@@", - }, - "ResponseBuilderFactory" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "HttpStatusCode" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - }, - "imports": Map { - "User" => { - "isDefault": false, - "isType": true, - "name": "User", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "User", - }, - "comments": [], - "exports": Map { - "User" => { - "beforeExport": "", - "code": "{"id"?: number,"username"?: string,"firstName"?: string,"lastName"?: string,"email"?: string,"password"?: string,"phone"?: string,"userStatus"?: number}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "User", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map {}, - "path": "components/User.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "path-types/user/createWithList.types.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - "paths/user/login.ts" => Script { - "cache": Map { - "OperationCoder@./petstore.yaml#/paths/~1user~1login/get:false" => "GET", - "OperationTypeCoder@./petstore.yaml#/paths/~1user~1login/get@path-types/user/login.types.ts:true:false" => "HTTP_GET", - }, - "comments": [], - "exports": Map { - "GET" => { - "beforeExport": "", - "code": "($) => { - return $.response[200].random(); - }", - "done": true, - "id": "OperationCoder@./petstore.yaml#/paths/~1user~1login/get", - "isDefault": false, - "isType": false, - "name": "GET", - "promise": Promise {}, - "typeDeclaration": "HTTP_GET", - }, - }, - "externalImport": Map {}, - "imports": Map { - "HTTP_GET" => { - "isDefault": false, - "isType": true, - "name": "HTTP_GET", - "script": Script { - "cache": Map { - "OperationTypeCoder@./petstore.yaml#/paths/~1user~1login/get:true" => "HTTP_GET", - }, - "comments": [ - "This code was automatically generated from an OpenAPI description.", - "Do not edit this file. Edit the OpenAPI file instead.", - "For more information, see https://github.com/pmcelhaney/counterfact/blob/main/docs/faq-generated-code.md", - ], - "exports": Map { - "HTTP_GET" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: {"username"?: string, "password"?: string}, path: never, header: never, body: never, context: Context, response: ResponseBuilderFactory<{ -200: { - headers: { -"X-Rate-Limit": { schema: number}, -"X-Expires-After": { schema: string} +" +`; + +exports[`end-to-end test generates the same code for pet store that it did on the last test run 20`] = ` +"path-types/user/createWithList.types.ts:// This code was automatically generated from an OpenAPI description. +// Do not edit this file. Edit the OpenAPI file instead. +// For more information, see https://github.com/pmcelhaney/counterfact/blob/main/docs/faq-generated-code.md + +import type { WideOperationArgument } from "../../types.d.ts"; +import type { OmitValueWhenNever } from "../../types.d.ts"; +import type { Context } from "@@CONTEXT_FILE_TOKEN@@"; +import type { ResponseBuilderFactory } from "../../types.d.ts"; +import type { HttpStatusCode } from "../../types.d.ts"; +import type { User } from "../../components/User.js"; + +export type HTTP_POST = ( + $: OmitValueWhenNever<{ + query: never; + path: never; + header: never; + body: Array; + context: Context; + response: ResponseBuilderFactory<{ + 200: { + headers: never; + requiredHeaders: never; + content: { + "application/xml": { + schema: User; + }; + "application/json": { + schema: User; + }; + }; + }; + [statusCode in Exclude]: { + headers: never; + requiredHeaders: never; + content: never; + }; + }>; + x: WideOperationArgument; + proxy: (url: string) => "COUNTERFACT_RESPONSE"; + user: never; + }>, +) => + | { + status: 200; + contentType?: "application/xml"; + body?: User; + } + | { + status: 200; + contentType?: "application/json"; + body?: User; + } + | { + status: number | undefined; + } + | { status: 415; contentType: "text/plain"; body: string } + | "COUNTERFACT_RESPONSE" + | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }; +" +`; + +exports[`end-to-end test generates the same code for pet store that it did on the last test run 21`] = ` +"paths/user/login.ts:import type { HTTP_GET } from "../../path-types/user/login.types.js"; + +export const GET: HTTP_GET = ($) => { + return $.response[200].random(); }; - requiredHeaders: never; - content: { -"application/xml": { - schema: string - }, -"application/json": { - schema: string - } +" +`; + +exports[`end-to-end test generates the same code for pet store that it did on the last test run 22`] = ` +"path-types/user/login.types.ts:// This code was automatically generated from an OpenAPI description. +// Do not edit this file. Edit the OpenAPI file instead. +// For more information, see https://github.com/pmcelhaney/counterfact/blob/main/docs/faq-generated-code.md + +import type { WideOperationArgument } from "../../types.d.ts"; +import type { OmitValueWhenNever } from "../../types.d.ts"; +import type { Context } from "@@CONTEXT_FILE_TOKEN@@"; +import type { ResponseBuilderFactory } from "../../types.d.ts"; + +export type HTTP_GET = ( + $: OmitValueWhenNever<{ + query: { username?: string; password?: string }; + path: never; + header: never; + body: never; + context: Context; + response: ResponseBuilderFactory<{ + 200: { + headers: { + "X-Rate-Limit": { schema: number }; + "X-Expires-After": { schema: string }; + }; + requiredHeaders: never; + content: { + "application/xml": { + schema: string; + }; + "application/json": { + schema: string; + }; + }; + }; + 400: { + headers: never; + requiredHeaders: never; + content: never; + }; + }>; + x: WideOperationArgument; + proxy: (url: string) => "COUNTERFACT_RESPONSE"; + user: never; + }>, +) => + | { + status: 200; + contentType?: "application/xml"; + body?: string; + } + | { + status: 200; + contentType?: "application/json"; + body?: string; + } + | { + status: 400; + } + | { status: 415; contentType: "text/plain"; body: string } + | "COUNTERFACT_RESPONSE" + | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }; +" +`; + +exports[`end-to-end test generates the same code for pet store that it did on the last test run 23`] = ` +"paths/user/logout.ts:import type { HTTP_GET } from "../../path-types/user/logout.types.js"; + +export const GET: HTTP_GET = ($) => { + return $.response[200]; }; - }, -400: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: 200, - contentType?: "application/xml", - body?: string - } | { - status: 200, - contentType?: "application/json", - body?: string - } | { - status: 400 - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1user~1login/get", - "isDefault": false, - "isType": true, - "name": "HTTP_GET", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map { - "WideOperationArgument" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "OmitValueWhenNever" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "Context" => { - "isType": true, - "modulePath": "@@CONTEXT_FILE_TOKEN@@", - }, - "ResponseBuilderFactory" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - }, - "imports": Map {}, - "path": "path-types/user/login.types.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "paths/user/login.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - "path-types/user/login.types.ts" => Script { - "cache": Map { - "OperationTypeCoder@./petstore.yaml#/paths/~1user~1login/get:true" => "HTTP_GET", - }, - "comments": [ - "This code was automatically generated from an OpenAPI description.", - "Do not edit this file. Edit the OpenAPI file instead.", - "For more information, see https://github.com/pmcelhaney/counterfact/blob/main/docs/faq-generated-code.md", - ], - "exports": Map { - "HTTP_GET" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: {"username"?: string, "password"?: string}, path: never, header: never, body: never, context: Context, response: ResponseBuilderFactory<{ -200: { - headers: { -"X-Rate-Limit": { schema: number}, -"X-Expires-After": { schema: string} +" +`; + +exports[`end-to-end test generates the same code for pet store that it did on the last test run 24`] = ` +"path-types/user/logout.types.ts:// This code was automatically generated from an OpenAPI description. +// Do not edit this file. Edit the OpenAPI file instead. +// For more information, see https://github.com/pmcelhaney/counterfact/blob/main/docs/faq-generated-code.md + +import type { WideOperationArgument } from "../../types.d.ts"; +import type { OmitValueWhenNever } from "../../types.d.ts"; +import type { Context } from "@@CONTEXT_FILE_TOKEN@@"; +import type { ResponseBuilderFactory } from "../../types.d.ts"; +import type { HttpStatusCode } from "../../types.d.ts"; + +export type HTTP_GET = ( + $: OmitValueWhenNever<{ + query: never; + path: never; + header: never; + body: never; + context: Context; + response: ResponseBuilderFactory<{ + [statusCode in HttpStatusCode]: { + headers: never; + requiredHeaders: never; + content: never; + }; + }>; + x: WideOperationArgument; + proxy: (url: string) => "COUNTERFACT_RESPONSE"; + user: never; + }>, +) => + | { + status: number | undefined; + } + | { status: 415; contentType: "text/plain"; body: string } + | "COUNTERFACT_RESPONSE" + | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }; +" +`; + +exports[`end-to-end test generates the same code for pet store that it did on the last test run 25`] = ` +"paths/user/{username}.ts:import type { HTTP_GET } from "../../path-types/user/{username}.types.js"; +import type { HTTP_PUT } from "../../path-types/user/{username}.types.js"; +import type { HTTP_DELETE } from "../../path-types/user/{username}.types.js"; + +export const GET: HTTP_GET = ($) => { + return $.response[200].random(); }; - requiredHeaders: never; - content: { -"application/xml": { - schema: string - }, -"application/json": { - schema: string - } + +export const PUT: HTTP_PUT = ($) => { + return $.response[200]; }; - }, -400: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: 200, - contentType?: "application/xml", - body?: string - } | { - status: 200, - contentType?: "application/json", - body?: string - } | { - status: 400 - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1user~1login/get", - "isDefault": false, - "isType": true, - "name": "HTTP_GET", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map { - "WideOperationArgument" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "OmitValueWhenNever" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "Context" => { - "isType": true, - "modulePath": "@@CONTEXT_FILE_TOKEN@@", - }, - "ResponseBuilderFactory" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - }, - "imports": Map {}, - "path": "path-types/user/login.types.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - "paths/user/logout.ts" => Script { - "cache": Map { - "OperationCoder@./petstore.yaml#/paths/~1user~1logout/get:false" => "GET", - "OperationTypeCoder@./petstore.yaml#/paths/~1user~1logout/get@path-types/user/logout.types.ts:true:false" => "HTTP_GET", - }, - "comments": [], - "exports": Map { - "GET" => { - "beforeExport": "", - "code": "($) => { - return $.response[200]; - }", - "done": true, - "id": "OperationCoder@./petstore.yaml#/paths/~1user~1logout/get", - "isDefault": false, - "isType": false, - "name": "GET", - "promise": Promise {}, - "typeDeclaration": "HTTP_GET", - }, - }, - "externalImport": Map {}, - "imports": Map { - "HTTP_GET" => { - "isDefault": false, - "isType": true, - "name": "HTTP_GET", - "script": Script { - "cache": Map { - "OperationTypeCoder@./petstore.yaml#/paths/~1user~1logout/get:true" => "HTTP_GET", - }, - "comments": [ - "This code was automatically generated from an OpenAPI description.", - "Do not edit this file. Edit the OpenAPI file instead.", - "For more information, see https://github.com/pmcelhaney/counterfact/blob/main/docs/faq-generated-code.md", - ], - "exports": Map { - "HTTP_GET" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: never, path: never, header: never, body: never, context: Context, response: ResponseBuilderFactory<{ -[statusCode in HttpStatusCode]: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: number | undefined - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1user~1logout/get", - "isDefault": false, - "isType": true, - "name": "HTTP_GET", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map { - "WideOperationArgument" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "OmitValueWhenNever" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "Context" => { - "isType": true, - "modulePath": "@@CONTEXT_FILE_TOKEN@@", - }, - "ResponseBuilderFactory" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "HttpStatusCode" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - }, - "imports": Map {}, - "path": "path-types/user/logout.types.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "paths/user/logout.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - "path-types/user/logout.types.ts" => Script { - "cache": Map { - "OperationTypeCoder@./petstore.yaml#/paths/~1user~1logout/get:true" => "HTTP_GET", - }, - "comments": [ - "This code was automatically generated from an OpenAPI description.", - "Do not edit this file. Edit the OpenAPI file instead.", - "For more information, see https://github.com/pmcelhaney/counterfact/blob/main/docs/faq-generated-code.md", - ], - "exports": Map { - "HTTP_GET" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: never, path: never, header: never, body: never, context: Context, response: ResponseBuilderFactory<{ -[statusCode in HttpStatusCode]: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: number | undefined - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1user~1logout/get", - "isDefault": false, - "isType": true, - "name": "HTTP_GET", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map { - "WideOperationArgument" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "OmitValueWhenNever" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "Context" => { - "isType": true, - "modulePath": "@@CONTEXT_FILE_TOKEN@@", - }, - "ResponseBuilderFactory" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "HttpStatusCode" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - }, - "imports": Map {}, - "path": "path-types/user/logout.types.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - "paths/user/{username}.ts" => Script { - "cache": Map { - "OperationCoder@./petstore.yaml#/paths/~1user~1{username}/get:false" => "GET", - "OperationTypeCoder@./petstore.yaml#/paths/~1user~1{username}/get@path-types/user/{username}.types.ts:true:false" => "HTTP_GET", - "OperationCoder@./petstore.yaml#/paths/~1user~1{username}/put:false" => "PUT", - "OperationTypeCoder@./petstore.yaml#/paths/~1user~1{username}/put@path-types/user/{username}.types.ts:true:false" => "HTTP_PUT", - "OperationCoder@./petstore.yaml#/paths/~1user~1{username}/delete:false" => "DELETE", - "OperationTypeCoder@./petstore.yaml#/paths/~1user~1{username}/delete@path-types/user/{username}.types.ts:true:false" => "HTTP_DELETE", - }, - "comments": [], - "exports": Map { - "GET" => { - "beforeExport": "", - "code": "($) => { - return $.response[200].random(); - }", - "done": true, - "id": "OperationCoder@./petstore.yaml#/paths/~1user~1{username}/get", - "isDefault": false, - "isType": false, - "name": "GET", - "promise": Promise {}, - "typeDeclaration": "HTTP_GET", - }, - "PUT" => { - "beforeExport": "", - "code": "($) => { - return $.response[200]; - }", - "done": true, - "id": "OperationCoder@./petstore.yaml#/paths/~1user~1{username}/put", - "isDefault": false, - "isType": false, - "name": "PUT", - "promise": Promise {}, - "typeDeclaration": "HTTP_PUT", - }, - "DELETE" => { - "beforeExport": "", - "code": "($) => { - return $.response[400]; - }", - "done": true, - "id": "OperationCoder@./petstore.yaml#/paths/~1user~1{username}/delete", - "isDefault": false, - "isType": false, - "name": "DELETE", - "promise": Promise {}, - "typeDeclaration": "HTTP_DELETE", - }, - }, - "externalImport": Map {}, - "imports": Map { - "HTTP_GET" => { - "isDefault": false, - "isType": true, - "name": "HTTP_GET", - "script": Script { - "cache": Map { - "OperationTypeCoder@./petstore.yaml#/paths/~1user~1{username}/get:true" => "HTTP_GET", - "OperationTypeCoder@./petstore.yaml#/paths/~1user~1{username}/put:true" => "HTTP_PUT", - "OperationTypeCoder@./petstore.yaml#/paths/~1user~1{username}/delete:true" => "HTTP_DELETE", - "SchemaTypeCoder@undefined@components/User.ts:true:false" => "User", - }, - "comments": [ - "This code was automatically generated from an OpenAPI description.", - "Do not edit this file. Edit the OpenAPI file instead.", - "For more information, see https://github.com/pmcelhaney/counterfact/blob/main/docs/faq-generated-code.md", - ], - "exports": Map { - "HTTP_GET" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: never, path: {"username": string}, header: never, body: never, context: Context, response: ResponseBuilderFactory<{ -200: { - headers: never; - requiredHeaders: never; - content: { -"application/xml": { - schema: User - }, -"application/json": { - schema: User - } + +export const DELETE: HTTP_DELETE = ($) => { + return $.response[400]; }; - }, -400: { - headers: never; - requiredHeaders: never; - content: never; - }, -404: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: 200, - contentType?: "application/xml", - body?: User - } | { - status: 200, - contentType?: "application/json", - body?: User - } | { - status: 400 - } | { - status: 404 - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1user~1{username}/get", - "isDefault": false, - "isType": true, - "name": "HTTP_GET", - "promise": Promise {}, - "typeDeclaration": "", - }, - "HTTP_PUT" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: never, path: {"username": string}, header: never, body: User, context: Context, response: ResponseBuilderFactory<{ -[statusCode in HttpStatusCode]: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: number | undefined - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1user~1{username}/put", - "isDefault": false, - "isType": true, - "name": "HTTP_PUT", - "promise": Promise {}, - "typeDeclaration": "", - }, - "HTTP_DELETE" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: never, path: {"username": string}, header: never, body: never, context: Context, response: ResponseBuilderFactory<{ -400: { - headers: never; - requiredHeaders: never; - content: never; - }, -404: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: 400 - } | { - status: 404 - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1user~1{username}/delete", - "isDefault": false, - "isType": true, - "name": "HTTP_DELETE", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map { - "WideOperationArgument" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "OmitValueWhenNever" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "Context" => { - "isType": true, - "modulePath": "@@CONTEXT_FILE_TOKEN@@", - }, - "ResponseBuilderFactory" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "HttpStatusCode" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - }, - "imports": Map { - "User" => { - "isDefault": false, - "isType": true, - "name": "User", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "User", - }, - "comments": [], - "exports": Map { - "User" => { - "beforeExport": "", - "code": "{"id"?: number,"username"?: string,"firstName"?: string,"lastName"?: string,"email"?: string,"password"?: string,"phone"?: string,"userStatus"?: number}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "User", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map {}, - "path": "components/User.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "path-types/user/{username}.types.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - "HTTP_PUT" => { - "isDefault": false, - "isType": true, - "name": "HTTP_PUT", - "script": Script { - "cache": Map { - "OperationTypeCoder@./petstore.yaml#/paths/~1user~1{username}/get:true" => "HTTP_GET", - "OperationTypeCoder@./petstore.yaml#/paths/~1user~1{username}/put:true" => "HTTP_PUT", - "OperationTypeCoder@./petstore.yaml#/paths/~1user~1{username}/delete:true" => "HTTP_DELETE", - "SchemaTypeCoder@undefined@components/User.ts:true:false" => "User", - }, - "comments": [ - "This code was automatically generated from an OpenAPI description.", - "Do not edit this file. Edit the OpenAPI file instead.", - "For more information, see https://github.com/pmcelhaney/counterfact/blob/main/docs/faq-generated-code.md", - ], - "exports": Map { - "HTTP_GET" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: never, path: {"username": string}, header: never, body: never, context: Context, response: ResponseBuilderFactory<{ -200: { - headers: never; - requiredHeaders: never; - content: { -"application/xml": { - schema: User - }, -"application/json": { - schema: User - } +" +`; + +exports[`end-to-end test generates the same code for pet store that it did on the last test run 26`] = ` +"path-types/user/{username}.types.ts:// This code was automatically generated from an OpenAPI description. +// Do not edit this file. Edit the OpenAPI file instead. +// For more information, see https://github.com/pmcelhaney/counterfact/blob/main/docs/faq-generated-code.md + +import type { WideOperationArgument } from "../../types.d.ts"; +import type { OmitValueWhenNever } from "../../types.d.ts"; +import type { Context } from "@@CONTEXT_FILE_TOKEN@@"; +import type { ResponseBuilderFactory } from "../../types.d.ts"; +import type { HttpStatusCode } from "../../types.d.ts"; +import type { User } from "../../components/User.js"; + +export type HTTP_GET = ( + $: OmitValueWhenNever<{ + query: never; + path: { username: string }; + header: never; + body: never; + context: Context; + response: ResponseBuilderFactory<{ + 200: { + headers: never; + requiredHeaders: never; + content: { + "application/xml": { + schema: User; + }; + "application/json": { + schema: User; + }; + }; + }; + 400: { + headers: never; + requiredHeaders: never; + content: never; + }; + 404: { + headers: never; + requiredHeaders: never; + content: never; + }; + }>; + x: WideOperationArgument; + proxy: (url: string) => "COUNTERFACT_RESPONSE"; + user: never; + }>, +) => + | { + status: 200; + contentType?: "application/xml"; + body?: User; + } + | { + status: 200; + contentType?: "application/json"; + body?: User; + } + | { + status: 400; + } + | { + status: 404; + } + | { status: 415; contentType: "text/plain"; body: string } + | "COUNTERFACT_RESPONSE" + | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }; + +export type HTTP_PUT = ( + $: OmitValueWhenNever<{ + query: never; + path: { username: string }; + header: never; + body: User; + context: Context; + response: ResponseBuilderFactory<{ + [statusCode in HttpStatusCode]: { + headers: never; + requiredHeaders: never; + content: never; + }; + }>; + x: WideOperationArgument; + proxy: (url: string) => "COUNTERFACT_RESPONSE"; + user: never; + }>, +) => + | { + status: number | undefined; + } + | { status: 415; contentType: "text/plain"; body: string } + | "COUNTERFACT_RESPONSE" + | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }; + +export type HTTP_DELETE = ( + $: OmitValueWhenNever<{ + query: never; + path: { username: string }; + header: never; + body: never; + context: Context; + response: ResponseBuilderFactory<{ + 400: { + headers: never; + requiredHeaders: never; + content: never; + }; + 404: { + headers: never; + requiredHeaders: never; + content: never; + }; + }>; + x: WideOperationArgument; + proxy: (url: string) => "COUNTERFACT_RESPONSE"; + user: never; + }>, +) => + | { + status: 400; + } + | { + status: 404; + } + | { status: 415; contentType: "text/plain"; body: string } + | "COUNTERFACT_RESPONSE" + | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }; +" +`; + +exports[`end-to-end test generates the same code for pet store that it did on the last test run 27`] = ` +"components/Pet.ts:import type { Category } from "./Category.js"; +import type { Tag } from "./Tag.js"; + +export type Pet = { + id?: number; + name: string; + category?: Category; + photoUrls: Array; + tags?: Array; + status?: "available" | "pending" | "sold"; }; - }, -400: { - headers: never; - requiredHeaders: never; - content: never; - }, -404: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: 200, - contentType?: "application/xml", - body?: User - } | { - status: 200, - contentType?: "application/json", - body?: User - } | { - status: 400 - } | { - status: 404 - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1user~1{username}/get", - "isDefault": false, - "isType": true, - "name": "HTTP_GET", - "promise": Promise {}, - "typeDeclaration": "", - }, - "HTTP_PUT" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: never, path: {"username": string}, header: never, body: User, context: Context, response: ResponseBuilderFactory<{ -[statusCode in HttpStatusCode]: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: number | undefined - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1user~1{username}/put", - "isDefault": false, - "isType": true, - "name": "HTTP_PUT", - "promise": Promise {}, - "typeDeclaration": "", - }, - "HTTP_DELETE" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: never, path: {"username": string}, header: never, body: never, context: Context, response: ResponseBuilderFactory<{ -400: { - headers: never; - requiredHeaders: never; - content: never; - }, -404: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: 400 - } | { - status: 404 - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1user~1{username}/delete", - "isDefault": false, - "isType": true, - "name": "HTTP_DELETE", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map { - "WideOperationArgument" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "OmitValueWhenNever" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "Context" => { - "isType": true, - "modulePath": "@@CONTEXT_FILE_TOKEN@@", - }, - "ResponseBuilderFactory" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "HttpStatusCode" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - }, - "imports": Map { - "User" => { - "isDefault": false, - "isType": true, - "name": "User", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "User", - }, - "comments": [], - "exports": Map { - "User" => { - "beforeExport": "", - "code": "{"id"?: number,"username"?: string,"firstName"?: string,"lastName"?: string,"email"?: string,"password"?: string,"phone"?: string,"userStatus"?: number}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "User", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map {}, - "path": "components/User.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "path-types/user/{username}.types.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - "HTTP_DELETE" => { - "isDefault": false, - "isType": true, - "name": "HTTP_DELETE", - "script": Script { - "cache": Map { - "OperationTypeCoder@./petstore.yaml#/paths/~1user~1{username}/get:true" => "HTTP_GET", - "OperationTypeCoder@./petstore.yaml#/paths/~1user~1{username}/put:true" => "HTTP_PUT", - "OperationTypeCoder@./petstore.yaml#/paths/~1user~1{username}/delete:true" => "HTTP_DELETE", - "SchemaTypeCoder@undefined@components/User.ts:true:false" => "User", - }, - "comments": [ - "This code was automatically generated from an OpenAPI description.", - "Do not edit this file. Edit the OpenAPI file instead.", - "For more information, see https://github.com/pmcelhaney/counterfact/blob/main/docs/faq-generated-code.md", - ], - "exports": Map { - "HTTP_GET" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: never, path: {"username": string}, header: never, body: never, context: Context, response: ResponseBuilderFactory<{ -200: { - headers: never; - requiredHeaders: never; - content: { -"application/xml": { - schema: User - }, -"application/json": { - schema: User - } +" +`; + +exports[`end-to-end test generates the same code for pet store that it did on the last test run 28`] = ` +"components/ApiResponse.ts:export type ApiResponse = { code?: number; type?: string; message?: string }; +" +`; + +exports[`end-to-end test generates the same code for pet store that it did on the last test run 29`] = ` +"components/Order.ts:export type Order = { + id?: number; + petId?: number; + quantity?: number; + shipDate?: string; + status?: "placed" | "approved" | "delivered"; + complete?: boolean; }; - }, -400: { - headers: never; - requiredHeaders: never; - content: never; - }, -404: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: 200, - contentType?: "application/xml", - body?: User - } | { - status: 200, - contentType?: "application/json", - body?: User - } | { - status: 400 - } | { - status: 404 - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1user~1{username}/get", - "isDefault": false, - "isType": true, - "name": "HTTP_GET", - "promise": Promise {}, - "typeDeclaration": "", - }, - "HTTP_PUT" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: never, path: {"username": string}, header: never, body: User, context: Context, response: ResponseBuilderFactory<{ -[statusCode in HttpStatusCode]: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: number | undefined - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1user~1{username}/put", - "isDefault": false, - "isType": true, - "name": "HTTP_PUT", - "promise": Promise {}, - "typeDeclaration": "", - }, - "HTTP_DELETE" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: never, path: {"username": string}, header: never, body: never, context: Context, response: ResponseBuilderFactory<{ -400: { - headers: never; - requiredHeaders: never; - content: never; - }, -404: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: 400 - } | { - status: 404 - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1user~1{username}/delete", - "isDefault": false, - "isType": true, - "name": "HTTP_DELETE", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map { - "WideOperationArgument" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "OmitValueWhenNever" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "Context" => { - "isType": true, - "modulePath": "@@CONTEXT_FILE_TOKEN@@", - }, - "ResponseBuilderFactory" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "HttpStatusCode" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - }, - "imports": Map { - "User" => { - "isDefault": false, - "isType": true, - "name": "User", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "User", - }, - "comments": [], - "exports": Map { - "User" => { - "beforeExport": "", - "code": "{"id"?: number,"username"?: string,"firstName"?: string,"lastName"?: string,"email"?: string,"password"?: string,"phone"?: string,"userStatus"?: number}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "User", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map {}, - "path": "components/User.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "path-types/user/{username}.types.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "paths/user/{username}.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - "path-types/user/{username}.types.ts" => Script { - "cache": Map { - "OperationTypeCoder@./petstore.yaml#/paths/~1user~1{username}/get:true" => "HTTP_GET", - "OperationTypeCoder@./petstore.yaml#/paths/~1user~1{username}/put:true" => "HTTP_PUT", - "OperationTypeCoder@./petstore.yaml#/paths/~1user~1{username}/delete:true" => "HTTP_DELETE", - "SchemaTypeCoder@undefined@components/User.ts:true:false" => "User", - }, - "comments": [ - "This code was automatically generated from an OpenAPI description.", - "Do not edit this file. Edit the OpenAPI file instead.", - "For more information, see https://github.com/pmcelhaney/counterfact/blob/main/docs/faq-generated-code.md", - ], - "exports": Map { - "HTTP_GET" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: never, path: {"username": string}, header: never, body: never, context: Context, response: ResponseBuilderFactory<{ -200: { - headers: never; - requiredHeaders: never; - content: { -"application/xml": { - schema: User - }, -"application/json": { - schema: User - } +" +`; + +exports[`end-to-end test generates the same code for pet store that it did on the last test run 30`] = ` +"components/User.ts:export type User = { + id?: number; + username?: string; + firstName?: string; + lastName?: string; + email?: string; + password?: string; + phone?: string; + userStatus?: number; }; - }, -400: { - headers: never; - requiredHeaders: never; - content: never; - }, -404: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: 200, - contentType?: "application/xml", - body?: User - } | { - status: 200, - contentType?: "application/json", - body?: User - } | { - status: 400 - } | { - status: 404 - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1user~1{username}/get", - "isDefault": false, - "isType": true, - "name": "HTTP_GET", - "promise": Promise {}, - "typeDeclaration": "", - }, - "HTTP_PUT" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: never, path: {"username": string}, header: never, body: User, context: Context, response: ResponseBuilderFactory<{ -[statusCode in HttpStatusCode]: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: number | undefined - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1user~1{username}/put", - "isDefault": false, - "isType": true, - "name": "HTTP_PUT", - "promise": Promise {}, - "typeDeclaration": "", - }, - "HTTP_DELETE" => { - "beforeExport": "", - "code": "($: OmitValueWhenNever<{ query: never, path: {"username": string}, header: never, body: never, context: Context, response: ResponseBuilderFactory<{ -400: { - headers: never; - requiredHeaders: never; - content: never; - }, -404: { - headers: never; - requiredHeaders: never; - content: never; - } -}>, x: WideOperationArgument, proxy: (url: string) => "COUNTERFACT_RESPONSE", user: never }>) => { - status: 400 - } | { - status: 404 - } | { status: 415, contentType: "text/plain", body: string } | "COUNTERFACT_RESPONSE" | { ALL_REMAINING_HEADERS_ARE_OPTIONAL: "COUNTERFACT_RESPONSE" }", - "done": true, - "id": "OperationTypeCoder@./petstore.yaml#/paths/~1user~1{username}/delete", - "isDefault": false, - "isType": true, - "name": "HTTP_DELETE", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map { - "WideOperationArgument" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "OmitValueWhenNever" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "Context" => { - "isType": true, - "modulePath": "@@CONTEXT_FILE_TOKEN@@", - }, - "ResponseBuilderFactory" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - "HttpStatusCode" => { - "isType": true, - "modulePath": "../../types.d.ts", - }, - }, - "imports": Map { - "User" => { - "isDefault": false, - "isType": true, - "name": "User", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "User", - }, - "comments": [], - "exports": Map { - "User" => { - "beforeExport": "", - "code": "{"id"?: number,"username"?: string,"firstName"?: string,"lastName"?: string,"email"?: string,"password"?: string,"phone"?: string,"userStatus"?: number}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "User", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map {}, - "path": "components/User.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "path-types/user/{username}.types.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - "components/Pet.ts" => Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "Pet", - "SchemaTypeCoder@undefined@components/Category.ts:true:false" => "Category", - "SchemaTypeCoder@undefined@components/Tag.ts:true:false" => "Tag", - }, - "comments": [], - "exports": Map { - "Pet" => { - "beforeExport": "", - "code": "{"id"?: number,"name": string,"category"?: Category,"photoUrls": Array,"tags"?: Array,"status"?: "available" | "pending" | "sold"}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "Pet", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map { - "Category" => { - "isDefault": false, - "isType": true, - "name": "Category", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "Category", - }, - "comments": [], - "exports": Map { - "Category" => { - "beforeExport": "", - "code": "{"id"?: number,"name"?: string}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "Category", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map {}, - "path": "components/Category.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - "Tag" => { - "isDefault": false, - "isType": true, - "name": "Tag", - "script": Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "Tag", - }, - "comments": [], - "exports": Map { - "Tag" => { - "beforeExport": "", - "code": "{"id"?: number,"name"?: string}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "Tag", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map {}, - "path": "components/Tag.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - }, - }, - "path": "components/Pet.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - "components/ApiResponse.ts" => Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "ApiResponse", - }, - "comments": [], - "exports": Map { - "ApiResponse" => { - "beforeExport": "", - "code": "{"code"?: number,"type"?: string,"message"?: string}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "ApiResponse", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map {}, - "path": "components/ApiResponse.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - "components/Order.ts" => Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "Order", - }, - "comments": [], - "exports": Map { - "Order" => { - "beforeExport": "", - "code": "{"id"?: number,"petId"?: number,"quantity"?: number,"shipDate"?: string,"status"?: "placed" | "approved" | "delivered","complete"?: boolean}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "Order", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map {}, - "path": "components/Order.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - "components/User.ts" => Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "User", - }, - "comments": [], - "exports": Map { - "User" => { - "beforeExport": "", - "code": "{"id"?: number,"username"?: string,"firstName"?: string,"lastName"?: string,"email"?: string,"password"?: string,"phone"?: string,"userStatus"?: number}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "User", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map {}, - "path": "components/User.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - "components/Category.ts" => Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "Category", - }, - "comments": [], - "exports": Map { - "Category" => { - "beforeExport": "", - "code": "{"id"?: number,"name"?: string}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "Category", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map {}, - "path": "components/Category.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, - "components/Tag.ts" => Script { - "cache": Map { - "SchemaTypeCoder@undefined:true" => "Tag", - }, - "comments": [], - "exports": Map { - "Tag" => { - "beforeExport": "", - "code": "{"id"?: number,"name"?: string}", - "done": true, - "id": "SchemaTypeCoder@undefined", - "isDefault": false, - "isType": true, - "name": "Tag", - "promise": Promise {}, - "typeDeclaration": "", - }, - }, - "externalImport": Map {}, - "imports": Map {}, - "path": "components/Tag.ts", - "repository": Repository { - "scripts": [Circular], - "writeFiles": [Function], - }, - "typeCache": Map {}, - }, -} +" `; -exports[`end-to-end test generates the same code for pet store that it did on the last test run 2`] = ` +exports[`end-to-end test generates the same code for pet store that it did on the last test run 31`] = ` +"components/Category.ts:export type Category = { id?: number; name?: string }; +" +`; + +exports[`end-to-end test generates the same code for pet store that it did on the last test run 32`] = ` +"components/Tag.ts:export type Tag = { id?: number; name?: string }; +" +`; + +exports[`end-to-end test generates the same code for pet store that it did on the last test run 33`] = ` ".cache " `; -exports[`end-to-end test generates the same code for pet store that it did on the last test run 3`] = ` +exports[`end-to-end test generates the same code for pet store that it did on the last test run 34`] = ` "This directory contains compiled JS files from the paths directory. Do not edit these files directly. " `; diff --git a/test/typescript-generator/generate.test.ts b/test/typescript-generator/generate.test.ts index aed89ce8..e06ff129 100644 --- a/test/typescript-generator/generate.test.ts +++ b/test/typescript-generator/generate.test.ts @@ -24,7 +24,10 @@ describe("end-to-end test", () => { ); await repository.finished(); - expect(repository.scripts).toMatchSnapshot(); + for (const [scriptPath, script] of repository.scripts.entries()) { + // eslint-disable-next-line no-await-in-loop, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call + expect(`${scriptPath}:${await script.contents()}`).toMatchSnapshot(); + } expect( await fs.readFile(nodePath.join(basePath, ".gitignore"), "utf8"), diff --git a/tsconfig.json b/tsconfig.json index 2d6aead1..3939c2f3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,7 +10,8 @@ "noUncheckedIndexedAccess": true, "allowJs": true, "outDir": "dist", - "skipLibCheck": true + "skipLibCheck": true, + "lib": ["es2022"] }, "include": ["src"] }