{
  "openapi": "3.1.0",
  "info": {
    "title": "Noemio API",
    "version": "1.0.0",
    "description": "Implemented Noemio service health and readiness endpoints. Responses describe the running process and its loaded application resources."
  },
  "servers": [
    { "url": "https://api.noemio.app", "description": "Production" },
    { "url": "https://api-test.noemio.app", "description": "Test" }
  ],
  "paths": {
    "/health": {
      "get": {
        "operationId": "getHealth",
        "summary": "Check process health",
        "responses": {
          "200": { "$ref": "#/components/responses/Health" },
          "405": { "$ref": "#/components/responses/Error" }
        }
      },
      "head": {
        "operationId": "headHealth",
        "summary": "Check process health without a response body",
        "responses": { "200": { "description": "The process is responding." } }
      }
    },
    "/api/v1/health": {
      "get": {
        "operationId": "getVersionedHealth",
        "summary": "Versioned alias of /health",
        "responses": { "200": { "$ref": "#/components/responses/Health" } }
      },
      "head": {
        "operationId": "headVersionedHealth",
        "summary": "Check process health without a response body",
        "responses": { "200": { "description": "The process is responding." } }
      }
    },
    "/readyz": {
      "get": {
        "operationId": "getReadiness",
        "summary": "Check loaded application dependencies",
        "description": "Checks the page template, translations and asset directory loaded at startup. Does not claim to check a database or external service.",
        "responses": {
          "200": {
            "description": "Application dependencies are ready.",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Readiness" } } }
          },
          "503": {
            "description": "An application dependency is unavailable.",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Readiness" } } }
          }
        }
      },
      "head": {
        "operationId": "headReadiness",
        "summary": "Check readiness without a response body",
        "responses": {
          "200": { "description": "Application dependencies are ready." },
          "503": { "description": "An application dependency is unavailable." }
        }
      }
    },
    "/openapi.json": {
      "get": {
        "operationId": "getOpenAPI",
        "summary": "Read this OpenAPI document",
        "responses": {
          "200": {
            "description": "OpenAPI 3.1 JSON document.",
            "content": { "application/json": { "schema": { "type": "object" } } }
          }
        }
      }
    }
  },
  "components": {
    "responses": {
      "Health": {
        "description": "The process is responding.",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Health" } } }
      },
      "Error": {
        "description": "The requested operation is not available.",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } }
      }
    },
    "schemas": {
      "Health": {
        "type": "object",
        "additionalProperties": false,
        "required": ["status", "service", "environment", "version"],
        "properties": {
          "status": { "type": "string", "const": "ok" },
          "service": { "type": "string", "const": "noemio-api" },
          "environment": { "type": "string", "enum": ["production", "test"] },
          "version": { "type": "string", "description": "Build version, normally the deployed Git commit SHA." }
        }
      },
      "Readiness": {
        "type": "object",
        "additionalProperties": false,
        "required": ["status", "service", "environment", "version", "checks"],
        "properties": {
          "status": { "type": "string", "enum": ["ready", "not_ready"] },
          "service": { "type": "string", "const": "noemio-api" },
          "environment": { "type": "string", "enum": ["production", "test"] },
          "version": { "type": "string" },
          "checks": {
            "type": "object",
            "additionalProperties": false,
            "required": ["web_template", "translations", "assets"],
            "properties": {
              "web_template": { "type": "boolean" },
              "translations": { "type": "boolean" },
              "assets": { "type": "boolean" }
            }
          }
        }
      },
      "Error": {
        "type": "object",
        "additionalProperties": false,
        "required": ["error"],
        "properties": {
          "error": {
            "type": "object",
            "additionalProperties": false,
            "required": ["code", "message"],
            "properties": {
              "code": { "type": "string" },
              "message": { "type": "string" }
            }
          }
        }
      }
    }
  }
}
