{
    "openapi": "3.0.3",
    "info": {
        "title": "Catalog108 API",
        "description": "Practice scraping sandbox. Stable, deterministic data backed by seed 108.",
        "version": "1.0.0",
        "contact": {
            "name": "Scraping Central",
            "url": "https://scrapingcentral.com"
        },
        "license": {
            "name": "MIT"
        }
    },
    "servers": [
        {
            "url": "https://practice.scrapingcentral.com",
            "description": "Production"
        },
        {
            "url": "http://127.0.0.1:8080",
            "description": "Local"
        }
    ],
    "paths": {
        "/api/products": {
            "get": {
                "summary": "List products",
                "parameters": [
                    {
                        "name": "page",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "default": 1
                        }
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "default": 12,
                            "maximum": 50
                        }
                    },
                    {
                        "name": "category",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Paginated product list",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ProductPage"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/api/products/{id}": {
            "get": {
                "summary": "Get one product",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Product",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/Product"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Not found"
                    }
                }
            }
        },
        "/api/products/{id}/reviews": {
            "get": {
                "summary": "List reviews for a product",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "page",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "default": 1
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Paginated reviews"
                    }
                }
            }
        },
        "/api/auth/login": {
            "post": {
                "summary": "Issue JWT tokens (System B)",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "email",
                                    "password"
                                ],
                                "properties": {
                                    "email": {
                                        "type": "string",
                                        "format": "email"
                                    },
                                    "password": {
                                        "type": "string",
                                        "format": "password"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Tokens issued"
                    },
                    "401": {
                        "description": "Invalid credentials"
                    }
                }
            }
        },
        "/api/auth/refresh": {
            "post": {
                "summary": "Refresh an access token",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "refresh_token": {
                                        "type": "string"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Refreshed"
                    },
                    "401": {
                        "description": "Invalid refresh token"
                    }
                }
            }
        },
        "/api/auth/me": {
            "get": {
                "summary": "Current authenticated user (Bearer required)",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Token payload"
                    },
                    "401": {
                        "description": "Not authenticated"
                    }
                }
            }
        },
        "/api/locations": {
            "get": {
                "summary": "Store locations (used by the map XHR on /locations)",
                "responses": {
                    "200": {
                        "description": "List of stores"
                    }
                }
            }
        },
        "/api/graphql": {
            "post": {
                "summary": "GraphQL endpoint (introspection enabled)",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "query": {
                                        "type": "string"
                                    },
                                    "variables": {
                                        "type": "object"
                                    },
                                    "extensions": {
                                        "type": "object"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "GraphQL response"
                    }
                }
            }
        },
        "/api/graphql/no-introspection": {
            "post": {
                "summary": "GraphQL endpoint with introspection disabled",
                "responses": {
                    "200": {
                        "description": "GraphQL response"
                    },
                    "400": {
                        "description": "Introspection blocked"
                    }
                }
            }
        },
        "/api/graphql/persisted": {
            "post": {
                "summary": "GraphQL endpoint accepting only persisted queries (by sha256Hash)",
                "responses": {
                    "200": {
                        "description": "GraphQL response"
                    },
                    "400": {
                        "description": "Persisted query not found"
                    }
                }
            }
        },
        "/api/ws/echo": {
            "post": {
                "summary": "Simulated WebSocket echo",
                "responses": {
                    "200": {
                        "description": "Echoes the JSON body"
                    }
                }
            }
        },
        "/api/ws/live-prices": {
            "get": {
                "summary": "Simulated live-price WebSocket feed (poll on 3s cadence)",
                "responses": {
                    "200": {
                        "description": "Frame list"
                    }
                }
            }
        },
        "/api/ws/socketio": {
            "get": {
                "summary": "Socket.IO polling transport, message frame (type 4)",
                "responses": {
                    "200": {
                        "description": "Type-prefixed JSON"
                    }
                }
            }
        },
        "/api/sse/notifications": {
            "get": {
                "summary": "Server-Sent Events stream (one frame per request on shared hosting)",
                "responses": {
                    "200": {
                        "description": "text/event-stream",
                        "content": {
                            "text/event-stream": []
                        }
                    }
                }
            }
        },
        "/oauth/authorize": {
            "get": {
                "summary": "OAuth 2.0 Authorization endpoint (System C)",
                "parameters": [
                    {
                        "name": "response_type",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "enum": [
                                "code"
                            ]
                        }
                    },
                    {
                        "name": "client_id",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "redirect_uri",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "scope",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "state",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "302": {
                        "description": "Redirect with code, or error"
                    }
                }
            }
        },
        "/oauth/token": {
            "post": {
                "summary": "OAuth 2.0 Token endpoint",
                "responses": {
                    "200": {
                        "description": "Access token"
                    },
                    "400": {
                        "description": "invalid_grant"
                    },
                    "401": {
                        "description": "invalid_client"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "Product": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "integer"
                    },
                    "sku": {
                        "type": "string"
                    },
                    "slug": {
                        "type": "string"
                    },
                    "name": {
                        "type": "string"
                    },
                    "price": {
                        "type": "string"
                    },
                    "price_cents": {
                        "type": "integer"
                    },
                    "currency": {
                        "type": "string"
                    },
                    "in_stock": {
                        "type": "boolean"
                    },
                    "rating": {
                        "type": "number"
                    },
                    "review_count": {
                        "type": "integer"
                    },
                    "description": {
                        "type": "string"
                    },
                    "brand_name": {
                        "type": "string"
                    },
                    "category_name": {
                        "type": "string"
                    }
                }
            },
            "ProductPage": {
                "type": "object",
                "properties": {
                    "meta": {
                        "type": "object",
                        "properties": {
                            "page": {
                                "type": "integer"
                            },
                            "per_page": {
                                "type": "integer"
                            },
                            "total": {
                                "type": "integer"
                            },
                            "total_pages": {
                                "type": "integer"
                            },
                            "has_next": {
                                "type": "boolean"
                            }
                        }
                    },
                    "data": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Product"
                        }
                    }
                }
            }
        },
        "securitySchemes": {
            "bearerAuth": {
                "type": "http",
                "scheme": "bearer",
                "bearerFormat": "JWT"
            }
        }
    }
}