Build the solution · 4 / 5
Make the supplier API discoverable
Package the delivery contract with its endpoint for integration authors.
YOUR TASK
Make this happen
Add a separate OPENAPI_3 external_schema.api backed by api.json. Define POST /deliveries, createDelivery, required Delivery request body and 202 response; retain the original JSON contract resource.
Keep the working capabilities from the previous lesson and connect the new pieces to the same solution.
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"
# Source file supplied for this field: api.json
# TODO: attach it with sourceText = file(...).
}
api.json
{
"openapi": "3.0.3",
"info": {
"title": "Supplier delivery API",
"version": "1.0.0"
},
"paths": {},
"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
}
}
}
}