{
    "swagger": "2.0",
    "info": {
      "version": "1.0.0",
      "title": "Product API",
      "description": "API documentation for product management, including image upload and basic CRUD operations"
    },
    "host": "localhost:3000", 
    "basePath": "/api/products", 
    "schemes": ["http"],
    "consumes": ["application/json", "multipart/form-data"],
    "produces": ["application/json"],
    "paths": {
      "/": {
        "post": {
          "summary": "Create a new product",
          "description": "Create a new product with an image upload",
          "consumes": ["multipart/form-data"],
          "parameters": [
            {
              "in": "formData",
              "name": "title",
              "type": "string",
              "required": true,
              "description": "Title of the product"
            },
            {
              "in": "formData",
              "name": "description",
              "type": "string",
              "required": true,
              "description": "Description of the product"
            },
            {
              "in": "formData",
              "name": "pricing",
              "type": "number",
              "format": "float",
              "required": true,
              "description": "Price of the product"
            },
            {
              "in": "formData",
              "name": "features",
              "type": "string",
              "required": false,
              "description": "Features of the product, stored as JSON"
            },
            {
              "in": "formData",
              "name": "image",
              "type": "file",
              "required": false,
              "description": "Image file for the product"
            }
          ],
          "responses": {
            "201": {
              "description": "Product created successfully",
              "schema": {
                "$ref": "#/definitions/ProductResponse"
              }
            },
            "500": {
              "description": "Server error"
            }
          }
        },
        "get": {
          "summary": "Get all products",
          "description": "Fetch all products with full image URLs",
          "responses": {
            "200": {
              "description": "List of all products",
              "schema": {
                "type": "array",
                "items": {
                  "$ref": "#/definitions/ProductResponse"
                }
              }
            },
            "500": {
              "description": "Server error"
            }
          }
        }
      },
      "/{id}": {
        "get": {
          "summary": "Get a product by ID",
          "description": "Fetch a single product by its ID with full image URL",
          "parameters": [
            {
              "in": "path",
              "name": "id",
              "type": "integer",
              "required": true,
              "description": "Product ID"
            }
          ],
          "responses": {
            "200": {
              "description": "Product fetched successfully",
              "schema": {
                "$ref": "#/definitions/ProductResponse"
              }
            },
            "404": {
              "description": "Product not found"
            },
            "500": {
              "description": "Server error"
            }
          }
        },
        "put": {
          "summary": "Update a product by ID",
          "description": "Update an existing product with an optional new image. The old image will be removed if a new one is provided.",
          "consumes": ["multipart/form-data"],
          "parameters": [
            {
              "in": "path",
              "name": "id",
              "type": "integer",
              "required": true,
              "description": "Product ID"
            },
            {
              "in": "formData",
              "name": "title",
              "type": "string",
              "required": false,
              "description": "Title of the product"
            },
            {
              "in": "formData",
              "name": "description",
              "type": "string",
              "required": false,
              "description": "Description of the product"
            },
            {
              "in": "formData",
              "name": "pricing",
              "type": "number",
              "format": "float",
              "required": false,
              "description": "Price of the product"
            },
            {
              "in": "formData",
              "name": "features",
              "type": "string",
              "required": false,
              "description": "Features of the product, stored as JSON"
            },
            {
              "in": "formData",
              "name": "image",
              "type": "file",
              "required": false,
              "description": "New image file for the product"
            }
          ],
          "responses": {
            "200": {
              "description": "Product updated successfully",
              "schema": {
                "$ref": "#/definitions/ProductResponse"
              }
            },
            "404": {
              "description": "Product not found"
            },
            "500": {
              "description": "Server error"
            }
          }
        },
        "delete": {
          "summary": "Delete a product by ID",
          "description": "Delete an existing product and its associated image",
          "parameters": [
            {
              "in": "path",
              "name": "id",
              "type": "integer",
              "required": true,
              "description": "Product ID"
            }
          ],
          "responses": {
            "200": {
              "description": "Product deleted successfully"
            },
            "404": {
              "description": "Product not found"
            },
            "500": {
              "description": "Server error"
            }
          }
        }
      }
    },
    "definitions": {
      "ProductResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "example": 1
          },
          "title": {
            "type": "string",
            "example": "Product Title"
          },
          "description": {
            "type": "string",
            "example": "Product Description"
          },
          "image": {
            "type": "string",
            "example": "http://localhost:3000/uploads/product/image.jpg"
          },
          "pricing": {
            "type": "number",
            "format": "float",
            "example": 99.99
          },
          "features": {
            "type": "string",
            "example": "[\"Feature1\", \"Feature2\"]"
          }
        }
      }
    }
  }
  