|
2 | 2 | from datetime import datetime |
3 | 3 | from typing import Optional, List, Union |
4 | 4 |
|
5 | | -from beanie import Document, PydanticObjectId |
| 5 | +from beanie import Document |
6 | 6 | from elasticsearch import Elasticsearch, NotFoundError |
7 | 7 | from fastapi import HTTPException |
8 | 8 | from pydantic import Field, validator, AnyUrl, BaseModel |
|
11 | 11 | EventListenerIn, |
12 | 12 | LegacyEventListenerIn, |
13 | 13 | EventListenerOut, |
14 | | - ExtractorInfo, |
15 | 14 | ) |
16 | 15 | from app.models.mongomodel import MongoDBRef |
17 | 16 | from app.models.users import UserOut |
@@ -101,6 +100,14 @@ class MetadataDefinitionBase(BaseModel): |
101 | 100 | class Settings: |
102 | 101 | name = "metadata_definitions" |
103 | 102 |
|
| 103 | + class Config: |
| 104 | + # Serialization Config Options |
| 105 | + # Specify JSON key names |
| 106 | + # This will rename the field `context` to `@context` in the JSON output |
| 107 | + fields = {"context": {"alias": "@context"}} |
| 108 | + # This will allow input by field name 'context' too along with '@context' |
| 109 | + allow_population_by_field_name = True |
| 110 | + |
104 | 111 |
|
105 | 112 | class MetadataDefinitionIn(MetadataDefinitionBase): |
106 | 113 | pass |
@@ -184,6 +191,14 @@ class MetadataBase(BaseModel): |
184 | 191 | str |
185 | 192 | ] # This will be fetched from metadata definition if one is provided (shown by GUI) |
186 | 193 |
|
| 194 | + class Config: |
| 195 | + # Serialization Config Options |
| 196 | + # Specify JSON key names |
| 197 | + # This will rename the field `context` to `@context` in the JSON output |
| 198 | + fields = {"context": {"alias": "@context"}} |
| 199 | + # This will allow input by field name 'context' too along with '@context' |
| 200 | + allow_population_by_field_name = True |
| 201 | + |
187 | 202 | @validator("context") |
188 | 203 | def contexts_are_valid(cls, v): |
189 | 204 | if False: |
|
0 commit comments