Export MongoDB collection schemas into JSON Schema format
Project description
MongoDB Schema Exporter
A tool to analyze MongoDB collections and generate schema definitions.
Features
- Infers schema from MongoDB collections
- Validate documents against generated schemas
Usage
# Basic usage
uvx mongo_schema_exporter --db your_database --collection your_collection
# Analyze multiple documents
uvx mongo_schema_exporter --db your_database --collection your_collection --limit 10
# Output as JSON Schema
uvx mongo_schema_exporter --db your_database --collection your_collection --output json
# Save output to a file
uvx mongo_schema_exporter --db your_database --collection your_collection --output json --output-file schema.json
# Connect to a remote MongoDB instance
uvx mongo_schema_exporter --uri "mongodb://user:password@hostname:port/" --db your_database --collection your_collection
# Validate documents against the generated schema
uvx mongo_schema_exporter --db your_database --collection your_collection --validate
Examples
Pretty-printed output
MongoObject(fields={
'name': MongoField(type=MongoString(), required=True),
'age': MongoField(type=MongoInteger(), required=False),
'tags': MongoField(type=MongoArray(element=MongoString()), required=True),
'metadata': MongoField(type=MongoObject(fields={
'created': MongoField(type=MongoDate(), required=True),
'modified': MongoField(type=MongoDate(), required=False)
}), required=False)
})
JSON Schema output
{
"$jsonSchema": {
"bsonType": "object",
"properties": {
"name": {
"bsonType": "string"
},
"age": {
"bsonType": "int"
},
"tags": {
"bsonType": "array",
"items": {
"bsonType": "string"
}
},
"metadata": {
"bsonType": "object",
"properties": {
"created": {
"bsonType": "date"
},
"modified": {
"bsonType": "date"
}
},
"required": ["created"]
}
},
"required": ["name", "tags"]
}
}
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mongo_schema_exporter-0.1.3-py3-none-any.whl.
File metadata
- Download URL: mongo_schema_exporter-0.1.3-py3-none-any.whl
- Upload date:
- Size: 9.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed4766e7f638dd15870a901a054845d2601649c55cc3368906be2d766c175d93
|
|
| MD5 |
2622b338be544f37304f3d351caaec4c
|
|
| BLAKE2b-256 |
c317132413a5e0bb77b3359a6002296fe95064ee09a083139f746466ef08d068
|