{
  "openapi": "3.1.0",
  "info": {
    "title": "KnalpotRacing Catalog API",
    "version": "1.5.3",
    "description": "Read-only motorcycle catalog API with a public HET feed and an HMAC-SHA256 protected private pricing feed."
  },
  "servers": [
    {
      "url": "https://api.knalpotracing.com"
    }
  ],
  "tags": [
    {
      "name": "Catalog"
    },
    {
      "name": "System"
    }
  ],
  "paths": {
    "/health/": {
      "get": {
        "tags": [
          "System"
        ],
        "summary": "Service health",
        "responses": {
          "200": {
            "description": "Service is available",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthResponse"
                }
              }
            }
          }
        },
        "description": "Browser requests receive the visual health dashboard. API clients can request JSON with Accept: application/json or ?format=json."
      }
    },
    "/v1/catalog/public/": {
      "get": {
        "tags": [
          "Catalog"
        ],
        "summary": "Public catalog feed",
        "description": "Browser-safe catalog feed exposing HET only.",
        "parameters": [
          {
            "name": "pretty",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "1"
              ]
            },
            "description": "Pretty-print JSON for manual inspection."
          }
        ],
        "responses": {
          "200": {
            "description": "Public catalog",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CatalogResponsePublic"
                }
              }
            }
          },
          "405": {
            "$ref": "#/components/responses/ApiError"
          },
          "500": {
            "$ref": "#/components/responses/ApiError"
          }
        }
      },
      "head": {
        "tags": [
          "Catalog"
        ],
        "summary": "Public catalog headers",
        "responses": {
          "200": {
            "description": "Catalog headers"
          }
        }
      }
    },
    "/v1/catalog/private/": {
      "get": {
        "tags": [
          "Catalog"
        ],
        "summary": "Private full-price catalog feed",
        "description": "Server-to-server only. Requires all HMAC v1 headers and scopes catalog.read, pricing.internal.read and stock.read.",
        "security": [
          {
            "KrClientId": [],
            "KrTimestamp": [],
            "KrNonce": [],
            "KrSignatureVersion": [],
            "KrSignature": []
          }
        ],
        "responses": {
          "200": {
            "description": "Private catalog",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "X-KR-Auth-Mode": {
                "schema": {
                  "type": "string",
                  "example": "hmac-v1"
                }
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CatalogResponsePrivate"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/ApiError"
          },
          "403": {
            "$ref": "#/components/responses/ApiError"
          },
          "409": {
            "$ref": "#/components/responses/ApiError"
          },
          "429": {
            "$ref": "#/components/responses/ApiError"
          },
          "500": {
            "$ref": "#/components/responses/ApiError"
          },
          "503": {
            "$ref": "#/components/responses/ApiError"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "KrClientId": {
        "type": "apiKey",
        "in": "header",
        "name": "X-KR-Client-Id"
      },
      "KrTimestamp": {
        "type": "apiKey",
        "in": "header",
        "name": "X-KR-Timestamp"
      },
      "KrNonce": {
        "type": "apiKey",
        "in": "header",
        "name": "X-KR-Nonce"
      },
      "KrSignatureVersion": {
        "type": "apiKey",
        "in": "header",
        "name": "X-KR-Signature-Version"
      },
      "KrSignature": {
        "type": "apiKey",
        "in": "header",
        "name": "X-KR-Signature"
      }
    },
    "responses": {
      "ApiError": {
        "description": "API error",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      }
    },
    "schemas": {
      "HealthResponse": {
        "type": "object",
        "required": [
          "success",
          "service",
          "version",
          "status",
          "time"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "const": true
          },
          "service": {
            "type": "string"
          },
          "version": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "example": "UP"
          },
          "time": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ApiInfo": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "version": {
            "type": "string"
          },
          "feed": {
            "type": "string",
            "enum": [
              "PUBLIC_HET_ONLY",
              "PRIVATE_FULL_PRICE"
            ]
          },
          "read_only": {
            "type": "boolean",
            "const": true
          }
        }
      },
      "Stock": {
        "type": "object",
        "properties": {
          "qty": {
            "type": "integer"
          },
          "available": {
            "type": "boolean"
          },
          "status": {
            "type": "string",
            "enum": [
              "OUT_OF_STOCK",
              "LOW_STOCK",
              "IN_STOCK"
            ]
          }
        }
      },
      "PublicPrices": {
        "type": "object",
        "properties": {
          "currency": {
            "type": "string",
            "example": "IDR"
          },
          "het": {
            "type": "integer"
          }
        }
      },
      "PrivatePrices": {
        "allOf": [
          {
            "$ref": "#/components/schemas/PublicPrices"
          },
          {
            "type": "object",
            "properties": {
              "modal": {
                "type": "integer"
              },
              "distributor": {
                "type": "integer"
              },
              "reseller": {
                "type": "integer"
              },
              "bengkel": {
                "type": "integer"
              },
              "admin": {
                "type": "integer"
              }
            }
          }
        ]
      },
      "ProductBase": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "barcode": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "brand": {
            "type": "string"
          },
          "categories": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "condition": {
            "type": "string"
          },
          "quality": {
            "type": "string"
          },
          "additional_info": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "weight_gram": {
            "type": "integer"
          },
          "stock": {
            "$ref": "#/components/schemas/Stock"
          },
          "status": {
            "type": "string",
            "enum": [
              "ACTIVE",
              "NONACTIVE"
            ]
          },
          "images": {
            "type": "object",
            "additionalProperties": true
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "updated_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "ProductPublic": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ProductBase"
          },
          {
            "type": "object",
            "properties": {
              "prices": {
                "$ref": "#/components/schemas/PublicPrices"
              }
            }
          }
        ]
      },
      "ProductPrivate": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ProductBase"
          },
          {
            "type": "object",
            "properties": {
              "prices": {
                "$ref": "#/components/schemas/PrivatePrices"
              }
            }
          }
        ]
      },
      "CatalogMeta": {
        "type": "object",
        "additionalProperties": true
      },
      "CatalogResponsePublic": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "const": true
          },
          "api": {
            "$ref": "#/components/schemas/ApiInfo"
          },
          "meta": {
            "$ref": "#/components/schemas/CatalogMeta"
          },
          "brands": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "categories": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "products": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProductPublic"
            }
          }
        }
      },
      "CatalogResponsePrivate": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "const": true
          },
          "api": {
            "$ref": "#/components/schemas/ApiInfo"
          },
          "meta": {
            "$ref": "#/components/schemas/CatalogMeta"
          },
          "brands": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "categories": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "products": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProductPrivate"
            }
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "const": false
          },
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  }
}
