hololinked.metadata.td.base.WoTSchema
Bases: BaseModel
Base pydantic model for all WoT schema components (as in, parts within the schema).
Call model_dump or json method to get the JSON representation of the schema (or the JSON Schema).
Source code in repo/hololinked/hololinked/metadata/td/base.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | |
Functions
declared_fields
staticmethod
declared_fields(model: type[BaseModel], skip_subclasses: tuple[type[BaseModel], ...] = ()) -> dict[str, str]
Collect the fields declared by a schema element and all of its subclasses.
The subclasses are included because they may declare additional fields that should be considered part of the schema. For example, a dataschema for a string has more fields than a generic dataschema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
type[BaseModel]
|
the base model |
required |
|
tuple[type[BaseModel], ...]
|
subclasses to skip |
()
|
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
key of each field in the JSON document (its alias, such as |
Source code in repo/hololinked/hololinked/metadata/td/base.py
format_doc
classmethod
Format a python docstring to a normal description.
Strip tabs, newlines, whitespaces etc. to format the docstring nicely. Parameter sections are removed,
both numpydoc (Parameters underlined with dashes) and Sphinx/reST field
lists (:param x:, :returns:, :raises: etc.). Lines are joined with a single space.
Returns:
| Type | Description |
|---|---|
str
|
Formatted docstring |
Source code in repo/hololinked/hololinked/metadata/td/base.py
json
Same as model_dump.
Overrides pydantic's base class json() method.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
JSON representation |
Source code in repo/hololinked/hololinked/metadata/td/base.py
model_dump
Return the JSON representation of the schema.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
JSON representation |