$schema: https://json-schema.org/draft/2020-12/schema
$id: MappingSchema.yaml
type: object
properties: {}
unevaluatedProperties:
  anyOf:
    - $ref: MappingFunction.yaml
    - $ref: MappingSchema.yaml
examples:
  - id:
      const: '123'
    opportunity:
      status:
        switch:
          field: summary.opportunity_status
          case:
            active: open
            inactive: closed
          default: custom
      amount:
        field: summary.opportunity_amount
  - opportunity:
      status:
        switch:
          field: summary.opportunity_status
          case:
            active: open
            inactive: closed
          default: custom
      amount:
        field: summary.opportunity_amount
  - opportunityAmount:
      field: summary.opportunity_amount
    opportunityStatus:
      switch:
        field: summary.opportunity_status
        case:
          active: open
          inactive: closed
        default: custom
  - id:
      const: '123'
    opportunity:
      status:
        field: summary.opportunity_status
      amount:
        field: summary.opportunity_amount
  - id:
      const: '123'
    opportunityStatus:
      field: summary.opportunity_status
    opportunityAmount:
      field: summary.opportunity_amount
description: |-
  A mapping format for translating data from one schema to another.

  Example:

  The following mapping:

  ```json
  {
    "id": { "const": "123" },
    "opportunity": {
      "status": {
        "switch": {
          "field": "summary.opportunity_status",
          "case": { "active": "open", "inactive": "closed" },
          "default": "custom",
        },
      },
      "amount": { "field": "summary.opportunity_amount" },
    }
  }
  ```

  Will translate the following data:

  ```json
  {
    "id": "123",
    "summary": {
      "opportunity_status": "active",
      "opportunity_amount": 100,
    },
  }
  ```

  To the following data:

  ```json
  {
    "id": "123",
    "opportunity": { "status": "open", "amount": 100 },
  }
  ```
