Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,260 changes: 2,260 additions & 0 deletions apps/api/openapi/sam-cli.openapi.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
"test:coverage": "vitest run --coverage",
"typecheck": "tsc --noEmit",
"lint": "eslint 'src/**/*.ts' 'tests/**/*.ts'",
"openapi:generate": "tsx scripts/generate-openapi.ts",
"openapi:check": "tsx scripts/generate-openapi.ts --check",
"deploy": "wrangler deploy",
"deploy:staging": "wrangler deploy --env staging"
},
Expand Down
36 changes: 36 additions & 0 deletions apps/api/scripts/generate-openapi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { mkdir, readFile, writeFile } from 'node:fs/promises';
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';

import { samCliOpenApiDocument } from '../src/openapi/sam-cli';

const currentDir = dirname(fileURLToPath(import.meta.url));
const apiRoot = resolve(currentDir, '..');
const outputPath = resolve(apiRoot, 'openapi/sam-cli.openapi.json');

function serializeContract(): string {
return `${JSON.stringify(samCliOpenApiDocument, null, 2)}\n`;
}

async function main(): Promise<void> {
const checkOnly = process.argv.includes('--check');
const contract = serializeContract();

if (checkOnly) {
const existing = await readFile(outputPath, 'utf8');
if (existing !== contract) {
throw new Error(
`OpenAPI contract is stale. Run pnpm --filter @simple-agent-manager/api openapi:generate and commit ${outputPath}.`,
);
}
return;
}

await mkdir(dirname(outputPath), { recursive: true });
await writeFile(outputPath, contract, 'utf8');
}

main().catch((err: unknown) => {

Check warning on line 33 in apps/api/scripts/generate-openapi.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Prefer top-level await over using a promise chain.

See more on https://sonarcloud.io/project/issues?id=raphaeltm_simple-agent-manager&issues=AZ6D1W7hkw1Sk8lwaD7X&open=AZ6D1W7hkw1Sk8lwaD7X&pullRequest=1172
console.error(err instanceof Error ? err.message : String(err));
process.exit(1);
});
Loading
Loading