Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
LOFAR
Manage
Activity
Members
Labels
Plan
Issues
Wiki
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RadioObservatory
LOFAR
Commits
6c8234e5
Commit
6c8234e5
authored
4 years ago
by
Jorrit Schaap
Browse files
Options
Downloads
Patches
Plain Diff
TMSS-272
: implemented a generic template get schema as json url and method
parent
4af57fdc
No related branches found
No related tags found
1 merge request
!213
Resolve TMSS-272
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
SAS/TMSS/src/tmss/tmssapp/views.py
+6
-18
6 additions, 18 deletions
SAS/TMSS/src/tmss/tmssapp/views.py
SAS/TMSS/src/tmss/urls.py
+2
-1
2 additions, 1 deletion
SAS/TMSS/src/tmss/urls.py
with
8 additions
and
19 deletions
SAS/TMSS/src/tmss/tmssapp/views.py
+
6
−
18
View file @
6c8234e5
...
...
@@ -8,6 +8,7 @@ from lofar.sas.tmss.tmss.tmssapp.adapters.parset import convert_to_parset
from
drf_yasg.utils
import
swagger_auto_schema
from
rest_framework.permissions
import
AllowAny
from
rest_framework.decorators
import
authentication_classes
,
permission_classes
from
django.apps
import
apps
def
subtask_template_default_specification
(
request
,
subtask_template_pk
:
int
):
...
...
@@ -39,24 +40,11 @@ def task_specify_observation(request, pk=None):
@authentication_classes
([
AllowAny
])
@swagger_auto_schema
(
responses
=
{
200
:
'
JSON schema
'
,
404
:
'
the schema with requested <name> and <version> is not available
'
},
operation_description
=
"
Get the JSON schema with the given <name> and <version> as application/json content response.
"
)
def
get_
common
_json_schema
(
request
,
name
:
str
,
version
:
str
):
template
=
get_object_or_404
(
models
.
CommonSchemaTemplate
,
name
=
name
,
version
=
version
)
schema
=
template
.
schema
schema
[
'
$id
'
]
=
request
.
get_raw_uri
()
operation_description
=
"
Get the JSON schema
for the given <template>
with the given <name> and <version> as application/json content response.
"
)
def
get_
template
_json_schema
(
request
,
template
:
str
,
name
:
str
,
version
:
str
):
template
_model
=
apps
.
get_model
(
"
tmssapp
"
,
template
)
template_instance
=
get_object_or_404
(
template_model
,
name
=
name
,
version
=
version
)
schema
=
template_instance
.
schema
return
JsonResponse
(
schema
,
json_dumps_params
=
{
"
indent
"
:
2
})
@permission_classes
([
AllowAny
])
@authentication_classes
([
AllowAny
])
@swagger_auto_schema
(
responses
=
{
200
:
'
JSON schema
'
,
404
:
'
the schema with requested <name> and <version> is not available
'
},
operation_description
=
"
Get the JSON schema with the given <name> and <version> as application/json content response.
"
)
def
get_subtask_template_json_schema
(
request
,
name
:
str
,
version
:
str
):
template
=
get_object_or_404
(
models
.
SubtaskTemplate
,
name
=
name
,
version
=
version
)
schema
=
template
.
schema
schema
[
'
$id
'
]
=
request
.
get_raw_uri
()
return
JsonResponse
(
schema
,
json_dumps_params
=
{
"
indent
"
:
2
})
This diff is collapsed.
Click to expand it.
SAS/TMSS/src/tmss/urls.py
+
2
−
1
View file @
6c8234e5
...
...
@@ -54,7 +54,8 @@ urlpatterns = [
path
(
'
docs/
'
,
include_docs_urls
(
title
=
'
TMSS API
'
)),
re_path
(
r
'
^swagger(?P<format>\.json|\.yaml)$
'
,
swagger_schema_view
.
without_ui
(
cache_timeout
=
0
),
name
=
'
schema-json
'
),
path
(
'
swagger/
'
,
swagger_schema_view
.
with_ui
(
'
swagger
'
,
cache_timeout
=
0
),
name
=
'
schema-swagger-ui
'
),
path
(
'
redoc/
'
,
swagger_schema_view
.
with_ui
(
'
redoc
'
,
cache_timeout
=
0
),
name
=
'
schema-redoc
'
)
path
(
'
redoc/
'
,
swagger_schema_view
.
with_ui
(
'
redoc
'
,
cache_timeout
=
0
),
name
=
'
schema-redoc
'
),
path
(
'
schemas/<str:template>/<str:name>/<str:version>/
'
,
views
.
get_template_json_schema
,
name
=
'
template_json_schema
'
)
]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment