{
  "openapi": "3.1.0",
  "info": {
    "title": "HostGrade discovery API",
    "version": "1.0.0",
    "summary": "Minimal read-only API surface for machine discovery.",
    "description": "OpenAPI fallback for HostGrade discovery surfaces. Covers health, assistant wizard offers, and affiliate redirect endpoints.",
    "contact": {
      "name": "HostGrade.pl",
      "email": "kontakt@hostgrade.pl",
      "url": "https://hostgrade.pl/kontakt"
    },
    "license": {
      "name": "Proprietary",
      "url": "https://hostgrade.pl/regulamin"
    }
  },
  "jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
  "servers": [
    {
      "url": "https://hostgrade.pl",
      "description": "Tenant-aware canonical origin derived from the Host header."
    }
  ],
  "paths": {
    "/api/health": {
      "get": {
        "operationId": "getHealth",
        "summary": "Health and readiness probe",
        "description": "Returns application liveness plus DB latency-derived readiness status.",
        "responses": {
          "200": {
            "description": "Service is reachable and not down.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status",
                    "checks",
                    "timestamp",
                    "version"
                  ],
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": [
                        "ok",
                        "degraded",
                        "down"
                      ]
                    },
                    "checks": {
                      "type": "object",
                      "required": [
                        "db"
                      ],
                      "properties": {
                        "db": {
                          "type": "object",
                          "required": [
                            "status",
                            "latencyMs"
                          ],
                          "properties": {
                            "status": {
                              "type": "string",
                              "enum": [
                                "ok",
                                "degraded",
                                "down"
                              ]
                            },
                            "latencyMs": {
                              "type": "integer",
                              "minimum": 0
                            }
                          },
                          "additionalProperties": false
                        }
                      },
                      "additionalProperties": false
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "version": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": false
                }
              }
            }
          },
          "503": {
            "description": "Service is reachable but health status is down.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status",
                    "checks",
                    "timestamp",
                    "version"
                  ],
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": [
                        "ok",
                        "degraded",
                        "down"
                      ]
                    },
                    "checks": {
                      "type": "object",
                      "required": [
                        "db"
                      ],
                      "properties": {
                        "db": {
                          "type": "object",
                          "required": [
                            "status",
                            "latencyMs"
                          ],
                          "properties": {
                            "status": {
                              "type": "string",
                              "enum": [
                                "ok",
                                "degraded",
                                "down"
                              ]
                            },
                            "latencyMs": {
                              "type": "integer",
                              "minimum": 0
                            }
                          },
                          "additionalProperties": false
                        }
                      },
                      "additionalProperties": false
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "version": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/api/wizard-offers.json": {
      "get": {
        "operationId": "getWizardOffers",
        "summary": "Assistant wizard offers feed",
        "description": "Returns a read-only JSON array of offers used by the on-site assistant wizard.",
        "responses": {
          "200": {
            "description": "Offer feed loaded successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "description": "DisplayOffer-like object returned by the assistant wizard feed.",
                    "properties": {
                      "providerSlug": {
                        "type": "string"
                      },
                      "slug": {
                        "type": "string"
                      },
                      "name": {
                        "type": "string"
                      },
                      "category": {
                        "type": "string"
                      },
                      "grade": {
                        "type": [
                          "string",
                          "null"
                        ]
                      },
                      "promoPrice": {
                        "type": [
                          "number",
                          "null"
                        ]
                      },
                      "renewalPrice": {
                        "type": [
                          "number",
                          "null"
                        ]
                      },
                      "currency": {
                        "type": [
                          "string",
                          "null"
                        ]
                      },
                      "affiliateUrl": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "format": "uri-reference"
                      }
                    },
                    "additionalProperties": true
                  }
                }
              }
            }
          },
          "500": {
            "description": "Offer feed could not be loaded.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "integer"
                    }
                  },
                  "additionalProperties": true
                }
              }
            }
          }
        }
      }
    },
    "/out/{slug}": {
      "get": {
        "operationId": "redirectAffiliateSlug",
        "summary": "Temporary affiliate redirect",
        "description": "Resolves a partner slug to a temporary redirect. Use for navigation only; clients should not treat the destination as canonical.",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Affiliate link slug or provider slug.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]+$"
            }
          }
        ],
        "responses": {
          "302": {
            "description": "Temporary redirect to the resolved partner destination or fallback page.",
            "headers": {
              "Location": {
                "description": "Resolved redirect target.",
                "schema": {
                  "type": "string",
                  "format": "uri-reference"
                }
              }
            }
          },
          "500": {
            "description": "Unexpected redirect resolution error.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "integer"
                    }
                  },
                  "additionalProperties": true
                }
              }
            }
          }
        }
      }
    }
  }
}