tesr / lk-api-spec.json
abeea's picture
Upload 6 files
3a74bdf verified
Raw
History Blame Contribute Delete
16.1 kB
{
"openapi": "3.0.3",
"info": {
"title": "lk API",
"description": "Auto-generated API specification for lk (fashion_apparel store). Variant dimensions: Size, Color.",
"version": "1.0.0"
},
"servers": [
{
"url": "https://bdwewiveuzpakrzphljo.supabase.co/functions/v1",
"description": "Supabase Edge Functions"
}
],
"components": {
"securitySchemes": {
"ApiKeyAuth": {
"type": "apiKey",
"in": "header",
"name": "x-api-key"
}
},
"schemas": {
"Product": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid"
},
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"base_price": {
"type": "number"
},
"category": {
"type": "string"
},
"is_active": {
"type": "boolean"
},
"extra_fields": {
"type": "object"
},
"variants": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Variant"
}
}
}
},
"Variant": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid"
},
"product_id": {
"type": "string",
"format": "uuid"
},
"size": {
"type": "string"
},
"color": {
"type": "string"
},
"stock_quantity": {
"type": "integer"
},
"price_override": {
"type": "number",
"nullable": true
},
"image_url": {
"type": "string",
"nullable": true
},
"is_active": {
"type": "boolean"
}
}
},
"Order": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid"
},
"tracking_id": {
"type": "string"
},
"customer_name": {
"type": "string"
},
"customer_email": {
"type": "string"
},
"customer_phone": {
"type": "string"
},
"delivery_status": {
"type": "string"
},
"subtotal": {
"type": "number"
},
"shipping_fee": {
"type": "number"
},
"total": {
"type": "number"
},
"items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"variant_id": {
"type": "string",
"format": "uuid"
},
"product_id": {
"type": "string",
"format": "uuid"
},
"product_name": {
"type": "string"
},
"variant_label": {
"type": "string"
},
"quantity": {
"type": "integer"
},
"unit_price": {
"type": "number"
}
}
}
},
"created_at": {
"type": "string",
"format": "date-time"
}
}
},
"TrackingResponse": {
"type": "object",
"properties": {
"tracking_id": {
"type": "string"
},
"status": {
"type": "string"
},
"customer_name": {
"type": "string"
},
"items_summary": {
"type": "array",
"items": {
"type": "string"
}
},
"created_at": {
"type": "string",
"format": "date-time"
}
}
},
"Error": {
"type": "object",
"properties": {
"error": {
"type": "string"
}
}
}
}
},
"security": [
{
"ApiKeyAuth": []
}
],
"paths": {
"/products": {
"get": {
"summary": "List products",
"description": "Returns paginated list of active products with nested variants.",
"parameters": [
{
"name": "category",
"in": "query",
"schema": {
"type": "string"
},
"description": "Filter by category"
},
{
"name": "search",
"in": "query",
"schema": {
"type": "string"
},
"description": "Search by product name"
},
{
"name": "page",
"in": "query",
"schema": {
"type": "integer",
"default": 1
}
},
{
"name": "limit",
"in": "query",
"schema": {
"type": "integer",
"default": 20
}
}
],
"responses": {
"200": {
"description": "Paginated product list",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Product"
}
},
"total": {
"type": "integer"
},
"page": {
"type": "integer"
},
"limit": {
"type": "integer"
}
}
}
}
}
}
}
},
"post": {
"summary": "Create product",
"description": "Create a new product with optional variants. Requires can_write permission.",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Product"
}
}
}
},
"responses": {
"201": {
"description": "Product created",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Product"
}
}
}
}
}
}
},
"/products/{id}": {
"get": {
"summary": "Get product by ID",
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "string",
"format": "uuid"
}
}
],
"responses": {
"200": {
"description": "Product with variants",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Product"
}
}
}
},
"404": {
"description": "Not found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
},
"put": {
"summary": "Update product",
"description": "Update product base fields. Requires can_write.",
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "string",
"format": "uuid"
}
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Product"
}
}
}
},
"responses": {
"200": {
"description": "Product updated",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Product"
}
}
}
}
}
},
"delete": {
"summary": "Delete product (soft)",
"description": "Soft-deletes a product by setting is_active to false.",
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "string",
"format": "uuid"
}
}
],
"responses": {
"200": {
"description": "Product deactivated"
}
}
}
},
"/variants/{productId}": {
"get": {
"summary": "List variants for a product",
"parameters": [
{
"name": "productId",
"in": "path",
"required": true,
"schema": {
"type": "string",
"format": "uuid"
}
}
],
"responses": {
"200": {
"description": "Variant list",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Variant"
}
}
}
}
}
}
}
}
},
"post": {
"summary": "Add variant to product",
"parameters": [
{
"name": "productId",
"in": "path",
"required": true,
"schema": {
"type": "string",
"format": "uuid"
}
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Variant"
}
}
}
},
"responses": {
"201": {
"description": "Variant created",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Variant"
}
}
}
}
}
}
},
"/orders": {
"get": {
"summary": "List orders",
"parameters": [
{
"name": "status",
"in": "query",
"schema": {
"type": "string"
}
},
{
"name": "search",
"in": "query",
"schema": {
"type": "string"
}
},
{
"name": "page",
"in": "query",
"schema": {
"type": "integer",
"default": 1
}
}
],
"responses": {
"200": {
"description": "Paginated order list",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Order"
}
},
"total": {
"type": "integer"
},
"page": {
"type": "integer"
},
"limit": {
"type": "integer"
}
}
}
}
}
}
}
},
"post": {
"summary": "Create order",
"description": "Creates a new order, validates variants, decrements stock atomically, fires order_created webhook.",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"items",
"customer_name"
],
"properties": {
"customer_name": {
"type": "string"
},
"customer_email": {
"type": "string"
},
"customer_phone": {
"type": "string"
},
"shipping_address": {
"type": "object"
},
"shipping_fee": {
"type": "number"
},
"notes": {
"type": "string"
},
"items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"variant_id": {
"type": "string",
"format": "uuid"
},
"quantity": {
"type": "integer"
}
}
}
}
}
}
}
}
},
"responses": {
"201": {
"description": "Order created"
}
}
}
},
"/orders/{id}": {
"patch": {
"summary": "Update order status",
"description": "Update delivery_status only. Fires status_changed webhook.",
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "string",
"format": "uuid"
}
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"delivery_status": {
"type": "string"
}
}
}
}
}
},
"responses": {
"200": {
"description": "Status updated"
}
}
}
},
"/orders/track/{trackingId}": {
"get": {
"summary": "Track order (public)",
"description": "Public endpoint — no API key required. Returns minimal tracking info only.",
"security": [],
"parameters": [
{
"name": "trackingId",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Tracking info",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/TrackingResponse"
}
}
}
},
"404": {
"description": "Order not found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
}
}
}
}