diff --git a/netbox/dcim/forms/model_forms.py b/netbox/dcim/forms/model_forms.py index 44703d1a0..421c3d824 100644 --- a/netbox/dcim/forms/model_forms.py +++ b/netbox/dcim/forms/model_forms.py @@ -409,6 +409,7 @@ class DeviceTypeForm(NetBoxModelForm): class ModuleTypeProfileForm(NetBoxModelForm): schema = JSONField( label=_('Schema'), + required=False, help_text=_("Enter a valid JSON schema to define supported attributes.") ) comments = CommentField() diff --git a/netbox/dcim/migrations/0204_moduletypeprofile.py b/netbox/dcim/migrations/0204_moduletypeprofile.py index 70a45d4a0..6f3348679 100644 --- a/netbox/dcim/migrations/0204_moduletypeprofile.py +++ b/netbox/dcim/migrations/0204_moduletypeprofile.py @@ -25,7 +25,7 @@ class Migration(migrations.Migration): ('description', models.CharField(blank=True, max_length=200)), ('comments', models.TextField(blank=True)), ('name', models.CharField(max_length=100, unique=True)), - ('schema', models.JSONField()), + ('schema', models.JSONField(blank=True, null=True)), ('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')), ], options={ diff --git a/netbox/dcim/models/modules.py b/netbox/dcim/models/modules.py index f677c6ebc..6f64275ce 100644 --- a/netbox/dcim/models/modules.py +++ b/netbox/dcim/models/modules.py @@ -33,6 +33,8 @@ class ModuleTypeProfile(PrimaryModel): unique=True ) schema = models.JSONField( + blank=True, + null=True, verbose_name=_('schema') ) @@ -50,12 +52,13 @@ class ModuleTypeProfile(PrimaryModel): super().clean() # Validate the schema definition - try: - JSONSchemaValidator.check_schema(self.schema) - except SchemaError as e: - raise ValidationError({ - 'schema': _("Invalid schema: {error}").format(error=e) - }) + if self.schema: + try: + JSONSchemaValidator.check_schema(self.schema) + except SchemaError as e: + raise ValidationError({ + 'schema': _("Invalid schema: {error}").format(error=e) + }) class ModuleType(ImageAttachmentsMixin, PrimaryModel, WeightMixin):