{
  "openapi": "3.1.0",
  "info": {
    "title": "Inventory API — synthetic documentation example",
    "version": "1.0.0",
    "description": "A fictional interface for customer training. No provider behavior or runtime readiness is asserted."
  },
  "servers": [
    {
      "url": "https://inventory.example.invalid"
    }
  ],
  "security": [
    {
      "InventoryTestKey": []
    }
  ],
  "paths": {
    "/items": {
      "post": {
        "operationId": "createItem",
        "summary": "Create an inventory item",
        "description": "Creates one inventory item. A duplicate SKU is rejected; retry and idempotency behavior require owner review.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Item"
              },
              "example": {
                "sku": "SKU-001",
                "quantity": 5
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created inventory item",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Item"
                },
                "example": {
                  "sku": "SKU-001",
                  "quantity": 5
                }
              }
            }
          },
          "409": {
            "description": "SKU already exists",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid test authentication",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Item not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/items/{sku}": {
      "parameters": [
        {
          "name": "sku",
          "in": "path",
          "required": true,
          "description": "Exact item identifier from the reviewed input or prior response.",
          "schema": {
            "type": "string",
            "pattern": "^[A-Z][A-Z0-9-]{2,15}$"
          }
        }
      ],
      "get": {
        "operationId": "getItem",
        "summary": "Read an inventory item",
        "description": "Reads the current inventory record for an exact SKU. A missing item returns 404.",
        "responses": {
          "200": {
            "description": "Current item",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Item"
                },
                "example": {
                  "sku": "SKU-001",
                  "quantity": 5
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid test authentication",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Item not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "replaceItem",
        "summary": "Replace an inventory record",
        "description": "Replaces the whole existing inventory record. Body SKU must equal path SKU. This operation changes state.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Item"
              },
              "example": {
                "sku": "SKU-001",
                "quantity": 7
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Replaced item",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Item"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid test authentication",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Item not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateQuantity",
        "summary": "Update the available quantity",
        "description": "Sets quantity on an existing inventory record. This is an assignment of a value, not an increment.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "quantity"
                ],
                "properties": {
                  "quantity": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 10000
                  }
                }
              },
              "example": {
                "quantity": 9
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated item",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Item"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid test authentication",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Item not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteItem",
        "summary": "Delete an inventory item",
        "description": "Deletes the exact inventory record. A later read is expected to return 404 in a stateful implementation.",
        "responses": {
          "204": {
            "description": "Item deleted; no response body"
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid test authentication",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Item not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "InventoryTestKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Inventory-Test-Key",
        "description": "Synthetic teaching contract. Provision actual sandbox values only through the supported Vault controls."
      }
    },
    "schemas": {
      "Item": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "sku",
          "quantity"
        ],
        "properties": {
          "sku": {
            "type": "string",
            "pattern": "^[A-Z][A-Z0-9-]{2,15}$",
            "description": "Inventory item identifier."
          },
          "quantity": {
            "type": "integer",
            "minimum": 0,
            "maximum": 10000,
            "description": "Available units; changing this value is a mutation."
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "code",
          "message"
        ],
        "properties": {
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      }
    }
  }
}
