Skip to content

Commit 3f1af11

Browse files
committed
Require channel ID for topic embed request
1 parent 3ded0ed commit 3f1af11

4 files changed

Lines changed: 78 additions & 20 deletions

File tree

js/EmbedTopicsRequest.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ export const SCHEMA = {
1010
"description": "Schema for embed topics requests received by RayServe",
1111
"additionalProperties": false,
1212
"definitions": {
13-
"id": {
14-
"$ref": "/schemas/common_embed_definitions#/definitions/uuid",
15-
"description": "The ID of the topic content node on Studio"
16-
},
1713
"title": {
1814
"type": "string",
1915
"description": "The title of the topic"
@@ -37,7 +33,8 @@ export const SCHEMA = {
3733
"additionalProperties": false,
3834
"properties": {
3935
"id": {
40-
"$ref": "#/definitions/id"
36+
"$ref": "/schemas/common_embed_definitions#/definitions/uuid",
37+
"description": "The ID of the topic content node on Studio"
4138
},
4239
"title": {
4340
"$ref": "#/definitions/title"
@@ -72,7 +69,12 @@ export const SCHEMA = {
7269
"additionalProperties": false,
7370
"properties": {
7471
"id": {
75-
"$ref": "#/definitions/id"
72+
"$ref": "/schemas/common_embed_definitions#/definitions/uuid",
73+
"description": "The ID of the topic content node on Studio"
74+
},
75+
"channel_id": {
76+
"$ref": "/schemas/common_embed_definitions#/definitions/uuid",
77+
"description": "The UUID of the channel that the topic belongs to"
7678
},
7779
"title": {
7880
"$ref": "#/definitions/title"
@@ -89,6 +91,7 @@ export const SCHEMA = {
8991
},
9092
"required": [
9193
"id",
94+
"channel_id",
9295
"title",
9396
"description",
9497
"language"

le_utils/constants/embed_topics_request.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616
"description": "Schema for embed topics requests received by RayServe",
1717
"additionalProperties": False,
1818
"definitions": {
19-
"id": {
20-
"$ref": "/schemas/common_embed_definitions#/definitions/uuid",
21-
"description": "The ID of the topic content node on Studio",
22-
},
2319
"title": {"type": "string", "description": "The title of the topic"},
2420
"description": {
2521
"type": "string",
@@ -39,7 +35,10 @@
3935
"description": "An ancestor in the tree structure",
4036
"additionalProperties": False,
4137
"properties": {
42-
"id": {"$ref": "#/definitions/id"},
38+
"id": {
39+
"$ref": "/schemas/common_embed_definitions#/definitions/uuid",
40+
"description": "The ID of the topic content node on Studio",
41+
},
4342
"title": {"$ref": "#/definitions/title"},
4443
"description": {"$ref": "#/definitions/description"},
4544
"language": {"$ref": "#/definitions/language"},
@@ -57,13 +56,20 @@
5756
"description": "A topic in the tree structure",
5857
"additionalProperties": False,
5958
"properties": {
60-
"id": {"$ref": "#/definitions/id"},
59+
"id": {
60+
"$ref": "/schemas/common_embed_definitions#/definitions/uuid",
61+
"description": "The ID of the topic content node on Studio",
62+
},
63+
"channel_id": {
64+
"$ref": "/schemas/common_embed_definitions#/definitions/uuid",
65+
"description": "The UUID of the channel that the topic belongs to",
66+
},
6167
"title": {"$ref": "#/definitions/title"},
6268
"description": {"$ref": "#/definitions/description"},
6369
"language": {"$ref": "#/definitions/language"},
6470
"ancestors": {"$ref": "#/definitions/ancestors"},
6571
},
66-
"required": ["id", "title", "description", "language"],
72+
"required": ["id", "channel_id", "title", "description", "language"],
6773
},
6874
},
6975
"properties": {

spec/schema-embed_topics_request.json

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
"description": "Schema for embed topics requests received by RayServe",
66
"additionalProperties": false,
77
"definitions": {
8-
"id": {
9-
"$ref": "/schemas/common_embed_definitions#/definitions/uuid",
10-
"description": "The ID of the topic content node on Studio"
11-
},
128
"title": {
139
"type": "string",
1410
"description": "The title of the topic"
@@ -32,7 +28,8 @@
3228
"additionalProperties": false,
3329
"properties": {
3430
"id": {
35-
"$ref": "#/definitions/id"
31+
"$ref": "/schemas/common_embed_definitions#/definitions/uuid",
32+
"description": "The ID of the topic content node on Studio"
3633
},
3734
"title": {
3835
"$ref": "#/definitions/title"
@@ -67,7 +64,12 @@
6764
"additionalProperties": false,
6865
"properties": {
6966
"id": {
70-
"$ref": "#/definitions/id"
67+
"$ref": "/schemas/common_embed_definitions#/definitions/uuid",
68+
"description": "The ID of the topic content node on Studio"
69+
},
70+
"channel_id": {
71+
"$ref": "/schemas/common_embed_definitions#/definitions/uuid",
72+
"description": "The UUID of the channel that the topic belongs to"
7173
},
7274
"title": {
7375
"$ref": "#/definitions/title"
@@ -84,6 +86,7 @@
8486
},
8587
"required": [
8688
"id",
89+
"channel_id",
8790
"title",
8891
"description",
8992
"language"

tests/test_schemas.py

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ def test_embed__topics__without_ancestors__valid():
287287
"topics": [
288288
{
289289
"id": str(uuid.uuid4()),
290+
"channel_id": str(uuid.uuid4()),
290291
"title": "Target topic",
291292
"description": "Target description",
292293
"language": "en",
@@ -308,6 +309,7 @@ def test_embed__topics__with_ancestors__valid():
308309
"topics": [
309310
{
310311
"id": str(uuid.uuid4()),
312+
"channel_id": str(uuid.uuid4()),
311313
"title": "Target topic",
312314
"description": "Target description",
313315
"language": "en",
@@ -316,7 +318,6 @@ def test_embed__topics__with_ancestors__valid():
316318
"id": str(uuid.uuid4()),
317319
"title": "Parent topic",
318320
"description": "Parent description",
319-
"language": "en",
320321
"level": 1,
321322
}
322323
],
@@ -338,6 +339,7 @@ def test_embed__topics__invalid_id():
338339
"topics": [
339340
{
340341
"id": "123",
342+
"channel_id": str(uuid.uuid4()),
341343
"title": "Target topic",
342344
"description": "Target description",
343345
"language": "en",
@@ -359,8 +361,52 @@ def test_embed__topics__missing_language():
359361
"topics": [
360362
{
361363
"id": str(uuid.uuid4()),
364+
"channel_id": str(uuid.uuid4()),
365+
"title": "Target topic",
366+
"description": "Target description",
367+
}
368+
],
369+
"metadata": {
370+
"channel_title": "Channel title",
371+
"some_additional_field": "some_random_value",
372+
},
373+
}
374+
)
375+
376+
377+
@skip_if_jsonschema_unavailable
378+
def test_embed__topics__invalid_channel_id():
379+
with pytest.raises(jsonschema.ValidationError):
380+
validate_embed_topics_request(
381+
{
382+
"topics": [
383+
{
384+
"id": str(uuid.uuid4()),
385+
"channel_id": "123",
362386
"title": "Target topic",
363387
"description": "Target description",
388+
"language": "en",
389+
}
390+
],
391+
"metadata": {
392+
"channel_title": "Channel title",
393+
"some_additional_field": "some_random_value",
394+
},
395+
}
396+
)
397+
398+
399+
@skip_if_jsonschema_unavailable
400+
def test_embed__topics__missing_channel_id():
401+
with pytest.raises(jsonschema.ValidationError):
402+
validate_embed_topics_request(
403+
{
404+
"topics": [
405+
{
406+
"id": str(uuid.uuid4()),
407+
"title": "Target topic",
408+
"description": "Target description",
409+
"language": "en",
364410
}
365411
],
366412
"metadata": {

0 commit comments

Comments
 (0)