Skip to content

Commit 8ac6668

Browse files
committed
refactor(api): improve JSON parsing and type assertion for schema retrieval
1 parent 91f71aa commit 8ac6668

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

app/api/get-schema/[name]/route.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,13 @@ export async function GET(
4646
console.log(`Attempting to read schema file: ${filePath}`);
4747

4848
const fileContent: string = await fs.readFile(filePath, "utf-8");
49-
// Parse JSON with proper type assertion
50-
const schemaJson: Record<string, unknown> = JSON.parse(fileContent);
49+
// Parse JSON with proper type assertion that satisfies ESLint
50+
const parsedContent = JSON.parse(fileContent);
51+
// Use type assertion after validation to satisfy ESLint
52+
const schemaJson: Record<string, unknown> =
53+
typeof parsedContent === 'object' && parsedContent !== null
54+
? parsedContent as Record<string, unknown>
55+
: {};
5156

5257
return NextResponse.json(schemaJson);
5358
} catch (error: unknown) {

0 commit comments

Comments
 (0)