MCPcopy Create free account
hub / github.com/EvilFreelancer/openapi-to-cli / createPostApiDeps

Function createPostApiDeps

tests/cli.test.ts:581–629  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

579 // --- Body flag JSON parsing tests ---
580
581 function createPostApiDeps() {
582 const localDir = `${cwd}/.ocli`;
583 const profilesPath = `${localDir}/profiles.ini`;
584 const cachePath = `${localDir}/specs/body-api.json`;
585
586 const spec = {
587 openapi: "3.0.0",
588 paths: {
589 "/{org_slug}/{repo_slug}/ci/workflows/{workflow_name}/trigger": {
590 post: {
591 summary: "Trigger workflow",
592 parameters: [
593 { name: "org_slug", in: "path", required: true, schema: { type: "string" } },
594 { name: "repo_slug", in: "path", required: true, schema: { type: "string" } },
595 { name: "workflow_name", in: "path", required: true, schema: { type: "string" } },
596 ],
597 },
598 },
599 },
600 };
601
602 const iniContent = [
603 "[body-api]",
604 "api_base_url = https://api.example.com",
605 "api_basic_auth = ",
606 "api_bearer_token = tok",
607 "openapi_spec_source = /spec.json",
608 `openapi_spec_cache = ${cachePath}`,
609 "include_endpoints = ",
610 "exclude_endpoints = ",
611 "",
612 ].join("\n");
613
614 const capturedConfigs: unknown[] = [];
615 const fakeHttpClient: HttpClient = {
616 request: async (config: any) => {
617 capturedConfigs.push(config);
618 return { status: 200, statusText: "OK", headers: {}, config, data: { ok: true } };
619 },
620 };
621
622 const { profileStore, openapiLoader } = createCliDeps(cwd, homeDir, {
623 [profilesPath]: iniContent,
624 [cachePath]: JSON.stringify(spec),
625 [`${localDir}/current`]: "body-api",
626 });
627
628 return { profileStore, openapiLoader, fakeHttpClient, capturedConfigs };
629 }
630
631 it("parses JSON object body flags before sending request", async () => {
632 const { profileStore, openapiLoader, fakeHttpClient, capturedConfigs } = createPostApiDeps();

Callers 1

cli.test.tsFile · 0.85

Calls 1

createCliDepsFunction · 0.85

Tested by

no test coverage detected