{
  "openapi": "3.0.3",
  "info": {
    "title": "OrcaSlicer API",
    "version": "1.0.0",
    "description": "REST API for slicing 3D models (STL, STEP, 3MF) using the OrcaSlicer CLI. Upload and manage slicing profiles (printers, presets, filaments). Returns G-code or 3MF files, with multi-plate support (ZIP archive if multiple G-codes)."
  },
  "servers": [
    {
      "url": "http://localhost:3000"
    }
  ],
  "tags": [
    {
      "name": "Slicing",
      "description": "Endpoints for slicing 3D models"
    },
    {
      "name": "Profiles",
      "description": "Endpoints for managing printer, preset, and filament profiles"
    }
  ],
  "paths": {
    "/slice": {
      "post": {
        "tags": [
          "Slicing"
        ],
        "summary": "Slice a 3D model file",
        "description": "Uploads a 3D model (STL, STEP, or 3MF) and returns a G-code or 3MF file. If multiple G-codes are generated (multi-plate), a ZIP archive is returned.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "file"
                ],
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "description": "STL, STEP, or 3MF model file"
                  },
                  "printer": {
                    "type": "string",
                    "description": "Printer profile name, must match uploaded profile (optional for 3mf, default: profile from 3mf)"
                  },
                  "preset": {
                    "type": "string",
                    "description": "Preset profile name, must match uploaded profile (optional for 3mf, default: profile from 3mf)"
                  },
                  "filament": {
                    "type": "string",
                    "description": "Filament profile name, must match uploaded profile (optional for 3mf, default: profile from 3mf)"
                  },
                  "bedType": {
                    "type": "string",
                    "description": "Bed type as named inside the profile (optional, default: Textured PEI Plate)"
                  },
                  "plate": {
                    "type": "string",
                    "description": "Plate number to slice (optional, default: 1, 0 for all plates)"
                  },
                  "arrange": {
                    "type": "boolean",
                    "description": "Auto-arrange models on the plate (optional, default: false)"
                  },
                  "orient": {
                    "type": "boolean",
                    "description": "Auto-orient models (optional, default: false)"
                  },
                  "exportType": {
                    "type": "string",
                    "enum": [
                      "gcode",
                      "3mf"
                    ],
                    "description": "Export gcode or 3mf (optional, default: gcode)"
                  },
                  "multicolorOnePlate": {
                    "type": "boolean",
                    "description": "Allow multicolor on one plate when using arrange (optional, default: false)"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "G-code or 3MF file generated. If multiple G-codes, a ZIP archive is returned.",
            "headers": {
              "X-Print-Time-Seconds": {
                "description": "Estimated total print time in seconds",
                "schema": {
                  "type": "string"
                }
              },
              "X-Filament-Used-g": {
                "description": "Filament used in grams",
                "schema": {
                  "type": "string"
                }
              },
              "X-Filament-Used-mm": {
                "description": "Filament used in millimeters",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/octet-stream": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                },
                "examples": {
                  "gcodeFile": {
                    "summary": "Example G-code file",
                    "description": "A sample G-code file generated by the slicer.",
                    "value": "G28 ; Home all axes\n..."
                  },
                  "3mfFile": {
                    "summary": "Example 3MF file",
                    "description": "A sample 3MF file generated by the slicer, includes gcodes for printing.",
                    "value": "<3mf data>"
                  },
                  "zipFile": {
                    "summary": "Example ZIP file",
                    "description": "A ZIP archive containing multiple G-code files.",
                    "value": "<binary zip data>"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or missing parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Slicing failed or server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/profiles/{category}": {
      "post": {
        "tags": [
          "Profiles"
        ],
        "summary": "Upload a profile (printer, preset, or filament)",
        "description": "Upload a new printer, preset, or filament profile (OrcaSlicer JSON format).",
        "parameters": [
          {
            "$ref": "#/components/parameters/Category"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "file",
                  "name"
                ],
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "description": "OrcaSlicer profile JSON file"
                  },
                  "name": {
                    "type": "string",
                    "description": "Name for the profile (alphanumeric)"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Profile uploaded",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or missing parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Profiles"
        ],
        "summary": "List all profiles in a category",
        "description": "List all uploaded profiles for a given category (printers, presets, filaments).",
        "parameters": [
          {
            "$ref": "#/components/parameters/Category"
          }
        ],
        "responses": {
          "200": {
            "description": "List of profile names",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid category",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/profiles/{category}/{name}": {
      "get": {
        "tags": [
          "Profiles"
        ],
        "summary": "Get a specific profile by name",
        "description": "Get a specific printer, preset, or filament profile by name.",
        "parameters": [
          {
            "$ref": "#/components/parameters/Category"
          },
          {
            "name": "name",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Profile name (alphanumeric)"
          }
        ],
        "responses": {
          "200": {
            "description": "Profile JSON",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "parameters": {
      "Category": {
        "name": "category",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string",
          "enum": [
            "printers",
            "presets",
            "filaments"
          ]
        },
        "description": "Profile category (printers, presets, filaments)"
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string"
          }
        }
      }
    }
  }
}