Commit 064cc126 authored by ozzeh's avatar ozzeh
Browse files

Checkpoint commit

parent 1ab5eed9
......@@ -105,7 +105,7 @@ class SchemaRegistry:
def get_schema(self, name) -> Schema:
return self._schemas.get(name)
return self._schemas[name]
def register_model(
from typing import Optional, List
from pydantic import BaseModel, create_model, Field
from pydantic import BaseModel, create_model, Field, PrivateAttr
from devtools import debug
from jsonpointer import resolve_pointer
......@@ -20,10 +20,18 @@ def reflect_event(event_dict: dict) -> BaseModel:
class _ReflectedModel(BaseModel):
__detail_type__: str = PrivateAttr()
def detail_type(self) -> Optional[str]:
return self.__detail_type__ or None
class Config:
alias_generator = lambda x: "fields_" if x == "fields" else x
class SchemaReflector:
def __init__(self, schema, registry=None):
self.schema = schema
......@@ -8,9 +8,4 @@ def test_loading_schemas():
registry = SchemaRegistry("TAPI-TEST")
schema: Schema = registry._schemas["schema_registry.test.TestingModel"]
reflector: SchemaReflector = schema.reflect()
model = reflector.create_model_for_jsonschema()
instance = model(name="ozzeh", description="big willy johnston")
registry.register_model("schema_registry.test", model)
registry.send_event("auth-dev", "com.pleaseignore.tvm.test", instance)
reflector: SchemaReflector = SchemaReflector(schema.get().content_dict)
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment