pydantic-jsonschema 0.0.1__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.
@@ -0,0 +1,31 @@
1
+ # Python
2
+ __pycache__/
3
+
4
+ # Virtual environment
5
+ .venv
6
+
7
+ # IDE & OS
8
+ .vscode/
9
+ .idea/
10
+ .DS_Store
11
+
12
+ # Testing
13
+ .pytest_cache/
14
+ .coverage*
15
+ coverage.xml
16
+ htmlcov/
17
+
18
+ # Linting
19
+ .mypy_cache/
20
+ .ruff_cache/
21
+
22
+ # Documentation
23
+ site/
24
+
25
+ # Build artifacts
26
+ dist/
27
+ build/
28
+ *.egg-info/
29
+
30
+ # Auto-generated by hatch-vcs
31
+ pydantic_jsonschema/_version.py
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) Danipulok 2026 to present
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,86 @@
1
+ Metadata-Version: 2.4
2
+ Name: pydantic-jsonschema
3
+ Version: 0.0.1
4
+ Summary: JSON Schema to Pydantic model conversion library
5
+ Project-URL: Homepage, https://github.com/Danipulok/pydantic-jsonschema
6
+ Project-URL: Documentation, https://danipulok.github.io/pydantic-jsonschema/
7
+ Project-URL: Repository, https://github.com/Danipulok/pydantic-jsonschema
8
+ Project-URL: Issues, https://github.com/Danipulok/pydantic-jsonschema/issues
9
+ Project-URL: Changelog, https://github.com/Danipulok/pydantic-jsonschema/blob/main/docs/changelog.md
10
+ Author-email: Danipulok <danipulok@gmail.com>
11
+ License: MIT
12
+ License-File: LICENSE
13
+ Keywords: ai,json-schema,llm,pydantic,schema,type-safety,validation
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Programming Language :: Python :: 3.14
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Classifier: Typing :: Typed
23
+ Requires-Python: >=3.12
24
+ Requires-Dist: openapi-pydantic>=0.5.0
25
+ Requires-Dist: pydantic>=2.0.0
26
+ Provides-Extra: formats-all
27
+ Requires-Dist: email-validator>=2.0.0; extra == 'formats-all'
28
+ Requires-Dist: fqdn; extra == 'formats-all'
29
+ Requires-Dist: pydantic-extra-types[all]; extra == 'formats-all'
30
+ Requires-Dist: rfc3986>=2.0.0; extra == 'formats-all'
31
+ Provides-Extra: formats-base
32
+ Requires-Dist: email-validator>=2.0.0; extra == 'formats-base'
33
+ Requires-Dist: fqdn; extra == 'formats-base'
34
+ Requires-Dist: rfc3986>=2.0.0; extra == 'formats-base'
35
+ Provides-Extra: formats-extra
36
+ Requires-Dist: pydantic-extra-types[all]; extra == 'formats-extra'
37
+ Description-Content-Type: text/markdown
38
+
39
+ # Pydantic JSON Schema
40
+
41
+ [![CI](https://github.com/danipulok/pydantic-jsonschema/workflows/CI/badge.svg)](https://github.com/danipulok/pydantic-jsonschema/actions)
42
+ [![Coverage](https://img.shields.io/codecov/c/github/danipulok/pydantic-jsonschema)](https://codecov.io/gh/danipulok/pydantic-jsonschema)
43
+ [![PyPI](https://img.shields.io/pypi/v/pydantic-jsonschema.svg)](https://pypi.org/project/pydantic-jsonschema/)
44
+ [![Python Versions](https://img.shields.io/pypi/pyversions/pydantic-jsonschema.svg)](https://pypi.org/project/pydantic-jsonschema/)
45
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/danipulok/pydantic-jsonschema/blob/main/LICENSE)
46
+ [![Docs](https://img.shields.io/badge/docs-latest-blue.svg)](https://danipulok.github.io/pydantic-jsonschema/)
47
+
48
+ Convert JSON Schema definitions into Pydantic models with runtime validation.
49
+
50
+ ## Installation
51
+
52
+ ```bash
53
+ uv add pydantic-jsonschema
54
+ ```
55
+
56
+ Requires Python 3.12+.
57
+ See the [installation guide](https://danipulok.github.io/pydantic-jsonschema/install/) for optional format validator extras.
58
+
59
+ ## Quick Start
60
+
61
+ ```python
62
+ from pydantic_jsonschema import Schema, to_model
63
+
64
+ schema = Schema.model_validate({
65
+ "type": "object",
66
+ "properties": {
67
+ "name": {"type": "string"},
68
+ "age": {"type": "integer", "minimum": 0},
69
+ },
70
+ "required": ["name"],
71
+ })
72
+
73
+ User = to_model(schema, model_name="User")
74
+
75
+ user = User(name="Alice", age=30)
76
+ print(user.model_dump())
77
+ #> {'name': 'Alice', 'age': 30}
78
+ ```
79
+
80
+ ## Documentation
81
+
82
+ [https://danipulok.github.io/pydantic-jsonschema/](https://danipulok.github.io/pydantic-jsonschema/)
83
+
84
+ ## License
85
+
86
+ MIT License - see [LICENSE](LICENSE) for details.
@@ -0,0 +1,48 @@
1
+ # Pydantic JSON Schema
2
+
3
+ [![CI](https://github.com/danipulok/pydantic-jsonschema/workflows/CI/badge.svg)](https://github.com/danipulok/pydantic-jsonschema/actions)
4
+ [![Coverage](https://img.shields.io/codecov/c/github/danipulok/pydantic-jsonschema)](https://codecov.io/gh/danipulok/pydantic-jsonschema)
5
+ [![PyPI](https://img.shields.io/pypi/v/pydantic-jsonschema.svg)](https://pypi.org/project/pydantic-jsonschema/)
6
+ [![Python Versions](https://img.shields.io/pypi/pyversions/pydantic-jsonschema.svg)](https://pypi.org/project/pydantic-jsonschema/)
7
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/danipulok/pydantic-jsonschema/blob/main/LICENSE)
8
+ [![Docs](https://img.shields.io/badge/docs-latest-blue.svg)](https://danipulok.github.io/pydantic-jsonschema/)
9
+
10
+ Convert JSON Schema definitions into Pydantic models with runtime validation.
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ uv add pydantic-jsonschema
16
+ ```
17
+
18
+ Requires Python 3.12+.
19
+ See the [installation guide](https://danipulok.github.io/pydantic-jsonschema/install/) for optional format validator extras.
20
+
21
+ ## Quick Start
22
+
23
+ ```python
24
+ from pydantic_jsonschema import Schema, to_model
25
+
26
+ schema = Schema.model_validate({
27
+ "type": "object",
28
+ "properties": {
29
+ "name": {"type": "string"},
30
+ "age": {"type": "integer", "minimum": 0},
31
+ },
32
+ "required": ["name"],
33
+ })
34
+
35
+ User = to_model(schema, model_name="User")
36
+
37
+ user = User(name="Alice", age=30)
38
+ print(user.model_dump())
39
+ #> {'name': 'Alice', 'age': 30}
40
+ ```
41
+
42
+ ## Documentation
43
+
44
+ [https://danipulok.github.io/pydantic-jsonschema/](https://danipulok.github.io/pydantic-jsonschema/)
45
+
46
+ ## License
47
+
48
+ MIT License - see [LICENSE](LICENSE) for details.
@@ -0,0 +1,17 @@
1
+ # Examples
2
+
3
+ This folder contains runnable examples demonstrating how to use Pydantic JSON Schema.
4
+
5
+ All examples are complete and can be run as-is:
6
+
7
+ ```bash
8
+ uv run python examples/custom_validators.py
9
+ uv run python examples/nested_schemas.py
10
+ ```
11
+
12
+ ## Examples
13
+
14
+ - **[custom_validators.py](custom_validators.py)** - Add domain-specific validation
15
+ - **[nested_schemas.py](nested_schemas.py)** - Handle complex schemas with references
16
+
17
+ See the [documentation](../docs/examples.md) for detailed explanations and more examples.
@@ -0,0 +1,20 @@
1
+ """Public API for the pydantic_jsonschema package."""
2
+
3
+ from pydantic_jsonschema._version import __version__
4
+ from pydantic_jsonschema.converters import (
5
+ Ref,
6
+ SchemaConverter,
7
+ to_model,
8
+ )
9
+ from pydantic_jsonschema.types import DataType, JsonType, Reference, Schema
10
+
11
+ __all__ = [
12
+ "DataType",
13
+ "JsonType",
14
+ "Ref",
15
+ "Reference",
16
+ "Schema",
17
+ "SchemaConverter",
18
+ "__version__",
19
+ "to_model",
20
+ ]
@@ -0,0 +1,20 @@
1
+ """Internal utilities for identifier sanitization."""
2
+
3
+ import re
4
+
5
+ __all__ = [
6
+ "sanitize_identifier",
7
+ ]
8
+
9
+ _LEADING_NON_ALPHA: re.Pattern[str] = re.compile(r"^[^a-zA-Z_]+")
10
+ _INVALID_CHARS: re.Pattern[str] = re.compile(r"[^a-zA-Z0-9_]")
11
+
12
+
13
+ def sanitize_identifier(name: str) -> str:
14
+ """Sanitize string to be a valid Python identifier.
15
+
16
+ :param name: String to sanitize.
17
+ :returns: Valid Python identifier.
18
+ """
19
+ name = _LEADING_NON_ALPHA.sub("", name)
20
+ return _INVALID_CHARS.sub("", name)
@@ -0,0 +1,24 @@
1
+ # file generated by vcs-versioning
2
+ # don't change, don't track in version control
3
+ from __future__ import annotations
4
+
5
+ __all__ = [
6
+ "__version__",
7
+ "__version_tuple__",
8
+ "version",
9
+ "version_tuple",
10
+ "__commit_id__",
11
+ "commit_id",
12
+ ]
13
+
14
+ version: str
15
+ __version__: str
16
+ __version_tuple__: tuple[int | str, ...]
17
+ version_tuple: tuple[int | str, ...]
18
+ commit_id: str | None
19
+ __commit_id__: str | None
20
+
21
+ __version__ = version = '0.0.1'
22
+ __version_tuple__ = version_tuple = (0, 0, 1)
23
+
24
+ __commit_id__ = commit_id = None