Registry / serialization / getschema

getschema

JSON →
library0.2.11pypypi✓ verified 28d ago

GetSchema is a Python library designed to infer JSON schemas from sample data records. It analyzes diverse data inputs to automatically generate a robust JSON Schema definition. The project is actively maintained, with frequent patch releases addressing bug fixes and minor feature enhancements, currently at version 0.2.11.

pip install getschema
INSTALL
IMPORT
SIG · GETSCHEMA
G
getschema
serializationpythonv0.2.11
Install
2.3s avg
Import
238ms
Disk
24MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.2.11 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.254s · 22.1MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 2.3s · import 0.222s · 23MB
24MB installed
● package 24MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

infer_schema
✓ import getschema # or from getschema import infer_schema

This quickstart demonstrates how to use `getschema.infer_schema` to generate a JSON Schema from a list of Python dictionaries representing sample records. The output is a formatted JSON string of the inferred schema.

import getschema import json sample_records = [ {"name": "Alice", "age": 30, "city": "New York"}, {"name": "Bob", "age": 24, "city": "London", "email": "bob@example.com"}, {"name": "Charlie", "age": None, "city": "Paris"}, {"name": "David", "age": 35, "city": "Berlin", "hobbies": ["reading", "hiking"]} ] # Infer schema from a list of records schema = getschema.infer_schema(sample_records) print(json.dumps(schema, indent=2))
Debug
Known issues
breakingVersions prior to 0.2.5 incorrectly auto-converted values like 0, 0.0, empty strings (''), and false to `null` during schema inference. This behavior was a bug and has been fixed in v0.2.5 and later.
fix
Upgrade to getschema v0.2.5 or later. If your logic previously relied on this implicit conversion, ensure your input data is pre-processed or adjust your schema expectations accordingly.
affects: < 0.2.5
gotchaThe default inference for fields containing only `null` values changed in v0.2.10. Prior to this version, such fields might have been inferred as `{"type": "null"}` or `{"type": "string"}` (since v0.2.3). From v0.2.10, they default to `{"type": ["null", "string"]}` (nullable string).
fix
If 'nullable string' is not the desired type for fields containing only nulls, explicitly define the expected type in a post-processing step or through custom logic.
affects: < 0.2.10
gotchaIn versions prior to v0.2.3, if a field contained only `null` values across all sample records, the inferred JSON Schema type for that field would be `{"type": "null"}`. From v0.2.3, this default was changed to `{"type": "string"}` (and later to `{"type": ["null", "string"]}` in v0.2.10).
fix
Review schemas inferred from fields with only null values if using older versions. Upgrade to a newer version for consistent handling, or explicitly specify the desired type for such fields.
affects: < 0.2.3
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'getschema'
The 'getschema' Python package is not installed in the current environment or the import statement has a typo.
fix
Install the library using pip: `pip install getschema`
ModuleNotFoundError: No module named 'pandas'
The 'getschema' library depends on 'pandas', but 'pandas' is not installed in the current environment.
fix
Install the pandas library: `pip install pandas`
TypeError: 'NoneType' object is not iterable
The `infer_schema` function was called with an input data parameter that is `None` or an unexpected non-iterable type, which pandas (a dependency of getschema) cannot process.
fix
Ensure the `data` argument passed to `getschema.infer_schema()` is a list of dictionaries, a dictionary, or a similar iterable structure expected by pandas. For example: `getschema.infer_schema([{'key': 'value'}])`
AttributeError: 'dict' object has no attribute 'some_method'
After inferring the schema, the user is attempting to call a method on the returned schema object, which is a standard Python dictionary (JSON schema), expecting it to be a custom object with specific methods.
fix
Access the schema properties using dictionary keys (e.g., `schema['properties']`) as the returned object is a dictionary representing the JSON schema, not a custom object with methods.
Upgrade
Version history
0.2.11latest on PyPI · released Sep 3, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
Resources
getschema — pip install getschema · libregistry