Skip to content
Merged
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
8 changes: 8 additions & 0 deletions openapi-ts.config.local.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineConfig, defaultPlugins } from '@hey-api/openapi-ts';

export default defineConfig({
// Local gateway with new endpoints
input: 'http://localhost:4000/api/eor/openapi',
output: 'src/client',
plugins: defaultPlugins,
});
2 changes: 2 additions & 0 deletions openapi-ts.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { defineConfig, defaultPlugins } from '@hey-api/openapi-ts';

export default defineConfig({
// Production gateway - use npm run openapi-ts for production generation
// For local gateway with new endpoints, use npm run openapi-ts:local instead
input: 'https://gateway.remote.com/v1/docs/openapi.json',
output: 'src/client',
plugins: defaultPlugins,
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"lint:workflows:fix": "zizmor --fix .github/workflows/",
"format": "oxfmt",
"openapi-ts": "openapi-ts && npm run format",
"openapi-ts:local": "openapi-ts -f openapi-ts.config.local.ts && tsx scripts/cleanup-local-openapi.ts && npm run format",
"test": "vitest",
"test:coverage": "vitest --coverage",
"coverage:extract": "tsx scripts/extract-coverage.ts",
Expand Down
47 changes: 47 additions & 0 deletions scripts/cleanup-local-openapi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { readFileSync, writeFileSync } from 'fs';
import { resolve } from 'path';

/**
* Removes /api/eor prefix from generated OpenAPI client files
* This is needed when generating from local OpenAPI spec that includes the prefix
*/
function cleanupApiEorPrefix() {
const files = [
resolve(process.cwd(), 'src/client/sdk.gen.ts'),
resolve(process.cwd(), 'src/client/types.gen.ts'),
];

let totalReplacements = 0;

for (const filePath of files) {
try {
let content = readFileSync(filePath, 'utf-8');
const originalContent = content;

// Replace /api/eor/ prefix with / (handles v1/, v2/, auth/, and any other paths)
content = content.replace(/url: '\/api\/eor\//g, "url: '/");
Comment thread
gabrielseco marked this conversation as resolved.

if (content !== originalContent) {
writeFileSync(filePath, content, 'utf-8');
const fileName = filePath.split('/').pop();
const replacements = (originalContent.match(/\/api\/eor\//g) || [])
.length;
console.log(`✓ Cleaned ${replacements} URLs in ${fileName}`);
totalReplacements += replacements;
}
} catch (error) {
console.error(`Error processing ${filePath}:`, error);
process.exit(1);
}
}

if (totalReplacements > 0) {
console.log(
`\n✓ Successfully removed /api/eor prefix from ${totalReplacements} URLs`,
);
} else {
console.log('\n✓ No /api/eor prefixes found');
}
}

cleanupApiEorPrefix();
Loading