Files
social-media/frontend/scripts/fetch-openapi.mjs
Jonathan Bourdon b6eb692c27
Some checks failed
Backend CI/CD / build_and_deploy (push) Has been cancelled
Frontend CI/CD / build_and_deploy (push) Has been cancelled
chore: moving towards agentic development
2026-04-24 21:12:26 -04:00

20 lines
627 B
JavaScript

import { mkdir, writeFile } from 'node:fs/promises';
const url = process.env.OPENAPI_URL ?? 'http://localhost:5080/swagger/v1/swagger.json';
const output = new URL('../../shared/openapi/openapi.json', import.meta.url);
console.log(`Fetching OpenAPI schema from ${url}`);
const response = await fetch(url);
if (!response.ok) {
throw new Error(`Failed to fetch OpenAPI schema: ${response.status} ${response.statusText}`);
}
const schema = await response.text();
await mkdir(new URL('../../shared/openapi', import.meta.url), { recursive: true });
await writeFile(output, schema);
console.log(`Wrote ${output.pathname}`);