Import: Avro

Creates a data contract from an Avro schema (.avsc) file.

{/* AUTOGENERATED EXAMPLE: do not edit by hand; regenerate with the update script. */}

Given this orders.avsc:

{
  "type": "record",
  "name": "orders",
  "namespace": "com.example.checkout",
  "fields": [
    { "name": "order_id", "type": "string", "doc": "Unique identifier of the order." },
    { "name": "order_timestamp", "type": { "type": "long", "logicalType": "timestamp-millis" } },
    { "name": "customer_id", "type": "string" },
    { "name": "order_total", "type": "long" },
    { "name": "status", "type": "string" }
  ]
}

Run:

datacontract import avro --source orders.avsc

to produce the data contract:

version: 1.0.0
kind: DataContract
apiVersion: v3.1.0
id: my-data-contract
name: My Data Contract
status: draft
schema:
- name: orders
  physicalType: record
  customProperties:
  - property: namespace
    value: com.example.checkout
  logicalType: object
  physicalName: orders
  properties:
  - name: order_id
    physicalType: string
    description: Unique identifier of the order.
    logicalType: string
    required: true
  - name: order_timestamp
    physicalType: long
    logicalType: date
    required: true
  - name: customer_id
    physicalType: string
    logicalType: string
    required: true
  - name: order_total
    physicalType: long
    logicalType: integer
    required: true
  - name: status
    physicalType: string
# …

{/* END AUTOGENERATED EXAMPLE */}