{
  "openapi": "3.2.1",
  "info": {
    "title": "OEDTP v0.1 registry interface",
    "version": "0.1.0",
    "summary": "Register, search, retrieve and revalidate networks that publish an OEDTP identity document.",
    "description": "A vendor-neutral interface any party may implement. Registration is not endorsement and validation is not a security certification: records keep `registered` and `validated` as separate fields and always carry `endorsement: false`. Paths are relative to the registry's base URL.",
    "license": {
      "name": "MIT",
      "identifier": "MIT"
    }
  },
  "servers": [
    {
      "url": "https://registry.example.org",
      "description": "Any registry. Replace with the registry's base URL."
    }
  ],
  "paths": {
    "/v0.1/registry/networks": {
      "post": {
        "operationId": "registerNetwork",
        "summary": "Register a domain (state: registered), then validate it",
        "description": "Accepts a domain, records it as registered, fetches https://<domain>/.well-known/open-edge.json from the domain itself, and records the validation result. No account, credential, payment or approval is required.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "domain"
                ],
                "properties": {
                  "domain": {
                    "$ref": "#/components/schemas/Domain"
                  }
                },
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The record after registration and validation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NetworkRecord"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Problem"
          },
          "422": {
            "description": "The domain does not serve an identity document at /.well-known/open-edge.json yet, so it is not listed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/Problem"
          }
        }
      },
      "get": {
        "operationId": "searchNetworks",
        "summary": "Search registered networks",
        "parameters": [
          {
            "name": "capability",
            "in": "query",
            "description": "Capability id, or a prefix ending in * (for example org.example.*)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "state",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "registered",
                "validated",
                "indexed"
              ]
            }
          },
          {
            "name": "source_type",
            "in": "query",
            "required": false,
            "description": "native: submitted by the domain itself. external_indexed: copied from a public catalog; never registered, validated or endorsed here.",
            "schema": {
              "type": "string",
              "enum": [
                "native",
                "external_indexed"
              ]
            }
          },
          {
            "name": "q",
            "in": "query",
            "description": "Text matched against network name, domain and capability summaries",
            "schema": {
              "type": "string",
              "maxLength": 100
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Matching records",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "count",
                    "networks",
                    "endorsement"
                  ],
                  "properties": {
                    "count": {
                      "type": "integer"
                    },
                    "networks": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/NetworkRecord"
                      }
                    },
                    "endorsement": {
                      "const": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v0.1/registry/networks/{domain}": {
      "get": {
        "operationId": "getNetwork",
        "summary": "Retrieve one record",
        "parameters": [
          {
            "name": "domain",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/Domain"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The record",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NetworkRecord"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          }
        }
      }
    },
    "/v0.1/registry/networks/{domain}/validate": {
      "post": {
        "operationId": "revalidateNetwork",
        "summary": "Validate a registered domain again",
        "parameters": [
          {
            "name": "domain",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/Domain"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The record after validation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NetworkRecord"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          },
          "429": {
            "$ref": "#/components/responses/Problem"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Domain": {
        "type": "string",
        "pattern": "^(?=.{1,253}$)([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\\.)+[a-z][a-z0-9-]{0,61}[a-z0-9]$"
      },
      "NetworkRecord": {
        "type": "object",
        "required": [
          "domain",
          "registered",
          "validated",
          "state",
          "endorsement"
        ],
        "properties": {
          "domain": {
            "$ref": "#/components/schemas/Domain"
          },
          "identity_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "name": {
            "type": [
              "string",
              "null"
            ]
          },
          "registered": {
            "type": "boolean",
            "description": "The registry accepted the domain into its index after the domain was submitted. Always false for external_indexed records. Says nothing about content."
          },
          "validated": {
            "type": "boolean",
            "description": "The last validation passed every required check. Not an endorsement or security certification."
          },
          "state": {
            "type": "string",
            "enum": [
              "registered",
              "validated",
              "indexed"
            ]
          },
          "endorsement": {
            "const": false
          },
          "registered_at": {
            "type": "string",
            "format": "date-time"
          },
          "capabilities": {
            "type": "array",
            "description": "Capability ids from the last passing validation",
            "items": {
              "type": "object",
              "required": [
                "id",
                "version",
                "summary"
              ],
              "properties": {
                "id": {
                  "type": "string"
                },
                "version": {
                  "type": "string"
                },
                "summary": {
                  "type": "string"
                }
              }
            }
          },
          "validation": {
            "type": [
              "object",
              "null"
            ],
            "required": [
              "checked_at",
              "protocol_version",
              "suite_version",
              "result",
              "failed_checks"
            ],
            "properties": {
              "checked_at": {
                "type": "string",
                "format": "date-time"
              },
              "protocol_version": {
                "const": "0.1.0"
              },
              "suite_version": {
                "type": "string"
              },
              "result": {
                "type": "string",
                "enum": [
                  "pass",
                  "fail"
                ]
              },
              "failed_checks": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "security_certification": {
                "const": false
              }
            }
          },
          "source_type": {
            "type": "string",
            "enum": [
              "native",
              "external_indexed"
            ],
            "description": "native: the domain publishes an OEDTP identity document and was submitted to this registry. external_indexed: a public capability record indexed from another open catalog (registered false, validated false, state indexed). Indexing is not registration, validation or endorsement."
          },
          "indexed_from": {
            "type": "object",
            "description": "For external_indexed records: the public catalog the record was copied from.",
            "properties": {
              "source": {
                "type": "string"
              },
              "url": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "uri"
              },
              "indexed_at": {
                "type": "string"
              }
            }
          }
        }
      },
      "Problem": {
        "type": "object",
        "required": [
          "error",
          "message"
        ],
        "properties": {
          "error": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      }
    },
    "responses": {
      "Problem": {
        "description": "An error",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      }
    }
  }
}
