Skip to content
Snippets Groups Projects
Commit 872fb18e authored by Jorrit Schaap's avatar Jorrit Schaap
Browse files

TMSS-272: minor fixes

parent 353594c5
No related branches found
No related tags found
1 merge request!213Resolve TMSS-272
...@@ -111,17 +111,6 @@ class SubtaskTemplateViewSet(LOFARViewSet): ...@@ -111,17 +111,6 @@ class SubtaskTemplateViewSet(LOFARViewSet):
subtask_template = get_object_or_404(models.SubtaskTemplate, pk=pk) subtask_template = get_object_or_404(models.SubtaskTemplate, pk=pk)
return JsonResponse(subtask_template.schema) 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', @swagger_auto_schema(responses={200: 'JSON object with all the defaults from the schema filled in',
403: 'forbidden'}, 403: 'forbidden'},
operation_description="Get a JSON object with all the defaults from the schema filled in.") operation_description="Get a JSON object with all the defaults from the schema filled in.")
......
...@@ -51,9 +51,7 @@ class CommonSchemaTemplateViewSet(LOFARViewSet): ...@@ -51,9 +51,7 @@ class CommonSchemaTemplateViewSet(LOFARViewSet):
@action(methods=['get'], detail=True) @action(methods=['get'], detail=True)
def schema(self, request, pk=None): def schema(self, request, pk=None):
template = get_object_or_404(models.CommonSchemaTemplate, pk=pk) template = get_object_or_404(models.CommonSchemaTemplate, pk=pk)
base_url = "%s://%s" % (request.scheme, request.get_host()) return JsonResponse(template.schema)
schema = models.Template.update_tmss_common_json_schema_refs(template.schema, base_url)
return JsonResponse(schema)
@swagger_auto_schema(responses={200: 'The schema as a JSON object', @swagger_auto_schema(responses={200: 'The schema as a JSON object',
403: 'forbidden'}, 403: 'forbidden'},
...@@ -62,10 +60,19 @@ class CommonSchemaTemplateViewSet(LOFARViewSet): ...@@ -62,10 +60,19 @@ class CommonSchemaTemplateViewSet(LOFARViewSet):
def resolved_schema(self, request, pk=None): def resolved_schema(self, request, pk=None):
template = get_object_or_404(models.CommonSchemaTemplate, pk=pk) template = get_object_or_404(models.CommonSchemaTemplate, pk=pk)
base_url = "%s://%s" % (request.scheme, request.get_host()) base_url = "%s://%s" % (request.scheme, request.get_host())
schema = models.Template.update_tmss_common_json_schema_refs(template.schema, base_url) schema = json_utils.resolved_refs(template.schema)
schema = models.Template.flatten_schema(schema)
return JsonResponse(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): class GeneratorTemplateViewSet(LOFARViewSet):
queryset = models.GeneratorTemplate.objects.all() queryset = models.GeneratorTemplate.objects.all()
serializer_class = serializers.GeneratorTemplateSerializer serializer_class = serializers.GeneratorTemplateSerializer
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment