Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
steering
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
AURA
steering
Commits
96ddc3e2
Verified
Commit
96ddc3e2
authored
1 year ago
by
Ernesto Rico Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
feat: define and use JSON Schema for tags
parent
e32adc72
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#5678
passed
1 year ago
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
program/serializers.py
+10
-1
10 additions, 1 deletion
program/serializers.py
with
10 additions
and
1 deletion
program/serializers.py
+
10
−
1
View file @
96ddc3e2
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
import
re
import
re
from
typing
import
List
,
TypedDict
from
typing
import
List
,
TypedDict
from
drf_jsonschema_serializer
import
JSONSchemaField
from
rest_framework
import
serializers
from
rest_framework
import
serializers
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
...
@@ -806,6 +807,14 @@ class NoteLinkSerializer(serializers.ModelSerializer):
...
@@ -806,6 +807,14 @@ class NoteLinkSerializer(serializers.ModelSerializer):
fields
=
(
"
type
"
,
"
url
"
)
fields
=
(
"
type
"
,
"
url
"
)
tags_json_schema
=
{
"
type
"
:
"
array
"
,
"
items
"
:
{
"
type
"
:
"
string
"
}
}
class
NoteSerializer
(
serializers
.
ModelSerializer
):
class
NoteSerializer
(
serializers
.
ModelSerializer
):
contributor_ids
=
serializers
.
PrimaryKeyRelatedField
(
contributor_ids
=
serializers
.
PrimaryKeyRelatedField
(
many
=
True
,
queryset
=
Host
.
objects
.
all
(),
source
=
"
contributors
"
many
=
True
,
queryset
=
Host
.
objects
.
all
(),
source
=
"
contributors
"
...
@@ -815,7 +824,7 @@ class NoteSerializer(serializers.ModelSerializer):
...
@@ -815,7 +824,7 @@ class NoteSerializer(serializers.ModelSerializer):
)
)
links
=
NoteLinkSerializer
(
many
=
True
,
required
=
False
)
links
=
NoteLinkSerializer
(
many
=
True
,
required
=
False
)
playlist_id
=
serializers
.
IntegerField
(
required
=
False
)
playlist_id
=
serializers
.
IntegerField
(
required
=
False
)
tags
=
serializers
.
JSONField
(
default
=
[],
required
=
False
)
tags
=
JSONSchemaField
(
tags_json_schema
)
timeslot_id
=
serializers
.
PrimaryKeyRelatedField
(
timeslot_id
=
serializers
.
PrimaryKeyRelatedField
(
queryset
=
TimeSlot
.
objects
.
all
(),
required
=
False
queryset
=
TimeSlot
.
objects
.
all
(),
required
=
False
)
)
...
...
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