Skip to content

Commit 5e16c10

Browse files
feedback
1 parent 30cf3a5 commit 5e16c10

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,9 @@ RUN chown -R sourcebot:sourcebot /app
220220
# Copy zoekt proto files (needed for gRPC client at runtime)
221221
COPY --chown=sourcebot:sourcebot vendor/zoekt/grpc/protos /app/vendor/zoekt/grpc/protos
222222

223+
# Copy OpenAPI docs
224+
COPY --chown=sourcebot:sourcebot docs/api-reference/sourcebot-public.openapi.json /app/docs/api-reference/sourcebot-public.openapi.json
225+
223226
# Copy all of the things
224227
COPY --chown=sourcebot:sourcebot --from=web-builder /app/packages/web/public ./packages/web/public
225228
COPY --chown=sourcebot:sourcebot --from=web-builder /app/packages/web/.next/standalone ./

packages/web/src/app/api/(server)/openapi.json/route.ts

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,15 @@ import { apiHandler } from '@/lib/apiHandler';
44

55
export const dynamic = 'force-dynamic';
66

7-
const openApiPathCandidates = [
8-
path.resolve(process.cwd(), 'docs/api-reference/sourcebot-public.openapi.json'),
9-
path.resolve(process.cwd(), '../docs/api-reference/sourcebot-public.openapi.json'),
10-
path.resolve(process.cwd(), '../../docs/api-reference/sourcebot-public.openapi.json'),
11-
];
12-
137
async function loadOpenApiDocument() {
14-
for (const candidate of openApiPathCandidates) {
15-
try {
16-
return JSON.parse(await fs.readFile(candidate, 'utf8'));
17-
} catch (error) {
18-
if ((error as NodeJS.ErrnoException).code !== 'ENOENT') {
19-
throw error;
20-
}
8+
const openApiPath = path.resolve(process.cwd(), '../../docs/api-reference/sourcebot-public.openapi.json');
9+
try {
10+
return JSON.parse(await fs.readFile(openApiPath, 'utf8'));
11+
} catch (error) {
12+
if ((error as NodeJS.ErrnoException).code !== 'ENOENT') {
13+
throw error;
2114
}
2215
}
23-
24-
throw new Error('OpenAPI spec file not found');
2516
}
2617

2718
export const GET = apiHandler(async () => {

0 commit comments

Comments
 (0)