From 08f1c4a9c3254fc70690be488e533c2dbdf739b9 Mon Sep 17 00:00:00 2001 From: Gerald Pinder Date: Sat, 26 Oct 2024 15:35:46 -0400 Subject: [PATCH] fix: Add additionalProperties = false for schemas --- fetchModuleSchemas.js | 8 +++++++- src-tsp/main.tsp | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/fetchModuleSchemas.js b/fetchModuleSchemas.js index 02cbf22..3e11562 100644 --- a/fetchModuleSchemas.js +++ b/fetchModuleSchemas.js @@ -21,12 +21,18 @@ for (const module of modules) { text = text // add `...ModuleDefaults;` after the model type .split("\n") .flatMap(line => { + if (line.trimStart().startsWith("model")) { + return [ + `@extension("additionalProperties", false)`, + line + ]; + } if (line.trimStart().startsWith(`type: "${module.name}"`)) { return [ line, '', ' ...ModuleDefaults; // added by fetchModuleSchemas.js', - ] + ]; } else { return line; } diff --git a/src-tsp/main.tsp b/src-tsp/main.tsp index 28ae83d..3f1a225 100644 --- a/src-tsp/main.tsp +++ b/src-tsp/main.tsp @@ -4,6 +4,7 @@ import "./modules/index.tsp"; using TypeSpec.JsonSchema; @jsonSchema("recipe-v1.json") +@extension("additionalProperties", false) model Recipe { /** * The image name. Used when publishing to GHCR as `ghcr.io/user/name`. @@ -57,6 +58,7 @@ model Recipe { } @jsonSchema("stage-list-v1.json") +@extension("additionalProperties", false) model StageList { /** * A list of [stages](https://blue-build.org/reference/stages/) that are executed before the build of the final image. @@ -72,6 +74,7 @@ union StageEntry { } @jsonSchema("stage-v1.json") +@extension("additionalProperties", false) model Stage { /** * The name of the stage. This is used when referencing @@ -92,6 +95,7 @@ model Stage { } @jsonSchema("module-list-v1.json") +@extension("additionalProperties", false) model ModuleList { /** * A list of [modules](https://blue-build.org/reference/module/) that is executed in order. Multiple of the same module can be included. @@ -109,6 +113,7 @@ union ModuleEntry { @jsonSchema("module-v1.json") @oneOf +@extension("additionalProperties", false) union Module { RepoModule, CustomModule, @@ -135,6 +140,7 @@ model CustomModule { ...Record; } +@extension("additionalProperties", false) model ImportedModule { /** The path to another file containing module configuration to import here. * https://blue-build.org/how-to/multiple-files/ @@ -143,6 +149,7 @@ model ImportedModule { } @jsonSchema("module-stage-list-v1.json") +@extension("additionalProperties", false) model ModuleStageList { ...ModuleList; ...StageList;