A CLI tool to generate YAML schemas from schema.org vocabulary.
SchemaORG2YAML downloads the schema.org vocabulary and generates normalized YAML files describing schema.org types with their properties, inheritance, and metadata. Perfect for developers who need readable and versionable schemas aligned with schema.org for data modeling.
- π Automatic vocabulary download from schema.org (JSON-LD/TTL/RDF)
- 𧬠Inheritance resolution (rdfs:subClassOf) with property merging
- π YAML export for individual types or type lists
- π·οΈ Alias mapping support for local naming conventions
- π Type discovery with filtering capabilities
- β‘ CLI ergonomics with multiple subcommands
- π§ͺ Comprehensive tests and CI/CD
pipx install schemaorg2yamlpip install schemaorg2yamlgit clone https://github.com/johanremy/schemaorg2yaml.git
cd schemaorg2yaml
pip install -e .-
Fetch the schema.org vocabulary:
schemaorg2yaml fetch-vocab
-
List available types:
schemaorg2yaml list-types --filter Person
-
Generate YAML schemas:
schemaorg2yaml generate --types Person,Article --out ./schema
-
Preview a schema:
schemaorg2yaml show --type WebPage
# Download latest schema.org vocabulary
schemaorg2yaml fetch-vocab
# Use custom source
schemaorg2yaml fetch-vocab --source https://schema.org/version/latest/schemaorg-current-https.jsonld --format jsonld
# Force refresh cache
schemaorg2yaml fetch-vocab --force# Generate specific types
schemaorg2yaml generate --types Person,WebPage --out ./schema
# Generate from file list
schemaorg2yaml generate --file types.txt --out ./schema
# Use aliases mapping
schemaorg2yaml generate --types Person --out ./schema --aliases ./aliases.yaml
# Include ancestor metadata
schemaorg2yaml generate --types Article --out ./schema --include-ancestors
# Minimal output (no descriptions)
schemaorg2yaml generate --types Person --out ./schema --no-descriptions# List all available types
schemaorg2yaml list-types
# Filter types by pattern
schemaorg2yaml list-types --filter ".*Page.*"
# Show schema in console
schemaorg2yaml show --type ArticleEach generated YAML file follows this stable structure:
$schema: "https://example.com/specs/schema-yaml/v1"
id: "schema:Person"
label: "Person"
description: "A person (alive, dead, undead, or fictional)."
parents: ["Thing"]
seeAlso:
- "https://schema.org/Person"
properties:
birthDate:
id: "schema:birthDate"
label: "birthDate"
description: "Date of birth."
range: ["Date", "DateTime", "Text"]
required: false
repeated: false
givenName:
id: "schema:givenName"
label: "givenName"
description: "Given name."
range: ["Text"]
required: false
repeated: false
aliases: ["first_name"]- Sorted properties alphabetically
- Inheritance chain in
parentsfield - Type ranges from schema.org preserved
- Cardinality information (
required,repeated) - Local aliases for property mapping
- Stable format for version control
Create an aliases.yaml file to map schema.org properties to local names:
Person:
givenName: ["first_name", "prenom"]
familyName: ["last_name", "nom"]
birthDate: ["date_of_birth"]
WebPage:
breadcrumb: ["fil_ariane"]
mainContentOfPage: ["main_content"]git clone https://github.com/johanremy/schemaorg2yaml.git
cd schemaorg2yaml
pip install -e ".[dev]"# Format code
black src/ tests/
ruff check src/ tests/ --fix
# Type checking
mypy src/
# Run tests
pytest# Run all tests
pytest
# With coverage
pytest --cov=src/schemaorg2yaml --cov-report=html
# Specific test file
pytest tests/test_cli.py -vfetch-vocab- Download/update schema.org vocabularygenerate- Generate YAML files for specified typeslist-types- List available schema.org typesshow- Display YAML for a type in console
--help- Show help message--version- Show version information
Run schemaorg2yaml COMMAND --help for detailed command options.
- No runtime data validation
- No reverse generation (YAML β RDF)
- No web UI
- Limited to schema.org vocabulary
- ποΈ Versioned vocabulary cache
- π― Profile-based property filtering (Web, SEO, e-commerce)
- π JSON export format
- π Multi-type index generation
- βοΈ Minimal vs extended property sets
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Run the test suite
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Schema.org for the vocabulary
- RDFLib for RDF processing
- Click for CLI framework