diff --git a/SAS/TMSS/src/tmss/tmssapp/viewsets/scheduling.py b/SAS/TMSS/src/tmss/tmssapp/viewsets/scheduling.py index 14eac2af4afad9a0a1db3bd2a37f5c8b34e625f9..3b1b00922cb89377ba0bb9a3d32eebc482b97363 100644 --- a/SAS/TMSS/src/tmss/tmssapp/viewsets/scheduling.py +++ b/SAS/TMSS/src/tmss/tmssapp/viewsets/scheduling.py @@ -111,17 +111,6 @@ class SubtaskTemplateViewSet(LOFARViewSet): subtask_template = get_object_or_404(models.SubtaskTemplate, pk=pk) return JsonResponse(subtask_template.schema) - @swagger_auto_schema(responses={200: 'The schema as a JSON object', - 403: 'forbidden'}, - operation_description="Get the schema as a JSON object.") - @action(methods=['get'], detail=True) - def resolved_schema(self, request, pk=None): - template = get_object_or_404(models.SubtaskTemplate, pk=pk) - base_url = "%s://%s" % (request.scheme, request.get_host()) - schema = models.Template.update_tmss_common_json_schema_refs(template.schema, base_url) - schema = models.Template.flatten_schema(schema) - return JsonResponse(schema) - @swagger_auto_schema(responses={200: 'JSON object with all the defaults from the schema filled in', 403: 'forbidden'}, operation_description="Get a JSON object with all the defaults from the schema filled in.") diff --git a/SAS/TMSS/src/tmss/tmssapp/viewsets/specification.py b/SAS/TMSS/src/tmss/tmssapp/viewsets/specification.py index 822efa47080acf062bba93354b3a024fa0a14fd9..9f2622df03213bedc9cfc052180b5f79f0cc5a3d 100644 --- a/SAS/TMSS/src/tmss/tmssapp/viewsets/specification.py +++ b/SAS/TMSS/src/tmss/tmssapp/viewsets/specification.py @@ -51,9 +51,7 @@ class CommonSchemaTemplateViewSet(LOFARViewSet): @action(methods=['get'], detail=True) def schema(self, request, pk=None): template = get_object_or_404(models.CommonSchemaTemplate, pk=pk) - base_url = "%s://%s" % (request.scheme, request.get_host()) - schema = models.Template.update_tmss_common_json_schema_refs(template.schema, base_url) - return JsonResponse(schema) + return JsonResponse(template.schema) @swagger_auto_schema(responses={200: 'The schema as a JSON object', 403: 'forbidden'}, @@ -62,10 +60,19 @@ class CommonSchemaTemplateViewSet(LOFARViewSet): def resolved_schema(self, request, pk=None): template = get_object_or_404(models.CommonSchemaTemplate, pk=pk) base_url = "%s://%s" % (request.scheme, request.get_host()) - schema = models.Template.update_tmss_common_json_schema_refs(template.schema, base_url) - schema = models.Template.flatten_schema(schema) + schema = json_utils.resolved_refs(template.schema) return JsonResponse(schema) + @swagger_auto_schema(responses={200: 'JSON object with all the defaults from the schema filled in', + 403: 'forbidden'}, + operation_description="Get a JSON object with all the defaults from the schema filled in.") + @action(methods=['get'], detail=True) + def default_specification(self, request, pk=None): + template = get_object_or_404(models.CommonSchemaTemplate, pk=pk) + spec = get_default_json_object_for_schema(template.schema) + return JsonResponse(spec) + + class GeneratorTemplateViewSet(LOFARViewSet): queryset = models.GeneratorTemplate.objects.all() serializer_class = serializers.GeneratorTemplateSerializer