Import: JSON Schema

Creates a data contract from a JSON Schema file.

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

Given this orders.schema.json:

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "orders",
  "type": "object",
  "properties": {
    "order_id": { "type": "string", "description": "Unique identifier of the order." },
    "order_timestamp": { "type": "string", "format": "date-time" },
    "customer_id": { "type": "string" },
    "order_total": { "type": "integer" },
    "status": { "type": "string" }
  },
  "required": ["order_id", "order_timestamp", "customer_id", "order_total", "status"]
}

Run:

datacontract import jsonschema --source orders.schema.json

to produce the data contract:

version: 1.0.0
kind: DataContract
apiVersion: v3.1.0
id: my-data-contract
name: orders
status: draft
schema:
- name: orders
  physicalType: object
  businessName: orders
  logicalType: object
  physicalName: orders
  properties:
  - name: order_id
    physicalType: string
    description: Unique identifier of the order.
    logicalType: string
    required: true
  - name: order_timestamp
    physicalType: string
    logicalType: string
    logicalTypeOptions:
      format: date-time
    required: true
  - name: customer_id
    physicalType: string
    logicalType: string
    required: true
  - name: order_total
    physicalType: integer
    logicalType: integer
    required: true
  - name: status
    physicalType: string
# …

{/* END AUTOGENERATED EXAMPLE */}