Fix mandatory field detection #175
1 changed files with 2 additions and 2 deletions
|
|
@ -49,7 +49,7 @@ def generate_django_model(schema, group, version, kind):
|
||||||
# resourceRef object
|
# resourceRef object
|
||||||
spec = schema["properties"].get("spec") or {}
|
spec = schema["properties"].get("spec") or {}
|
||||||
spec["properties"].pop("resourceRef", None)
|
spec["properties"].pop("resourceRef", None)
|
||||||
model_fields.update(build_object_fields(spec, "spec", parent_required=True))
|
model_fields.update(build_object_fields(spec, "spec", parent_required=False))
|
||||||
|
|
||||||
# Store the original schema on the model class
|
# Store the original schema on the model class
|
||||||
model_fields["SCHEMA"] = schema
|
model_fields["SCHEMA"] = schema
|
||||||
|
|
@ -69,7 +69,7 @@ def build_object_fields(schema, name, verbose_name_prefix=None, parent_required=
|
||||||
fields = {}
|
fields = {}
|
||||||
|
|
||||||
for field_name, field_schema in properties.items():
|
for field_name, field_schema in properties.items():
|
||||||
is_required = field_name in required_fields and parent_required
|
is_required = field_name in required_fields or parent_required
|
||||||
full_name = f"{name}.{field_name}"
|
full_name = f"{name}.{field_name}"
|
||||||
result = get_django_field(
|
result = get_django_field(
|
||||||
field_schema,
|
field_schema,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue