Documentation Language: Swift

Article

swift-ecore

Work with Ecore metamodels and model instances.

Overview

The swift-ecore command-line tool provides comprehensive utilities for working with Ecore metamodels and model instances in both XMI and JSON formats. It supports format conversion, model validation, metamodel inspection, and model manipulation operations.

Commands

convert

Convert models between XMI and JSON formats.

swift-ecore convert <input-file> [options]

Options:

Examples:

# Convert XMI to JSON
swift-ecore convert model.xmi --output model.json --pretty

# Convert JSON to XMI with validation
swift-ecore convert model.json --output model.xmi \
    --validate --metamodel MyMetamodel.ecore

# Convert with explicit format specification
swift-ecore convert data.txt --output result.xmi --format xmi

validate

Validate that a model conforms to its metamodel.

swift-ecore validate <model-file> [options]

Options:

Examples:

# Basic validation
swift-ecore validate model.xmi --metamodel MyMetamodel.ecore

# Strict validation with JSON report
swift-ecore validate model.xmi \
    --metamodel MyMetamodel.ecore \
    --strict \
    --report validation-report.json \
    --format json

inspect

Display information about a metamodel or model.

swift-ecore inspect <file> [options]

Options:

Examples:

# Inspect metamodel summary
swift-ecore inspect MyMetamodel.ecore

# Full inspection with references
swift-ecore inspect MyMetamodel.ecore \
    --detail full \
    --show-references

# Export inspection as JSON
swift-ecore inspect model.xmi \
    --format json \
    --output inspection.json

create

Create a new empty model conforming to a metamodel.

swift-ecore create [options]

Options:

Examples:

# Create empty XMI model
swift-ecore create \
    --metamodel MyMetamodel.ecore \
    --output new-model.xmi \
    --root-class MyRootClass

# Create empty JSON model
swift-ecore create \
    --metamodel MyMetamodel.ecore \
    --output new-model.json \
    --format json

merge

Merge multiple model files into a single model.

swift-ecore merge <input-files...> [options]

Options:

Examples:

# Merge multiple models
swift-ecore merge model1.xmi model2.xmi model3.xmi \
    --output merged.xmi

# Merge with validation
swift-ecore merge model1.xmi model2.xmi \
    --output merged.xmi \
    --validate \
    --metamodel MyMetamodel.ecore \
    --strategy merge

Common Workflows

Converting Legacy XMI to JSON

# Convert with validation and pretty printing
swift-ecore convert legacy-model.xmi \
    --output modern-model.json \
    --pretty \
    --validate \
    --metamodel schema.ecore

Validating Model Conformance

# Strict validation with detailed report
swift-ecore validate production-model.xmi \
    --metamodel schema.ecore \
    --strict \
    --report validation-report.json \
    --format json

Inspecting Metamodel Structure

# Full inspection with all details
swift-ecore inspect MyMetamodel.ecore \
    --detail full \
    --show-references \
    --show-attributes \
    --output metamodel-structure.txt

See Also

Related Documentation

A
Tutorials

Learn Swift MDE through comprehensive, interactive tutorials covering all major technologies.

A
swift-atl

Transform models with the Atlas Transformation Language.