← Schemas Academy

Build the solution · 5 / 5

Collect installation settings safely

Turn a schema into a clear integration configuration form.

YOUR TASK

Make this happen

3 steps
  1. Add integration_document.settings in settings.cococo with identity com.academy.supplier, SDK 2.0 and version 1.0.0. Define required endpoint/token and optional retries default 3; mark token as password. Preserve both external schemas.

  2. Keep the working capabilities from the previous lesson and connect the new pieces to the same solution.

  3. Check the complete solution, then inspect any unmet requirements.

This step starts with the earlier solution and one new challenge. Each lesson keeps its own draft.

Read the starter files

main.cococo

external_schema "supplier" {
  name = "Supplier delivery contract"
  format = "JSON_SCHEMA"
  sourceText = file("contract.json")
}

contract.json

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Supplier delivery",
  "type": "object",
  "properties": {
    "trackingId": {
      "type": "string",
      "minLength": 1
    },
    "status": {
      "type": "string",
      "enum": [
        "dispatched",
        "delivered"
      ],
      "default": "dispatched"
    },
    "packages": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "properties": {
          "weightKg": {
            "type": "number",
            "exclusiveMinimum": 0
          }
        },
        "required": [
          "weightKg"
        ],
        "additionalProperties": false
      }
    }
  },
  "required": [
    "trackingId",
    "packages"
  ],
  "additionalProperties": false
}

api.cococo

external_schema "api" {
  name = "Supplier delivery contract"
  format = "OPENAPI_3"
  sourceText = file("api.json")
}

api.json

{
  "openapi": "3.0.3",
  "info": {
    "title": "Supplier delivery API",
    "version": "1.0.0"
  },
  "paths": {
    "/deliveries": {
      "post": {
        "operationId": "createDelivery",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Delivery"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Delivery accepted"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Delivery": {
        "title": "Supplier delivery",
        "type": "object",
        "properties": {
          "trackingId": {
            "type": "string",
            "minLength": 1
          },
          "status": {
            "type": "string",
            "enum": [
              "dispatched",
              "delivered"
            ],
            "default": "dispatched"
          },
          "packages": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "object",
              "properties": {
                "weightKg": {
                  "type": "number",
                  "exclusiveMinimum": 0
                }
              },
              "required": [
                "weightKg"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "trackingId",
          "packages"
        ],
        "additionalProperties": false
      }
    }
  }
}

settings.cococo

integration_document "settings" {
  integrationId = "com.academy.supplier"
  sdkVersion = "2.0"
  version = "1.0.0"
  configurationSchema = {
    type = "object"
    additionalProperties = false
    properties = {
      # TODO: define endpoint (URI), token (password) and retries (integer).
    }
    required = [] # TODO: require endpoint and token.
    "x-propertyOrder" = ["endpoint", "token", "retries"]
  }
}

Reference: schemas · authoringschemas · external-schemas