Add JSON schema validation for Context Data #11107

Closed
opened 2025-12-29 21:40:26 +01:00 by adam · 2 comments
Owner

Originally created by @TribuneX on GitHub (May 2, 2025).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v4.3.0

Feature type

New functionality

Proposed functionality

Similar to the proposal outline in https://github.com/netbox-community/netbox/issues/19025 it would be really useful if a user could specify a json schema along with a config context entry.

Use case

The structure of config context can be crucial for consuming systems (e.g. automated provisioning). We currently implement JSON schema validation with custom validation. However, it is always difficult to identify which config context a certain validation should be applied to.

Being able to assign a schema directly to a config context entry would remove that complexity.

Database changes

Add an optional schema JSONField to the Config Context data model.

External dependencies

jsonschema for implementing the validation in the backend

Originally created by @TribuneX on GitHub (May 2, 2025). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v4.3.0 ### Feature type New functionality ### Proposed functionality Similar to the proposal outline in https://github.com/netbox-community/netbox/issues/19025 it would be really useful if a user could specify a json schema along with a [config context](https://netboxlabs.com/docs/netbox/en/stable/features/context-data/) entry. ### Use case The structure of config context can be crucial for consuming systems (e.g. automated provisioning). We currently implement JSON schema validation with [custom validation](https://netboxlabs.com/docs/netbox/en/stable/customization/custom-validation/). However, it is always difficult to identify which config context a certain validation should be applied to. Being able to assign a schema directly to a config context entry would remove that complexity. ### Database changes Add an optional schema `JSONField` to the Config Context data model. ### External dependencies `jsonschema` for implementing the validation in the backend
adam added the status: acceptedtype: featurecomplexity: medium labels 2025-12-29 21:40:26 +01:00
adam closed this issue 2025-12-29 21:40:26 +01:00
Author
Owner

@jeremystretch commented on GitHub (Jul 17, 2025):

Somewhat related to FR #19025

@jeremystretch commented on GitHub (Jul 17, 2025): Somewhat related to FR #19025
Author
Owner

@jeremystretch commented on GitHub (Aug 8, 2025):

Add an optional schema JSONField to the Config Context data model.

Rather than adding a schema definition field directly on the ConfigContext model, which would be of limited utility, I've introduced a new ConfigContextProfile model to hold the schema definition. This allows it to be reused, and separates its definition from the data it validates.

@jeremystretch commented on GitHub (Aug 8, 2025): > Add an optional schema JSONField to the Config Context data model. Rather than adding a schema definition field directly on the ConfigContext model, which would be of limited utility, I've introduced a new ConfigContextProfile model to hold the schema definition. This allows it to be reused, and separates its definition from the data it validates.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11107