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

TMSS-000: config Access-Control. Our schemas use url's to other schemas,...

TMSS-000: config Access-Control. Our schemas use  url's to other schemas, mainly pointing to our own common schemas with base definitions. We instruct the client to allow fetching those.
parent f4c84124
No related branches found
No related tags found
No related merge requests found
...@@ -51,7 +51,13 @@ def get_template_json_schema(request, template:str, name:str, version:str): ...@@ -51,7 +51,13 @@ def get_template_json_schema(request, template:str, name:str, version:str):
template_model = apps.get_model("tmssapp", template) template_model = apps.get_model("tmssapp", template)
template_instance = get_object_or_404(template_model, name=name, version=version) template_instance = get_object_or_404(template_model, name=name, version=version)
schema = template_instance.schema schema = template_instance.schema
return JsonResponse(schema, json_dumps_params={"indent":2}) response = JsonResponse(schema, json_dumps_params={"indent":2})
# config Access-Control. Our schemas use $ref url's to other schemas, mainly pointing to our own common schemas with base definitions.
# We instruct the client to allow fetching those.
response["Access-Control-Allow-Origin"] = "*"
response["Access-Control-Allow-Methods"] = "GET, OPTIONS"
return response
def utc(request): def utc(request):
......
...@@ -112,12 +112,10 @@ class AbstractTemplateViewSet(LOFARViewSet): ...@@ -112,12 +112,10 @@ class AbstractTemplateViewSet(LOFARViewSet):
def retrieve(self, request, pk=None, **kwargs): def retrieve(self, request, pk=None, **kwargs):
response = super().retrieve(request, pk, **kwargs) response = super().retrieve(request, pk, **kwargs)
if 'application/json' in request.accepted_media_type: # config Access-Control. Our schemas use $ref url's to other schemas, mainly pointing to our own common schemas with base definitions.
# config Access-Control. Our schemas use $ref url's to other schemas, mainly pointing to our own common schemas with base definitions. # We instruct the client to allow fetching those.
# We instruct the client to allow fetching those. response["Access-Control-Allow-Origin"] = "*"
response["Access-Control-Allow-Origin"] = "*" response["Access-Control-Allow-Methods"] = "GET, OPTIONS"
response["Access-Control-Allow-Methods"] = "GET, OPTIONS"
return response return response
@swagger_auto_schema(responses={200: 'The schema as a JSON object', @swagger_auto_schema(responses={200: 'The schema as a JSON object',
......
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