{
  "openapi": "3.1.0",
  "info": {
    "title": "BDI Orkestratie Register API",
    "version": "0.1.0",
    "description": "Generated OpenAPI specification for ors. See the BDI reference implementation for wire-format details."
  },
  "servers": [
    {
      "url": "http://localhost:8080",
      "description": "local-dev"
    }
  ],
  "tags": [
    {
      "name": "bdi",
      "description": "BDI core operations"
    }
  ],
  "paths": {
    "/contexts": {
      "post": {
        "operationId": "createChainContext",
        "summary": "Create a chain context",
        "tags": [
          "bdi",
          "contexts"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "association_id",
                  "orchestrator",
                  "kind"
                ],
                "properties": {
                  "association_id": {
                    "$ref": "#/components/schemas/AssociationId"
                  },
                  "orchestrator": {
                    "$ref": "#/components/schemas/Euid"
                  },
                  "kind": {
                    "type": "string",
                    "enum": [
                      "order",
                      "transport",
                      "shipment",
                      "custom"
                    ]
                  },
                  "identifiers": {
                    "type": "array",
                    "items": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created"
          }
        }
      }
    },
    "/contexts/{id}/parties": {
      "post": {
        "operationId": "addParty",
        "summary": "Add an involved party",
        "tags": [
          "bdi",
          "contexts"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/ChainContextId"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "actor",
                  "member_euid",
                  "roles"
                ],
                "properties": {
                  "actor": {
                    "$ref": "#/components/schemas/Euid"
                  },
                  "member_euid": {
                    "$ref": "#/components/schemas/Euid"
                  },
                  "roles": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Added"
          }
        }
      }
    },
    "/contexts/{id}/bvod": {
      "post": {
        "operationId": "issueBvod",
        "summary": "Issue a BVOD",
        "tags": [
          "bdi",
          "contexts"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/ChainContextId"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "BVOD JWS"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Euid": {
        "type": "string",
        "pattern": "^[A-Z]{2}\\.[A-Z]+\\.[A-Z0-9-]+$",
        "description": "EUID — country.register.localId"
      },
      "AssociationId": {
        "type": "string",
        "pattern": "^[a-z][a-z0-9_-]{1,31}$"
      },
      "ConnectorId": {
        "type": "string",
        "pattern": "^urn:bdi:connector:[0-9a-f-]{36}$"
      },
      "ChainContextId": {
        "type": "string",
        "pattern": "^[0-9a-f-]{36}$"
      },
      "Assurance": {
        "type": "string",
        "enum": [
          "substantial",
          "high"
        ]
      },
      "MemberStatus": {
        "type": "string",
        "enum": [
          "draft",
          "verified",
          "activated",
          "suspended",
          "revoked"
        ]
      },
      "ErrorResponse": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string"
          },
          "detail": {
            "type": "string"
          }
        }
      }
    },
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      },
      "oauth2": {
        "type": "oauth2",
        "flows": {
          "clientCredentials": {
            "tokenUrl": "/oauth2/token",
            "scopes": {}
          }
        }
      }
    }
  }
}
