{
    "openapi": "3.1.0",
    "info": {
        "title": "Nova E-Ticaret API",
        "version": "1.0.0",
        "description": "Mobil uygulamalar ve harici sistemler için katalog, sipariş ve analitik API'si."
    },
    "tags": [
        {
            "name": "Catalog"
        },
        {
            "name": "Orders"
        },
        {
            "name": "Analytics"
        },
        {
            "name": "Experiments"
        }
    ],
    "components": {
        "securitySchemes": {
            "bearerAuth": {
                "type": "http",
                "scheme": "bearer",
                "bearerFormat": "Nova API token"
            }
        },
        "schemas": {
            "Error": {
                "type": "object",
                "required": [
                    "error"
                ],
                "properties": {
                    "error": {
                        "type": "string"
                    }
                }
            },
            "OrderItemInput": {
                "type": "object",
                "required": [
                    "product_id",
                    "quantity"
                ],
                "properties": {
                    "product_id": {
                        "type": "integer",
                        "minimum": 1
                    },
                    "variant_id": {
                        "type": "integer",
                        "minimum": 0,
                        "default": 0
                    },
                    "quantity": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 99
                    }
                }
            },
            "OrderInput": {
                "type": "object",
                "required": [
                    "name",
                    "email",
                    "phone",
                    "address",
                    "city",
                    "payment_method",
                    "items"
                ],
                "properties": {
                    "name": {
                        "type": "string"
                    },
                    "email": {
                        "type": "string",
                        "format": "email"
                    },
                    "phone": {
                        "type": "string"
                    },
                    "address": {
                        "type": "string"
                    },
                    "city": {
                        "type": "string"
                    },
                    "district": {
                        "type": "string"
                    },
                    "postal_code": {
                        "type": "string"
                    },
                    "payment_method": {
                        "type": "string",
                        "description": "Aktif havale veya kapıda ödeme yöntem kodu; credit_card kabul edilmez."
                    },
                    "invoice_type": {
                        "type": "string",
                        "enum": [
                            "individual",
                            "company"
                        ],
                        "default": "individual"
                    },
                    "company_name": {
                        "type": "string"
                    },
                    "tax_office": {
                        "type": "string"
                    },
                    "tax_number": {
                        "type": "string"
                    },
                    "notes": {
                        "type": "string"
                    },
                    "items": {
                        "type": "array",
                        "minItems": 1,
                        "items": {
                            "$ref": "#/components/schemas/OrderItemInput"
                        }
                    }
                }
            }
        },
        "responses": {
            "Unauthorized": {
                "description": "Token geçersiz veya gerekli yetki yok",
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/Error"
                        }
                    }
                }
            },
            "NotFound": {
                "description": "Kayıt bulunamadı",
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/Error"
                        }
                    }
                }
            },
            "ValidationError": {
                "description": "İş kuralı veya doğrulama hatası",
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/Error"
                        }
                    }
                }
            }
        }
    },
    "paths": {
        "/api/v1/products": {
            "get": {
                "tags": [
                    "Catalog"
                ],
                "summary": "Ürünleri listele",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Ürün listesi"
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    }
                }
            }
        },
        "/api/v1/products/{id}": {
            "get": {
                "tags": [
                    "Catalog"
                ],
                "summary": "Ürün detayını getir",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Ürün, varyantlar ve görseller"
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "404": {
                        "$ref": "#/components/responses/NotFound"
                    }
                }
            }
        },
        "/api/v1/categories": {
            "get": {
                "tags": [
                    "Catalog"
                ],
                "summary": "Kategorileri listele",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Kategori listesi"
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    }
                }
            }
        },
        "/api/v1/search": {
            "get": {
                "tags": [
                    "Catalog"
                ],
                "summary": "Katalogda ara",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "parameters": [
                    {
                        "name": "q",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 100,
                            "default": 24
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Arama sonuçları"
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "503": {
                        "description": "Arama sağlayıcısı kullanılamıyor"
                    }
                }
            }
        },
        "/api/v1/orders": {
            "get": {
                "tags": [
                    "Orders"
                ],
                "summary": "Siparişleri listele",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "parameters": [
                    {
                        "name": "limit",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 200,
                            "default": 50
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Sipariş listesi"
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    }
                }
            },
            "post": {
                "tags": [
                    "Orders"
                ],
                "summary": "Sipariş oluştur",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/OrderInput"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Sipariş oluşturuldu"
                    },
                    "400": {
                        "description": "Geçersiz JSON"
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "422": {
                        "$ref": "#/components/responses/ValidationError"
                    }
                }
            }
        },
        "/api/v1/analytics": {
            "post": {
                "tags": [
                    "Analytics"
                ],
                "summary": "Analitik olay gönder",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "event"
                                ],
                                "properties": {
                                    "event": {
                                        "type": "string"
                                    },
                                    "properties": {
                                        "type": "object",
                                        "additionalProperties": true
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "202": {
                        "description": "Olay kabul edildi"
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    }
                }
            }
        },
        "/api/v1/experiments/{key}": {
            "get": {
                "tags": [
                    "Experiments"
                ],
                "summary": "Ziyaretçiye atanan varyantı getir",
                "parameters": [
                    {
                        "name": "key",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Deney ataması"
                    }
                }
            }
        }
    },
    "servers": [
        {
            "url": "https://eticaret.wawbilisim.com",
            "description": "Bu mağaza"
        }
    ]
}