Skip to content

Commit 7c25aac

Browse files
authored
Bug: Spec Validation in dev Command (#68)
1 parent 26a655e commit 7c25aac

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

src/commands/deploy.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ export const deployCommand = new Command()
2626
console.error("OpenAPI specification validation failed.");
2727
return;
2828
}
29-
const accountId = xMbSpec["account-id"];
3029

3130
const pluginService = new PluginService();
3231
try {

src/commands/dev.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ async function fetchAndValidateSpec(url: string): Promise<ValidationResult> {
5252
try {
5353
console.log("[Dev] Validating OpenAPI spec...");
5454
const validation = await validateAndParseOpenApiSpec(specUrl);
55-
({ isValid, accountId } = validation);
55+
if (!validation) {
56+
throw new Error("Invalid OpenAPI spec");
57+
}
58+
isValid = true;
59+
accountId = validation["account-id"];
5660
console.log("[Dev] Validation result:", { isValid, accountId });
5761
} catch (error) {
5862
console.error(

src/utils/openapi.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,10 @@ export async function validateAndParseOpenApiSpec(
5151
}
5252

5353
const xMbSpec = apiResponse["x-mb"];
54-
isXMbSpec(xMbSpec);
55-
56-
return xMbSpec;
54+
if (isXMbSpec(xMbSpec)) {
55+
return xMbSpec;
56+
}
57+
throw new Error("Invalid OpenAPI spec");
5758
} catch (error) {
5859
console.error(
5960
"Unexpected error:",

0 commit comments

Comments
 (0)