Simplify check for defaults and add another test

This commit is contained in:
Ola Hungerford
2025-03-18 06:23:25 -07:00
parent a85d5e7050
commit c463dc58c2
2 changed files with 7 additions and 2 deletions

View File

@@ -8,8 +8,7 @@ import { JsonObject } from "./jsonPathUtils";
*/
export function generateDefaultValue(schema: JsonSchemaType): JsonValue {
if ("default" in schema) {
// Ensure we don't return undefined even if schema.default is undefined
return schema.default === undefined ? null : schema.default;
return schema.default;
}
if (!schema.required) {