{
  "openapi": "3.0.1",
  "info": {
    "title": "Broker API",
    "description": "Event broker for Sanity webhooks",
    "version": "v1.0.0"
  },
  "servers": [
    {
      "url": "https://broker.api.snokam.no"
    }
  ],
  "paths": {
    "/v1.0/pubsub/tv/uri": {
      "get": {
        "tags": [
          "WebPubSub"
        ],
        "summary": "Gets a Web PubSub token",
        "description": "Generates a Web PubSub token for joining and leaving the 'tv' group.",
        "operationId": "GetPubsubToken",
        "responses": {
          "200": {
            "description": "Web PubSub token generated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/pubSubToken"
                }
              }
            },
            "x-ms-summary": "Success"
          }
        }
      }
    },
    "/v1.0/sanity-webhook-to-azure": {
      "post": {
        "tags": [
          "Sanity"
        ],
        "summary": "Handles Sanity webhook events",
        "description": "Forwards Sanity webhook events to Azure Web PubSub and Service Bus.",
        "operationId": "SanityWebhookToAzure",
        "requestBody": {
          "description": "The Sanity webhook payload",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/sanityDocument"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Event processed successfully",
            "x-ms-summary": "Success"
          }
        },
        "security": [
          {
            "Implicit": []
          },
          {
            "ApiKey": []
          }
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "pubSubToken": {
        "type": "object",
        "properties": {
          "uri": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "sanityDocument": {
        "type": "object",
        "properties": {
          "_id": {
            "type": "string",
            "nullable": true
          },
          "_type": {
            "type": "string",
            "nullable": true
          },
          "_rev": {
            "type": "string",
            "nullable": true
          },
          "_key": {
            "type": "string",
            "nullable": true
          },
          "_createdAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "_updatedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      }
    },
    "securitySchemes": {
      "Implicit": {
        "type": "oauth2",
        "flows": {
          "implicit": {
            "authorizationUrl": "https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize",
            "tokenUrl": "https://login.microsoftonline.com/organizations/oauth2/v2.0/token",
            "refreshUrl": "https://login.microsoftonline.com/organizations/oauth2/v2.0/token",
            "scopes": {
              "api://bb21a8d0-366b-4a95-aa59-dbbf708322d1/.default": "Default function scope"
            }
          }
        }
      },
      "ApiKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    }
  }
}