From 6b8782556cb7d1f92c9c44d84050ed23c8a99081 Mon Sep 17 00:00:00 2001 From: "Jens L." Date: Fri, 20 Dec 2024 03:27:28 +0100 Subject: [PATCH] blueprints: fix schema for meta models (#12421) Signed-off-by: Jens Langhammer --- .../management/commands/make_blueprint_schema.py | 7 ++++++- blueprints/schema.json | 6 +----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/authentik/blueprints/management/commands/make_blueprint_schema.py b/authentik/blueprints/management/commands/make_blueprint_schema.py index 9b3f27b602..8d97c7e9f9 100644 --- a/authentik/blueprints/management/commands/make_blueprint_schema.py +++ b/authentik/blueprints/management/commands/make_blueprint_schema.py @@ -126,7 +126,7 @@ class Command(BaseCommand): def_name_perm = f"model_{model_path}_permissions" def_path_perm = f"#/$defs/{def_name_perm}" self.schema["$defs"][def_name_perm] = self.model_permissions(model) - return { + template = { "type": "object", "required": ["model", "identifiers"], "properties": { @@ -143,6 +143,11 @@ class Command(BaseCommand): "identifiers": {"$ref": def_path}, }, } + # Meta models don't require identifiers, as there's no matching database model to find + if issubclass(model, BaseMetaModel): + del template["properties"]["identifiers"] + template["required"].remove("identifiers") + return template def field_to_jsonschema(self, field: Field) -> dict: """Convert a single field to json schema""" diff --git a/blueprints/schema.json b/blueprints/schema.json index cc8774f020..e26feb2266 100644 --- a/blueprints/schema.json +++ b/blueprints/schema.json @@ -3884,8 +3884,7 @@ { "type": "object", "required": [ - "model", - "identifiers" + "model" ], "properties": { "model": { @@ -3915,9 +3914,6 @@ }, "attrs": { "$ref": "#/$defs/model_authentik_blueprints.metaapplyblueprint" - }, - "identifiers": { - "$ref": "#/$defs/model_authentik_blueprints.metaapplyblueprint" } } }