-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add test for msgspec json schema convertion
- Loading branch information
1 parent
fa25797
commit a0a8d7c
Showing
2 changed files
with
19 additions
and
0 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
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,18 @@ | ||
import json | ||
import msgspec | ||
from typing_extensions import Annotated | ||
from pydantic.dataclasses import dataclass | ||
from typing import Optional | ||
|
||
from ai_powered.schema_deref import deref | ||
|
||
@dataclass | ||
class UserInfo: | ||
name: str | ||
country: Annotated[Optional[str], "None is used for unknown cases"] | ||
age: Annotated[Optional[str], "None is used for unknown cases"] | ||
|
||
if __name__ == "__main__": | ||
schema = msgspec.json.schema(UserInfo) | ||
print("schema =", json.dumps(schema, indent=2)) | ||
print("deref(schema) =", json.dumps(deref(schema), indent=2)) |