{
  "openapi": "3.1.0",
  "info": {
    "title": "a2a-to-poppy",
    "version": "0.5.0",
    "summary": "Converts between A2A Agent Cards and Personal Agent Protocol (Poppy) poppy.json documents, and explains where each field goes.",
    "description": "Stateless. Only public https hosts on port 443 are fetched; IP literals, internal names and this site itself are refused, redirects are re-checked hop by hop, and only Agent Cards and poppy.json documents are returned."
  },
  "servers": [
    {
      "url": "https://a2a-to-poppy.com"
    }
  ],
  "paths": {
    "/api/convert": {
      "get": {
        "operationId": "convertByUrl",
        "summary": "Fetch a public Agent Card or poppy.json and convert it",
        "parameters": [
          {
            "name": "url",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "A domain or an https URL. A bare domain tries /.well-known/poppy.json, then /.well-known/agent-card.json, then /.well-known/agent.json."
          },
          {
            "name": "raw",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "1"
              ]
            },
            "description": "1 returns only the converted document."
          },
          {
            "name": "kind",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "poppy",
                "card"
              ]
            },
            "description": "Which document to look for or expect. Default: detect."
          },
          {
            "name": "adapter",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uri"
            },
            "description": "https base URL of the adapter that will run the bridge. Default: this site."
          },
          {
            "name": "domain",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Agent Card to poppy.json only: the Company domain that will serve the result."
          },
          {
            "name": "issuer",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uri"
            },
            "description": "Agent Card to poppy.json only: the OAuth issuer for sign-in."
          },
          {
            "name": "card",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "1.0",
                "0.3"
              ]
            },
            "description": "poppy.json to Agent Card only: which A2A card shape to write. Default 1.0."
          },
          {
            "name": "fold",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "0",
                "1"
              ]
            },
            "description": "Agent Card to poppy.json only: 0 keeps skill names out of the entry description."
          }
        ],
        "responses": {
          "200": {
            "description": "The source, the converted document, the mapping records, checks and companion documents",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Conversion"
                }
              }
            }
          },
          "400": {
            "description": "The request was refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No Agent Card or poppy.json found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "The remote host failed or returned something else",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "convertDocument",
        "summary": "Convert a document you already have. Nothing is fetched",
        "parameters": [
          {
            "name": "kind",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "poppy",
                "card"
              ]
            },
            "description": "Which document to look for or expect. Default: detect."
          },
          {
            "name": "adapter",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uri"
            },
            "description": "https base URL of the adapter that will run the bridge. Default: this site."
          },
          {
            "name": "domain",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Agent Card to poppy.json only: the Company domain that will serve the result."
          },
          {
            "name": "issuer",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uri"
            },
            "description": "Agent Card to poppy.json only: the OAuth issuer for sign-in."
          },
          {
            "name": "card",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "1.0",
                "0.3"
              ]
            },
            "description": "poppy.json to Agent Card only: which A2A card shape to write. Default 1.0."
          },
          {
            "name": "fold",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "0",
                "1"
              ]
            },
            "description": "Agent Card to poppy.json only: 0 keeps skill names out of the entry description."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "description": "An Agent Card or a poppy.json, at most 256 KB."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "As for GET, without a source URL",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Conversion"
                }
              }
            }
          },
          "400": {
            "description": "The request was refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Body too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "Body is not JSON",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Not an Agent Card or a poppy.json",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/health": {
      "get": {
        "operationId": "health",
        "summary": "Liveness",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "service"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "service": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Check": {
        "type": "object",
        "required": [
          "level",
          "text"
        ],
        "properties": {
          "level": {
            "type": "string",
            "enum": [
              "must",
              "note",
              "ok"
            ]
          },
          "text": {
            "type": "string",
            "description": "Markdown-style backticks mark field names."
          }
        }
      },
      "Mapping": {
        "type": "object",
        "required": [
          "kind",
          "from",
          "to",
          "note"
        ],
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "copy",
              "shape",
              "adapter",
              "lost"
            ],
            "description": "copy: carried unchanged. shape: reshaped or renamed. adapter: consumed or supplied by the adapter. lost: no counterpart."
          },
          "from": {
            "type": [
              "string",
              "null"
            ],
            "description": "Path in the source document."
          },
          "to": {
            "type": [
              "string",
              "null"
            ],
            "description": "Path in the output document."
          },
          "note": {
            "type": "string"
          },
          "ref": {
            "type": "string",
            "description": "Spec section."
          }
        }
      },
      "Companion": {
        "type": "object",
        "required": [
          "tab",
          "where",
          "json"
        ],
        "properties": {
          "tab": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "where": {
            "type": "string",
            "description": "URL the document must be served at."
          },
          "note": {
            "type": "string"
          },
          "json": {
            "type": "object"
          }
        }
      },
      "Conversion": {
        "type": "object",
        "required": [
          "source",
          "output",
          "maps",
          "checks",
          "companions"
        ],
        "properties": {
          "source": {
            "type": "object",
            "required": [
              "kind",
              "json"
            ],
            "properties": {
              "url": {
                "type": "string"
              },
              "kind": {
                "type": "string",
                "enum": [
                  "agent-card",
                  "poppy"
                ]
              },
              "notes": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Check"
                }
              },
              "json": {
                "type": "object"
              }
            }
          },
          "output": {
            "type": "object",
            "required": [
              "kind",
              "json"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "agent-card",
                  "poppy"
                ]
              },
              "json": {
                "type": "object"
              }
            }
          },
          "maps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Mapping"
            }
          },
          "checks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Check"
            }
          },
          "companions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Companion"
            }
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "tried": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "url": {
                      "type": "string"
                    },
                    "reason": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
