blueprints: fix schema for meta models (#12421)

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens L.
2024-12-20 03:27:28 +01:00
committed by GitHub
parent 7f6f3b6602
commit 6b8782556c
2 changed files with 7 additions and 6 deletions

View File

@ -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"""

View File

@ -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"
}
}
}