Skip to content

Commit 165f11d

Browse files
committed
build: small fixes
- Throw an error when a schema component is refered to in the schema but not the definition isn't present - Don't add the `action` property if it is already present in the `required` field
1 parent 1dfdb2b commit 165f11d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

scripts/build.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ async function run() {
5959
}
6060
if (key === "$ref" && typeof obj[key] === "string") {
6161
const ref = obj[key].split("/").at(-1);
62-
tempSchema.components.schemas[ref] = schema.components.schemas[ref];
62+
const originalSchemaComponent = schema.components.schemas[ref];
63+
if (originalSchemaComponent === undefined) {
64+
throw new Error(`Schema component ${obj[key]} not found`);
65+
}
66+
tempSchema.components.schemas[ref] = originalSchemaComponent;
6367
// Call the function with the new definition to handle any of it's `$ref`s, and `enterprise` keys
6468
specialHandling(tempSchema.components.schemas[ref]);
6569
} else {
@@ -70,7 +74,7 @@ async function run() {
7074
};
7175

7276
function addActionToRequired(schema) {
73-
if (schema.properties.action !== undefined) {
77+
if (schema.properties.action !== undefined && schema.required !== undefined && !schema.required.includes("action")){
7478
schema.required.push("action");
7579
}
7680
}

0 commit comments

Comments
 (0)