string-schema 0.1.3__tar.gz → 0.1.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {string_schema-0.1.3/string_schema.egg-info → string_schema-0.1.4}/PKG-INFO +1 -1
- {string_schema-0.1.3 → string_schema-0.1.4}/pyproject.toml +1 -1
- {string_schema-0.1.3 → string_schema-0.1.4}/setup.py +1 -1
- {string_schema-0.1.3 → string_schema-0.1.4}/string_schema/integrations/pydantic.py +13 -13
- {string_schema-0.1.3 → string_schema-0.1.4}/string_schema/utilities.py +3 -3
- {string_schema-0.1.3 → string_schema-0.1.4/string_schema.egg-info}/PKG-INFO +1 -1
- {string_schema-0.1.3 → string_schema-0.1.4}/LICENSE +0 -0
- {string_schema-0.1.3 → string_schema-0.1.4}/MANIFEST.in +0 -0
- {string_schema-0.1.3 → string_schema-0.1.4}/README.md +0 -0
- {string_schema-0.1.3 → string_schema-0.1.4}/docs/README.md +0 -0
- {string_schema-0.1.3 → string_schema-0.1.4}/docs/advanced-usage.md +0 -0
- {string_schema-0.1.3 → string_schema-0.1.4}/docs/api-reference.md +0 -0
- {string_schema-0.1.3 → string_schema-0.1.4}/docs/examples.md +0 -0
- {string_schema-0.1.3 → string_schema-0.1.4}/docs/faq.md +0 -0
- {string_schema-0.1.3 → string_schema-0.1.4}/docs/getting-started.md +0 -0
- {string_schema-0.1.3 → string_schema-0.1.4}/docs/pydantic-utilities.md +0 -0
- {string_schema-0.1.3 → string_schema-0.1.4}/docs/string-syntax.md +0 -0
- {string_schema-0.1.3 → string_schema-0.1.4}/docs/troubleshooting.md +0 -0
- {string_schema-0.1.3 → string_schema-0.1.4}/examples/demo.py +0 -0
- {string_schema-0.1.3 → string_schema-0.1.4}/examples/pydantic_utility_demo.py +0 -0
- {string_schema-0.1.3 → string_schema-0.1.4}/setup.cfg +0 -0
- {string_schema-0.1.3 → string_schema-0.1.4}/string_schema/__init__.py +0 -0
- {string_schema-0.1.3 → string_schema-0.1.4}/string_schema/core/__init__.py +0 -0
- {string_schema-0.1.3 → string_schema-0.1.4}/string_schema/core/builders.py +0 -0
- {string_schema-0.1.3 → string_schema-0.1.4}/string_schema/core/fields.py +0 -0
- {string_schema-0.1.3 → string_schema-0.1.4}/string_schema/core/validators.py +0 -0
- {string_schema-0.1.3 → string_schema-0.1.4}/string_schema/examples/__init__.py +0 -0
- {string_schema-0.1.3 → string_schema-0.1.4}/string_schema/examples/presets.py +0 -0
- {string_schema-0.1.3 → string_schema-0.1.4}/string_schema/examples/recipes.py +0 -0
- {string_schema-0.1.3 → string_schema-0.1.4}/string_schema/integrations/__init__.py +0 -0
- {string_schema-0.1.3 → string_schema-0.1.4}/string_schema/integrations/json_schema.py +0 -0
- {string_schema-0.1.3 → string_schema-0.1.4}/string_schema/integrations/openapi.py +0 -0
- {string_schema-0.1.3 → string_schema-0.1.4}/string_schema/integrations/reverse.py +0 -0
- {string_schema-0.1.3 → string_schema-0.1.4}/string_schema/parsing/__init__.py +0 -0
- {string_schema-0.1.3 → string_schema-0.1.4}/string_schema/parsing/optimizer.py +0 -0
- {string_schema-0.1.3 → string_schema-0.1.4}/string_schema/parsing/string_parser.py +0 -0
- {string_schema-0.1.3 → string_schema-0.1.4}/string_schema/parsing/syntax.py +0 -0
- {string_schema-0.1.3 → string_schema-0.1.4}/string_schema/py.typed +0 -0
- {string_schema-0.1.3 → string_schema-0.1.4}/string_schema.egg-info/SOURCES.txt +0 -0
- {string_schema-0.1.3 → string_schema-0.1.4}/string_schema.egg-info/dependency_links.txt +0 -0
- {string_schema-0.1.3 → string_schema-0.1.4}/string_schema.egg-info/requires.txt +0 -0
- {string_schema-0.1.3 → string_schema-0.1.4}/string_schema.egg-info/top_level.txt +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "string-schema"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.4"
|
|
8
8
|
description = "A simple, LLM-friendly schema definition library for converting string syntax to structured schemas"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "MIT"
|
|
@@ -9,7 +9,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
|
|
|
9
9
|
|
|
10
10
|
setup(
|
|
11
11
|
name="string-schema",
|
|
12
|
-
version="0.1.
|
|
12
|
+
version="0.1.4",
|
|
13
13
|
author="Michael Chen",
|
|
14
14
|
author_email="xychen@msn.com",
|
|
15
15
|
description="A simple, LLM-friendly schema definition library for converting string syntax to structured schemas",
|
|
@@ -111,41 +111,41 @@ def _simple_field_to_pydantic(field: SimpleField) -> tuple:
|
|
|
111
111
|
|
|
112
112
|
|
|
113
113
|
# New consistent naming
|
|
114
|
-
def json_schema_to_model(
|
|
114
|
+
def json_schema_to_model(json_schema: Dict[str, Any], name: str) -> Type[BaseModel]:
|
|
115
115
|
"""
|
|
116
116
|
Create Pydantic model from JSON Schema dictionary.
|
|
117
117
|
|
|
118
118
|
Args:
|
|
119
|
-
name: Name of the model class
|
|
120
119
|
json_schema: JSON Schema dictionary
|
|
120
|
+
name: Name of the model class
|
|
121
121
|
|
|
122
122
|
Returns:
|
|
123
123
|
Dynamically created Pydantic model class
|
|
124
124
|
|
|
125
125
|
Example:
|
|
126
|
-
UserModel = json_schema_to_model('User'
|
|
126
|
+
UserModel = json_schema_to_model(json_schema, 'User')
|
|
127
127
|
"""
|
|
128
|
-
return create_pydantic_from_json_schema(
|
|
128
|
+
return create_pydantic_from_json_schema(json_schema, name)
|
|
129
129
|
|
|
130
130
|
|
|
131
131
|
# Legacy alias for backward compatibility
|
|
132
|
-
def json_schema_to_pydantic(
|
|
132
|
+
def json_schema_to_pydantic(json_schema: Dict[str, Any], name: str) -> Type[BaseModel]:
|
|
133
133
|
"""
|
|
134
134
|
Create Pydantic model from JSON Schema dictionary.
|
|
135
135
|
|
|
136
136
|
DEPRECATED: Use json_schema_to_model() instead for consistent naming.
|
|
137
137
|
"""
|
|
138
|
-
return json_schema_to_model(
|
|
138
|
+
return json_schema_to_model(json_schema, name)
|
|
139
139
|
|
|
140
140
|
|
|
141
|
-
def create_pydantic_from_json_schema(
|
|
141
|
+
def create_pydantic_from_json_schema(json_schema: Dict[str, Any], name: str) -> Type[BaseModel]:
|
|
142
142
|
"""
|
|
143
143
|
Create Pydantic model from JSON Schema.
|
|
144
|
-
|
|
144
|
+
|
|
145
145
|
Args:
|
|
146
|
-
name: Name of the model class
|
|
147
146
|
json_schema: JSON Schema dictionary
|
|
148
|
-
|
|
147
|
+
name: Name of the model class
|
|
148
|
+
|
|
149
149
|
Returns:
|
|
150
150
|
Dynamically created Pydantic model class
|
|
151
151
|
"""
|
|
@@ -184,7 +184,7 @@ def _json_schema_to_pydantic_field(field_schema: Dict[str, Any], required: bool
|
|
|
184
184
|
python_type = TypingUnion[tuple(union_types)]
|
|
185
185
|
elif field_schema.get('type') == 'object':
|
|
186
186
|
# Handle nested objects by creating a nested Pydantic model
|
|
187
|
-
nested_model = create_pydantic_from_json_schema(f"{parent_name}Nested"
|
|
187
|
+
nested_model = create_pydantic_from_json_schema(field_schema, f"{parent_name}Nested")
|
|
188
188
|
python_type = nested_model
|
|
189
189
|
elif field_schema.get('type') == 'array':
|
|
190
190
|
# Handle arrays
|
|
@@ -192,7 +192,7 @@ def _json_schema_to_pydantic_field(field_schema: Dict[str, Any], required: bool
|
|
|
192
192
|
if items_schema.get('type') == 'object':
|
|
193
193
|
# Array of objects
|
|
194
194
|
from typing import List
|
|
195
|
-
item_model = create_pydantic_from_json_schema(f"{parent_name}Item"
|
|
195
|
+
item_model = create_pydantic_from_json_schema(items_schema, f"{parent_name}Item")
|
|
196
196
|
python_type = List[item_model]
|
|
197
197
|
else:
|
|
198
198
|
# Array of primitives
|
|
@@ -441,7 +441,7 @@ def _string_to_model_with_name(name: str, schema_str: str) -> Type[BaseModel]:
|
|
|
441
441
|
|
|
442
442
|
# Convert string to JSON Schema, then to Pydantic
|
|
443
443
|
json_schema = parse_string_schema(schema_str)
|
|
444
|
-
return create_pydantic_from_json_schema(
|
|
444
|
+
return create_pydantic_from_json_schema(json_schema, name)
|
|
445
445
|
|
|
446
446
|
|
|
447
447
|
# Legacy alias for backward compatibility
|
|
@@ -93,7 +93,7 @@ def string_to_model(schema_str: str, name: Optional[str] = None) -> Type[BaseMod
|
|
|
93
93
|
if items_schema.get('type') == 'object':
|
|
94
94
|
# Array of objects: create nested model for items
|
|
95
95
|
from .integrations.pydantic import create_pydantic_from_json_schema
|
|
96
|
-
ItemModel = create_pydantic_from_json_schema(f"{name}Item"
|
|
96
|
+
ItemModel = create_pydantic_from_json_schema(items_schema, f"{name}Item")
|
|
97
97
|
|
|
98
98
|
# Create the array model using RootModel
|
|
99
99
|
class ArrayModel(RootModel[List[ItemModel]]):
|
|
@@ -125,7 +125,7 @@ def string_to_model(schema_str: str, name: Optional[str] = None) -> Type[BaseMod
|
|
|
125
125
|
if items_schema.get('type') == 'object':
|
|
126
126
|
# Array of objects: create nested model for items
|
|
127
127
|
from .integrations.pydantic import create_pydantic_from_json_schema
|
|
128
|
-
ItemModel = create_pydantic_from_json_schema(f"{name}Item"
|
|
128
|
+
ItemModel = create_pydantic_from_json_schema(items_schema, f"{name}Item")
|
|
129
129
|
|
|
130
130
|
# Create constraints for the array
|
|
131
131
|
constraints = {}
|
|
@@ -159,7 +159,7 @@ def string_to_model(schema_str: str, name: Optional[str] = None) -> Type[BaseMod
|
|
|
159
159
|
else:
|
|
160
160
|
# Regular object schema
|
|
161
161
|
from .integrations.pydantic import create_pydantic_from_json_schema
|
|
162
|
-
return create_pydantic_from_json_schema(
|
|
162
|
+
return create_pydantic_from_json_schema(json_schema, name)
|
|
163
163
|
|
|
164
164
|
except Exception as e:
|
|
165
165
|
raise ValueError(f"Failed to create model from schema '{schema_str}': {str(e)}") from e
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|