-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #120 from akolson/split-embed-request-schema
Split embed request schema
- Loading branch information
Showing
11 changed files
with
233 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// -*- coding: utf-8 -*- | ||
// Generated by scripts/generate_from_specs.py | ||
// EmbedContentRequest | ||
|
||
|
||
export const SCHEMA = { | ||
"$id": "/schemas/embed_content_request", | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"type": "object", | ||
"description": "Schema for embed content requests received by RayServe", | ||
"additionalProperties": false, | ||
"definitions": { | ||
"language": { | ||
"type": "string", | ||
"description": "Language code from https://github.com/learningequality/le-utils/blob/main/le_utils/resources/languagelookup.json", | ||
"pattern": "^[a-z]{2,3}(?:-[a-zA-Z]+)?$" | ||
}, | ||
"resource": { | ||
"type": "object", | ||
"description": "The key textual metadata and data for a content resource", | ||
"additionalProperties": false, | ||
"properties": { | ||
"id": { | ||
"type": "string", | ||
"description": "The ID of the content resource" | ||
}, | ||
"title": { | ||
"type": "string", | ||
"description": "The title of the content resource" | ||
}, | ||
"description": { | ||
"type": "string", | ||
"description": "The description of the content resource" | ||
}, | ||
"text": { | ||
"type": "string", | ||
"description": "The cleaned up text extracted from the content resource (in markdown or plaintext format)" | ||
}, | ||
"language": { | ||
"$ref": "#/definitions/language" | ||
} | ||
}, | ||
"required": [ | ||
"id", | ||
"title", | ||
"description", | ||
"text" | ||
] | ||
} | ||
}, | ||
"properties": { | ||
"resources": { | ||
"type": "array", | ||
"description": "A list of content resources to embed", | ||
"items": { | ||
"$ref": "#/definitions/resource" | ||
} | ||
}, | ||
"metadata": { | ||
"type": "object", | ||
"description": "The metadata of the channel for logging purposes" | ||
} | ||
}, | ||
"required": ["resources"] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,5 +27,5 @@ | |
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"version": "0.2.3" | ||
"version": "0.2.4" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by scripts/generate_from_specs.py | ||
from __future__ import unicode_literals | ||
|
||
# EmbedTopicsRequest | ||
|
||
|
||
choices = () | ||
|
||
EMBEDTOPICSREQUESTLIST = [] | ||
|
||
SCHEMA = { | ||
"$id": "/schemas/embed_topics_request", | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"type": "object", | ||
"description": "Schema for embed topics requests received by RayServe", | ||
"additionalProperties": False, | ||
"definitions": { | ||
"ancestors": { | ||
"type": "array", | ||
"description": "The ancestors of the topic, in order, from the parent to the root", | ||
"items": {"$ref": "#/definitions/topic"}, | ||
}, | ||
"language": { | ||
"type": "string", | ||
"description": "Language code from https://github.com/learningequality/le-utils/blob/main/le_utils/resources/languagelookup.json", | ||
"pattern": "^[a-z]{2,3}(?:-[a-zA-Z]+)?$", | ||
}, | ||
"topic": { | ||
"type": "object", | ||
"description": "A topic in the tree structure", | ||
"additionalProperties": False, | ||
"properties": { | ||
"id": { | ||
"type": "string", | ||
"description": "The ID of the topic content node on Studio", | ||
}, | ||
"title": {"type": "string", "description": "The title of the topic"}, | ||
"description": { | ||
"type": "string", | ||
"description": "The description of the topic", | ||
}, | ||
"language": {"$ref": "#/definitions/language"}, | ||
"ancestors": {"$ref": "#/definitions/ancestors"}, | ||
}, | ||
"required": ["id", "title", "description"], | ||
}, | ||
}, | ||
"properties": { | ||
"topics": { | ||
"type": "array", | ||
"description": "A list of topics to embed", | ||
"items": {"$ref": "#/definitions/topic"}, | ||
}, | ||
"metadata": { | ||
"type": "object", | ||
"description": "The metadata of the channel for logging purposes", | ||
}, | ||
}, | ||
"required": ["topics"], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import jsonschema | ||
|
||
from le_utils.constants.embed_content_request import SCHEMA | ||
|
||
|
||
def validate(data): | ||
""" | ||
:param data: Dictionary of data to validate | ||
:raises: jsonschema.ValidationError: When invalid | ||
""" | ||
jsonschema.validate(instance=data, schema=SCHEMA) |
2 changes: 1 addition & 1 deletion
2
le_utils/validators/embed_request.py → le_utils/validators/embed_topics_request.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
{ | ||
"$id": "/schemas/embed_content_request", | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"type": "object", | ||
"description": "Schema for embed content requests received by RayServe", | ||
"additionalProperties": false, | ||
"definitions": { | ||
"language": { | ||
"type": "string", | ||
"description": "Language code from https://github.com/learningequality/le-utils/blob/main/le_utils/resources/languagelookup.json", | ||
"pattern": "^[a-z]{2,3}(?:-[a-zA-Z]+)?$" | ||
}, | ||
"resource": { | ||
"type": "object", | ||
"description": "The key textual metadata and data for a content resource", | ||
"additionalProperties": false, | ||
"properties": { | ||
"id": { | ||
"type": "string", | ||
"description": "The ID of the content resource" | ||
}, | ||
"title": { | ||
"type": "string", | ||
"description": "The title of the content resource" | ||
}, | ||
"description": { | ||
"type": "string", | ||
"description": "The description of the content resource" | ||
}, | ||
"text": { | ||
"type": "string", | ||
"description": "The cleaned up text extracted from the content resource (in markdown or plaintext format)" | ||
}, | ||
"language": { | ||
"$ref": "#/definitions/language" | ||
} | ||
}, | ||
"required": [ | ||
"id", | ||
"title", | ||
"description", | ||
"text" | ||
] | ||
} | ||
}, | ||
"properties": { | ||
"resources": { | ||
"type": "array", | ||
"description": "A list of content resources to embed", | ||
"items": { | ||
"$ref": "#/definitions/resource" | ||
} | ||
}, | ||
"metadata": { | ||
"type": "object", | ||
"description": "The metadata of the channel for logging purposes" | ||
} | ||
}, | ||
"required": ["resources"] | ||
} |
Oops, something went wrong.