diff --git a/src/openforms/registrations/contrib/json/config.py b/src/openforms/registrations/contrib/json/config.py index 091cc529e0..7b7c9580eb 100644 --- a/src/openforms/registrations/contrib/json/config.py +++ b/src/openforms/registrations/contrib/json/config.py @@ -15,20 +15,22 @@ class JSONOptionsSerializer(JsonSchemaSerializerMixin, serializers.Serializer): queryset=Service.objects.all(), label=_("Service"), help_text=_("Which service to use."), + required=True, ) - # TODO-4098: show the complete API endpoint as a (tooltip) hint after user entry? Might be a front-end thing... + # TODO-4098: show the complete API endpoint as a (tooltip) hint after user entry? + # Might be a front-end thing... relative_api_endpoint = serializers.CharField( max_length=255, label=_("Relative API endpoint"), help_text=_("The API endpoint to send the data to (relative to the service API root)."), allow_blank=True, + required=False, ) form_variables = serializers.ListField( child=FormioVariableKeyField(max_length=50), label=_("Form variable key list"), - help_text=_( - "A comma-separated list of form variables (can also include static variables) to use." - ) + help_text=_("A list of form variables (can also include static variables) to use."), + required=True, ) diff --git a/src/openforms/registrations/contrib/json/plugin.py b/src/openforms/registrations/contrib/json/plugin.py index 13f4a9c843..c3276a7c1c 100644 --- a/src/openforms/registrations/contrib/json/plugin.py +++ b/src/openforms/registrations/contrib/json/plugin.py @@ -20,6 +20,8 @@ class JSONRegistration(BasePlugin): def register_submission(self, submission: Submission, options: JSONOptions) -> None: # TODO-4908: the email plugin works with a EmailConfig singleton model. Is that useful here? + # Doesn't look like it. Seems to be used as a model for default configuration options, which + # which wouldn't really be useful for this plugin # TODO-4908: any other form field types that need 'special attention'? @@ -40,8 +42,9 @@ def register_submission(self, submission: Submission, options: JSONOptions) -> N variable.key: variable.initial_value for variable in static_variables } - # TODO-4908: what should the behaviour be when a form - # variable is not in the data or static variables? + # TODO-4908: what should the behaviour be when a form variable is not in the data or static variables? + # Raising an error probably a good idea, the form variable is currently just set to None in the + # resulting values dict # Update values dict with relevant form data values.update({ form_variable: submission.data.get( @@ -58,7 +61,7 @@ def register_submission(self, submission: Submission, options: JSONOptions) -> N # TODO-4098: is the service type relevant here? with build_client(service) as client: response = client.post( - options["relative_api_endpoint"], + options.get("relative_api_endpoint", ""), json=json, headers={"Content-Type": "application/json"}, )