Migrate from DCS to ODCS
Contracts that start with dataContractSpecification: and describe their structure under
models:/fields: use the Data Contract Specification (DCS), the format the CLI was
originally built around. The CLI now uses the
Open Data Contract Standard (ODCS) natively.
lint, test, and export detect a DCS file and convert it in memory before doing their work.
Migrating just makes the ODCS version the file you keep in Git.
Convert
datacontract export odcs datacontract.yaml --output datacontract.odcs.yaml
For a whole repository of contracts:
find . -name 'datacontract.yaml' -exec sh -c \
'datacontract export odcs "$1" --output "$(dirname "$1")/datacontract.odcs.yaml"' _ {} \;
Verify
# 1. The new file is valid ODCS.
datacontract lint datacontract.odcs.yaml
# 2. Nothing changed semantically — both files are compared as ODCS,
# so an empty table means the conversion was lossless.
datacontract changelog datacontract.yaml datacontract.odcs.yaml
# 3. The new file still passes against real data.
datacontract test datacontract.odcs.yaml
Once all three pass, delete the DCS file and point your CI/CD pipeline at the new one.
Three things to fix by hand
statusis required in ODCS. Withoutinfo.statusin the DCS file,lintreportsdata must contain ['status'] properties. Add a top-levelstatus: active.- The deprecated
primary: trueis not carried over — onlyprimaryKey: trueis. Search your contracts forprimary:and setprimaryKey: truein the ODCS file. physicalTypeholds the DCStype, so a column readsphysicalType: stringinstead of its native type. Replace it with the real type (VARCHAR,NUMBER(12,2), …) or drop it and keep onlylogicalType.
Everything else is mapped automatically: models → schema, fields → properties,
servicelevels → slaProperties, terms → description, field.enum → a
quality rule, $ref definitions inlined. Anything without an ODCS
equivalent (contact details, Kafka topic, pii, precision) is preserved under
customProperties.
Going back
datacontract export dcs converts the other way, if a downstream tool still
expects DCS:
datacontract export dcs datacontract.odcs.yaml --output datacontract.yaml